aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/github')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java38
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java169
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java1117
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java541
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java1136
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java141
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java398
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java82
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java427
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java95
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElement.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java48
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java245
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java317
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java108
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/PositionNew.java36
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java21
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java30
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java152
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java85
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java33
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java60
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java56
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java63
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/GuiElementSlider.java58
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/MiscUtils.java31
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/Splitters.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/StringUtils.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpUtils.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingFloat.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/lerp/LerpingInteger.java16
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/RenderUtils.java146
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/util/render/TextRenderUtils.java32
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java130
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeNode.java112
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java282
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java356
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java53
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonBlocks.java59
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java747
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java277
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java480
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/GuiGamemodes.java208
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java163
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java208
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java322
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java41
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java165
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java288
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/NEUItemEditor.java173
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java102
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/BetterContainers.java27
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalOverlay.java161
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java457
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomSkulls.java91
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java80
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java232
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java144
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java230
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java114
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java110
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java228
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java100
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java49
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java76
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java98
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java28
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java98
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java487
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java261
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java285
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java549
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/CalendarOverlay.java761
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java961
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java243
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiInvButtonEditor.java399
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java249
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/NEUOverlayPlacements.java103
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java1220
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java615
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/NeuTutorial.java152
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/tutorials/TutorialBase.java97
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinAbstractClientPlayer.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java74
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java116
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java23
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java35
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java53
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java44
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java92
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRendererLivingEntity.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java216
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java526
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java228
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java128
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java105
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java176
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java26
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java78
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java62
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java201
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java2059
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java65
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java256
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java550
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/NEUResourceManager.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java49
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java37
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java55
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java28
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java570
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java88
198 files changed, 12730 insertions, 12819 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
index c16cb7d0..7eefac6a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItems.java
@@ -31,7 +31,7 @@ public class CustomItems {
"DUCTTAPE",
"iron_shovel",
"You ever accidentally bury your duct tape?",
- "No problem! Our team of experts specialise in",
+ "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",
@@ -44,24 +44,24 @@ public class CustomItems {
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");
+ "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");
+ "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",
@@ -79,9 +79,9 @@ public class CustomItems {
JsonObject json = new JsonObject();
json.addProperty("itemid", itemid);
json.addProperty("internalname", internalname);
- json.addProperty("displayname", EnumChatFormatting.RED+displayname);
+ json.addProperty("displayname", EnumChatFormatting.RED + displayname);
JsonArray jsonlore = new JsonArray();
- for(String line : lore) {
+ for (String line : lore) {
jsonlore.add(new JsonPrimitive(EnumChatFormatting.GRAY + line));
}
json.add("lore", jsonlore);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
index 83c4b7ae..0aa80126 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/ItemPriceInformation.java
@@ -4,7 +4,6 @@ import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.core.config.KeybindHelper;
import io.github.moulberry.notenoughupdates.util.Constants;
-import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
@@ -21,10 +20,10 @@ public class ItemPriceInformation {
}
public static boolean addToTooltip(List<String> tooltip, String internalname, ItemStack stack, boolean useStackSize) {
- if(stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")){
+ if (stack.getTagCompound().hasKey("disableNeuTooltip") && stack.getTagCompound().getBoolean("disableNeuTooltip")) {
return false;
}
- if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey && !KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)){
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKey && !KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.disablePriceKeyKeybind)) {
return false;
}
JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
@@ -39,7 +38,7 @@ public class ItemPriceInformation {
NumberFormat format = NumberFormat.getInstance(Locale.US);
- if(bazaarItem) {
+ if (bazaarItem) {
List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoBaz;
boolean added = false;
@@ -48,161 +47,169 @@ public class ItemPriceInformation {
int stackMultiplier = 1;
int shiftStackMultiplier = useStackSize && stack.stackSize > 1 ? stack.stackSize : 64;
- if(shiftPressed) {
+ if (shiftPressed) {
stackMultiplier = shiftStackMultiplier;
}
//values = {"", "Buy", "Sell", "Buy (Insta)", "Sell (Insta)", "Raw Craft Cost"}
- for(int lineId : lines) {
+ for (int lineId : lines) {
switch (lineId) {
case 0:
- if(bazaarInfo.has("avg_buy")) {
- if(!added) {
+ if (bazaarInfo.has("avg_buy")) {
+ if (!added) {
tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
+ 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+format.format(bazaarBuyPrice)+" coins");
+ 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) {
+ if (bazaarInfo.has("avg_sell")) {
+ if (!added) {
tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
+ 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+format.format(bazaarSellPrice)+" coins");
+ 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) {
+ if (bazaarInfo.has("curr_buy")) {
+ if (!added) {
tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
+ 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+format.format(bazaarInstantBuyPrice)+" coins");
+ 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) {
+ if (bazaarInfo.has("curr_sell")) {
+ if (!added) {
tooltip.add("");
- if(!shiftPressed) tooltip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show x"+shiftStackMultiplier+"]");
+ 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+format.format(bazaarInstantSellPrice)+" coins");
+ 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) {
+ 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");
+ 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) {
+ } else if (auctionItem) {
List<Integer> lines = NotEnoughUpdates.INSTANCE.config.tooltipTweaks.priceInfoAuc;
boolean added = false;
- for(int lineId : lines) {
+ for (int lineId : lines) {
switch (lineId) {
case 0:
- if(lowestBin > 0) {
- if(!added) {
+ 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");
+ 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) {
+ 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");
+ 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");
+ 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) {
+ 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");
+ 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");
+ 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) {
+ 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");
+ 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) {
+ 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");
+ 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;
+ if (Constants.ESSENCECOSTS == null) break;
JsonObject essenceCosts = Constants.ESSENCECOSTS;
- if(!essenceCosts.has(internalname)) {
+ 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() &&
+ if (stack != null && stack.hasTagCompound() &&
stack.getTagCompound().hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = stack.getTagCompound().getCompoundTag("ExtraAttributes");
@@ -210,24 +217,24 @@ public class ItemPriceInformation {
dungeonItemLevel = ea.getInteger("dungeon_item_level");
}
}
- if(dungeonItemLevel == -1) {
+ if (dungeonItemLevel == -1) {
int dungeonizeCost = 0;
- if(itemCosts.has("dungeonize")) {
+ 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)+"";
+ 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++) {
+ 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);
+ tooltip.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "Upgrade to " +
+ EnumChatFormatting.GOLD + star + EnumChatFormatting.YELLOW + EnumChatFormatting.BOLD + ": " +
+ EnumChatFormatting.GOLD + EnumChatFormatting.BOLD + upgradeCost + " " + essenceType);
}
break;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java
index 56a196b4..df06aae7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUApi.java
@@ -4,7 +4,8 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper;
public class NEUApi {
static boolean disableInventoryButtons = false;
- public static void setInventoryButtonsToDisabled(){
+
+ 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..527abd02 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -1,7 +1,10 @@
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;
@@ -82,7 +85,7 @@ public class NEUEventListener {
private void displayUpdateMessageIfOutOfDate() {
File repo = neu.manager.repoLocation;
- if(repo.exists()) {
+ if (repo.exists()) {
File updateJson = new File(repo, "update.json");
try {
JsonObject o = neu.manager.getJsonFromFile(updateJson);
@@ -93,7 +96,7 @@ public class NEUEventListener {
boolean shouldUpdate = !NotEnoughUpdates.VERSION.equalsIgnoreCase(version);
boolean shouldPreUpdate = !NotEnoughUpdates.PRE_VERSION.equalsIgnoreCase(preVersion);
- if(o.has("version_id") && o.get("version_id").isJsonPrimitive()) {
+ if (o.has("version_id") && o.get("version_id").isJsonPrimitive()) {
int version_id = o.get("version_id").getAsInt();
shouldUpdate = version_id > NotEnoughUpdates.VERSION_ID;
}
@@ -102,20 +105,20 @@ public class NEUEventListener {
shouldPreUpdate = pre_version_id > NotEnoughUpdates.PRE_VERSION_ID;
}
- if(shouldUpdate) {
+ if (shouldUpdate) {
String update_msg = o.get("update_msg").getAsString();
int first_len = -1;
- for(String line : update_msg.split("\n")) {
+ for (String line : update_msg.split("\n")) {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int len = fr.getStringWidth(line);
- if(first_len == -1) {
+ if (first_len == -1) {
first_len = len;
}
- int missing_len = first_len-len;
- if(missing_len > 0) {
+ int missing_len = first_len - len;
+ if (missing_len > 0) {
StringBuilder sb = new StringBuilder(line);
- for(int i=0; i<missing_len/8; i++) {
+ for (int i = 0; i < missing_len / 8; i++) {
sb.insert(0, " ");
}
line = sb.toString();
@@ -153,7 +156,7 @@ public class NEUEventListener {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
}
@@ -184,12 +187,13 @@ public class NEUEventListener {
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) {
+ if (showForever) {
notificationDisplayMillis = -420;
} else {
notificationDisplayMillis = System.currentTimeMillis();
@@ -200,30 +204,30 @@ public class NEUEventListener {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if(Minecraft.getMinecraft().currentScreen == null || !(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) {
+ 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 (event.phase != TickEvent.Phase.START) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
+ if (Minecraft.getMinecraft().thePlayer == null) return;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
ContainerChest cc = (ContainerChest) chest.inventorySlots;
- if(!loadedInvName.equals(cc.getLowerChestInventory().getDisplayName().getUnformattedText())) {
+ 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) {
+ 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) {
+ for (ItemStack stack : chest.inventorySlots.getInventory()) {
+ if (stack != null) {
+ if (--inventoryLoadedTicks <= 0) {
inventoryLoaded = true;
}
break;
@@ -236,7 +240,7 @@ public class NEUEventListener {
inventoryLoadedTicks = 3;
}
- if(Keyboard.isKeyDown(Keyboard.KEY_NUMPAD1) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD4) && Keyboard.isKeyDown(Keyboard.KEY_NUMPAD9)) {
+ 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");
@@ -248,51 +252,51 @@ public class NEUEventListener {
return;
}
- if(neu.hasSkyblockScoreboard()) {
- if(!preloadedItems) {
+ if (neu.hasSkyblockScoreboard()) {
+ if (!preloadedItems) {
preloadedItems = true;
List<JsonObject> list = new ArrayList<>(neu.manager.getItemInformation().values());
- for(JsonObject json : list) {
+ for (JsonObject json : list) {
itemPreloader.submit(() -> {
ItemStack stack = neu.manager.jsonToStack(json, true, true);
- if(stack.getItem() == Items.skull) toPreload.add(stack);
+ if (stack.getItem() == Items.skull) toPreload.add(stack);
});
}
- } else if(!toPreload.isEmpty()) {
+ } else if (!toPreload.isEmpty()) {
Utils.drawItemStack(toPreload.get(0), -100, -100);
toPreload.remove(0);
} else {
itemPreloader.shutdown();
}
- for(TextOverlay overlay : OverlayManager.textOverlays) {
+ for (TextOverlay overlay : OverlayManager.textOverlays) {
overlay.shouldUpdateFrequent = true;
}
}
boolean longUpdate = false;
long currentTime = System.currentTimeMillis();
- if(currentTime - lastLongUpdate > 1000) {
+ if (currentTime - lastLongUpdate > 1000) {
longUpdate = true;
lastLongUpdate = currentTime;
}
- if(!NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
+ if (!NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
DungeonBlocks.tick();
}
DungeonWin.tick();
String containerName = null;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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)) {
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
GuiCustomEnchant.getInstance().tick();
}
}
- if(longUpdate) {
+ if (longUpdate) {
CrystalOverlay.tick();
DwarvenMinesTextures.tick();
FairySouls.tick();
@@ -303,8 +307,8 @@ public class NEUEventListener {
NPCRetexturing.getInstance().tick();
StorageOverlay.getInstance().markDirty();
- if(neu.hasSkyblockScoreboard()) {
- for(TextOverlay overlay : OverlayManager.textOverlays) {
+ if (neu.hasSkyblockScoreboard()) {
+ for (TextOverlay overlay : OverlayManager.textOverlays) {
overlay.tick();
}
}
@@ -315,58 +319,57 @@ public class NEUEventListener {
NotEnoughUpdates.profileViewer.putNameUuid(Minecraft.getMinecraft().thePlayer.getName(),
Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
- if(NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.slowDungeonBlocks) {
DungeonBlocks.tick();
}
- if(System.currentTimeMillis() - SBInfo.getInstance().joinedWorld > 500 &&
+ 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")) {
+ if (containerName != null) {
+ if (!containerName.trim().startsWith("Accessory Bag")) {
AccessoryBagOverlay.resetCache();
}
} else {
AccessoryBagOverlay.resetCache();
}
- if(neu.hasSkyblockScoreboard()) {
+ if (neu.hasSkyblockScoreboard()) {
SBInfo.getInstance().tick();
lastSkyblockScoreboard = currentTime;
- if(!joinedSB) {
+ if (!joinedSB) {
joinedSB = true;
//SBGamemodes.loadFromFile();
-
- if(NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) {
+ if (NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) {
displayUpdateMessageIfOutOfDate();
}
- if(NotEnoughUpdates.INSTANCE.config.notifications.doRamNotif) {
- long maxMemoryMB = Runtime.getRuntime().maxMemory()/1024L/1024L;
- if(maxMemoryMB > 4100) {
+ 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(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");
+ notificationLines.add(EnumChatFormatting.GRAY + "For more information, visit #ram-info in discord.gg/moulberry");
}
}
- if(!NotEnoughUpdates.INSTANCE.config.hidden.loadedModBefore) {
+ 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"));
+ 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"));
+ 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(""));
@@ -379,14 +382,14 @@ public class NEUEventListener {
}
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.");
+ 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
+ if (currentTime - lastSkyblockScoreboard < 5 * 60 * 1000) { //5 minutes
neu.manager.auctionManager.tick();
} else {
neu.manager.auctionManager.markNeedsUpdate();
@@ -472,10 +475,10 @@ public class NEUEventListener {
}
}*/
- @SubscribeEvent(priority= EventPriority.HIGHEST)
+ @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) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiProfileViewer) {
+ if (((GuiProfileViewer) Minecraft.getMinecraft().currentScreen).getEntityPlayer() == event.entity) {
event.setCanceled(true);
}
}
@@ -487,19 +490,19 @@ public class NEUEventListener {
Minecraft.getMinecraft().currentScreen instanceof GuiContainer && neu.overlay.isUsingMobsFilter()) {
event.setCanceled(true);
}
- if(event.type != null && event.type.equals(RenderGameOverlayEvent.ElementType.PLAYER_LIST)) {
+ 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)) {
+ 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())) {
+ for (TextOverlay overlay : OverlayManager.textOverlays) {
+ if (OverlayManager.dontRenderOverlay != null && OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) {
continue;
}
GlStateManager.translate(0, 0, -1);
@@ -509,55 +512,56 @@ public class NEUEventListener {
GlStateManager.popMatrix();
OverlayManager.dontRenderOverlay = null;
}
- if(Keyboard.isKeyDown(Keyboard.KEY_X)) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_X)) {
notificationDisplayMillis = 0;
}
- if(event.type == RenderGameOverlayEvent.ElementType.ALL){
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
renderNotification();
}
}
- private static void renderNotification(){
+
+ private static void renderNotification() {
long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis);
boolean display = timeRemaining > 0 || notificationDisplayMillis == -420;
- if(display && notificationLines != null && notificationLines.size() > 0) {
+ if (display && notificationLines != null && notificationLines.size() > 0) {
int width = 0;
- int height = notificationLines.size()*10+10;
+ int height = notificationLines.size() * 10 + 10;
- for(String line : notificationLines) {
+ for (String line : notificationLines) {
int len = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line) + 8;
- if(len > width) {
+ 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);
+ 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);
+ 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);
+ 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++) {
+ 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);
+ midX, topY + 4 + 5 + 2 + i * 10, false, -1);
}
Utils.pushGuiScale(-1);
@@ -572,12 +576,13 @@ public class NEUEventListener {
* 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 ||
+ 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) {
@@ -586,11 +591,11 @@ public class NEUEventListener {
return;
}
- if(!(event.gui instanceof GuiContainer) && Minecraft.getMinecraft().currentScreen != null) {
+ if (!(event.gui instanceof GuiContainer) && Minecraft.getMinecraft().currentScreen != null) {
CalendarOverlay.setEnabled(false);
}
- if(Minecraft.getMinecraft().currentScreen != null) {
+ if (Minecraft.getMinecraft().currentScreen != null) {
lastGuiClosed = System.currentTimeMillis();
}
@@ -599,15 +604,15 @@ public class NEUEventListener {
inventoryLoaded = false;
inventoryLoadedTicks = 3;
- if(event.gui == null && neu.manager.auctionManager.customAH.isRenderOverAuctionView() &&
+ 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)) {
+ 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)){
+ } 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();
@@ -618,46 +623,46 @@ public class NEUEventListener {
}
//OPEN
- if(Minecraft.getMinecraft().currentScreen == null
+ 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) {
+ 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) {
+ if (Minecraft.getMinecraft().currentScreen != event.gui) {
return;
}
- if(lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) {
+ 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) {
+ if (lower.getStackInSlot(48) != null) {
String backName = null;
NBTTagCompound tag = lower.getStackInSlot(48).getTagCompound();
- if(tag.hasKey("display", 10)) {
+ if (tag.hasKey("display", 10)) {
NBTTagCompound nbttagcompound = tag.getCompoundTag("display");
- if(nbttagcompound.getTagId("Lore") == 9){
+ if (nbttagcompound.getTagId("Lore") == 9) {
NBTTagList nbttaglist1 = nbttagcompound.getTagList("Lore", 8);
backName = nbttaglist1.getStringTagAt(0);
}
}
- if(backName != null) {
+ 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);
+ 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.writeJsonDefaultDir(json, resInternalname + ".json");
neu.manager.loadItem(resInternalname);
}
}
@@ -713,7 +718,7 @@ public class NEUEventListener {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
neu.manager.writeJsonDefaultDir(json, resInternalname+".json");
neu.manager.loadItem(resInternalname);*/
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -742,22 +747,22 @@ public class NEUEventListener {
private IChatComponent processChatComponent(IChatComponent chatComponent) {
IChatComponent newComponent;
- if(chatComponent instanceof ChatComponentText) {
+ if (chatComponent instanceof ChatComponentText) {
ChatComponentText text = (ChatComponentText) chatComponent;
newComponent = new ChatComponentText(processText(text.getUnformattedTextForChat()));
newComponent.setChatStyle(text.getChatStyle().createShallowCopy());
- for(IChatComponent sibling : text.getSiblings()) {
+ for (IChatComponent sibling : text.getSiblings()) {
newComponent.appendSibling(processChatComponent(sibling));
}
- } else if(chatComponent instanceof ChatComponentTranslation) {
+ } 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) {
+ 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];
@@ -765,7 +770,7 @@ public class NEUEventListener {
}
newComponent = new ChatComponentTranslation(trans.getKey(), newArgs);
- for(IChatComponent sibling : trans.getSiblings()) {
+ for (IChatComponent sibling : trans.getSiblings()) {
newComponent.appendSibling(processChatComponent(sibling));
}
} else {
@@ -776,27 +781,27 @@ public class NEUEventListener {
}
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 (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;
+ 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", ""));
+ return Utils.trimIgnoreColour(text.replaceAll(EnumChatFormatting.DARK_GREEN + "\\S+ Drill Fuel", ""));
}
+ private IChatComponent replaceSocialControlsWithPV(IChatComponent chatComponent) {
- 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")){
+ 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."));
+ 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;
+ return chatComponent;
}
/**
@@ -806,11 +811,11 @@ public class NEUEventListener {
*/
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
public void onGuiChat(ClientChatReceivedEvent e) {
- if(e.type == 2) {
+ if (e.type == 2) {
CrystalMetalDetectorSolver.process(e.message);
e.message = processChatComponent(e.message);
return;
- } else if(e.type == 0){
+ } else if (e.type == 0) {
e.message = replaceSocialControlsWithPV(e.message);
}
@@ -818,50 +823,50 @@ public class NEUEventListener {
String r = null;
String unformatted = Utils.cleanColour(e.message.getUnformattedText());
- if(unformatted.startsWith("You are playing on profile: ")) {
+ 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:
+ } 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 ")) {
+ } 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+
+ 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 ")) {
+ 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 &&
+ 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)) {
+ 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") &&
+ 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)) {
+ if (!m.equals(m2)) {
e.message = new ChatComponentText(m2);
}
}
- if (unformatted.startsWith("You found ") && SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("crystal_hollows")){
+ 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!"))
+ 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);
}
@@ -870,67 +875,70 @@ public class NEUEventListener {
/**
* 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.
+ *
* @param event
*/
@SubscribeEvent
public void onGuiBackgroundDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
- if(showNotificationOverInv){
+ if (showNotificationOverInv) {
renderNotification();
}
- if((shouldRenderOverlay(event.gui) || event.gui instanceof CustomAHGui) && neu.isOnSkyblock()) {
+ 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();
+ boolean hoverPane = event.getMouseX() < width * neu.overlay.getInfoPaneOffsetFactor() ||
+ event.getMouseX() > width * neu.overlay.getItemPaneOffsetFactor();
- if(event.gui instanceof GuiContainer) {
+ 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;
+ 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;
+ if (hoverPane) {
+ if (!hoverInv) focusInv = false;
} else {
focusInv = true;
}
- } catch(NullPointerException npe) {
+ } catch (NullPointerException npe) {
focusInv = !hoverPane;
}
}
- if(event.gui instanceof GuiItemRecipe) {
- GuiItemRecipe guiItemRecipe = ((GuiItemRecipe)event.gui);
+ 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;
+ if (hoverPane) {
+ if (!hoverInv) focusInv = false;
} else {
focusInv = true;
}
}
- if(focusInv) {
+ if (focusInv) {
try {
neu.overlay.render(hoverInv);
- } catch(ConcurrentModificationException e) {e.printStackTrace();}
+ } catch (ConcurrentModificationException e) {
+ e.printStackTrace();
+ }
GL11.glTranslatef(0, 0, 10);
}
- if(hoverInv) {
+ if (hoverInv) {
renderDungeonChestOverlay(event.gui);
- if(NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
+ if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
AccessoryBagOverlay.renderOverlay();
}
}
@@ -945,12 +953,12 @@ public class NEUEventListener {
public void onGuiScreenDrawPre(GuiScreenEvent.DrawScreenEvent.Pre event) {
doInventoryButtons = false;
- if(AuctionSearchOverlay.shouldReplace()) {
+ if (AuctionSearchOverlay.shouldReplace()) {
AuctionSearchOverlay.render();
event.setCanceled(true);
return;
}
- if(RancherBootOverlay.shouldReplace()) {
+ if (RancherBootOverlay.shouldReplace()) {
RancherBootOverlay.render();
event.setCanceled(true);
return;
@@ -958,13 +966,13 @@ public class NEUEventListener {
String containerName = null;
GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
- if(guiScreen instanceof GuiChest) {
+ if (guiScreen instanceof GuiChest) {
GuiChest eventGui = (GuiChest) guiScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
}
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
GuiCustomEnchant.getInstance().render(event.renderPartialTicks);
event.setCanceled(true);
return;
@@ -974,13 +982,13 @@ public class NEUEventListener {
boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName);
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
- if(storageOverlayActive) {
+ if (storageOverlayActive) {
StorageOverlay.getInstance().render();
event.setCanceled(true);
return;
}
- if(tradeWindowActive || customAhActive) {
+ if (tradeWindowActive || customAhActive) {
event.setCanceled(true);
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -990,25 +998,25 @@ public class NEUEventListener {
//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) {
+ 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) {
+ } else if (tradeWindowActive) {
TradeWindow.render(event.mouseX, event.mouseY);
}
neu.overlay.render(false);
} else {
neu.overlay.render(false);
- if(customAhActive) {
+ if (customAhActive) {
neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
- } else if(tradeWindowActive) {
+ } else if (tradeWindowActive) {
TradeWindow.render(event.mouseX, event.mouseY);
}
}
}
- if(CalendarOverlay.isEnabled() || event.isCanceled()) return;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui)
+ if (CalendarOverlay.isEnabled() || event.isCanceled()) return;
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui)
&& event.gui instanceof GuiContainer) {
doInventoryButtons = true;
@@ -1060,11 +1068,11 @@ public class NEUEventListener {
private static boolean shouldRenderOverlay(Gui gui) {
boolean validGui = gui instanceof GuiContainer || gui instanceof GuiItemRecipe;
- if(gui instanceof GuiChest) {
+ 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")) {
+ if (containerName.trim().equals("Fast Travel")) {
validGui = false;
}
}
@@ -1079,6 +1087,7 @@ public class NEUEventListener {
/**
* 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
@@ -1088,7 +1097,7 @@ public class NEUEventListener {
String containerName = null;
GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
- if(guiScreen instanceof GuiChest) {
+ if (guiScreen instanceof GuiChest) {
GuiChest eventGui = (GuiChest) guiScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
@@ -1097,7 +1106,7 @@ public class NEUEventListener {
}
}
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName)) {
return;
}
@@ -1105,10 +1114,10 @@ public class NEUEventListener {
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()) {
+ if (!(tradeWindowActive || storageOverlayActive || customAhActive)) {
+ if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
GlStateManager.pushMatrix();
- if(!focusInv) {
+ if (!focusInv) {
GL11.glTranslatef(0, 0, 300);
neu.overlay.render(hoverInv && focusInv);
GL11.glTranslatef(0, 0, -300);
@@ -1117,16 +1126,16 @@ public class NEUEventListener {
}
}
- if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) {
+ if (shouldRenderOverlay(event.gui) && neu.isOnSkyblock() && !hoverInv) {
renderDungeonChestOverlay(event.gui);
- if(NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
+ if (NotEnoughUpdates.INSTANCE.config.accessoryBag.enableOverlay) {
AccessoryBagOverlay.renderOverlay();
}
}
boolean hoveringButton = false;
- if(!doInventoryButtons) return;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) &&
+ 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;
@@ -1179,91 +1188,92 @@ public class NEUEventListener {
}
}
}
- if(!hoveringButton) buttonHovered = null;
+ if (!hoveringButton) buttonHovered = null;
- if(AuctionBINWarning.getInstance().shouldShow()) {
+ if (AuctionBINWarning.getInstance().shouldShow()) {
AuctionBINWarning.getInstance().render();
}
}
private void renderDungeonChestOverlay(GuiScreen gui) {
- if(NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return;
+ if (NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc == 3) return;
- if(gui instanceof GuiChest && NotEnoughUpdates.INSTANCE.config.dungeons.profitDisplayLoc != 2) {
+ 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;
+ 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")) {
+ 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++) {
+ for (int i = 0; i < line6.length(); i++) {
char c = line6.charAt(i);
- if("0123456789".indexOf(c) >= 0) {
+ if ("0123456789".indexOf(c) >= 0) {
cost.append(c);
}
}
- if(cost.length() > 0) {
+ if (cost.length() > 0) {
chestCost = Integer.parseInt(cost.toString());
}
- } catch(Exception ignored) {}
+ } 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);
+ for (int i = 0; i < 5; i++) {
+ ItemStack item = lower.getStackInSlot(11 + i);
String internal = neu.manager.getInternalNameForItem(item);
- if(internal != null) {
+ 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")) {
+ if (bazaarInfo != null && bazaarInfo.has("curr_sell")) {
bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat();
}
- if(bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
+ if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
float worth = -1;
- if(bazaarPrice > 0) {
+ if (bazaarPrice > 0) {
worth = bazaarPrice;
} else {
- switch(NotEnoughUpdates.INSTANCE.config.dungeons.profitType) {
+ 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();
+ 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());
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
}
}
break;
default:
worth = neu.manager.auctionManager.getLowestBin(internal);
}
- if(worth <= 0) {
+ if (worth <= 0) {
worth = neu.manager.auctionManager.getLowestBin(internal);
- if(worth <= 0) {
+ if (worth <= 0) {
worth = neu.manager.auctionManager.getItemAvgBin(internal);
- if(worth <= 0) {
+ 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();
+ 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());
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
}
}
}
@@ -1271,21 +1281,21 @@ public class NEUEventListener {
}
}
- if(worth > 0 && totalValue >= 0) {
+ if (worth > 0 && totalValue >= 0) {
totalValue += worth;
String display = item.getDisplayName();
- if(display.contains("Enchanted Book")) {
+ if (display.contains("Enchanted Book")) {
NBTTagCompound tag = item.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ 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()) {
+ for (String enchname : enchants.getKeySet()) {
int level = enchants.getInteger(enchname);
- if(level > highestLevel) {
- display = EnumChatFormatting.BLUE+WordUtils.capitalizeFully(
+ if (level > highestLevel) {
+ display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully(
enchname.replace("_", " ")
.replace("Ultimate", "")
.trim()) + " " + level;
@@ -1296,7 +1306,7 @@ public class NEUEventListener {
itemValues.put(display, worth);
} else {
- if(totalValue != -1) {
+ if (totalValue != -1) {
missingItem = internal;
}
totalValue = -1;
@@ -1307,32 +1317,32 @@ public class NEUEventListener {
NumberFormat format = NumberFormat.getInstance(Locale.US);
String valueStringBIN1;
String valueStringBIN2;
- if(totalValue >= 0) {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Value (BIN): ";
+ if (totalValue >= 0) {
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): ";
valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
} else {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Can't find BIN: ";
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: ";
valueStringBIN2 = missingItem;
}
int profitLossBIN = totalValue - chestCost;
- String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
+ String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
String lossPrefix = EnumChatFormatting.RED.toString();
String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix;
String plStringBIN;
- if(profitLossBIN >= 0) {
+ 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)) {
+ 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,
+ Minecraft.getMinecraft().fontRendererObj.drawString(plStringBIN, guiLeft + xSize - 5 - w, guiTop + 5,
0xffffffff, true);
GlStateManager.translate(0, 0, -200);
return;
@@ -1341,36 +1351,36 @@ public class NEUEventListener {
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.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);
+ 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+
+ 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);
+ guiLeft + xSize + 4 + 10, guiTop + 29 + (++index) * 10, 160);
}
}
- } catch(Exception e) {
+ } 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)) {
+ 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());
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
}
}
}
@@ -1384,11 +1394,12 @@ public class NEUEventListener {
/**
* 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()) {
+ if (Mouse.getEventButtonState() && StorageManager.getInstance().onAnyClick()) {
event.setCanceled(true);
return;
}
@@ -1399,21 +1410,21 @@ public class NEUEventListener {
int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth;
int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1;
- if(AuctionBINWarning.getInstance().shouldShow()) {
+ if (AuctionBINWarning.getInstance().shouldShow()) {
AuctionBINWarning.getInstance().mouseInput(mouseX, mouseY);
event.setCanceled(true);
return;
}
- if(!event.isCanceled()) {
+ if (!event.isCanceled()) {
Utils.scrollTooltip(Mouse.getEventDWheel());
}
- if(AuctionSearchOverlay.shouldReplace()) {
+ if (AuctionSearchOverlay.shouldReplace()) {
AuctionSearchOverlay.mouseEvent();
event.setCanceled(true);
return;
}
- if(RancherBootOverlay.shouldReplace()) {
+ if (RancherBootOverlay.shouldReplace()) {
RancherBootOverlay.mouseEvent();
event.setCanceled(true);
return;
@@ -1421,17 +1432,17 @@ public class NEUEventListener {
String containerName = null;
GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
- if(guiScreen instanceof GuiChest) {
+ 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 &&
+ 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){
+ 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")){
+ 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});
@@ -1440,7 +1451,7 @@ public class NEUEventListener {
}
}
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
GuiCustomEnchant.getInstance().mouseInput(mouseX, mouseY)) {
event.setCanceled(true);
return;
@@ -1450,28 +1461,28 @@ public class NEUEventListener {
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)) {
+ if (storageOverlayActive) {
+ if (StorageOverlay.getInstance().mouseInput(mouseX, mouseY)) {
event.setCanceled(true);
}
return;
}
- if(tradeWindowActive || customAhActive) {
+ if (tradeWindowActive || customAhActive) {
event.setCanceled(true);
- if(customAhActive) {
+ if (customAhActive) {
neu.manager.auctionManager.customAH.handleMouseInput();
- } else if(tradeWindowActive) {
+ } 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()) {
+ 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 {
@@ -1479,15 +1490,15 @@ public class NEUEventListener {
}
}
}
- if(event.isCanceled()) return;
- if(!doInventoryButtons) return;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && shouldRenderOverlay(event.gui) && Mouse.getEventButton() >= 0
+ 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) {
+ 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;
@@ -1538,18 +1549,18 @@ public class NEUEventListener {
*/
@SubscribeEvent
public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(AuctionBINWarning.getInstance().shouldShow()) {
+ if (AuctionBINWarning.getInstance().shouldShow()) {
AuctionBINWarning.getInstance().keyboardInput();
event.setCanceled(true);
return;
}
- if(AuctionSearchOverlay.shouldReplace()) {
+ if (AuctionSearchOverlay.shouldReplace()) {
AuctionSearchOverlay.keyEvent();
event.setCanceled(true);
return;
}
- if(RancherBootOverlay.shouldReplace()) {
+ if (RancherBootOverlay.shouldReplace()) {
RancherBootOverlay.keyEvent();
event.setCanceled(true);
return;
@@ -1557,16 +1568,16 @@ public class NEUEventListener {
String containerName = null;
GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen;
- if(guiScreen instanceof GuiChest) {
+ 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")){
+ if (CraftingOverlay.shouldRender && containerName.equals("Craft Item")) {
CraftingOverlay.keyInput();
}
}
- if(GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
+ if (GuiCustomEnchant.getInstance().shouldOverride(containerName) &&
GuiCustomEnchant.getInstance().keyboardInput()) {
event.setCanceled(true);
return;
@@ -1576,24 +1587,24 @@ public class NEUEventListener {
boolean storageOverlayActive = StorageManager.getInstance().shouldRenderStorageOverlay(containerName);
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
- if(storageOverlayActive) {
- if(StorageOverlay.getInstance().keyboardInput()) {
+ if (storageOverlayActive) {
+ if (StorageOverlay.getInstance().keyboardInput()) {
event.setCanceled(true);
return;
}
}
- if(tradeWindowActive || customAhActive) {
- if(customAhActive) {
- if(neu.manager.auctionManager.customAH.keyboardInput()) {
+ if (tradeWindowActive || customAhActive) {
+ if (customAhActive) {
+ if (neu.manager.auctionManager.customAH.keyboardInput()) {
event.setCanceled(true);
Minecraft.getMinecraft().dispatchKeypresses();
- } else if(neu.overlay.keyboardInput(focusInv)) {
+ } else if (neu.overlay.keyboardInput(focusInv)) {
event.setCanceled(true);
}
- } else if(tradeWindowActive) {
+ } else if (tradeWindowActive) {
TradeWindow.keyboardInput();
- if(Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKey() != Keyboard.KEY_ESCAPE) {
event.setCanceled(true);
Minecraft.getMinecraft().dispatchKeypresses();
neu.overlay.keyboardInput(focusInv);
@@ -1602,58 +1613,58 @@ public class NEUEventListener {
return;
}
- if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
- if(neu.overlay.keyboardInput(focusInv)) {
+ 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 &&
+ 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) {
+ 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;
+ if (!lower.getDisplayName().getUnformattedText().endsWith("Essence")) return;
- for(int i=0; i<lower.getSizeInventory(); i++) {
+ for (int i = 0; i < lower.getSizeInventory(); i++) {
ItemStack stack = lower.getStackInSlot(i);
String internalname = neu.manager.getInternalNameForItem(stack);
- if(internalname != null) {
+ if (internalname != null) {
String[] lore = neu.manager.getLoreFromNBT(stack.getTagCompound());
- for(String line : lore) {
- if(line.contains(":") && (line.startsWith("\u00A77Upgrade to") ||
+ 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') {
+ 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];
+ String type = afterSplit[afterSplit.length - 2];
- if(!essenceJson.has(internalname)) {
+ 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")) {
+ if (line.startsWith("\u00A77Convert to Dungeon Item")) {
obj.addProperty("dungeonize", cost);
- } else if(line.startsWith("\u00A77Upgrade to")) {
+ } else if (line.startsWith("\u00A77Upgrade to")) {
int stars = 0;
- for(char c : line.toCharArray()) {
- if(c == '\u272A') stars++;
+ for (char c : line.toCharArray()) {
+ if (c == '\u272A') stars++;
}
- if(stars > 0) {
- obj.addProperty(stars+"", cost);
+ if (stars > 0) {
+ obj.addProperty(stars + "", cost);
}
}
}
@@ -1663,15 +1674,15 @@ public class NEUEventListener {
System.out.println(essenceJson);
}
}
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev && NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Minecraft.getMinecraft().theWorld != null &&
+ 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) {
+ if (gui instanceof GuiChest) {
GuiChest eventGui = (GuiChest) event.gui;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
IInventory lower = cc.getLowerChestInventory();
- if(lower.getStackInSlot(23) != null &&
+ if (lower.getStackInSlot(23) != null &&
lower.getStackInSlot(23).getDisplayName().endsWith("Crafting Table")) {
ItemStack res = lower.getStackInSlot(25);
String resInternalname = neu.manager.getInternalNameForItem(res);
@@ -1685,27 +1696,27 @@ public class NEUEventListener {
JOptionPane.PLAIN_MESSAGE,
null, new String[]{"Enter"}, "Enter");
resInternalname = tf.getText();
- if(resInternalname.trim().length() == 0) {
+ if (resInternalname.trim().length() == 0) {
return;
}
JsonObject recipe = new JsonObject();
- String[] x = {"1","2","3"};
- String[] y = {"A","B","C"};
+ 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);
+ 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) {
+ if (stack != null) {
internalname = neu.manager.getInternalNameForItem(stack);
- if(!neu.manager.getItemInformation().containsKey(internalname)) {
+ if (!neu.manager.getItemInformation().containsKey(internalname)) {
neu.manager.writeItemToFile(stack);
}
- internalname += ":"+stack.stackSize;
+ internalname += ":" + stack.stackSize;
}
- recipe.addProperty(y[i/9]+x[j], internalname);
+ recipe.addProperty(y[i / 9] + x[j], internalname);
}
}
@@ -1716,17 +1727,16 @@ public class NEUEventListener {
json.addProperty("modver", NotEnoughUpdates.VERSION);
try {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + resInternalname));
- neu.manager.writeJsonDefaultDir(json, resInternalname+".json");
+ neu.manager.writeJsonDefaultDir(json, resInternalname + ".json");
neu.manager.loadItem(resInternalname);
- } catch(IOException e) {}
+ } catch (IOException ignored) {}
}
}
}
}
+ private final HashSet<String> percentStats = new HashSet<>();
-
- private HashSet<String> percentStats = new HashSet<>();
{
percentStats.add("bonus_attack_speed");
percentStats.add("crit_damage");
@@ -1744,9 +1754,10 @@ public class NEUEventListener {
//just to try and optimize it a bit
private int sbaloaded = -1;
- private boolean isSbaloaded(){
- if(sbaloaded == -1){
- if(Loader.isModLoaded("skyblockaddons")) {
+
+ private boolean isSbaloaded() {
+ if (sbaloaded == -1) {
+ if (Loader.isModLoaded("skyblockaddons")) {
sbaloaded = 1;
} else {
sbaloaded = 0;
@@ -1757,33 +1768,34 @@ public class NEUEventListener {
@SubscribeEvent(priority = EventPriority.LOW)
public void onItemTooltipLow(ItemTooltipEvent event) {
- if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return;
+ if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return;
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack);
- if(internalname == null) {
+ 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();
+ 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) {
+ if (enchantsConst != null && hasEnchantments && NotEnoughUpdates.INSTANCE.config.tooltipTweaks.missingEnchantList) {
try {
JsonArray enchantPools = enchantsConst.get("enchant_pools").getAsJsonArray();
- for(JsonElement element : enchantPools) {
+ for (JsonElement element : enchantPools) {
Set<String> currentPool = new HashSet<>();
- for(JsonElement poolElement : element.getAsJsonArray()) {
+ for (JsonElement poolElement : element.getAsJsonArray()) {
String poolS = poolElement.getAsString();
currentPool.add(poolS);
}
- for(JsonElement poolElement : element.getAsJsonArray()) {
+ for (JsonElement poolElement : element.getAsJsonArray()) {
String poolS = poolElement.getAsString();
- if(enchantIds.contains(poolS)) {
+ if (enchantIds.contains(poolS)) {
ignoreFromPool.addAll(currentPool);
break;
}
@@ -1792,16 +1804,16 @@ public class NEUEventListener {
JsonObject enchantsObj = enchantsConst.get("enchants").getAsJsonObject();
NBTTagCompound tag = event.itemStack.getTagCompound();
- if(tag != null) {
+ 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())) {
+ 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;
}
@@ -1810,7 +1822,7 @@ public class NEUEventListener {
}
}
}
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
}
boolean gotToEnchants = false;
@@ -1820,42 +1832,41 @@ public class NEUEventListener {
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) {
+ 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)) {
+ if (reforgeStones != null && reforgeStones.has(internalname)) {
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
- if(!pressedShiftLast && shift) {
+ 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]");
+ 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]");
+ 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) {
+ 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++) {
+ for (int i = 0; i < requiredRaritiesArray.size(); i++) {
requiredRarities[i] = requiredRaritiesArray.get(i).getAsString();
}
- int rarityIndex = requiredRarities.length-1;
+ int rarityIndex = requiredRarities.length - 1;
String rarity = requiredRarities[rarityIndex];
- for(int i=0; i<requiredRarities.length; i++) {
+ for (int i = 0; i < requiredRarities.length; i++) {
String rar = requiredRarities[i];
- if(rar.equalsIgnoreCase(currentRarity)) {
+ if (rar.equalsIgnoreCase(currentRarity)) {
rarity = rar;
rarityIndex = i;
break;
@@ -1864,14 +1875,14 @@ public class NEUEventListener {
boolean left = Keyboard.isKeyDown(Keyboard.KEY_LEFT);
boolean right = Keyboard.isKeyDown(Keyboard.KEY_RIGHT);
- if(!pressedArrowLast && (left || right)) {
- if(left) {
+ if (!pressedArrowLast && (left || right)) {
+ if (left) {
rarityIndex--;
- } else if(right) {
+ } else if (right) {
rarityIndex++;
}
- if(rarityIndex < 0) rarityIndex = 0;
- if(rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length-1;
+ if (rarityIndex < 0) rarityIndex = 0;
+ if (rarityIndex >= requiredRarities.length) rarityIndex = requiredRarities.length - 1;
currentRarity = requiredRarities[rarityIndex];
rarity = currentRarity;
}
@@ -1879,7 +1890,6 @@ public class NEUEventListener {
JsonElement statsE = reforgeInfo.get("reforgeStats");
-
String rarityFormatted = Utils.rarityArrMap.getOrDefault(rarity, rarity);
JsonElement reforgeAbilityE = reforgeInfo.get("reforgeAbility");
@@ -1908,7 +1918,7 @@ public class NEUEventListener {
newTooltip.add(EnumChatFormatting.BLUE + "Stats for " + rarityFormatted + "\u00a79: [\u00a7l\u00a7m< \u00a79Switch\u00a7l\u27a1\u00a79]");
- if(statsE != null && statsE.isJsonObject()) {
+ if (statsE != null && statsE.isJsonObject()) {
JsonObject stats = statsE.getAsJsonObject();
JsonElement statsRarE = stats.get(rarity);
@@ -1960,50 +1970,49 @@ public class NEUEventListener {
}
-
continue;
}
- } else if(line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) {
+ } 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) {
+ 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) {
+ for (String s : enchantIds) {
String enchantName = WordUtils.capitalizeFully(s.replace("_", " "));
- if(line.contains(enchantName)) {
+ if (line.contains(enchantName)) {
lineHasEnch = true;
break;
}
}
- if(lineHasEnch) {
+ if (lineHasEnch) {
gotToEnchants = true;
} else {
- if(gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) {
- if(enchantsConst != null && allItemEnchs != null) {
+ if (gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) {
+ if (enchantsConst != null && allItemEnchs != null) {
List<String> missing = new ArrayList<>();
- for(JsonElement enchIdElement : allItemEnchs) {
+ for (JsonElement enchIdElement : allItemEnchs) {
String enchId = enchIdElement.getAsString();
- if(!enchId.startsWith("ultimate_") && !ignoreFromPool.contains(enchId) && !enchantIds.contains(enchId)) {
+ 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++) {
+ 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) {
+ 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) {
+ if (currentLine.length() != 0 && i != 0) {
currentLine.append(", ").append(enchName);
} else {
currentLine.append(EnumChatFormatting.GRAY).append(enchName);
}
}
- if(currentLine.length() != 0) {
+ if (currentLine.length() != 0) {
newTooltip.add(currentLine.toString());
}
}
@@ -2011,7 +2020,7 @@ public class NEUEventListener {
}
}
}
- for(String op : NotEnoughUpdates.INSTANCE.config.hidden.enchantColours) {
+ 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);
@@ -2021,21 +2030,23 @@ public class NEUEventListener {
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;
+ 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; }
+ } catch (Exception e) {
+ continue;
+ }
- if(comparatorI < 0) continue;
+ if (comparatorI < 0) continue;
String regexText = "0123456789abcdefz";
- if(isSbaloaded()) {
+ if (isSbaloaded()) {
regexText = regexText + "Z";
}
@@ -2045,118 +2056,142 @@ public class NEUEventListener {
//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+") " +
+ 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
+ } 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;
-
+ 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;
+ if (levelStr == null) continue;
try {
level = Integer.parseInt(levelStr);
- } catch(Exception e) {
- switch(levelStr) {
+ } catch (Exception e) {
+ switch (levelStr) {
case "I":
- level = 1; break;
+ level = 1;
+ break;
case "II":
- level = 2; break;
+ level = 2;
+ break;
case "III":
- level = 3; break;
+ level = 3;
+ break;
case "IV":
- level = 4; break;
+ level = 4;
+ break;
case "V":
- level = 5; break;
+ level = 5;
+ break;
case "VI":
- level = 6; break;
+ level = 6;
+ break;
case "VII":
- level = 7; break;
+ level = 7;
+ break;
case "VIII":
- level = 8; break;
+ level = 8;
+ break;
case "IX":
- level = 9; break;
+ level = 9;
+ break;
case "X":
- level = 10; break;
+ level = 10;
+ break;
case "XI":
- level = 11; break;
+ level = 11;
+ break;
case "XII":
- level = 12; break;
+ level = 12;
+ break;
case "XIII":
- level = 13; break;
+ level = 13;
+ break;
case "XIV":
- level = 14; break;
+ level = 14;
+ break;
case "XV":
- level = 15; break;
+ level = 15;
+ break;
case "XVI":
- level = 16; break;
+ level = 16;
+ break;
case "XVII":
- level = 17; break;
+ level = 17;
+ break;
case "XVIII":
- level = 18; break;
+ level = 18;
+ break;
case "XIX":
- level = 19; break;
+ level = 19;
+ break;
case "XX":
- level = 20; break;
+ level = 20;
+ break;
}
}
boolean matches = false;
- if(level > 0) {
- switch(comparator) {
+ if (level > 0) {
+ switch (comparator) {
case ">":
- matches = level > levelToFind; break;
+ matches = level > levelToFind;
+ break;
case "=":
- matches = level == levelToFind; break;
+ matches = level == levelToFind;
+ break;
case "<":
- matches = level < levelToFind; break;
+ matches = level < levelToFind;
+ break;
}
}
- if(matches) {
+ if (matches) {
String enchantText = matcher.group("enchantName");
StringBuilder extraModifiersBuilder = new StringBuilder();
- if((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
+ if ((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) {
extraModifiersBuilder.append(EnumChatFormatting.BOLD);
}
- if((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
+ if ((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) {
extraModifiersBuilder.append(EnumChatFormatting.ITALIC);
}
- if((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
+ if ((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) {
extraModifiersBuilder.append(EnumChatFormatting.UNDERLINE);
}
- if((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) {
+ if ((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) {
extraModifiersBuilder.append(EnumChatFormatting.OBFUSCATED);
}
- if((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
+ 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);
+ 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));
+ "\\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));
+ "\\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));
+ "\\u00A7l\\u00A7d\\u00A7l" + enchantText + ".*", ""));
+ line = line.replace("\u00A7l\u00A7d\u00A7l" + enchantText, Utils.chromaString(enchantText,
+ offset / 12f + index, true));
}
}
}
@@ -2165,25 +2200,24 @@ public class NEUEventListener {
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(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)) {
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
newTooltip.add("");
- newTooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]");
+ 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")) {
+ 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) {
+ } else if (index == 7 && dungeonProfit) {
GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen;
ContainerChest cc = (ContainerChest) eventGui.inventorySlots;
IInventory lower = cc.getLowerChestInventory();
@@ -2192,64 +2226,64 @@ public class NEUEventListener {
try {
String line6 = Utils.cleanColour(line);
StringBuilder cost = new StringBuilder();
- for(int i=0; i<line6.length(); i++) {
+ for (int i = 0; i < line6.length(); i++) {
char c = line6.charAt(i);
- if("0123456789".indexOf(c) >= 0) {
+ if ("0123456789".indexOf(c) >= 0) {
cost.append(c);
}
}
- if(cost.length() > 0) {
+ if (cost.length() > 0) {
chestCost = Integer.parseInt(cost.toString());
}
- } catch(Exception ignored) {}
+ } 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);
+ for (int i = 0; i < 5; i++) {
+ ItemStack item = lower.getStackInSlot(11 + i);
String internal = neu.manager.getInternalNameForItem(item);
- if(internal != null) {
+ 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")) {
+ if (bazaarInfo != null && bazaarInfo.has("curr_sell")) {
bazaarPrice = bazaarInfo.get("curr_sell").getAsFloat();
}
- if(bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
+ if (bazaarPrice < 5000000 && internal.equals("RECOMBOBULATOR_3000")) bazaarPrice = 5000000;
float worth = -1;
- if(bazaarPrice > 0) {
+ if (bazaarPrice > 0) {
worth = bazaarPrice;
} else {
- switch(NotEnoughUpdates.INSTANCE.config.dungeons.profitType) {
+ 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();
+ 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());
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
}
}
break;
default:
worth = neu.manager.auctionManager.getLowestBin(internal);
}
- if(worth <= 0) {
+ if (worth <= 0) {
worth = neu.manager.auctionManager.getLowestBin(internal);
- if(worth <= 0) {
+ if (worth <= 0) {
worth = neu.manager.auctionManager.getItemAvgBin(internal);
- if(worth <= 0) {
+ 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();
+ 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());
+ worth = (int) (auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat());
}
}
}
@@ -2257,22 +2291,22 @@ public class NEUEventListener {
}
}
- if(worth > 0 && totalValue >= 0) {
+ if (worth > 0 && totalValue >= 0) {
totalValue += worth;
String display = item.getDisplayName();
- if(display.contains("Enchanted Book")) {
+ if (display.contains("Enchanted Book")) {
NBTTagCompound tag = item.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ 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()) {
+ for (String enchname : enchants.getKeySet()) {
int level = enchants.getInteger(enchname);
- if(level > highestLevel) {
- display = EnumChatFormatting.BLUE+WordUtils.capitalizeFully(
+ if (level > highestLevel) {
+ display = EnumChatFormatting.BLUE + WordUtils.capitalizeFully(
enchname.replace("_", " ")
.replace("Ultimate", "")
.trim()) + " " + level;
@@ -2283,7 +2317,7 @@ public class NEUEventListener {
itemValues.put(display, worth);
} else {
- if(totalValue != -1) {
+ if (totalValue != -1) {
missingItem = internal;
}
totalValue = -1;
@@ -2294,35 +2328,35 @@ public class NEUEventListener {
NumberFormat format = NumberFormat.getInstance(Locale.US);
String valueStringBIN1;
String valueStringBIN2;
- if(totalValue >= 0) {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Value (BIN): ";
+ if (totalValue >= 0) {
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Value (BIN): ";
valueStringBIN2 = EnumChatFormatting.GOLD + format.format(totalValue) + " coins";
} else {
- valueStringBIN1 = EnumChatFormatting.YELLOW+"Can't find BIN: ";
+ valueStringBIN1 = EnumChatFormatting.YELLOW + "Can't find BIN: ";
valueStringBIN2 = missingItem;
}
int profitLossBIN = totalValue - chestCost;
- String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
+ String profitPrefix = EnumChatFormatting.DARK_GREEN.toString();
String lossPrefix = EnumChatFormatting.RED.toString();
String prefix = profitLossBIN >= 0 ? profitPrefix : lossPrefix;
String plStringBIN;
- if(profitLossBIN >= 0) {
+ if (profitLossBIN >= 0) {
plStringBIN = prefix + "+" + format.format(profitLossBIN) + " coins";
} else {
- plStringBIN = prefix + "-"+ format.format(-profitLossBIN) + " coins";
+ 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);
+ 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+"+"+
+ for (Map.Entry<String, Float> entry : itemValues.entrySet()) {
+ newTooltip.add(neu + entry.getKey() + prefix + "+" +
format.format(entry.getValue().intValue()));
}
}
@@ -2331,14 +2365,14 @@ public class NEUEventListener {
index++;
}
- for (int i = newTooltip.size()-1; i >=0; i--) {
+ 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){
+ if (line.equals(Utils.rarityArr[i1])) {
+ if (i - 2 < 0) {
break;
}
- newTooltip.addAll(i-1, petToolTipXPExtend(event));
+ newTooltip.addAll(i - 1, petToolTipXPExtend(event));
break;
}
}
@@ -2360,27 +2394,23 @@ public class NEUEventListener {
hypixelOrder.add("reforge_bonus");
hypixelOrder.add("rarity");
- if(NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
+ if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
ItemPriceInformation.addToTooltip(event.toolTip, internalname, event.itemStack);
}
-
-
-
-
}
- private Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))");
+ private final Pattern xpLevelPattern = Pattern.compile("(.*) (\\xA7e(.*)\\xA76/\\xA7e(.*))");
- private void onItemToolTipInternalNameNull(ItemTooltipEvent event){
+ private void onItemToolTipInternalNameNull(ItemTooltipEvent event) {
petToolTipXPExtendPetMenu(event);
}
private List<String> petToolTipXPExtend(ItemTooltipEvent event) {
- List<String> tooltipText = new ArrayList();
+ List<String> tooltipText = new ArrayList<>();
if (NotEnoughUpdates.INSTANCE.config.tooltipTweaks.petExtendExp) {
- if(event.itemStack.getTagCompound().hasKey("DisablePetExp")){
- if(event.itemStack.getTagCompound().getBoolean("DisablePetExp")){
+ if (event.itemStack.getTagCompound().hasKey("DisablePetExp")) {
+ if (event.itemStack.getTagCompound().getBoolean("DisablePetExp")) {
return tooltipText;
}
}
@@ -2399,7 +2429,7 @@ public class NEUEventListener {
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();
+ //Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip))).getAsInt();
petlevel = GuiProfileViewer.getPetLevel(petName, Utils.getRarityFromInt(Utils.checkItemTypePet(event.toolTip)), exp.getAsLong());
}
}
@@ -2407,13 +2437,13 @@ public class NEUEventListener {
if (petlevel != null) {
tooltipText.add("");
- if(petlevel.totalXp > petlevel.maxXP) {
- tooltipText.add(EnumChatFormatting.AQUA + "" + EnumChatFormatting.BOLD +"MAX LEVEL");
+ 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) +
+ 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");
}
}
@@ -2422,7 +2452,7 @@ public class NEUEventListener {
}
return tooltipText;
}
-
+
private static final String petToolTipRegex = "((Farming)|(Combat)|(Fishing)|(Mining)|(Foraging)|(Enchanting)|(Alchemy)) ((Mount)|(Pet)|(Morph)).*";
private void petToolTipXPExtendPetMenu(ItemTooltipEvent event) {
@@ -2450,11 +2480,11 @@ public class NEUEventListener {
}
petlevel = pet.petLevel;
- if (petlevel == null||xpLine==-1) {
+ if (petlevel == null || xpLine == -1) {
return;
}
- event.toolTip.add(xpLine+1, EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) +
+ event.toolTip.add(xpLine + 1, EnumChatFormatting.GRAY + "EXP: " + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.levelXp) +
EnumChatFormatting.GOLD + "/" + EnumChatFormatting.YELLOW + myFormatter.format(petlevel.currentLevelRequirement));
}
@@ -2466,11 +2496,12 @@ public class NEUEventListener {
/**
* 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 (!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));
@@ -2528,37 +2559,37 @@ public class NEUEventListener {
}
}
}*/
- 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);
+ 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()) {
+ for (char c : nbt.toCharArray()) {
boolean newline = false;
- if(c == '{' || c == '[') {
+ if (c == '{' || c == '[') {
indent++;
newline = true;
- } else if(c == '}' || c == ']') {
+ } else if (c == '}' || c == ']') {
indent--;
sb.append("\n");
- for(int i=0; i<indent; i++) sb.append(" ");
- } else if(c == ',') {
+ for (int i = 0; i < indent; i++) sb.append(" ");
+ } else if (c == ',') {
newline = true;
- } else if(c == '\"') {
+ } else if (c == '\"') {
sb.append(EnumChatFormatting.RESET.toString() + EnumChatFormatting.GRAY);
}
sb.append(c);
- if(newline) {
+ if (newline) {
sb.append("\n");
- for(int i=0; i<indent; i++) sb.append(" ");
+ for (int i = 0; i < indent; i++) sb.append(" ");
}
}
event.toolTip.add(sb.toString());
- if(Keyboard.isKeyDown(Keyboard.KEY_H)) {
- if(!copied) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_H)) {
+ if (!copied) {
copied = true;
StringSelection selection = new StringSelection(sb.toString());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
@@ -2566,10 +2597,10 @@ public class NEUEventListener {
} else {
copied = false;
}
- } else if(NotEnoughUpdates.INSTANCE.packDevEnabled) {
+ } 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");
+ 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);
@@ -2577,20 +2608,20 @@ public class NEUEventListener {
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) {
+ event.toolTip.add(EnumChatFormatting.AQUA + "Internal Name: " + EnumChatFormatting.GRAY + internal + EnumChatFormatting.GOLD + " [K]");
+ if (!copied && k) {
MiscUtils.copyToClipboard(internal);
}
- if(event.itemStack.getTagCompound() != null) {
+ 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) {
+ 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());
}
@@ -2598,9 +2629,9 @@ public class NEUEventListener {
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]");
+ event.toolTip.add(EnumChatFormatting.AQUA + "Skull Texture Link: " + EnumChatFormatting.GRAY + profTex.getUrl() + EnumChatFormatting.GOLD + " [N]");
- if(!copied && n) {
+ if (!copied && n) {
MiscUtils.copyToClipboard(profTex.getUrl());
}
}
@@ -2608,16 +2639,12 @@ public class NEUEventListener {
}
}
- if(k || m || n) {
- copied = true;
- } else {
- copied = false;
- }
+ copied = k || m || n;
}
}
@SubscribeEvent
- public void onRenderLast(RenderWorldLastEvent event){
+ 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..59332f23 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -40,10 +40,10 @@ public class NEUManager {
public final Gson gson;
public final APIManager auctionManager;
- private TreeMap<String, JsonObject> itemMap = new TreeMap<>();
+ private final 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<>();
+ 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");
@@ -52,23 +52,23 @@ public class NEUManager {
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,
+ 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 = "";
+ private final String currentProfileBackup = "";
public final HypixelApi hypixelApi = new HypixelApi();
- private Map<String, ItemStack> itemstackCache = new HashMap<>();
+ private final Map<String, ItemStack> itemstackCache = new HashMap<>();
- private ExecutorService repoLoaderES = Executors.newSingleThreadExecutor();
+ private final ExecutorService repoLoaderES = Executors.newSingleThreadExecutor();
private static String GIT_COMMITS_URL;
- private HashMap<String, Set<String>> usagesMap = new HashMap<>();
+ private final HashMap<String, Set<String>> usagesMap = new HashMap<>();
public String latestRepoCommit = null;
@@ -97,25 +97,33 @@ public class NEUManager {
}
public <T> T getJsonFromFile(File file, Class<T> clazz) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ 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; }
+ } 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))) {
+ 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; }
+ } 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) {}
+ try {
+ Utils.recursiveDelete(new File(configLocation, "repo"));
+ } catch (Exception ignored) {}
+ try {
+ new File(configLocation, "currentCommit.json").delete();
+ } catch (Exception ignored) {}
}
/**
@@ -158,27 +166,27 @@ public class NEUManager {
repoLoaderES.submit(() -> {
JDialog dialog = null;
try {
- if(NotEnoughUpdates.INSTANCE.config.hidden.autoupdate) {
+ 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 (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())) {
+ 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 (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)) {
+ 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;
}
@@ -189,12 +197,11 @@ public class NEUManager {
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 (NotEnoughUpdates.INSTANCE.config.hidden.dev) dialog.setVisible(true);
if (Display.isActive()) dialog.toFront();
File itemsZip = new File(repoLocation, "neu-items-master.zip");
@@ -204,13 +211,12 @@ public class NEUManager {
return;
}
-
URL url = new URL(dlUrl);
URLConnection urlConnection = url.openConnection();
urlConnection.setConnectTimeout(15000);
urlConnection.setReadTimeout(30000);
- try(InputStream is = urlConnection.getInputStream()) {
+ try (InputStream is = urlConnection.getInputStream()) {
FileUtils.copyInputStreamToFile(is, itemsZip);
} catch (IOException e) {
dialog.dispose();
@@ -237,29 +243,28 @@ public class NEUManager {
unzipIgnoreFirstFolder(itemsZip.getAbsolutePath(), repoLocation.getAbsolutePath());
- if(currentCommitJSON == null || !currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) {
+ 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 (IOException ignored) {}
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
} finally {
- if(dialog != null) dialog.dispose();
+ if (dialog != null) dialog.dispose();
}
File items = new File(repoLocation, "items");
- if(items.exists()) {
+ 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)) {
+ if (itemFiles != null) {
+ for (File f : itemFiles) {
+ String internalname = f.getName().substring(0, f.getName().length() - 5);
+ synchronized (itemMap) {
+ if (!itemMap.containsKey(internalname)) {
loadItem(internalname);
}
}
@@ -269,19 +274,19 @@ public class NEUManager {
try {
Constants.reload();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
});
File items = new File(repoLocation, "items");
- if(items.exists()) {
+ 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)) {
+ if (itemFiles != null) {
+ for (File f : itemFiles) {
+ String internalname = f.getName().substring(0, f.getName().length() - 5);
+ synchronized (itemMap) {
+ if (!itemMap.containsKey(internalname)) {
loadItem(internalname);
}
}
@@ -291,7 +296,7 @@ public class NEUManager {
try {
Constants.reload();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -299,41 +304,42 @@ public class NEUManager {
/**
* 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) {
+ if (json == null) {
return;
}
- if(json.get("itemid") == null) return;
+ if (json.get("itemid") == null) return;
String itemid = json.get("itemid").getAsString();
Item mcitem = Item.getByNameOrId(itemid);
- if(mcitem != null) {
+ if (mcitem != null) {
itemid = mcitem.getRegistryName();
}
json.addProperty("itemid", itemid);
itemMap.put(internalName, json);
- if(json.has("recipe")) {
- synchronized(usagesMap) {
+ 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[] 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) {
+ if (itemS != null && itemS.split(":").length == 2) {
itemS = itemS.split(":")[0];
}
- if(!usagesMap.containsKey(itemS)) {
+ if (!usagesMap.containsKey(itemS)) {
usagesMap.put(itemS, new HashSet<>());
}
usagesMap.get(itemS).add(internalName);
@@ -341,15 +347,15 @@ public class NEUManager {
}
}
- if(json.has("displayname")) {
- synchronized(titleWordMap) {
- int wordIndex=0;
- for(String str : json.get("displayname").getAsString().split(" ")) {
+ if (json.has("displayname")) {
+ synchronized (titleWordMap) {
+ int wordIndex = 0;
+ for (String str : json.get("displayname").getAsString().split(" ")) {
str = clean(str);
- if(!titleWordMap.containsKey(str)) {
+ if (!titleWordMap.containsKey(str)) {
titleWordMap.put(str, new HashMap<>());
}
- if(!titleWordMap.get(str).containsKey(internalName)) {
+ if (!titleWordMap.get(str).containsKey(internalName)) {
titleWordMap.get(str).put(internalName, new ArrayList<>());
}
titleWordMap.get(str).get(internalName).add(wordIndex);
@@ -358,16 +364,16 @@ public class NEUManager {
}
}
- if(json.has("lore")) {
- synchronized(loreWordMap) {
- int wordIndex=0;
- for(JsonElement element : json.get("lore").getAsJsonArray()) {
- for(String str : element.getAsString().split(" ")) {
+ 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)) {
+ if (!loreWordMap.containsKey(str)) {
loreWordMap.put(str, new HashMap<>());
}
- if(!loreWordMap.get(str).containsKey(internalName)) {
+ if (!loreWordMap.get(str).containsKey(internalName)) {
loreWordMap.get(str).put(internalName, new ArrayList<>());
}
loreWordMap.get(str).get(internalName).add(wordIndex);
@@ -376,11 +382,11 @@ public class NEUManager {
}
}
}
- } catch(Exception e) {
- synchronized(loreWordMap) {
+ } catch (Exception e) {
+ synchronized (loreWordMap) {
System.out.println("loreWordMap is : " + loreWordMap);
}
- synchronized(titleWordMap) {
+ synchronized (titleWordMap) {
System.out.println("titleWordMap is : " + titleWordMap);
}
System.out.println("internalName is : " + internalName);
@@ -399,9 +405,9 @@ public class NEUManager {
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) {
+ 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;
@@ -419,14 +425,14 @@ public class NEUManager {
* more complex map-based search function.
*/
public boolean doesStackMatchSearch(ItemStack stack, String query) {
- if(query.startsWith("title:")) {
+ if (query.startsWith("title:")) {
query = query.substring(6);
return searchString(stack.getDisplayName(), query);
- } else if(query.startsWith("desc:")) {
+ } else if (query.startsWith("desc:")) {
query = query.substring(5);
String lore = "";
NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
+ if (tag != null) {
NBTTagCompound display = tag.getCompoundTag("display");
if (display.hasKey("Lore", 9)) {
NBTTagList list = display.getTagList("Lore", 8);
@@ -436,15 +442,15 @@ public class NEUManager {
}
}
return searchString(lore, query);
- } else if(query.startsWith("id:")) {
+ } 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(" ")) {
+ if (!query.trim().contains(" ")) {
StringBuilder sb = new StringBuilder();
- for(char c : query.toCharArray()) {
+ for (char c : query.toCharArray()) {
sb.append(c).append(" ");
}
result = result || searchString(stack.getDisplayName(), sb.toString());
@@ -453,7 +459,7 @@ public class NEUManager {
String lore = "";
NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
+ if (tag != null) {
NBTTagCompound display = tag.getCompoundTag("display");
if (display.hasKey("Lore", 9)) {
NBTTagList list = display.getTagList("Lore", 8);
@@ -474,16 +480,16 @@ public class NEUManager {
* eg. search(A|B) = search(A) + search(B)
*/
public Set<String> search(String query, boolean multi) {
- if(multi) {
+ if (multi) {
Set<String> result = new HashSet<>();
StringBuilder query2 = new StringBuilder();
char lastOp = '|';
- for(char c : query.toCharArray()) {
- if(c == '|' || c == '&') {
- if(lastOp == '|') {
+ for (char c : query.toCharArray()) {
+ if (c == '|' || c == '&') {
+ if (lastOp == '|') {
result.addAll(search(query2.toString()));
- } else if(lastOp == '&') {
+ } else if (lastOp == '&') {
result.retainAll(search(query2.toString()));
}
@@ -493,9 +499,9 @@ public class NEUManager {
query2.append(c);
}
}
- if(lastOp == '|') {
+ if (lastOp == '|') {
result.addAll(search(query2.toString()));
- } else if(lastOp == '&') {
+ } else if (lastOp == '&') {
result.retainAll(search(query2.toString()));
}
@@ -543,22 +549,22 @@ public class NEUManager {
public Set<String> search(String query) {
query = query.trim();
boolean negate = query.startsWith("!");
- if(negate) query = query.substring(1);
+ if (negate) query = query.substring(1);
LinkedHashSet<String> results = new LinkedHashSet<>();
- if(query.startsWith("title:")) {
+ if (query.startsWith("title:")) {
query = query.substring(6);
results.addAll(new TreeSet<>(search(query, titleWordMap)));
- } else if(query.startsWith("desc:")) {
+ } else if (query.startsWith("desc:")) {
query = query.substring(5);
results.addAll(new TreeSet<>(search(query, loreWordMap)));
- } else if(query.startsWith("id:")) {
+ } else if (query.startsWith("id:")) {
query = query.substring(3);
results.addAll(new TreeSet<>(subMapWithKeysThatAreSuffixes(query.toUpperCase(), itemMap).keySet()));
} else {
- if(!query.trim().contains(" ")) {
+ if (!query.trim().contains(" ")) {
StringBuilder sb = new StringBuilder();
- for(char c : query.toCharArray()) {
+ for (char c : query.toCharArray()) {
sb.append(c).append(" ");
}
results.addAll(new TreeSet<>(search(sb.toString(), titleWordMap)));
@@ -566,11 +572,11 @@ public class NEUManager {
results.addAll(new TreeSet<>(search(query, titleWordMap)));
results.addAll(new TreeSet<>(search(query, loreWordMap)));
}
- if(!negate) {
+ if (!negate) {
return results;
} else {
Set<String> negatedResults = new HashSet<>();
- for(String internalname : itemMap.keySet()) {
+ for (String internalname : itemMap.keySet()) {
negatedResults.add(internalname);
}
negatedResults.removeAll(results);
@@ -589,24 +595,24 @@ public class NEUManager {
HashMap<String, List<Integer>> matches = null;
query = clean(query).toLowerCase();
- for(String queryWord : query.split(" ")) {
+ 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) {
+ 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)) {
+ 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)) {
+ 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);
@@ -617,7 +623,7 @@ public class NEUManager {
}
}
}
- if(matchesToKeep.isEmpty()) return new HashSet<>();
+ if (matchesToKeep.isEmpty()) return new HashSet<>();
matches = matchesToKeep;
}
@@ -634,11 +640,11 @@ public class NEUManager {
}
public String createLexicographicallyNextStringOfTheSameLength(String input) {
- final int lastCharPosition = input.length()-1;
+ final int lastCharPosition = input.length() - 1;
String inputWithoutLastChar = input.substring(0, lastCharPosition);
- char lastChar = input.charAt(lastCharPosition) ;
+ char lastChar = input.charAt(lastCharPosition);
char incrementedLastChar = (char) (lastChar + 1);
- return inputWithoutLastChar+incrementedLastChar;
+ return inputWithoutLastChar + incrementedLastChar;
}
public JsonObject getJsonFromItemBytes(String item_bytes) {
@@ -646,7 +652,7 @@ public class NEUManager {
NBTTagCompound tag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
//System.out.println(tag.toString());
return getJsonFromNBT(tag);
- } catch(IOException e) {
+ } catch (IOException e) {
return null;
}
}
@@ -665,41 +671,47 @@ public class NEUManager {
public String getInternalnameFromNBT(NBTTagCompound tag) {
String internalname = null;
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("id", 8)) {
+ if (ea.hasKey("id", 8)) {
internalname = ea.getString("id").replaceAll(":", "-");
} else {
return null;
}
- if("PET".equals(internalname)) {
+ if ("PET".equals(internalname)) {
String petInfo = ea.getString("petInfo");
- if(petInfo.length() > 0) {
+ if (petInfo.length() > 0) {
JsonObject petInfoObject = gson.fromJson(petInfo, JsonObject.class);
internalname = petInfoObject.get("type").getAsString();
String tier = petInfoObject.get("tier").getAsString();
- switch(tier) {
+ switch (tier) {
case "COMMON":
- internalname += ";0"; break;
+ internalname += ";0";
+ break;
case "UNCOMMON":
- internalname += ";1"; break;
+ internalname += ";1";
+ break;
case "RARE":
- internalname += ";2"; break;
+ internalname += ";2";
+ break;
case "EPIC":
- internalname += ";3"; break;
+ internalname += ";3";
+ break;
case "LEGENDARY":
- internalname += ";4"; break;
+ internalname += ";4";
+ break;
case "MYTHIC":
- internalname += ";5"; break;
+ internalname += ";5";
+ break;
}
}
}
- if("ENCHANTED_BOOK".equals(internalname)) {
+ if ("ENCHANTED_BOOK".equals(internalname)) {
NBTTagCompound enchants = ea.getCompoundTag("enchantments");
- for(String enchname : enchants.getKeySet()) {
+ for (String enchname : enchants.getKeySet()) {
internalname = enchname.toUpperCase() + ";" + enchants.getInteger(enchname);
break;
}
@@ -713,10 +725,10 @@ public class NEUManager {
String[] lore = new String[0];
NBTTagCompound display = tag.getCompoundTag("display");
- if(display.hasKey("Lore", 9)) {
+ if (display.hasKey("Lore", 9)) {
NBTTagList list = display.getTagList("Lore", 8);
lore = new String[list.tagCount()];
- for(int k=0; k<list.tagCount(); k++) {
+ for (int k = 0; k < list.tagCount(); k++) {
lore[k] = list.getStringTagAt(k);
}
}
@@ -728,24 +740,24 @@ public class NEUManager {
}
public JsonObject getJsonFromNBTEntry(NBTTagCompound tag) {
- if(tag.getKeySet().size() == 0) return null;
+ 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
+ if (id == 141) id = 391; //for some reason hypixel thinks carrots have id 141
String internalname = getInternalnameFromNBT(tag);
- if(internalname == null) return null;
+ 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) {
+ if (itemMc != null) {
itemid = itemMc.getRegistryName();
}
String displayname = display.getString("Name");
@@ -757,29 +769,29 @@ public class NEUManager {
item.addProperty("itemid", itemid);
item.addProperty("displayname", displayname);
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ 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")) {
+ 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) {
+ if (bytes != null) {
JsonArray bytesArr = new JsonArray();
- for(byte b : bytes) {
+ for (byte b : bytes) {
bytesArr.add(new JsonPrimitive(b));
}
item.add("item_contents", bytesArr);
}
- if(ea.hasKey("dungeon_item_level")) {
+ if (ea.hasKey("dungeon_item_level")) {
item.addProperty("dungeon_item_level", ea.getInteger("dungeon_item_level"));
}
}
- if(lore != null && lore.length > 0) {
+ if (lore != null && lore.length > 0) {
JsonArray jsonLore = new JsonArray();
for (String line : lore) {
jsonLore.add(new JsonPrimitive(line));
@@ -788,7 +800,7 @@ public class NEUManager {
}
item.addProperty("damage", damage);
- if(count > 1) item.addProperty("count", count);
+ if (count > 1) item.addProperty("count", count);
item.addProperty("nbttag", tag.toString());
return item;
@@ -800,22 +812,22 @@ public class NEUManager {
public void showRecipe(JsonObject item) {
ContainerChest container = null;
- if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest)
+ 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()) {
+ } else if (item.has("useneucraft") && item.get("useneucraft").getAsBoolean()) {
displayGuiItemRecipe(item.get("internalname").getAsString(), "");
- } else if(item.has("clickcommand")) {
+ } else if (item.has("clickcommand")) {
String clickcommand = item.get("clickcommand").getAsString();
- if(clickcommand.equals("viewrecipe")) {
+ 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")) {
+ } else if (clickcommand.equals("viewpotion")) {
neu.sendChatMessage(
"/" + clickcommand + " " +
item.get("internalname").getAsString().split(";")[0].toLowerCase());
@@ -833,26 +845,26 @@ public class NEUManager {
//Item lore
String[] lore = new String[0];
- if(tag.hasKey("display", 10)) {
+ if (tag.hasKey("display", 10)) {
NBTTagCompound display = tag.getCompoundTag("display");
- if(display.hasKey("Lore", 9)) {
+ if (display.hasKey("Lore", 9)) {
NBTTagList list = display.getTagList("Lore", 8);
lore = new String[list.tagCount()];
- for(int i=0; i<list.tagCount(); i++) {
+ 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 (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);
+ 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;
}
@@ -863,7 +875,7 @@ public class NEUManager {
json.addProperty("damage", stack.getItemDamage());
JsonArray jsonlore = new JsonArray();
- for(String line : lore) {
+ for (String line : lore) {
jsonlore.add(new JsonPrimitive(line));
}
json.add("lore", jsonlore);
@@ -872,13 +884,13 @@ public class NEUManager {
}
public String getInternalNameForItem(ItemStack stack) {
- if(stack == null) return null;
+ if (stack == null) return null;
NBTTagCompound tag = stack.getTagCompound();
return getInternalnameFromNBT(tag);
}
public String getUUIDForItem(ItemStack stack) {
- if(stack == null) return null;
+ if (stack == null) return null;
NBTTagCompound tag = stack.getTagCompound();
return getUUIDFromNBT(tag);
}
@@ -886,7 +898,7 @@ public class NEUManager {
public void writeItemToFile(ItemStack stack) {
String internalname = getInternalNameForItem(stack);
- if(internalname == null) {
+ if (internalname == null) {
return;
}
@@ -896,8 +908,8 @@ public class NEUManager {
json.addProperty("modver", NotEnoughUpdates.VERSION);
try {
- writeJson(json, new File(new File(repoLocation, "items"), internalname+".json"));
- } catch (IOException e) {}
+ writeJson(json, new File(new File(repoLocation, "items"), internalname + ".json"));
+ } catch (IOException ignored) {}
loadItem(internalname);
}
@@ -907,33 +919,33 @@ public class NEUManager {
*/
public boolean displayGuiItemUsages(String internalName) {
List<ItemStack[]> craftMatrices = new ArrayList<>();
- List<JsonObject> results = new ArrayList<>();
+ List<JsonObject> results = new ArrayList<>();
- if(!usagesMap.containsKey(internalName)) {
+ if (!usagesMap.containsKey(internalName)) {
return false;
}
- for(String internalNameResult : usagesMap.get(internalName)) {
+ for (String internalNameResult : usagesMap.get(internalName)) {
JsonObject item = getItemInformation().get(internalNameResult);
results.add(item);
- if(item != null && item.has("recipe")) {
+ 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[] 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]);
+ if (itemS != null && itemS.split(":").length == 2) {
+ count = Integer.parseInt(itemS.split(":")[1]);
itemS = itemS.split(":")[0];
}
JsonObject craft = getItemInformation().get(itemS);
- if(craft != null) {
+ if (craft != null) {
ItemStack stack = jsonToStack(craft);
stack.stackSize = count;
craftMatrix[i] = stack;
@@ -944,7 +956,7 @@ public class NEUManager {
}
}
- if(craftMatrices.size() > 0) {
+ if (craftMatrices.size() > 0) {
Minecraft.getMinecraft().displayGuiScreen(new GuiItemRecipe("Item Usages", craftMatrices, results, this));
return true;
}
@@ -956,23 +968,23 @@ public class NEUManager {
*/
public boolean displayGuiItemRecipe(String internalName, String text) {
JsonObject item = getItemInformation().get(internalName);
- if(item != null && item.has("recipe")) {
+ 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[] 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]);
+ if (itemS != null && itemS.split(":").length == 2) {
+ count = Integer.parseInt(itemS.split(":")[1]);
itemS = itemS.split(":")[0];
}
JsonObject craft = getItemInformation().get(itemS);
- if(craft != null) {
+ if (craft != null) {
ItemStack stack = jsonToStack(craft);
stack.stackSize = count;
craftMatrix[i] = stack;
@@ -981,7 +993,7 @@ public class NEUManager {
Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(
Minecraft.getMinecraft().thePlayer.openContainer.windowId));
- Minecraft.getMinecraft().displayGuiScreen(new GuiItemRecipe(text!=null?text:"Item Recipe",
+ Minecraft.getMinecraft().displayGuiScreen(new GuiItemRecipe(text != null ? text : "Item Recipe",
Lists.<ItemStack[]>newArrayList(craftMatrix), Lists.newArrayList(item), this));
return true;
}
@@ -993,8 +1005,8 @@ public class NEUManager {
* 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) {
+ if (viewItemAttemptID != null && !viewItemAttemptID.isEmpty()) {
+ if (System.currentTimeMillis() - viewItemAttemptTime < 500) {
return displayGuiItemRecipe(viewItemAttemptID, text);
}
}
@@ -1005,8 +1017,8 @@ public class NEUManager {
* 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()) {
+ File f = new File(configLocation, "tmp/" + Base64.getEncoder().encodeToString(url.getBytes()) + ".html");
+ if (f.exists()) {
return f;
}
@@ -1017,9 +1029,9 @@ public class NEUManager {
} catch (IOException e) {
return null;
}
- try (BufferedInputStream inStream = new BufferedInputStream(new URL(url+"?action=raw&templates=expand").openStream());
+ try (BufferedInputStream inStream = new BufferedInputStream(new URL(url + "?action=raw&templates=expand").openStream());
FileOutputStream fileOutputStream = new FileOutputStream(f)) {
- byte dataBuffer[] = new byte[1024];
+ byte[] dataBuffer = new byte[1024];
int bytesRead;
while ((bytesRead = inStream.read(dataBuffer, 0, 1024)) != -1) {
fileOutputStream.write(dataBuffer, 0, bytesRead);
@@ -1032,14 +1044,13 @@ public class NEUManager {
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();
+ if (!dir.exists()) dir.mkdirs();
FileInputStream fis;
//buffer for read and write data to file
byte[] buffer = new byte[1024];
@@ -1047,10 +1058,10 @@ public class NEUManager {
fis = new FileInputStream(zipFilePath);
ZipInputStream zis = new ZipInputStream(fis);
ZipEntry ze = zis.getNextEntry();
- while(ze != null){
- if(!ze.isDirectory()) {
+ while (ze != null) {
+ if (!ze.isDirectory()) {
String fileName = ze.getName();
- fileName = fileName.substring(fileName.split("/")[0].length()+1);
+ 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();
@@ -1083,8 +1094,8 @@ public class NEUManager {
try {
ZipInputStream zis = new ZipInputStream(src);
ZipEntry ze = zis.getNextEntry();
- while(ze != null){
- if(!ze.isDirectory()) {
+ while (ze != null) {
+ if (!ze.isDirectory()) {
String fileName = ze.getName();
File newFile = new File(dest, fileName);
//create directories for sub directories in zip
@@ -1121,7 +1132,7 @@ public class NEUManager {
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()) {
+ if (internalname == null || internalname.isEmpty()) {
return null;
}
@@ -1134,9 +1145,9 @@ public class NEUManager {
json.addProperty("damage", damage);
json.addProperty("nbttag", nbttag.toString());
json.addProperty("modver", NotEnoughUpdates.VERSION);
- json.addProperty("infoType", infoType.toString());
+ json.addProperty("infoType", infoType);
- if(info != null && info.length > 0) {
+ if (info != null && info.length > 0) {
JsonArray jsoninfo = new JsonArray();
for (String line : info) {
jsoninfo.add(new JsonPrimitive(line));
@@ -1145,7 +1156,7 @@ public class NEUManager {
}
JsonArray jsonlore = new JsonArray();
- for(String line : lore) {
+ for (String line : lore) {
jsonlore.add(new JsonPrimitive(line));
}
json.add("lore", jsonlore);
@@ -1161,13 +1172,13 @@ public class NEUManager {
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) {
+ if (json == null) {
return false;
}
try {
- writeJsonDefaultDir(json, internalname+".json");
- } catch(IOException e) {
+ writeJsonDefaultDir(json, internalname + ".json");
+ } catch (IOException e) {
return false;
}
@@ -1178,7 +1189,7 @@ public class NEUManager {
public void writeJson(JsonObject json, File file) throws IOException {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(json));
}
}
@@ -1193,8 +1204,8 @@ public class NEUManager {
}
public String removeUnusedDecimal(double num) {
- if(num % 1 == 0) {
- return String.valueOf((int)num);
+ if (num % 1 == 0) {
+ return String.valueOf((int) num);
} else {
return String.valueOf(num);
}
@@ -1202,58 +1213,57 @@ public class NEUManager {
public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
JsonObject petnums = null;
- if(petname != null && tier != 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")){
+ 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);
+ replacements.put("LVL", "1\u27A1" + maxLvl);
} else {
replacements.put("LVL", "1\u27A1100");
}
} else {
- replacements.put("LVL", ""+level);
+ replacements.put("LVL", "" + level);
}
-
- if(petnums != null) {
- if(petnums.has(petname)) {
+ if (petnums != null) {
+ if (petnums.has(petname)) {
JsonObject petInfo = petnums.get(petname).getAsJsonObject();
- if(petInfo.has(tier)) {
+ if (petInfo.has(tier)) {
JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject();
- if(petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) {
+ 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) {
+ if (level < 1) {
JsonArray otherNumsMin = min.get("otherNums").getAsJsonArray();
JsonArray otherNumsMax = max.get("otherNums").getAsJsonArray();
boolean addZero = false;
- if(petInfoTier.has("stats_levelling_curve")){
+ if (petInfoTier.has("stats_levelling_curve")) {
String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":");
- if(stringArray.length == 3) {
+ if (stringArray.length == 3) {
int type = Integer.parseInt(stringArray[2]);
- if(type == 1){
+ 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 (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;
+ 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 {
@@ -1264,8 +1274,7 @@ public class NEUManager {
int statsLevel = level;
-
- if(petInfoTier.has("stats_levelling_curve")) {
+ if (petInfoTier.has("stats_levelling_curve")) {
String[] stringArray = petInfoTier.get("stats_levelling_curve").getAsString().split(":");
if (stringArray.length == 3) {
minStatsLevel = Integer.parseInt(stringArray[0]);
@@ -1287,22 +1296,22 @@ public class NEUManager {
}
}
}
- float minMix = (maxStatsLevel-(minStatsLevel-(statsLevelingType==-1?0:1))-statsLevel)/99f;
- float maxMix = (statsLevel-1)/99f;
+ 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){
+ 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) {
+ 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();
@@ -1323,27 +1332,32 @@ public class NEUManager {
public HashMap<String, String> getLoreReplacements(NBTTagCompound tag, int level) {
String petname = null;
String tier = null;
- if(tag != null && tag.hasKey("ExtraAttributes")) {
+ if (tag != null && tag.hasKey("ExtraAttributes")) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("petInfo")) {
+ 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")) {
+ if (petInfo.has("heldItem")) {
String heldItem = petInfo.get("heldItem").getAsString();
- if(heldItem.equals("PET_ITEM_TIER_BOOST")) {
- switch(tier) {
+ if (heldItem.equals("PET_ITEM_TIER_BOOST")) {
+ switch (tier) {
case "COMMON":
- tier = "UNCOMMON"; break;
+ tier = "UNCOMMON";
+ break;
case "UNCOMMON":
- tier = "RARE"; break;
+ tier = "RARE";
+ break;
case "RARE":
- tier = "EPIC"; break;
+ tier = "EPIC";
+ break;
case "EPIC":
- tier = "LEGENDARY"; break;
+ tier = "LEGENDARY";
+ break;
case "LEGENDARY":
- tier = "MYTHIC"; break;
+ tier = "MYTHIC";
+ break;
}
}
}
@@ -1354,12 +1368,12 @@ public class NEUManager {
public NBTTagList processLore(JsonArray lore, HashMap<String, String> replacements) {
NBTTagList nbtLore = new NBTTagList();
- for(JsonElement line : lore) {
+ for (JsonElement line : lore) {
String lineStr = line.getAsString();
- if(!lineStr.contains("Click to view recipes!") &&
+ 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());
+ for (Map.Entry<String, String> entry : replacements.entrySet()) {
+ lineStr = lineStr.replace("{" + entry.getKey() + "}", entry.getValue());
}
nbtLore.appendTag(new NBTTagString(lineStr));
}
@@ -1380,13 +1394,13 @@ public class NEUManager {
}
public ItemStack jsonToStack(JsonObject json, boolean useCache, boolean useReplacements, boolean copyStack) {
- if(json == null) return new ItemStack(Items.painting, 1, 10);
+ if (json == null) return new ItemStack(Items.painting, 1, 10);
String internalname = json.get("internalname").getAsString();
- if(useCache) {
+ if (useCache) {
ItemStack stack = itemstackCache.get(internalname);
- if(stack != null) {
- if(copyStack) {
+ if (stack != null) {
+ if (copyStack) {
return stack.copy();
} else {
return stack;
@@ -1397,40 +1411,39 @@ public class NEUManager {
ItemStack stack = new ItemStack(Item.itemRegistry.getObject(
new ResourceLocation(json.get("itemid").getAsString())));
- if(json.has("count")) {
+ if (json.has("count")) {
stack.stackSize = json.get("count").getAsInt();
}
- if(stack.getItem() == null) {
+ if (stack.getItem() == null) {
stack = new ItemStack(Item.getItemFromBlock(Blocks.stone), 0, 255); //Purple broken texture item
} else {
- if(json.has("damage")) {
+ if (json.has("damage")) {
stack.setItemDamage(json.get("damage").getAsInt());
}
- if(json.has("nbttag")) {
+ if (json.has("nbttag")) {
try {
NBTTagCompound tag = JsonToNBT.getTagFromJson(json.get("nbttag").getAsString());
stack.setTagCompound(tag);
- } catch(NBTException e) {
- }
+ } catch (NBTException ignored) {}
}
HashMap<String, String> replacements = new HashMap<>();
- if(useReplacements) {
+ 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());
+ for (Map.Entry<String, String> entry : replacements.entrySet()) {
+ displayname = displayname.replace("{" + entry.getKey() + "}", entry.getValue());
}
stack.setStackDisplayName(displayname);
}
- if(json.has("lore")) {
+ if (json.has("lore")) {
NBTTagCompound display = new NBTTagCompound();
- if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("display")) {
+ if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("display")) {
display = stack.getTagCompound().getCompoundTag("display");
}
display.setTag("Lore", processLore(json.get("lore").getAsJsonArray(), replacements));
@@ -1440,8 +1453,8 @@ public class NEUManager {
}
}
- if(useCache) itemstackCache.put(internalname, stack);
- if(copyStack) {
+ if (useCache) itemstackCache.put(internalname, stack);
+ if (copyStack) {
return stack.copy();
} else {
return stack;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 080353a7..f40c60cd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -8,7 +8,10 @@ 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.HTMLInfoPane;
+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;
@@ -16,9 +19,14 @@ import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned;
import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating;
import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu;
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.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.block.model.BakedQuad;
@@ -66,22 +74,22 @@ public class NEUOverlay extends Gui {
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 final NEUManager manager;
- private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
- private String petRegex = ".*?;[0-5]$";
+ private final String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
+ private final String petRegex = ".*?;[0-5]$";
- private ResourceLocation[] sortIcons = new ResourceLocation[] {
- sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
+ private final ResourceLocation[] sortIcons = new ResourceLocation[]{
+ sort_all, sort_mob, sort_pet, sort_tool, sort_armor, sort_accessory
};
- private ResourceLocation[] sortIconsActive = new ResourceLocation[] {
+ 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 ResourceLocation[] orderIcons = new ResourceLocation[] {
+ private final ResourceLocation[] orderIcons = new ResourceLocation[]{
order_alphabetical, order_rarity, order_value
};
- private ResourceLocation[] orderIconsActive = new ResourceLocation[] {
+ private final ResourceLocation[] orderIconsActive = new ResourceLocation[]{
order_alphabetical_active, order_rarity_active, order_value_active
};
@@ -95,7 +103,7 @@ public class NEUOverlay extends Gui {
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 Color fg = new Color(100, 100, 100, 255);
private InfoPane activeInfoPane = null;
@@ -113,9 +121,9 @@ public class NEUOverlay extends Gui {
private int page = 0;
- private LerpingFloat itemPaneOffsetFactor = new LerpingFloat(1);
- private LerpingInteger itemPaneTabOffset = new LerpingInteger(20, 50);
- private LerpingFloat infoPaneOffsetFactor = new LerpingFloat(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;
@@ -131,7 +139,7 @@ public class NEUOverlay extends Gui {
private boolean redrawItems = false;
private boolean searchBarHasFocus = false;
- private GuiTextField textField = new GuiTextField(0, null, 0, 0, 0, 0);
+ 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;
@@ -167,27 +175,27 @@ public class NEUOverlay extends Gui {
public int getWidth() {
int paddingUnscaled = getPaddingUnscaled();
- return getSearchBarXSize() + 2*paddingUnscaled;
+ return getSearchBarXSize() + 2 * paddingUnscaled;
}
public int getHeight() {
int paddingUnscaled = getPaddingUnscaled();
- return getSearchBarYSize() + 2*paddingUnscaled;
+ return getSearchBarYSize() + 2 * paddingUnscaled;
}
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
return;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
setSearchBarFocus(true);
- if(Mouse.getEventButton() == 1) { //Right mouse button down
+ if (Mouse.getEventButton() == 1) { //Right mouse button down
textField.setText("");
updateSearch();
} else {
- if(System.currentTimeMillis() - millisLastLeftClick < 300) {
+ if (System.currentTimeMillis() - millisLastLeftClick < 300) {
searchMode = !searchMode;
if (searchMode && NotEnoughUpdates.INSTANCE.config.hidden.firstTimeSearchFocus) {
NEUEventListener.displayNotification(Lists.newArrayList(
@@ -215,14 +223,14 @@ public class NEUOverlay extends Gui {
@Override
public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
return;
}
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int paddingUnscaled = getPaddingUnscaled();
GlStateManager.color(1, 1, 1, 1);
- if(searchMode) {
+ if (searchMode) {
Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR_GOLD);
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_BAR);
@@ -231,36 +239,36 @@ public class NEUOverlay extends Gui {
int w = getWidth();
int h = getHeight();
- for(int yIndex=0; yIndex<=2; yIndex++) {
- for(int xIndex=0; xIndex<=2; xIndex++) {
+ 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;
+ float uMax = 4 / 20f;
+ int partX = (int) x;
int partW = 4;
- if(xIndex == 1) {
+ 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;
+ 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;
+ float vMax = 4 / 20f;
+ int partY = (int) y;
int partH = 4;
- if(yIndex == 1) {
+ 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;
+ 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);
@@ -268,35 +276,35 @@ public class NEUOverlay extends Gui {
}
//Search bar text
- fr.drawString(textField.getText(), (int)x + 5,
- (int) y-4 + getHeight()/2, Color.WHITE.getRGB());
+ 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) {
+ 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());
+ 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()) {
+ 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());
+ 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());
+ (int) x + 5 + textBeforeSelectionWidth,
+ (int) y - 4 + getHeight() / 2, Color.BLACK.getRGB());
}
}
@@ -311,7 +319,7 @@ public class NEUOverlay extends Gui {
return new MBGuiElement() {
@Override
public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
}
@Override
@@ -325,10 +333,10 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
return;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
}
}
@@ -342,8 +350,7 @@ public class NEUOverlay extends Gui {
int paddingUnscaled = getPaddingUnscaled();
int searchYSize = getSearchBarYSize();
-
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableSettingsButton) {
return;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background);
@@ -365,7 +372,7 @@ public class NEUOverlay extends Gui {
return new MBGuiElement() {
@Override
public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
}
@Override
@@ -379,10 +386,10 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton){
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
return;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
//displayInformationPane(HTMLInfoPane.createFromWikiUrl(overlay, manager, "Help",
// "https://moulberry.github.io/files/neu_help.html"));
//Minecraft.getMinecraft().displayGuiScreen(new HelpGUI());
@@ -400,7 +407,7 @@ public class NEUOverlay extends Gui {
int paddingUnscaled = getPaddingUnscaled();
int searchYSize = getSearchBarYSize();
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.enableHelpButton) {
return;
}
@@ -423,7 +430,7 @@ public class NEUOverlay extends Gui {
return new MBGuiElement() {
@Override
public int getWidth() {
- return getSearchBarYSize()+getPaddingUnscaled()*2;
+ return getSearchBarYSize() + getPaddingUnscaled() * 2;
}
@Override
@@ -437,16 +444,16 @@ public class NEUOverlay extends Gui {
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
- if((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
+ if ((NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType != 0 && Mouse.getEventButtonState()) ||
(NotEnoughUpdates.INSTANCE.config.toolbar.quickCommandsClickType == 0 && !Mouse.getEventButtonState() && Mouse.getEventButton() != -1)) {
- if(quickCommandStr.contains(":")) {
+ if (quickCommandStr.contains(":")) {
String command = quickCommandStr.split(":")[0].trim();
- if(command.startsWith("/")) {
+ if (command.startsWith("/")) {
NotEnoughUpdates.INSTANCE.sendChatMessage(command);
} else {
- ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/"+command);
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/" + command);
}
Utils.playPressSound();
}
@@ -459,19 +466,19 @@ public class NEUOverlay extends Gui {
@Override
public void render(float x, float y) {
- if(!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.quickCommands) return;
int paddingUnscaled = getPaddingUnscaled();
int bigItemSize = getSearchBarYSize();
String[] quickCommandStrSplit = quickCommandStr.split(":");
- if(quickCommandStrSplit.length!=3) {
+ if (quickCommandStrSplit.length != 3) {
return;
}
String display = quickCommandStrSplit[2];
ItemStack render = null;
float extraScale = 1;
- if(display.length() > 20) { //Custom head
+ if (display.length() > 20) { //Custom head
render = new ItemStack(Items.skull, 1, 3);
NBTTagCompound nbt = new NBTTagCompound();
NBTTagCompound skullOwner = new NBTTagCompound();
@@ -492,15 +499,15 @@ public class NEUOverlay extends Gui {
render.setTagCompound(nbt);
extraScale = 1.3f;
- } else if(manager.getItemInformation().containsKey(display)) {
+ } 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) {
+ if (item != null) {
render = new ItemStack(item);
}
}
- if(render != null) {
+ if (render != null) {
NBTTagCompound tag = render.getTagCompound() != null ? render.getTagCompound() : new NBTTagCompound();
tag.setString("qc_id", quickCommandStrSplit[0].toLowerCase().trim());
render.setTagCompound(tag);
@@ -508,24 +515,24 @@ public class NEUOverlay extends Gui {
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);
+ 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) {
+ if (mouseX > x && mouseX < x + bigItemSize) {
+ if (mouseY > y && mouseY < y + bigItemSize) {
textToDisplay = new ArrayList<>();
- textToDisplay.add(EnumChatFormatting.GRAY+quickCommandStrSplit[1]);
+ textToDisplay.add(EnumChatFormatting.GRAY + quickCommandStrSplit[1]);
}
}
GlStateManager.enableDepth();
- float itemScale = bigItemSize/(float)ITEM_SIZE*extraScale;
+ 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);
+ GlStateManager.translate((x - (extraScale - 1) * bigItemSize / 2 + paddingUnscaled) / itemScale,
+ (y - (extraScale - 1) * bigItemSize / 2 + paddingUnscaled) / itemScale, 0f);
Utils.drawItemStack(render, 0, 0);
GlStateManager.popMatrix();
}
@@ -535,12 +542,12 @@ public class NEUOverlay extends Gui {
private MBGuiGroupAligned createQuickCommandGroup() {
List<MBGuiElement> children = new ArrayList<>();
- for(String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
+ for (String quickCommand : NotEnoughUpdates.INSTANCE.config.hidden.quickCommands) {
children.add(createQuickCommand(quickCommand));
}
return new MBGuiGroupAligned(children, false) {
public int getPadding() {
- return getPaddingUnscaled()*4;
+ return getPaddingUnscaled() * 4;
}
};
}
@@ -549,7 +556,7 @@ public class NEUOverlay extends Gui {
List<MBGuiElement> children = Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this));
return new MBGuiGroupAligned(children, false) {
public int getPadding() {
- return getPaddingUnscaled()*4;
+ return getPaddingUnscaled() * 4;
}
};
}
@@ -564,7 +571,7 @@ public class NEUOverlay extends Gui {
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));
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4));
map.put(createSearchBarGroup(), searchBarAnchor);
map.put(createQuickCommandGroup(), quickCommandAnchor);
@@ -576,32 +583,31 @@ public class NEUOverlay extends Gui {
MBAnchorPoint searchBarAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar);
MBAnchorPoint quickCommandAnchor = MBAnchorPoint.createFromString(NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand);
- if(onlyIfNull) {
+ 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));
+ -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));
+ -searchBarYOffset - getSearchBarYSize() - getPaddingUnscaled() * 4));
}
-
int index = 0;
Set<MBGuiElement> set = new LinkedHashSet<>(guiGroup.getChildrenMap().keySet());
- for(MBGuiElement element : set) {
- switch(index) {
+ for (MBGuiElement element : set) {
+ switch (index) {
case 0:
- if(searchBarAnchor == null) continue;
+ 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;
+ if (quickCommandAnchor == null) continue;
guiGroup.getChildrenMap().get(element).anchorPoint = quickCommandAnchor.anchorPoint;
guiGroup.getChildrenMap().get(element).offset = quickCommandAnchor.offset;
break;
@@ -615,12 +621,12 @@ public class NEUOverlay extends Gui {
*/
public void reset() {
searchBarHasFocus = false;
- if(!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
+ if (!(searchMode || (NotEnoughUpdates.INSTANCE.config.itemlist.keepopen && itemPaneOpen))) {
itemPaneOpen = false;
itemPaneOffsetFactor.setValue(1);
itemPaneTabOffset.setValue(20);
}
- if(activeInfoPane != null) activeInfoPane.reset();
+ if (activeInfoPane != null) activeInfoPane.reset();
guiGroup.recalculate();
}
@@ -628,7 +634,7 @@ public class NEUOverlay extends Gui {
* Calls #displayInformationPane with a HTMLInfoPane created from item.info and item.infoType.
*/
public void showInfo(JsonObject item) {
- if(item.has("info") && item.has("infoType")) {
+ 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();
@@ -636,7 +642,7 @@ public class NEUOverlay extends Gui {
String internalname = item.get("internalname").getAsString();
String name = item.get("displayname").getAsString();
- switch(item.get("infoType").getAsString()) {
+ switch (item.get("infoType").getAsString()) {
case "WIKI_URL":
displayInformationPane(HTMLInfoPane.createFromWikiUrl(this, manager, name, loreS));
return;
@@ -652,13 +658,13 @@ public class NEUOverlay extends Gui {
}
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) {
+ 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));
+ if (hover != null) {
+ textField.setText("id:" + manager.getInternalNameForItem(hover));
itemPaneOpen = true;
updateSearch();
}
@@ -671,7 +677,7 @@ public class NEUOverlay extends Gui {
* Handles the mouse input, cancelling the forge event if a NEU gui element is clicked.
*/
public boolean mouseInput() {
- if(disabled) {
+ if (disabled) {
return false;
}
@@ -689,30 +695,30 @@ public class NEUOverlay extends Gui {
lastMouseX = mouseX;
lastMouseY = mouseY;
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
mouseDown = true;
- } else if(Mouse.getEventButton() != -1) {
+ } 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);
+ 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) {
+ 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) {
+ if (Mouse.getEventButton() == 0) {
manager.showRecipe(item);
- } else if(Mouse.getEventButton() == 1) {
+ } 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());
+ } else if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + item.get("internalname").getAsString());
updateSearch();
searchMode = true;
}
@@ -725,8 +731,8 @@ public class NEUOverlay extends Gui {
}
//Item selection (right) gui
- if(mouseX > width*getItemPaneOffsetFactor()) {
- if(!Mouse.getEventButtonState()) {
+ if (mouseX > width * getItemPaneOffsetFactor()) {
+ if (!Mouse.getEventButtonState()) {
Utils.pushGuiScale(-1);
return true; //End early if the mouse isn't pressed, but still cancel event.
}
@@ -734,18 +740,18 @@ public class NEUOverlay extends Gui {
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) {
+ 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) {
+ if (Mouse.getEventButton() == 0) {
manager.showRecipe(item);
- } else if(Mouse.getEventButton() == 1) {
+ } 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());
+ } else if (Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode() + 100 && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + item.get("internalname").getAsString());
updateSearch();
searchMode = true;
}
@@ -754,52 +760,52 @@ public class NEUOverlay extends Gui {
}
}
});
- if(!clickedItem.get()) {
- int paneWidth = (int)(width/3*getWidthMult());
- int leftSide = (int)(width*getItemPaneOffsetFactor());
- int rightSide = leftSide+paneWidth-getBoxPadding()-getItemBoxXPadding();
- leftSide = leftSide+getBoxPadding()+getItemBoxXPadding();
+ 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);
+ 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);
+ 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 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;
+ 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) {
+ 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) {
+ } else if (Mouse.getEventButton() == 1) {
NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.set(i,
!NotEnoughUpdates.INSTANCE.config.hidden.compareAscending.get(i));
updateSearch();
@@ -808,9 +814,9 @@ public class NEUOverlay extends Gui {
}
}
- for(int i=0; i<sortIcons.length; i++) {
- int sortIconX = rightSide-scaledITEM_SIZE-i*scaledItemPaddedSize;
- if(mouseX >= sortIconX && mouseX <= sortIconX+scaledITEM_SIZE) {
+ 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();
@@ -823,9 +829,9 @@ public class NEUOverlay extends Gui {
}
//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
+ 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;
@@ -833,12 +839,12 @@ public class NEUOverlay extends Gui {
}
}
- if(activeInfoPane != null) {
- if(mouseX < width*getInfoPaneOffsetFactor()) {
+ 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
+ } else if (Mouse.getEventButton() <= 1 && Mouse.getEventButtonState()) { //Left or right click
activeInfoPane.mouseInputOutside();
}
}
@@ -848,8 +854,8 @@ public class NEUOverlay extends Gui {
}
public int getPaddingUnscaled() {
- int paddingUnscaled = searchBarPadding/Utils.peekGuiScale().getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
+ int paddingUnscaled = searchBarPadding / Utils.peekGuiScale().getScaleFactor();
+ if (paddingUnscaled < 1) paddingUnscaled = 1;
return paddingUnscaled;
}
@@ -863,7 +869,7 @@ public class NEUOverlay extends Gui {
*/
public int getSearchBarXSize() {
int searchBarXSize = NotEnoughUpdates.INSTANCE.config.toolbar.searchBarWidth;
- if(Utils.peekGuiScale().getScaleFactor()==4) return (int)(searchBarXSize*0.8);
+ if (Utils.peekGuiScale().getScaleFactor() == 4) return (int) (searchBarXSize * 0.8);
return searchBarXSize;
}
@@ -871,10 +877,10 @@ public class NEUOverlay extends Gui {
* Sets the activeInfoPane and sets the target of the infoPaneOffsetFactor to make the infoPane "slide" out.
*/
public void displayInformationPane(InfoPane pane) {
- if(pane == null) {
+ if (pane == null) {
infoPaneOffsetFactor.setTarget(0);
} else {
- infoPaneOffsetFactor.setTarget(1/3f);
+ infoPaneOffsetFactor.setTarget(1 / 3f);
}
infoPaneOffsetFactor.resetTimer();
this.activeInfoPane = pane;
@@ -891,15 +897,15 @@ public class NEUOverlay extends Gui {
int width = Utils.peekGuiScale().getScaledWidth();
int height = Utils.peekGuiScale().getScaledHeight();
- int xComp = mouseX - (width/2 - getSearchBarXSize()/2 + 5);
+ 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()) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < xComp - 5) {
linePos++;
}
}
@@ -907,7 +913,7 @@ public class NEUOverlay extends Gui {
}
public void setSearchBarFocus(boolean focus) {
- if(focus) {
+ if (focus) {
itemPaneOpen = true;
}
searchBarHasFocus = focus;
@@ -917,64 +923,64 @@ public class NEUOverlay extends Gui {
* 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;
+ if (Minecraft.getMinecraft().currentScreen == null) return false;
Keyboard.enableRepeatEvents(true);
- int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter()+256 : Keyboard.getEventKey();
+ int keyPressed = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
- if(disabled) {
- if(Keyboard.getEventKeyState() && keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
+ if (disabled) {
+ if (Keyboard.getEventKeyState() && keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
disabled = !disabled;
}
return false;
}
- if(Keyboard.isKeyDown(Keyboard.KEY_Y) && NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ 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) {
+ if (Keyboard.getEventKeyState()) {
+ if (!NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
searchBarHasFocus = false;
}
- if(searchBarHasFocus) {
- if(keyPressed == 1) {
+ if (searchBarHasFocus) {
+ if (keyPressed == 1) {
searchBarHasFocus = false;
} else {
- if(textField.textboxKeyTyped(Keyboard.getEventCharacter(), keyPressed)) {
+ if (textField.textboxKeyTyped(Keyboard.getEventCharacter(), keyPressed)) {
updateSearch();
}
}
} else {
- if(activeInfoPane != null) {
- if(activeInfoPane.keyboardInput()) {
+ if (activeInfoPane != null) {
+ if (activeInfoPane.keyboardInput()) {
return true;
}
}
- if(keyPressed == manager.keybindClosePanes.getKeyCode()) {
+ if (keyPressed == manager.keybindClosePanes.getKeyCode()) {
itemPaneOffsetFactor.setValue(1);
itemPaneTabOffset.setValue(20);
itemPaneOpen = false;
displayInformationPane(null);
}
- if(keyPressed == manager.keybindToggleDisplay.getKeyCode()) {
+ 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);
+ 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) {
+ if (hover != null) {
internalname.set(manager.getInternalNameForItem(hover));
itemstack.set(hover);
}
- } else if(!hoverInv) {
+ } else if (!hoverInv) {
Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale);
int width = Utils.peekGuiScale().getScaledWidth();
@@ -1005,39 +1011,38 @@ public class NEUOverlay extends Gui {
});
}
-
Utils.pushGuiScale(-1);
}
- if(internalname.get() != null) {
- if(itemstack.get() != null) {
- if(NotEnoughUpdates.INSTANCE.config.hidden.enableItemEditing && Keyboard.getEventCharacter() == 'k') {
+ 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()) {
+ if (item != null) {
+ if (keyPressed == manager.keybindViewUsages.getKeyCode()) {
manager.displayGuiItemUsages(internalname.get());
return true;
- } else if(keyPressed == manager.keybindFavourite.getKeyCode()) {
+ } else if (keyPressed == manager.keybindFavourite.getKeyCode()) {
toggleFavourite(item.get("internalname").getAsString());
return true;
- } else if(keyPressed == manager.keybindViewRecipe.getKeyCode()) {
+ } else if (keyPressed == manager.keybindViewRecipe.getKeyCode()) {
manager.showRecipe(item);
return true;
- } else if(keyPressed == manager.keybindGive.getKeyCode()) {
- if(Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) {
+ } 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') {
+ } 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());
+ } else if (keyPressed == manager.keybindItemSelect.getKeyCode() && NotEnoughUpdates.INSTANCE.config.toolbar.searchBar) {
+ textField.setText("id:" + internalname.get());
itemPaneOpen = true;
updateSearch();
}
@@ -1050,7 +1055,7 @@ public class NEUOverlay extends Gui {
}
public void toggleFavourite(String internalname) {
- if(getFavourites().contains(internalname)) {
+ if (getFavourites().contains(internalname)) {
getFavourites().remove(internalname);
} else {
getFavourites().add(internalname);
@@ -1058,14 +1063,14 @@ public class NEUOverlay extends Gui {
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",
+ 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",
};
/**
@@ -1080,11 +1085,11 @@ public class NEUOverlay extends Gui {
* 6 = SPECIAL
*/
public int getRarity(JsonArray lore) {
- for(int i=lore.size()-1; i>=0; i--) {
+ 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])) {
+ for (int j = 0; j < rarityArr.length; j++) {
+ if (line.startsWith(rarityArr[j])) {
return j;
}
}
@@ -1098,12 +1103,15 @@ public class NEUOverlay extends Gui {
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;
}
@@ -1116,74 +1124,73 @@ public class NEUOverlay extends Gui {
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())) {
+ 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())) {
+ 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) {
+ 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) {
+ 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;
+ 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 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());
+ 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"};
+ 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;
+ 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) {
+ 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());
+ 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--) {
+ 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])) {
+ for (String rarity : rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (line.trim().equals(rarity + " " + typeMatches[j])) {
return j;
}
}
@@ -1196,30 +1203,30 @@ public class NEUOverlay extends Gui {
* 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()) {
+ if (!NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems && item.has("vanilla") && item.get("vanilla").getAsBoolean()) {
return false;
}
- if(getSortMode() == SORT_MODE_ALL) {
+ if (getSortMode() == SORT_MODE_ALL) {
return !internalname.matches(mobRegex);
- } else if(getSortMode() == SORT_MODE_MOB) {
+ } else if (getSortMode() == SORT_MODE_MOB) {
return internalname.matches(mobRegex);
- } else if(getSortMode() == SORT_MODE_PET) {
+ } else if (getSortMode() == SORT_MODE_PET) {
return internalname.matches(petRegex) && item.get("displayname").getAsString().contains("[");
- } else if(getSortMode() == SORT_MODE_TOOL) {
+ } 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) {
+ } 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) {
+ } 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 final HashMap<String, JsonObject> parentMap = new HashMap<>();
- private ExecutorService searchES = Executors.newSingleThreadExecutor();
+ private final ExecutorService searchES = Executors.newSingleThreadExecutor();
/**
* Clears the current item list, creating a new TreeSet if necessary.
@@ -1229,7 +1236,7 @@ public class NEUOverlay extends Gui {
public void updateSearch() {
SunTzu.randomizeQuote();
- if(searchedItems == null) searchedItems = new TreeSet<>(getItemComparator());
+ if (searchedItems == null) searchedItems = new TreeSet<>(getItemComparator());
searchES.submit(() -> {
TreeSet<JsonObject> searchedItems = new TreeSet<>(getItemComparator());
@@ -1237,19 +1244,19 @@ public class NEUOverlay extends Gui {
Set<JsonObject> removeChildItems = new HashSet<>();
Set<String> itemsMatch = manager.search(textField.getText(), true);
- for(String itemname : itemsMatch) {
+ 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()) {
+ 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()) {
+ for (JsonElement e : Constants.PARENTS.get(itemname).getAsJsonArray()) {
+ if (e.isJsonPrimitive()) {
children.add(e.getAsString());
}
}
children.retainAll(itemsMatch);
- for(String child : children) {
+ for (String child : children) {
removeChildItems.add(manager.getItemInformation().get(child));
}
searchedItemsSubgroup.put(itemname, children);
@@ -1260,16 +1267,16 @@ public class NEUOverlay extends Gui {
}
searchedItems.removeAll(removeChildItems);
out:
- for(Map.Entry<String, List<String>> entry : searchedItemsSubgroup.entrySet()) {
- if(searchedItems.contains(manager.getItemInformation().get(entry.getKey()))) {
+ for (Map.Entry<String, List<String>> entry : searchedItemsSubgroup.entrySet()) {
+ if (searchedItems.contains(manager.getItemInformation().get(entry.getKey()))) {
continue;
}
- for(String itemname : entry.getValue()) {
+ for (String itemname : entry.getValue()) {
JsonObject item = manager.getItemInformation().get(itemname);
- if(item != null) searchedItems.add(item);
+ if (item != null) searchedItems.add(item);
}
}
- switch(textField.getText().toLowerCase().trim()) {
+ switch (textField.getText().toLowerCase().trim()) {
case "nullzee":
searchedItems.add(CustomItems.NULLZEE);
break;
@@ -1306,7 +1313,7 @@ public class NEUOverlay extends Gui {
this.searchedItems = searchedItems;
this.searchedItemsSubgroup = searchedItemsSubgroup;
- synchronized(this.searchedItemsArr) {
+ synchronized (this.searchedItemsArr) {
this.searchedItemsArr.clear();
}
@@ -1319,13 +1326,13 @@ public class NEUOverlay extends Gui {
* Whenever searchedItems is updated in updateSearch(), the array is recreated here.
*/
public List<JsonObject> getSearchedItems() {
- if(searchedItems == null) {
+ if (searchedItems == null) {
updateSearch();
return new ArrayList<>();
}
- if(searchedItems.size() > 0 && searchedItemsArr.size() == 0) {
- synchronized(searchedItemsArr) {
+ if (searchedItems.size() > 0 && searchedItemsArr.size() == 0) {
+ synchronized (searchedItemsArr) {
searchedItemsArr.addAll(searchedItems);
}
}
@@ -1334,13 +1341,14 @@ public class NEUOverlay extends Gui {
/**
* 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;
+ if (index < getSlotsXSize() * getSlotsYSize()) {
+ int actualIndex = index + getSlotsXSize() * getSlotsYSize() * page;
List<JsonObject> searchedItems = getSearchedItems();
- if(actualIndex < searchedItems.size()) {
+ if (actualIndex < searchedItems.size()) {
return searchedItems.get(actualIndex);
} else {
return null;
@@ -1352,22 +1360,22 @@ public class NEUOverlay extends Gui {
public int getItemBoxXPadding() {
int width = Utils.peekGuiScale().getScaledWidth();
- return (((int)(width/3*getWidthMult())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
+ 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);
+ return (int) (panePadding * 2 / Utils.peekGuiScale().getScaleFactor() + 5);
}
- private abstract class ItemSlotConsumer {
+ 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);
+ iterateItemSlots(itemSlotConsumer, (int) (width * getItemPaneOffsetFactor()) + getBoxPadding() + itemBoxXPadding);
}
/**
@@ -1379,18 +1387,18 @@ public class NEUOverlay extends Gui {
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 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 yStart = getBoxPadding() + getSearchBarYSize() + itemBoxYPadding;
int itemBoxXPadding = getItemBoxXPadding();
- int xEnd = xStart+paneWidth-getBoxPadding()*2-ITEM_SIZE-itemBoxXPadding;
- int yEnd = height-getBoxPadding()-ITEM_SIZE-2-itemBoxYPadding;
+ 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) {
+ 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++);
}
}
@@ -1398,9 +1406,10 @@ public class NEUOverlay extends Gui {
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;
+ 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;
}
/**
@@ -1409,12 +1418,12 @@ public class NEUOverlay extends Gui {
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;
+ 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)));
+ return (int) Math.ceil((xEnd - xStart) / ((float) (ITEM_SIZE + ITEM_PADDING)));
}
/**
@@ -1423,21 +1432,21 @@ public class NEUOverlay extends Gui {
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;
+ 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)));
+ 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());
+ 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);
+ return Math.max(searchBarYSize / Utils.peekGuiScale().getScaleFactor(), ITEM_SIZE);
}
/**
@@ -1447,78 +1456,78 @@ public class NEUOverlay extends Gui {
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;
+ 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;
+ 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)) {
+ 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
+ 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
+ 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());
+ 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,
+ Utils.drawTexturedRect(leftSide - 1 + leftPressed,
+ top + leftPressed,
buttonXSize, ySize, 1, 0, 0, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
- Utils.drawTexturedRect(leftSide-1,
+ Utils.drawTexturedRect(leftSide - 1,
top,
- buttonXSize, ySize, 1-leftPressed, leftPressed, 1-leftPressed, leftPressed);
+ 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());
+ 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());
+ 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,
+ Utils.drawTexturedRect(rightSide + 1 - buttonXSize + rightPressed,
+ top + rightPressed,
buttonXSize, ySize);
Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
- Utils.drawTexturedRect(rightSide+1-buttonXSize,
+ Utils.drawTexturedRect(rightSide + 1 - buttonXSize,
top,
- buttonXSize, ySize, 1-rightPressed, rightPressed, 1-rightPressed, rightPressed);
+ 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());
+ 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;
+ 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());
+ 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) {
@@ -1539,11 +1548,11 @@ public class NEUOverlay extends Gui {
EntityLivingBase[] entities = new EntityLivingBase[classes.length];
try {
EntityLivingBase last = null;
- for(int i=0; i<classes.length; i++) {
+ for (int i = 0; i < classes.length; i++) {
Class<? extends EntityLivingBase> clazz = classes[i];
- if(clazz == null) continue;
+ if (clazz == null) continue;
- EntityLivingBase newEnt = clazz.getConstructor(new Class[] {World.class}).newInstance(Minecraft.getMinecraft().theWorld);
+ EntityLivingBase newEnt = clazz.getConstructor(new Class[]{World.class}).newInstance(Minecraft.getMinecraft().theWorld);
//newEnt.renderYawOffset = yaw;
//newEnt.rotationYaw = yaw;
@@ -1553,7 +1562,7 @@ public class NEUOverlay extends Gui {
newEnt.setCustomNameTag(name);
- if(last != null) {
+ if (last != null) {
last.riddenByEntity = newEnt;
newEnt.ridingEntity = last;
last.updateRiderPosition();
@@ -1567,7 +1576,6 @@ public class NEUOverlay extends Gui {
return;
}
-
GlStateManager.enableColorMaterial();
GlStateManager.pushMatrix();
GlStateManager.translate(posX, posY, 50.0F);
@@ -1584,9 +1592,9 @@ public class NEUOverlay extends Gui {
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);
+ 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);
@@ -1608,15 +1616,15 @@ public class NEUOverlay extends Gui {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
@@ -1630,7 +1638,7 @@ public class NEUOverlay extends Gui {
int width = Utils.peekGuiScale().getScaledWidth();
int height = Utils.peekGuiScale().getScaledHeight();
- if(lastScreenWidth != width || lastScreenHeight != height || Utils.peekGuiScale().getScaleFactor() != lastScale) {
+ if (lastScreenWidth != width || lastScreenHeight != height || Utils.peekGuiScale().getScaleFactor() != lastScale) {
guiGroup.width = width;
guiGroup.height = height;
@@ -1652,7 +1660,7 @@ public class NEUOverlay extends Gui {
* Renders the search bar, quick commands, item selection (right) and item info (left) gui elements.
*/
public void render(boolean hoverInv) {
- if(disabled) {
+ if (disabled) {
return;
}
GlStateManager.enableDepth();
@@ -1667,15 +1675,15 @@ public class NEUOverlay extends Gui {
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) {
+ if (showVanillaLast != NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems) {
showVanillaLast = NotEnoughUpdates.INSTANCE.config.itemlist.showVanillaItems;
updateSearch();
}
- if(textField.getText().toLowerCase().contains("bald")) {
+ 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);
+ Utils.drawTexturedRect((width - 64) / 2f, (height - 64) / 2f - 114, 64, 64, GL11.GL_LINEAR);
GlStateManager.bindTexture(0);
}
@@ -1683,12 +1691,12 @@ public class NEUOverlay extends Gui {
updateGuiGroupSize();
- if(guiScaleLast != Utils.peekGuiScale().getScaleFactor()) {
+ if (guiScaleLast != Utils.peekGuiScale().getScaleFactor()) {
guiScaleLast = Utils.peekGuiScale().getScaleFactor();
redrawItems = true;
}
- if(oldWidthMult != getWidthMult()) {
+ if (oldWidthMult != getWidthMult()) {
oldWidthMult = getWidthMult();
redrawItems = true;
}
@@ -1701,29 +1709,29 @@ public class NEUOverlay extends Gui {
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());
+ 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);
+ if (itemPaneOpen) {
+ if (itemPaneTabOffset.getValue() == 0) {
+ if (itemPaneOffsetFactor.getTarget() != 2 / 3f) {
+ itemPaneOffsetFactor.setTarget(2 / 3f);
itemPaneOffsetFactor.resetTimer();
}
} else {
- if(itemPaneTabOffset.getTarget() != 0) {
+ if (itemPaneTabOffset.getTarget() != 0) {
itemPaneTabOffset.setTarget(0);
itemPaneTabOffset.resetTimer();
}
}
} else {
- if(itemPaneOffsetFactor.getValue() == 1) {
- if(itemPaneTabOffset.getTarget() != 20) {
+ if (itemPaneOffsetFactor.getValue() == 1) {
+ if (itemPaneTabOffset.getTarget() != 20) {
itemPaneTabOffset.setTarget(20);
itemPaneTabOffset.resetTimer();
}
} else {
- if(itemPaneOffsetFactor.getTarget() != 1f) {
+ if (itemPaneOffsetFactor.getTarget() != 1f) {
itemPaneOffsetFactor.setTarget(1f);
itemPaneOffsetFactor.resetTimer();
}
@@ -1734,27 +1742,27 @@ public class NEUOverlay extends Gui {
itemPaneTabOffset.tick();
infoPaneOffsetFactor.tick();
- if(page > getMaxPages()-1) setPage(getMaxPages()-1);
- if(page < 0) setPage(0);
+ 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();
+ int paneWidth = (int) (width / 3 * getWidthMult());
+ int leftSide = (int) (width * getItemPaneOffsetFactor());
+ int rightSide = leftSide + paneWidth - getBoxPadding() - getItemBoxXPadding();
//Tab
- if(NotEnoughUpdates.INSTANCE.config.itemlist.tabOpen) {
+ 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);
+ 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) {
+ if (!itemPaneOpen && mouseX > width - itemPaneTabOffset.getValue() && mouseY > height / 2 - 32
+ && mouseY < height / 2 + 32) {
itemPaneOpen = true;
}
}
@@ -1762,110 +1770,110 @@ public class NEUOverlay extends Gui {
//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) {
+ 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,
+ 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);
+ 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());
+ 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: ":"");
+ 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());
+ 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 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;
+ 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());
+ 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);
+ 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);
+ 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) {
+ 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";
+ 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);
+ 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());
+ 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) {
+ 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";
+ 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 (text != null) textToDisplay = Utils.createList(text);
}
}
}
}
- if(!hoveredOverControl) {
+ 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) {
+ 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) {
+ if (!hoverInv) {
iterateItemSlots(new ItemSlotConsumer() {
public void consume(int x, int y, int id) {
JsonObject json = getSearchedItemPage(id);
@@ -1875,14 +1883,14 @@ public class NEUOverlay extends Gui {
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 &&
+ 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)) {
+ for (String itemname : searchedItemsSubgroup.get(internalname)) {
children.add(manager.getItemInformation().get(itemname));
}
@@ -1901,15 +1909,15 @@ public class NEUOverlay extends Gui {
//Iterate through all item slots and display the appropriate item
int itemBoxXPadding = getItemBoxXPadding();
- int xStart = (int)(width*getItemPaneOffsetFactor())+getBoxPadding()+itemBoxXPadding;
+ int xStart = (int) (width * getItemPaneOffsetFactor()) + getBoxPadding() + itemBoxXPadding;
- if(OpenGlHelper.isFramebufferEnabled()) {
+ if (OpenGlHelper.isFramebufferEnabled()) {
renderItemsFromImage(xStart, width, height);
renderEnchOverlay();
checkFramebufferSizes(width, height);
- if(redrawItems || !NotEnoughUpdates.INSTANCE.config.hidden.cacheRenderedItempane) {
+ if (redrawItems || !NotEnoughUpdates.INSTANCE.config.hidden.cacheRenderedItempane) {
renderItemsToImage(width, height, fgFavourite2, fgFavourite, fgCustomOpacity, true, true);
redrawItems = false;
}
@@ -1917,36 +1925,36 @@ public class NEUOverlay extends Gui {
renderItems(xStart, true, true, true);
}
- if(selectedItemGroup != null) {
+ if (selectedItemGroup != null) {
GL11.glTranslatef(0, 0, 10);
- int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size());
+ 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);
+ 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) {
+ 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++) {
+ for (int i = 0; i < selectedItemGroup.size(); i++) {
JsonObject item = selectedItemGroup.get(i);
- Utils.drawItemStack(manager.jsonToStack(item), selectedX+18*i, selectedItemGroupY+18);
+ Utils.drawItemStack(manager.jsonToStack(item), selectedX + 18 * i, selectedItemGroupY + 18);
}
GL11.glTranslatef(0, 0, -20);
@@ -1959,32 +1967,32 @@ public class NEUOverlay extends Gui {
GlStateManager.disableLighting();
}
- /**
+ /*
* Search bar & quickcommand elements
*/
guiGroup.render(0, 0);
resetAnchors(true);
- /**
+ /*
* Item info (left) gui element rendering
*/
- rightSide = (int)(width*getInfoPaneOffsetFactor());
+ rightSide = (int) (width * getInfoPaneOffsetFactor());
leftSide = rightSide - paneWidth;
- if(activeInfoPane != null) {
+ 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);
+ 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) {
+ if (json != null) {
ItemStack stack = manager.jsonToStack(json);
{
@@ -1996,27 +2004,28 @@ public class NEUOverlay extends Gui {
List<String> text = stack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
String internalname = json.get("internalname").getAsString();
- if(!NotEnoughUpdates.INSTANCE.config.tooltipTweaks.showPriceInfoInvItem) {
+ 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()) {
+ if (json.has("clickcommand") && !json.get("clickcommand").getAsString().isEmpty()) {
hasClick = true;
}
- if(json.has("info") && json.get("info").getAsJsonArray().size() > 0) {
+ 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!");
-
+ 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) {
+ if (textToDisplay != null) {
Utils.drawHoveringText(textToDisplay, mouseX, mouseY, width, height, -1, fr);
textToDisplay = null;
}
@@ -2039,6 +2048,7 @@ public class NEUOverlay extends Gui {
/**
* Sets the current page and marks that the itemsPane should be redrawn
+ *
* @param page
*/
public void setPage(int page) {
@@ -2046,18 +2056,18 @@ public class NEUOverlay extends Gui {
redrawItems = true;
}
- private Framebuffer[] itemFramebuffers = new Framebuffer[2];
+ 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) {
+ 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);
@@ -2073,6 +2083,7 @@ public class NEUOverlay extends Gui {
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);
@@ -2085,8 +2096,8 @@ public class NEUOverlay extends Gui {
*/
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();
+ int sw = width * Utils.peekGuiScale().getScaleFactor();
+ int sh = height * Utils.peekGuiScale().getScaleFactor();
GL11.glPushMatrix();
prepareFramebuffer(itemFramebuffers[0], sw, sh);
@@ -2109,17 +2120,18 @@ public class NEUOverlay extends Gui {
* 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) {
+ 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);
+ 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);
+ Utils.drawTexturedRect(xOffset - 10, 0, width, height, 0, 1, 1, 0);
itemFramebuffers[0].unbindFramebufferTexture();
GL11.glTranslatef(0, 0, -itemRenderOffset);
}
@@ -2128,7 +2140,7 @@ public class NEUOverlay extends Gui {
/**
* 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.)
@@ -2137,66 +2149,66 @@ public class NEUOverlay extends Gui {
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;
+ 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);
+ 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;
- }
+ 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.pushMatrix();
+ GlStateManager.enableRescaleNormal();
+ GlStateManager.enableAlpha();
+ GlStateManager.alphaFunc(516, 0.1F);
+ GlStateManager.enableBlend();
- GlStateManager.disableLighting();
+ GlStateManager.disableLighting();
- GlStateManager.translate(x, y, 0);
- GlStateManager.scale(16f, 16f, 16f);
+ 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);
+ 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);
+ 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);
+ 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);
+ renderModel(model, -8372020, null);
- GlStateManager.popMatrix();
- GlStateManager.matrixMode(5888);
- GlStateManager.blendFunc(770, 771);
- GlStateManager.depthFunc(515);
- GlStateManager.depthMask(true);
+ GlStateManager.popMatrix();
+ GlStateManager.matrixMode(5888);
+ GlStateManager.blendFunc(770, 771);
+ GlStateManager.depthFunc(515);
+ GlStateManager.depthMask(true);
- GlStateManager.popMatrix();
+ GlStateManager.popMatrix();
}
});
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
GlStateManager.disableRescaleNormal();
- GL11.glTranslatef(0, 0, 7.5001f-itemRenderOffset);
+ GL11.glTranslatef(0, 0, 7.5001f - itemRenderOffset);
GL11.glPopMatrix();
GlStateManager.bindTexture(0);
@@ -2217,9 +2229,9 @@ public class NEUOverlay extends Gui {
}
private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color) {
- if(quads == null) return;
+ if (quads == null) return;
- for(BakedQuad quad : quads) {
+ for (BakedQuad quad : quads) {
renderer.addVertexData(quad.getVertexData());
renderer.putColor4(color);
}
@@ -2229,38 +2241,38 @@ public class NEUOverlay extends Gui {
* Renders all the item backgrounds, either squares or squircles.
*/
private void renderItemBackgrounds(Color fgFavourite2, Color fgFavourite, Color fgCustomOpacity) {
- if(fgCustomOpacity.getAlpha() == 0) return;
+ 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;
- }
+ 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);
+ 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);
+ 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 {
- drawRect(x-1, y-1, x+ITEM_SIZE+1, y+ITEM_SIZE+1, fgCustomOpacity.getRGB());
+ 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);
+ GlStateManager.bindTexture(0);
}
}, 10);
}
@@ -2274,7 +2286,7 @@ public class NEUOverlay extends Gui {
}
if (json.has("entityrender")) {
- if(!entities) return;
+ 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);
@@ -2303,10 +2315,10 @@ public class NEUOverlay extends Gui {
renderEntity(x + ITEM_SIZE / 2, y + ITEM_SIZE, scale, name, entities);
} else {
- if(!items) return;
+ if (!items) return;
ItemStack stack = manager.jsonToStack(json, true, true, false);
- if(stack != null) {
- if(glint) {
+ if (stack != null) {
+ if (glint) {
Utils.drawItemStack(stack, x, y);
} else {
Utils.drawItemStackWithoutGlint(stack, x, y);
@@ -2315,10 +2327,10 @@ public class NEUOverlay extends Gui {
}
GlStateManager.translate(0, 0, 50);
- if(searchedItemsSubgroup.containsKey(json.get("internalname").getAsString())) {
+ 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);
+ Utils.drawTexturedRect(x - 1, y - 1, ITEM_SIZE + 2, ITEM_SIZE + 2, GL11.GL_NEAREST);
}
GlStateManager.translate(0, 0, -50);
}
@@ -2326,7 +2338,7 @@ public class NEUOverlay extends Gui {
}
public float getItemPaneOffsetFactor() {
- return itemPaneOffsetFactor.getValue() * getWidthMult() + (1-getWidthMult());
+ return itemPaneOffsetFactor.getValue() * getWidthMult() + (1 - getWidthMult());
}
public float getInfoPaneOffsetFactor() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 6a0d3ab4..29eaf38e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -1,85 +1,45 @@
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.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.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.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 {
@@ -97,10 +57,11 @@ public class NotEnoughUpdates {
private File configFile;
- public File getConfigFile(){
+ public File getConfigFile() {
return this.configFile;
}
- public void newConfigFile(){
+
+ public void newConfigFile() {
this.configFile = new File(NotEnoughUpdates.INSTANCE.getNeuDir(), "configNew.json");
}
@@ -110,16 +71,15 @@ public class NotEnoughUpdates {
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");
+ 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());
@@ -135,15 +95,16 @@ public class NotEnoughUpdates {
public boolean packDevEnabled = false;
- private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
+ private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create();
private File neuDir;
- public File getNeuDir(){ return this.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
@@ -155,10 +116,10 @@ public class NotEnoughUpdates {
configFile = new File(neuDir, "configNew.json");
- if(configFile.exists()) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
+ 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) { }
+ } catch (Exception ignored) {}
}
ItemCustomizeManager.loadCustomization(new File(neuDir, "itemCustomization.json"));
@@ -167,7 +128,7 @@ public class NotEnoughUpdates {
PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json"));
SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json"));
- if(config == null) {
+ if (config == null) {
config = new NEUConfig();
saveConfig();
}
@@ -198,10 +159,10 @@ public class NotEnoughUpdates {
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());
+ 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();
@@ -213,14 +174,14 @@ public class NotEnoughUpdates {
overlay = new NEUOverlay(manager);
profileViewer = new ProfileViewer(manager);
- for(KeyBinding kb : manager.keybinds) {
+ 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()) {
+ if (tmp.exists()) {
+ for (File tmpFile : tmp.listFiles()) {
tmpFile.delete();
}
tmp.delete();
@@ -233,16 +194,26 @@ public class NotEnoughUpdates {
try {
configFile.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(config));
}
- } catch(Exception ignored) {}
+ } 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) {}
+ 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) {}
}
/**
@@ -250,7 +221,7 @@ public class NotEnoughUpdates {
* 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) {
+ if (System.currentTimeMillis() - lastChatMessage > CHAT_MSG_COOLDOWN) {
secondLastChatMessage = lastChatMessage;
lastChatMessage = System.currentTimeMillis();
Minecraft.getMinecraft().thePlayer.sendChatMessage(message);
@@ -270,22 +241,22 @@ public class NotEnoughUpdates {
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+"]");
+ 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+"]");
+ 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+"]");
+ 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+"]");
+ 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+"]");
+ 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+"]");
+ 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);
@@ -299,7 +270,7 @@ public class NotEnoughUpdates {
links.appendSibling(separator);
links.appendSibling(github);
links.appendSibling(separator);
- if(other != null) {
+ if (other != null) {
links.appendSibling(other);
links.appendSibling(separator);
}
@@ -310,7 +281,7 @@ public class NotEnoughUpdates {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.START) return;
- if(Minecraft.getMinecraft().thePlayer == null) {
+ if (Minecraft.getMinecraft().thePlayer == null) {
openGui = null;
currChatMessage = null;
return;
@@ -318,14 +289,14 @@ public class NotEnoughUpdates {
long currentTime = System.currentTimeMillis();
if (openGui != null) {
- if(Minecraft.getMinecraft().thePlayer.openContainer != 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) {
+ if (currChatMessage != null && currentTime - lastChatMessage > CHAT_MSG_COOLDOWN) {
lastChatMessage = currentTime;
Minecraft.getMinecraft().thePlayer.sendChatMessage(currChatMessage);
currChatMessage = null;
@@ -333,7 +304,7 @@ public class NotEnoughUpdates {
}
public boolean isOnSkyblock() {
- if(!config.misc.onlyShowOnSkyblock) return true;
+ if (!config.misc.onlyShowOnSkyblock) return true;
return hasSkyblockScoreboard();
}
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..6b421192 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -26,19 +26,18 @@ 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;
+ private final NEUManager manager;
public final CustomAH customAH;
- private TreeMap<String, Auction> auctionMap = new TreeMap<>();
+ private final 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 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;
@@ -47,7 +46,7 @@ public class APIManager {
private JsonObject bazaarJson = null;
private JsonObject auctionPricesJson = null;
- private HashMap<String, CraftInfo> craftCost = new HashMap<>();
+ private final HashMap<String, CraftInfo> craftCost = new HashMap<>();
public TreeMap<String, HashMap<Integer, HashSet<String>>> extrasToAucIdMap = new TreeMap<>();
@@ -117,16 +116,16 @@ public class APIManager {
}
public ItemStack getStack() {
- if(item_tag == null && item_tag_str != null) {
+ 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) {
+ } catch (IOException e) {
return null;
}
}
- if(stack != null) {
+ if (stack != null) {
return stack;
} else {
JsonObject item = manager.getJsonFromNBT(item_tag);
@@ -134,24 +133,24 @@ public class APIManager {
JsonObject itemDefault = manager.getItemInformation().get(item.get("internalname").getAsString());
- if(stack != null && itemDefault != null) {
+ if (stack != null && itemDefault != null) {
ItemStack stackDefault = manager.jsonToStack(itemDefault, true);
- if(stack.isItemEqual(stackDefault)) {
+ 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])) {
+ if (loreMatches) {
+ for (int i = 0; i < stackLore.length; i++) {
+ if (!stackLore[i].equals(defaultLore[i])) {
loreMatches = false;
break;
}
}
}
- if(loreMatches) {
+ if (loreMatches) {
stack = stackDefault;
}
}
@@ -174,46 +173,46 @@ public class APIManager {
public void tick() {
customAH.tick();
long currentTime = System.currentTimeMillis();
- if(NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse &&
+ if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse &&
NotEnoughUpdates.INSTANCE.config.apiKey.apiKey != null &&
!NotEnoughUpdates.INSTANCE.config.apiKey.apiKey.isEmpty()) {
- if(currentTime - lastAuctionUpdate > 60*1000) {
+ if (currentTime - lastAuctionUpdate > 60 * 1000) {
lastAuctionUpdate = currentTime;
updatePageTick();
}
- if(currentTime - lastShortAuctionUpdate > 10*1000) {
+ if (currentTime - lastShortAuctionUpdate > 10 * 1000) {
lastShortAuctionUpdate = currentTime;
updatePageTickShort();
ahNotification();
}
- if(currentTime - lastCleanup > 60*1000) {
+ if (currentTime - lastCleanup > 60 * 1000) {
lastCleanup = currentTime;
cleanup();
}
- if(currentTime - lastCustomAHSearch > 60*1000) {
+ if (currentTime - lastCustomAHSearch > 60 * 1000) {
lastCustomAHSearch = currentTime;
- if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) {
+ 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
+ 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
+ if (currentTime - lastBazaarUpdate > 5 * 60 * 1000) { //5 minutes
lastBazaarUpdate = currentTime;
updateBazaar();
}
- if(currentTime - lastLowestBinUpdate > 2*60*1000) {
+ if (currentTime - lastLowestBinUpdate > 2 * 60 * 1000) {
lastLowestBinUpdate = currentTime;
updateLowestBin();
}
}
private String niceAucId(String aucId) {
- if(aucId.length()!=32) return aucId;
+ if (aucId.length() != 32) return aucId;
StringBuilder niceAucId = new StringBuilder();
niceAucId.append(aucId, 0, 8);
@@ -229,18 +228,18 @@ public class APIManager {
}
public Set<String> getLowestBinKeySet() {
- if(lowestBins == null) return new HashSet<>();
+ if (lowestBins == null) return new HashSet<>();
HashSet<String> keys = new HashSet<>();
- for(Map.Entry<String, JsonElement> entry : lowestBins.entrySet()) {
+ 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)) {
+ if (lowestBins != null && lowestBins.has(internalname)) {
JsonElement e = lowestBins.get(internalname);
- if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) {
+ if (e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) {
return e.getAsInt();
}
}
@@ -249,10 +248,10 @@ public class APIManager {
public void updateLowestBin() {
manager.hypixelApi.getMyApiGZIPAsync("lowestbin.json.gz", (jsonObject) -> {
- if(lowestBins == null) {
+ if (lowestBins == null) {
lowestBins = new JsonObject();
}
- for(Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
+ for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
lowestBins.add(entry.getKey(), entry.getValue());
}
}, () -> {});
@@ -261,31 +260,31 @@ public class APIManager {
private void ahNotification() {
playerBidsNotified.retainAll(playerBids);
playerBidsFinishedNotified.retainAll(playerBids);
- if(NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification <= 0) {
+ if (NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.ahNotification <= 0) {
return;
}
- for(String aucid : playerBids) {
+ 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) {
+ 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.");
+ 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")));
+ 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()) {
+ 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.");
+ 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")));
+ clickEvent.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + "View auction")));
message.setChatStyle(clickEvent);
Minecraft.getMinecraft().thePlayer.addChatMessage(message);
@@ -295,76 +294,78 @@ public class APIManager {
}
}
- private ExecutorService es = Executors.newSingleThreadExecutor();
+ 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()) {
+ for (Map.Entry<String, Auction> entry : auctionMap.entrySet()) {
long timeToEnd = entry.getValue().end - currTime;
- if(timeToEnd < -120*1000) { //2 minutes
+ if (timeToEnd < -120 * 1000) { //2 minutes
toRemove.add(entry.getKey());
}
}
toRemove.removeAll(playerBids);
remove(toRemove);
- } catch(ConcurrentModificationException e) {
- lastCleanup = System.currentTimeMillis() - 110*1000;
+ } catch (ConcurrentModificationException e) {
+ lastCleanup = System.currentTimeMillis() - 110 * 1000;
}
});
}
private void remove(Set<String> toRemove) {
- for(String aucid : 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) {
+ 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()) {
+ for (HashSet<String> aucids : internalnameToAucIdMap.values()) {
aucids.removeAll(toRemove);
}
}
private void updatePageTickShort() {
- if(pagesToDownload == null || pagesToDownload.isEmpty()) return;
+ if (pagesToDownload == null || pagesToDownload.isEmpty()) return;
- if(firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate)%(60*1000) > 15*1000) 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;
+ if (disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return;
- while(!pagesToDownload.isEmpty()) {
+ while (!pagesToDownload.isEmpty()) {
try {
int page = pagesToDownload.pop();
getPageFromAPI(page);
- } catch(NoSuchElementException ignored) {} //Weird race condition?
+ } 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 (disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return;
- if(pagesToDownload == null) {
+ if (pagesToDownload == null) {
getPageFromAPI(0);
}
Consumer<JsonObject> process = jsonObject -> {
- if(jsonObject.get("success").getAsBoolean()) {
+ if (jsonObject.get("success").getAsBoolean()) {
JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray();
- for(JsonElement auctionElement : new_auctions) {
+ 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) {
+ for (JsonElement newBidElement : new_bids) {
JsonObject newBid = newBidElement.getAsJsonObject();
String newBidUUID = newBid.get("uuid").getAsString();
//System.out.println("new bid" + newBidUUID);
@@ -373,7 +374,7 @@ public class APIManager {
int bid_count = newBid.get("bid_count").getAsInt();
Auction auc = auctionMap.get(newBidUUID);
- if(auc != null) {
+ if (auc != null) {
//System.out.println("Setting auction " + newBidUUID + " price to " + newBidAmount);
auc.highest_bid_amount = newBidAmount;
auc.end = end;
@@ -382,7 +383,7 @@ public class APIManager {
}
Set<String> toRemove = new HashSet<>();
JsonArray removed_auctions = jsonObject.get("removed_auctions").getAsJsonArray();
- for(JsonElement removedAuctionsElement : removed_auctions) {
+ for (JsonElement removedAuctionsElement : removed_auctions) {
String removed = removedAuctionsElement.getAsString();
toRemove.add(removed);
}
@@ -390,23 +391,20 @@ public class APIManager {
}
};
- manager.hypixelApi.getMyApiGZIPAsync("auctionLast.json.gz", process, () -> {
- System.out.println("Error downloading auction from Moulberry's jank API. :(");
- });
+ 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);
+ if (jsonObject.get("success").getAsBoolean()) {
+ long apiUpdate = (long) jsonObject.get("time").getAsFloat();
+ if (lastApiUpdate == apiUpdate) {
+ lastAuctionUpdate -= 30 * 1000;
}
- }, () -> {
- System.out.println("Error downloading auction from Moulberry's jank API. :(");
- });
+ lastApiUpdate = apiUpdate;
+
+ process.accept(jsonObject);
+ }
+ }, () -> System.out.println("Error downloading auction from Moulberry's jank API. :("));
}
@@ -414,41 +412,41 @@ public class APIManager {
try {
uniqueItems = internalnameToAucIdMap.size();
Set<String> aucs = new HashSet<>();
- for(HashSet<String> aucids : internalnameToAucIdMap.values()) {
+ 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()) {
+ for (HashMap<Integer, HashSet<String>> extrasMap : extrasToAucIdMap.values()) {
+ for (HashSet<String> aucids : extrasMap.values()) {
aucs.addAll(aucids);
}
}
taggedAuctions = aucs.size();
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
}
-// String[] rarityArr = new String[] {
-// "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME",
-// };
+ //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--) {
+ 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])) {
+ 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])) {
+ } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
return j;
}
} else {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
return j;
- } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
return j;
}
}
@@ -458,15 +456,16 @@ public class APIManager {
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"};
+ 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[] 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("-","");
+ if (playerUUID == null)
+ playerUUID = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replaceAll("-", "");
String auctionUuid = auction.get("uuid").getAsString();
String auctioneerUuid = auction.get("auctioneer").getAsString();
@@ -475,7 +474,7 @@ public class APIManager {
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")) {
+ if (auction.has("bin")) {
bin = auction.get("bin").getAsBoolean();
}
String sbCategory = auction.get("category").getAsString();
@@ -491,15 +490,17 @@ public class APIManager {
try {
item_tag = CompressedStreamTools.readCompressed(
new ByteArrayInputStream(Base64.getDecoder().decode(item_bytes)));
- } catch(IOException e) { return; }
+ } 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)) {
+ if (display.hasKey("Lore", 9)) {
NBTTagList loreList = new NBTTagList();
- for(String line : item_lore.split("\n")) {
+ for (String line : item_lore.split("\n")) {
loreList.appendTag(new NBTTagString(line));
}
display.setTag("Lore", loreList);
@@ -507,17 +508,17 @@ public class APIManager {
tag.setTag("display", display);
item_tag.getTagList("i", 10).getCompoundTagAt(0).setTag("tag", tag);
- if(tag.hasKey("ExtraAttributes", 10)) {
+ if (tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("enchantments", 10)) {
+ if (ea.hasKey("enchantments", 10)) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- for(String key : enchantments.getKeySet()) {
+ 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];
+ if (enchantlevel >= 1 && enchantlevel <= 20) {
+ enchantLevelStr = romans[enchantlevel - 1];
} else {
enchantLevelStr = String.valueOf(enchantlevel);
}
@@ -526,10 +527,10 @@ public class APIManager {
}
}
- int index=0;
- for(String str : extras.split(" ")) {
+ int index = 0;
+ for (String str : extras.split(" ")) {
str = Utils.cleanColour(str).toLowerCase();
- if(str.length() > 0) {
+ 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);
@@ -537,19 +538,19 @@ public class APIManager {
index++;
}
- for(int j=0; j<bids.size(); j++) {
+ for (int j = 0; j < bids.size(); j++) {
JsonObject bid = bids.get(j).getAsJsonObject();
- if(bid.get("bidder").getAsString().equalsIgnoreCase(playerUUID)) {
+ if (bid.get("bidder").getAsString().equalsIgnoreCase(playerUUID)) {
playerBids.add(auctionUuid);
}
}
int dungeonTier = -1;
- if(checkItemType(item_lore, true, "DUNGEON") >= 0) {
+ if (checkItemType(item_lore, true, "DUNGEON") >= 0) {
dungeonTier = 0;
- for(int i=0; i<item_name.length(); i++) {
+ for (int i = 0; i < item_name.length(); i++) {
char c = item_name.charAt(i);
- if(c == 0x272A) {
+ if (c == 0x272A) {
dungeonTier++;
}
}
@@ -557,28 +558,28 @@ public class APIManager {
//Categories
String category = sbCategory;
- int itemType = checkItemType(item_lore, true,"SWORD", "FISHING ROD", "PICKAXE",
+ 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) {
+ 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") ||
+ 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")) {
+ if (tag.hasKey("ench")) {
auction1.enchLevel = 1;
- if(tag.hasKey("ExtraAttributes", 10)) {
+ if (tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
int hotpotatocount = ea.getInteger("hot_potato_count");
- if(hotpotatocount == 10) {
+ if (hotpotatocount == 10) {
auction1.enchLevel = 2;
}
}
@@ -586,27 +587,29 @@ public class APIManager {
auctionMap.put(auctionUuid, auction1);
internalnameToAucIdMap.computeIfAbsent(internalname, k -> new HashSet<>()).add(auctionUuid);
- } catch(Exception e) {e.printStackTrace();}
+ } 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);
+ args.put("page", "" + page);
manager.hypixelApi.getHypixelApiAsync(null, "skyblock/auctions",
- args, jsonObject -> {
- if(jsonObject == null) return;
+ args, jsonObject -> {
+ if (jsonObject == null) return;
if (jsonObject.get("success").getAsBoolean()) {
- if(pagesToDownload == null) {
+ if (pagesToDownload == null) {
int totalPages = jsonObject.get("totalPages").getAsInt();
pagesToDownload = new LinkedList<>();
- for(int i=0; i<totalPages+2; i++) {
+ for (int i = 0; i < totalPages + 2; i++) {
pagesToDownload.add(i);
}
}
- if(firstHypixelApiUpdate == 0) {
+ if (firstHypixelApiUpdate == 0) {
firstHypixelApiUpdate = jsonObject.get("lastUpdated").getAsLong();
}
activeAuctions = jsonObject.get("totalAuctions").getAsInt();
@@ -618,25 +621,23 @@ public class APIManager {
processAuction(auction);
}
- processMillis = (int)(System.currentTimeMillis() - startProcess);
+ processMillis = (int) (System.currentTimeMillis() - startProcess);
} else {
pagesToDownload.addLast(page);
}
- }, () -> {
- 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;
+ 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()) {
+ for (Map.Entry<String, JsonElement> entry : products.entrySet()) {
+ if (entry.getValue().isJsonObject()) {
JsonObject productInfo = new JsonObject();
JsonObject product = entry.getValue().getAsJsonObject();
@@ -644,16 +645,16 @@ public class APIManager {
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()) {
+ 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()) {
+ for (JsonElement element : product.get("buy_summary").getAsJsonArray()) {
+ if (element.isJsonObject()) {
JsonObject sellSummaryFirst = element.getAsJsonObject();
productInfo.addProperty("curr_buy", sellSummaryFirst.get("pricePerUnit").getAsFloat());
break;
@@ -672,74 +673,73 @@ public class APIManager {
auctionPricesJson = jsonObject;
lastAuctionAvgUpdate = System.currentTimeMillis();
}, () -> {});
- manager.hypixelApi.getMyApiGZIPAsync("auction_averages_lbin/1day.json.gz", (jsonObject) -> {
- auctionPricesAvgLowestBinJson = jsonObject;
- }, () -> {});
+ manager.hypixelApi.getMyApiGZIPAsync("auction_averages_lbin/1day.json.gz", (jsonObject) -> auctionPricesAvgLowestBinJson = jsonObject, () -> {});
}
public Set<String> getItemAuctionInfoKeySet() {
- if(auctionPricesJson == null) return new HashSet<>();
+ if (auctionPricesJson == null) return new HashSet<>();
HashSet<String> keys = new HashSet<>();
- for(Map.Entry<String, JsonElement> entry : auctionPricesJson.entrySet()) {
+ for (Map.Entry<String, JsonElement> entry : auctionPricesJson.entrySet()) {
keys.add(entry.getKey());
}
return keys;
}
public JsonObject getItemAuctionInfo(String internalname) {
- if(auctionPricesJson == null) return null;
+ if (auctionPricesJson == null) return null;
JsonElement e = auctionPricesJson.get(internalname);
- if(e == null) {
+ if (e == null) {
return null;
}
return e.getAsJsonObject();
}
public float getItemAvgBin(String internalname) {
- if(auctionPricesAvgLowestBinJson == null) return -1;
+ if (auctionPricesAvgLowestBinJson == null) return -1;
JsonElement e = auctionPricesAvgLowestBinJson.get(internalname);
- if(e == null) {
+ if (e == null) {
return -1;
}
return Math.round(e.getAsFloat());
}
public Set<String> getBazaarKeySet() {
- if(bazaarJson == null) return new HashSet<>();
+ if (bazaarJson == null) return new HashSet<>();
HashSet<String> keys = new HashSet<>();
- for(Map.Entry<String, JsonElement> entry : bazaarJson.entrySet()) {
+ for (Map.Entry<String, JsonElement> entry : bazaarJson.entrySet()) {
keys.add(entry.getKey());
}
return keys;
}
public JsonObject getBazaarInfo(String internalname) {
- if(bazaarJson == null) return null;
+ if (bazaarJson == null) return null;
JsonElement e = bazaarJson.get(internalname);
- if(e == null) {
+ 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",
+ "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;
+ 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)) {
+ if (manager.getItemInformation().containsKey(vanillaName)) {
JsonObject json = manager.getItemInformation().get(vanillaName);
- if(json != null && json.has("vanilla") && json.get("vanilla").getAsBoolean()) return true;
+ if (json != null && json.has("vanilla") && json.get("vanilla").getAsBoolean()) return true;
}
return Item.itemRegistry.getObject(new ResourceLocation(vanillaName)) != null;
}
- public class CraftInfo {
+ public static class CraftInfo {
public boolean fromRecipe = false;
public boolean vanillaItem = false;
public float craftCost = -1;
@@ -753,7 +753,7 @@ public class APIManager {
* Recursively calculates the cost of crafting an item from raw materials.
*/
public CraftInfo getCraftCost(String internalname, int depth) {
- if(craftCost.containsKey(internalname)) {
+ if (craftCost.containsKey(internalname)) {
return craftCost.get(internalname);
} else {
CraftInfo ci = new CraftInfo();
@@ -764,53 +764,53 @@ public class APIManager {
float lowestBin = getLowestBin(internalname);
JsonObject bazaarInfo = getBazaarInfo(internalname);
- if(bazaarInfo != null && bazaarInfo.get("curr_buy") != null) {
+ 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) {
+ if (lowestBin > 0 && !ci.vanillaItem) {
+ if (ci.craftCost < 0 || lowestBin < ci.craftCost) {
ci.craftCost = lowestBin;
}
- } else if(auctionInfo != null && !ci.vanillaItem) {
+ } else if (auctionInfo != null && !ci.vanillaItem) {
float auctionPrice = auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat();
- if(ci.craftCost < 0 || auctionPrice < ci.craftCost) {
+ if (ci.craftCost < 0 || auctionPrice < ci.craftCost) {
ci.craftCost = auctionPrice;
}
}
- if(depth > 16) {
+ if (depth > 16) {
craftCost.put(internalname, ci);
return ci;
}
JsonObject item = manager.getItemInformation().get(internalname);
- if(item != null && item.has("recipe")) {
+ 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[] 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;
+ if (itemS == null || itemS.length() == 0) continue;
int count = 1;
- if(itemS.split(":").length == 2) {
+ 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
+ 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) {
+ 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) {
+ if (!getCraftCost(itemS).vanillaItem) {
craftCost.put(internalname, ci);
return ci;
}
@@ -819,7 +819,7 @@ public class APIManager {
}
}
- if(ci.craftCost < 0 || craftPrice < ci.craftCost) {
+ if (ci.craftCost < 0 || craftPrice < ci.craftCost) {
ci.craftCost = craftPrice;
ci.fromRecipe = true;
}
@@ -834,18 +834,18 @@ public class APIManager {
*/
public float getCostOfEnchants(String internalname, NBTTagCompound tag) {
float costOfEnchants = 0;
- if(true) return 0;
+ if (true) return 0;
JsonObject info = getItemAuctionInfo(internalname);
- if(info == null || !info.has("price")) {
+ if (info == null || !info.has("price")) {
return 0;
}
- if(auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) {
+ 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)) {
+ if (!ench_prices.has(internalname) || !ench_maximums.has(internalname)) {
return 0;
}
JsonObject iid_variables = ench_prices.getAsJsonObject(internalname);
@@ -853,18 +853,18 @@ public class APIManager {
int enchants = 0;
float price = getItemAuctionInfo(internalname).get("price").getAsFloat();
- if(tag.hasKey("ExtraAttributes")) {
+ if (tag.hasKey("ExtraAttributes")) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("enchantments")) {
+ if (ea.hasKey("enchantments")) {
NBTTagCompound enchs = ea.getCompoundTag("enchantments");
- for(String ench : enchs.getKeySet()) {
+ 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 +
+ 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;
}
@@ -880,26 +880,26 @@ public class APIManager {
* eg. PROTECTION_GE6 will match -> ench_name = PROTECTION, lvl >= 6
*/
private boolean matchEnch(String ench, int level, String id) {
- if(!id.contains(":")) {
+ if (!id.contains(":")) {
return false;
}
String idEnch = id.split(":")[0];
String idLevel = id.split(":")[1];
- if(!ench.equalsIgnoreCase(idEnch)) {
+ if (!ench.equalsIgnoreCase(idEnch)) {
return false;
}
- if(String.valueOf(level).equalsIgnoreCase(idLevel)) {
+ if (String.valueOf(level).equalsIgnoreCase(idLevel)) {
return true;
}
- if(idLevel.startsWith("LE")) {
- int idLevelI = Integer.valueOf(idLevel.substring(2));
+ if (idLevel.startsWith("LE")) {
+ int idLevelI = Integer.parseInt(idLevel.substring(2));
return level <= idLevelI;
- } else if(idLevel.startsWith("GE")) {
- int idLevelI = Integer.valueOf(idLevel.substring(2));
+ } else if (idLevel.startsWith("GE")) {
+ int idLevelI = Integer.parseInt(idLevel.substring(2));
return level >= idLevelI;
}
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..6f3209b2 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;
@@ -106,45 +106,45 @@ public class CustomAH extends Gui {
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 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 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 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 Category CATEGORY_PET_ITEM = new Category("petitem", "Pet Items", "lead");
+ private final 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 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 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 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 Category CATEGORY_COMBAT = new Category("weapon", "Combat", "golden_sword", CATEGORY_SWORD,
+ private final 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,
+ private final 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,
+ 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 Category CATEGORY_BLOCKS = new Category("blocks", "Blocks", "cobblestone");
- private Category CATEGORY_MISC = new Category("misc", "Misc", "stick", CATEGORY_REFORGE_STONES, CATEGORY_RUNES,
+ 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 Category[] mainCategories = new Category[]{CATEGORY_COMBAT, CATEGORY_TOOL, CATEGORY_PET,
+ 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",
+ // 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,
@@ -175,23 +175,23 @@ public class CustomAH extends Gui {
private int binFilter = BIN_FILTER_ALL;
private int enchFilter = ENCH_FILTER_ALL;
- private static ItemStack DUNGEON_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush),
+ private static final ItemStack DUNGEON_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush),
EnumChatFormatting.GREEN + "Dungeon Sorting");
- private static ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper),
+ private static final ItemStack CONTROL_SORT = Utils.createItemStack(Item.getItemFromBlock(Blocks.hopper),
EnumChatFormatting.GREEN + "Sort");
- private static ItemStack CONTROL_TIER = Utils.createItemStack(Items.ender_eye,
+ private static final ItemStack CONTROL_TIER = Utils.createItemStack(Items.ender_eye,
EnumChatFormatting.GREEN + "Item Tier");
- private static ItemStack CONTROL_MYAUC = Utils.createItemStack(Items.gold_ingot,
+ private static final ItemStack CONTROL_MYAUC = Utils.createItemStack(Items.gold_ingot,
EnumChatFormatting.GREEN + "My Auctions");
- private static ItemStack CONTROL_BIN = Utils.createItemStack(Item.getItemFromBlock(Blocks.golden_rail),
+ private static final ItemStack CONTROL_BIN = Utils.createItemStack(Item.getItemFromBlock(Blocks.golden_rail),
EnumChatFormatting.GREEN + "BIN Filter");
- private static ItemStack CONTROL_ENCH = Utils.createItemStack(Items.enchanted_book,
+ private static final ItemStack CONTROL_ENCH = Utils.createItemStack(Items.enchanted_book,
EnumChatFormatting.GREEN + "Enchant Filter");
- private static ItemStack CONTROL_STATS = Utils.createItemStack(Item.getItemFromBlock(Blocks.command_block),
+ private static final 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 final ItemStack[] controls = {DUNGEON_SORT, CONTROL_SORT, CONTROL_TIER, null, CONTROL_MYAUC, null, CONTROL_BIN, CONTROL_ENCH, CONTROL_STATS};
- private NEUManager manager;
+ private final NEUManager manager;
public CustomAH(NEUManager manager) {
this.manager = manager;
@@ -229,7 +229,7 @@ public class CustomAH extends Gui {
}
}
- public class Category {
+ public static class Category {
public String categoryMatch;
public Category[] subcategories;
public String displayName;
@@ -439,7 +439,7 @@ public class CustomAH extends Gui {
GlStateManager.disableBlend();
}
- private HashMap<Pattern, Long> timeParseMap = new HashMap<>();
+ private final HashMap<Pattern, Long> timeParseMap = new HashMap<>();
public long prettyTimeToMillis(String endsInStr) {
if (timeParseMap.isEmpty()) {
@@ -891,8 +891,7 @@ public class CustomAH extends Gui {
tooltipToRender = getTooltipForAucId(aucid);
}
}
- } catch (Exception e) {
- }
+ } catch (Exception ignored) {}
}
}
}
@@ -1345,7 +1344,7 @@ public class CustomAH extends Gui {
return matches;
}
- private ExecutorService es = Executors.newSingleThreadExecutor();
+ private final ExecutorService es = Executors.newSingleThreadExecutor();
public void updateSearch() {
if (!NotEnoughUpdates.INSTANCE.config.neuAuctionHouse.enableNeuAuctionHouse) {
@@ -1726,7 +1725,6 @@ public class CustomAH extends Gui {
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) {
@@ -1795,22 +1793,20 @@ public class CustomAH extends Gui {
if (mouseX < auctionViewLeft + 16 + 32) {
//top left
increasePriceByFactor(2);
- Utils.playPressSound();
} else {
//top right
increasePriceByFactor(1.5f);
- Utils.playPressSound();
}
+ 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();
}
+ Utils.playPressSound();
} else if (mouseY > guiTop + 68 && mouseY < guiTop + 68 + 16) {
//bottom
Utils.playPressSound();
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..a42fdb64 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAHGui.java
@@ -1,7 +1,6 @@
package io.github.moulberry.notenoughupdates.auction;
import net.minecraft.client.gui.GuiScreen;
-import org.lwjgl.input.Mouse;
public class CustomAHGui extends GuiScreen {
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..ed479e79 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/collectionlog/GuiCollectionLog.java
@@ -24,29 +24,29 @@ public class GuiCollectionLog extends GuiScreen {
int colwidth = 307;
int colheight = 187;
- int left = width/2 - colwidth/2;
- int top = height/2 - colheight/2;
+ 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);
+ 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) {
+ 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.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);
+ Utils.drawStringCentered(cats[i], fontRendererObj, left + i * 71 + 71 / 2, top - 8, true, 0xfff5aa00);
}
}
@@ -54,50 +54,48 @@ public class GuiCollectionLog extends GuiScreen {
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);
+ 0, colwidth / 512f, 0, colheight / 512f, GL11.GL_NEAREST);
- GlScissorStack.push(0, top+3, width, top+colheight-6, scaledResolution);
+ GlScissorStack.push(0, top + 3, width, top + colheight - 6, scaledResolution);
int catIndex = 0;
- for(int h=top+3; h<top+colheight-6; h+=24) {
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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) {
+ 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.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);
+ 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..39d8bb24 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/ClientCommandBase.java
@@ -18,7 +18,7 @@ public abstract class ClientCommandBase extends CommandBase {
@Override
public String getCommandUsage(ICommandSender sender) {
- return "/"+name;
+ return "/" + name;
}
@Override
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..591d7053 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/Commands.java
@@ -25,7 +25,6 @@ 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;
@@ -40,23 +39,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.world.storage.MapData;
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.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -64,7 +57,7 @@ import java.util.concurrent.atomic.AtomicInteger;
public class Commands {
- public Commands(){
+ public Commands() {
//ClientCommandHandler.instance.registerCommand(collectionLogCommand);
//ClientCommandHandler.instance.registerCommand(collectionLogCommand2);
ClientCommandHandler.instance.registerCommand(nullzeeSphereCommand);
@@ -85,9 +78,9 @@ public class Commands {
ClientCommandHandler.instance.registerCommand(customizeCommand2);
ClientCommandHandler.instance.registerCommand(devTestCommand);
ClientCommandHandler.instance.registerCommand(packDevCommand);
- if(!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(viewCataCommand);
+ if (!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(viewCataCommand);
ClientCommandHandler.instance.registerCommand(peekCommand);
-// ClientCommandHandler.instance.registerCommand(tutorialCommand);
+ //ClientCommandHandler.instance.registerCommand(tutorialCommand);
ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand);
ClientCommandHandler.instance.registerCommand(enchantColourCommand);
ClientCommandHandler.instance.registerCommand(neuAhCommand);
@@ -115,16 +108,16 @@ public class Commands {
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"));
+ 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")) {
+ if (args[0].equalsIgnoreCase("on")) {
NullzeeSphere.enabled = true;
- } else if(args[0].equalsIgnoreCase("off")) {
+ } else if (args[0].equalsIgnoreCase("off")) {
NullzeeSphere.enabled = false;
- } else if(args[0].equalsIgnoreCase("setCenter")) {
- EntityPlayerSP p = ((EntityPlayerSP)sender);
+ } else if (args[0].equalsIgnoreCase("setCenter")) {
+ EntityPlayerSP p = ((EntityPlayerSP) sender);
NullzeeSphere.centerPos = new BlockPos(p.posX, p.posY, p.posZ);
NullzeeSphere.overlayVBO = null;
} else {
@@ -132,8 +125,8 @@ public class Commands {
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]));
+ } catch (Exception e) {
+ sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Can't parse radius: " + args[0]));
}
}
}
@@ -141,18 +134,18 @@ public class Commands {
/*SimpleCommand itemRenameCommand = new SimpleCommand("neurename", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if(args.length == 0) {
+ if (args.length == 0) {
args = new String[]{"help"};
}
String heldUUID = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(Minecraft.getMinecraft().thePlayer.getHeldItem());
- switch(args[0].toLowerCase()) {
+ 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) {
+ if (heldUUID == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't clear rename - no UUID"));
return;
}
@@ -161,7 +154,7 @@ public class Commands {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] Cleared custom name for held item"));
break;
case "copyuuid":
- if(heldUUID == null) {
+ if (heldUUID == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't clear rename - no UUID"));
return;
}
@@ -170,33 +163,33 @@ public class Commands {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "[NEU] UUID copied to clipboard"));
break;
case "uuid":
- if(heldUUID == null) {
+ 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")));
+ 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: " +
+ 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) {
+ if (heldUUID == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[NEU] Can't rename item - no UUID"));
return;
}
- if(args.length == 1) {
+ 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++) {
+ for (int i = 1; i < args.length; i++) {
sb.append(args[i]);
- if(i<args.length-1) sb.append(" ");
+ if (i < args.length - 1) sb.append(" ");
}
String name = sb.toString()
.replace("\\&", "{amp}")
@@ -208,7 +201,7 @@ public class Commands {
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]+"\""));
+ 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"));
@@ -255,21 +248,17 @@ public class Commands {
"",
"\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)
- ));
-
+ for (String neuHelpMessage : neuHelpMessages) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(neuHelpMessage));
}
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ 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)
- ));
-
+ for (String neuDevHelpMessage : neuDevHelpMessages) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(neuDevHelpMessage));
}
}
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
@@ -284,9 +273,9 @@ public class Commands {
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"));
+ 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;
}
@@ -295,11 +284,11 @@ public class Commands {
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){
+ 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.");
+ 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);
@@ -309,7 +298,6 @@ public class Commands {
}
});
-
SimpleCommand stWhyCommand = new SimpleCommand("neustwhy", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
NEUEventListener.displayNotification(Lists.newArrayList(
@@ -350,8 +338,8 @@ public class Commands {
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");
+ if (args.length > 0) {
+ DungeonWin.TEAM_SCORE = new ResourceLocation("notenoughupdates:dungeon_win/" + args[0].toLowerCase() + ".png");
}
DungeonWin.displayWin();
@@ -361,11 +349,11 @@ public class Commands {
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()) {
+ 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);
+ if (itemFiles != null) {
+ for (File f : itemFiles) {
+ String internalname = f.getName().substring(0, f.getName().length() - 5);
NotEnoughUpdates.INSTANCE.manager.loadItem(internalname);
}
}
@@ -373,10 +361,10 @@ public class Commands {
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))) {
+ 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) { }
+ } catch (Exception ignored) {}
}
}
});
@@ -386,48 +374,48 @@ public class Commands {
SimpleCommand peekCommand = new SimpleCommand("peek", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
String name;
- if(args.length == 0) {
+ 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;
+ 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 -> {
+ 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 api is down."), id);
+ EnumChatFormatting.RED + "[PEEK] Unknown player or api is down."), id);
} else {
profile.resetCache();
- if(peekCommandExecutorService == null || peekCommandExecutorService.isShutdown()) {
+ 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."));
+ 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);
+ 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) {
+ if (System.currentTimeMillis() - startTime > 10 * 1000) {
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(
- EnumChatFormatting.RED+"[PEEK] Getting profile info took too long, aborting."), id);
+ 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) {
+ if (profileInfo != null) {
float overallScore = 0;
boolean isMe = name.equalsIgnoreCase("moulberry");
@@ -435,21 +423,21 @@ public class Commands {
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+" "+
+ 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);
+ EnumChatFormatting.STRIKETHROUGH + "-=-"), id);
- if(skill == null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW+"Skills api disabled!"));
+ 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;
+ 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++;
}
@@ -461,9 +449,9 @@ public class Commands {
float wolf = Utils.getElementAsFloat(skill.get("level_slayer_wolf"), 0);
float enderman = Utils.getElementAsFloat(skill.get("level_slayer_enderman"), 0);
- float avgSkillLVL = totalSkillLVL/totalSkillCount;
+ float avgSkillLVL = totalSkillLVL / totalSkillCount;
- if(isMe) {
+ if (isMe) {
avgSkillLVL = 6;
combat = 4;
zombie = 2;
@@ -472,104 +460,104 @@ public class Commands {
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;
+ 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;
+ 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;
+ 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;
+ 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)));
+ 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)));
+ 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!"));
+ 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");
+ 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;
+ 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 "));
+ 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;
+ 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) : "")));
+ 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));
+ 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();
+ if (col == null) col = EnumChatFormatting.LIGHT_PURPLE.toString();
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g+"Pet : " +
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g + "Pet : " +
col + WordUtils.capitalizeFully(activePet.replace("_", " "))));
String overall = "Skywars Main";
- if(isMe) {
+ 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) {
+ } 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) {
+ } 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";
+ } 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 + ")"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(g + "Overall score: " +
+ overall + g + " (" + Math.round(overallScore * 10) / 10f + ")"));
peekCommandExecutorService.shutdownNow();
} else {
@@ -599,7 +587,7 @@ public class Commands {
public SimpleCommand.ProcessCommandRunnable viewProfileRunnable = new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if(!OpenGlHelper.isFramebufferEnabled()) {
+ 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."));
@@ -608,8 +596,8 @@ public class Commands {
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) {
+ 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 {
@@ -621,8 +609,8 @@ public class Commands {
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) {
+ 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 {
@@ -634,26 +622,25 @@ public class Commands {
}
};
-
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) {
+ if (args.length != 1) {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.RED+"Example Usage: /join f7, /join m6 or /join 7"));
+ EnumChatFormatting.RED + "Example Usage: /join f7, /join m6 or /join 7"));
} else {
String cataPrefix = "catacombs";
- if(args[0].startsWith("m")){
+ if (args[0].startsWith("m")) {
cataPrefix = "master_catacombs";
}
- String cmd = "/joindungeon "+cataPrefix+" " + args[0].charAt(args[0].length()-1);
+ String cmd = "/joindungeon " + cataPrefix + " " + args[0].charAt(args[0].length() - 1);
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- EnumChatFormatting.YELLOW+"Running command: "+cmd));
+ 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"));
+ 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);
}
}
@@ -663,13 +650,13 @@ public class Commands {
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;
+ if (args.length != 1) return null;
- String lastArg = args[args.length-1];
+ String lastArg = args[args.length - 1];
List<String> playerMatches = new ArrayList<>();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
String playerName = player.getName();
- if(playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
+ if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) {
playerMatches.add(playerName);
}
}
@@ -680,7 +667,7 @@ public class Commands {
SimpleCommand viewProfileShortCommand = new SimpleCommand("pv", new SimpleCommand.ProcessCommandRunnable() {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ if (!NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
Minecraft.getMinecraft().thePlayer.sendChatMessage("/pv " + StringUtils.join(args, " "));
} else {
viewProfileRunnable.processCommand(sender, args);
@@ -710,7 +697,7 @@ public class Commands {
}
});
- private ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor();
+ private final 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?",
@@ -724,8 +711,8 @@ public class Commands {
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) {
+ if (!devTestUsers.contains(Minecraft.getMinecraft().thePlayer.getName().toLowerCase())) {
+ if (devFailIndex >= devFailStrings.length) {
throw new Error("L") {
@Override
public void printStackTrace() {
@@ -733,7 +720,7 @@ public class Commands {
}
};
}
- if(devFailIndex == devFailStrings.length-2) {
+ if (devFailIndex == devFailStrings.length - 2) {
devFailIndex++;
ChatComponentText component = new ChatComponentText("\u00a7cYou are permanently banned from this server!");
@@ -746,39 +733,39 @@ public class Commands {
Minecraft.getMinecraft().getNetHandler().getNetworkManager().closeChannel(component);
return;
}
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+devFailStrings[devFailIndex++]));
+ 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")) {
+ if (args.length == 1 && args[0].equalsIgnoreCase("positiontest")) {
NotEnoughUpdates.INSTANCE.openGui = new GuiPositionEditor();
return;
}
- if(args.length == 2 && args[0].equalsIgnoreCase("pt")) {
+ 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")) {
+ if (args.length == 1 && args[0].equalsIgnoreCase("dev")) {
NotEnoughUpdates.INSTANCE.config.hidden.dev = true;
return;
}
- if(args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) {
+ if (args.length == 1 && args[0].equalsIgnoreCase("saveconfig")) {
NotEnoughUpdates.INSTANCE.saveConfig();
return;
}
- if(args.length == 1 && args[0].equalsIgnoreCase("center")) {
+ 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"));
+ 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;
@@ -790,22 +777,22 @@ public class Commands {
@Override
public void run() {
Minecraft.getMinecraft().addScheduledTask(() -> {
- ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-"+perspective.get()+".png",
+ 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) {
+ if (perspective.incrementAndGet() >= 6) {
FancyPortals.perspectiveId = -1;
return;
}
devES.schedule(() -> {
FancyPortals.perspectiveId = perspective.get();
- if(FancyPortals.perspectiveId == 5) {
+ 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;
+ } 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;
}
@@ -821,7 +808,7 @@ public class Commands {
NEUEventListener.displayUpdateMessageIfOutOfDate();
} */
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Executing dubious code"));
+ 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(
@@ -835,33 +822,33 @@ public class Commands {
SimpleCommand packDevCommand = new SimpleCommand("neupackdev", new SimpleCommand.ProcessCommandRunnable() {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if(args.length == 1 && args[0].equalsIgnoreCase("getnpc")) {
+ 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) {
+ 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) {
+ if (dSq < distSq) {
distSq = dSq;
closestNPC = player;
}
}
}
- if(closestNPC == null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"No NPCs found within 5 blocks :("));
+ 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/", ""));
+ 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."));
+ 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."));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Disabled pack developer mode."));
}
}
});
@@ -870,7 +857,7 @@ public class Commands {
@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"));
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.AQUA + "Warping to:" + EnumChatFormatting.YELLOW + " Deez Nuts lmao"));
}
});
@@ -900,7 +887,7 @@ public class Commands {
SimpleCommand linksCommand = new SimpleCommand("neulinks", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
File repo = NotEnoughUpdates.INSTANCE.manager.repoLocation;
- if(repo.exists()) {
+ if (repo.exists()) {
File updateJson = new File(repo, "update.json");
try {
JsonObject update = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(updateJson);
@@ -926,47 +913,46 @@ public class Commands {
}
});
-
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(
+ 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++) {
+ 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()) {
+ 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) { }
+ } catch (Exception ignored) {}
}
- if(!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
return;
}
- if(args.length == 1 && args[0].equals("reset")) {
+ if (args.length == 1 && args[0].equals("reset")) {
NotEnoughUpdates.INSTANCE.colourMap = null;
return;
}
- if(args.length != 2) {
+ if (args.length != 2) {
NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor();
return;
}
- if(args[0].equals("save")) {
+ if (args[0].equals("save")) {
ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(stack != null && stack.getItem() instanceof ItemMap) {
+ if (stack != null && stack.getItem() instanceof ItemMap) {
ItemMap map = (ItemMap) stack.getItem();
MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
@@ -986,33 +972,33 @@ public class Commands {
c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true);
}
- json.addProperty(x+":"+y, c.getRGB());
+ 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) {
+ 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+
+ 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"));
+ 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++) {
+ 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()) {
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
int x = Integer.parseInt(entry.getKey().split(":")[0]);
int y = Integer.parseInt(entry.getKey().split(":")[1]);
@@ -1028,7 +1014,7 @@ public class Commands {
SimpleCommand cosmeticsCommand = new SimpleCommand("neucosmetics", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if(!OpenGlHelper.isFramebufferEnabled()) {
+ 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."));
@@ -1042,14 +1028,14 @@ public class Commands {
public void processCommand(ICommandSender sender, String[] args) {
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(held == null) {
+ if (held == null) {
sender.addChatMessage(new ChatComponentText("\u00a7cYou can't customize your hand..."));
return;
}
String heldUUID = NotEnoughUpdates.INSTANCE.manager.getUUIDForItem(held);
- if(heldUUID == null) {
+ if (heldUUID == null) {
sender.addChatMessage(new ChatComponentText("\u00a7cHeld item does not have UUID, cannot be customized"));
return;
}
@@ -1063,7 +1049,7 @@ public class Commands {
SimpleCommand.ProcessCommandRunnable settingsRunnable = new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
- if(args.length > 0) {
+ 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);
@@ -1085,11 +1071,11 @@ public class Commands {
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+
+ 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+
+ } 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();
@@ -1097,7 +1083,8 @@ public class Commands {
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, " "));
+ if (args.length > 0)
+ NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.setSearch(StringUtils.join(args, " "));
}
}
});
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java
index 029e24db..f13dca10 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/SimpleCommand.java
@@ -5,13 +5,12 @@ 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 final String commandName;
+ private final ProcessCommandRunnable runnable;
private TabCompleteRunnable tabRunnable;
public SimpleCommand(String commandName, ProcessCommandRunnable runnable) {
@@ -50,7 +49,7 @@ public class SimpleCommand extends CommandBase {
}
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
- if(tabRunnable != null) return tabRunnable.tabComplete(sender, args, 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
index b61c58ed..e0743162 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/StatsCommand.java
@@ -36,7 +36,7 @@ public class StatsCommand extends ClientCommandBase {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if (args.length > 0){
+ if (args.length > 0) {
switch (args[0].toLowerCase(Locale.ROOT)) {
case "modlist":
clipboardAndSendMessage(createModList(new DiscordMarkdownBuilder()).toString());
@@ -49,7 +49,7 @@ public class StatsCommand extends ClientCommandBase {
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){
+ } catch (Exception e) {
clipboardAndSendMessage(null);
}
});
@@ -103,8 +103,8 @@ public class StatsCommand extends ClientCommandBase {
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());
+ 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));
@@ -113,7 +113,7 @@ public class StatsCommand extends ClientCommandBase {
builder.append("FPS", String.valueOf(Minecraft.getDebugFPS()));
builder.append("Loaded Mods", String.valueOf(activeModCount));
builder.append("Forge", ForgeVersion.getVersion());
- builder.category("Neu Settings");
+ 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());
@@ -132,13 +132,13 @@ public class StatsCommand extends ClientCommandBase {
return builder;
}
- private static long getMemorySize(){
+ private static long getMemorySize() {
try {
return ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
- } catch(Exception e){
+ } catch (Exception e) {
try {
return ((com.sun.management.UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
- } catch(Exception ignored){/*IGNORE*/}
+ } catch (Exception ignored) {/*IGNORE*/}
}
return -1;
}
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..98b4ccfe 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;
@@ -39,15 +36,16 @@ public class BackgroundBlur {
}
}
- private static HashMap<Float, OutputStuff> blurOutput = new HashMap<>();
- private static HashMap<Float, Long> lastBlurUse = new HashMap<>();
+ 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 HashSet<Float> requestedBlurs = new HashSet<>();
+ private static final HashSet<Float> requestedBlurs = new HashSet<>();
private static int fogColour = 0;
private static boolean registered = false;
+
public static void registerListener() {
- if(!registered) {
+ if (!registered) {
registered = true;
MinecraftForge.EVENT_BUS.register(new BackgroundBlur());
}
@@ -56,18 +54,18 @@ public class BackgroundBlur {
private static boolean shouldBlur = true;
public static void markDirty() {
- if(Minecraft.getMinecraft().theWorld != null) {
+ if (Minecraft.getMinecraft().theWorld != null) {
shouldBlur = true;
}
}
public static void processBlurs() {
- if(shouldBlur) {
+ if (shouldBlur) {
shouldBlur = false;
long currentTime = System.currentTimeMillis();
- for(float blur : requestedBlurs) {
+ for (float blur : requestedBlurs) {
lastBlur = currentTime;
lastBlurUse.put(blur, currentTime);
@@ -80,12 +78,12 @@ public class BackgroundBlur {
return new OutputStuff(fb, null, null);
});
- if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
+ if (output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
output.framebuffer.createBindFramebuffer(width, height);
- if(output.blurShaderHorz != null) {
+ if (output.blurShaderHorz != null) {
output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
}
- if(output.blurShaderVert != null) {
+ if (output.blurShaderVert != null) {
output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
}
}
@@ -94,15 +92,15 @@ public class BackgroundBlur {
}
Set<Float> remove = new HashSet<>();
- for(Map.Entry<Float, Long> entry : lastBlurUse.entrySet()) {
- if(currentTime - entry.getValue() > 30*1000) {
+ 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);
+ remove.remove((float) NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor);
- for(Map.Entry<Float, OutputStuff> entry : blurOutput.entrySet()) {
- if(remove.contains(entry.getKey())) {
+ 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();
@@ -118,7 +116,7 @@ public class BackgroundBlur {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onScreenRender(RenderGameOverlayEvent.Pre event) {
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
processBlurs();
}
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
@@ -127,9 +125,9 @@ public class BackgroundBlur {
@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;
+ 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;
@@ -137,15 +135,15 @@ public class BackgroundBlur {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
@@ -154,9 +152,10 @@ public class BackgroundBlur {
return projMatrix;
}
- private static double lastBgBlurFactor = -1;
+ private static final double lastBgBlurFactor = -1;
+
private static void blurBackground(OutputStuff output, float blurFactor) {
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
@@ -168,36 +167,36 @@ public class BackgroundBlur {
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, 0.0F, -2000.0F);
- if(blurOutputHorz == null) {
+ if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputHorz == null || output == null) {
+ if (blurOutputHorz == null || output == null) {
return;
}
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
blurOutputHorz.createBindFramebuffer(width, height);
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- if(output.blurShaderHorz == null) {
+ 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) { }
+ } catch (Exception ignored) {}
}
- if(output.blurShaderVert == null) {
+ 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) { }
+ } catch (Exception ignored) {}
}
- if(output.blurShaderHorz != null && output.blurShaderVert != null) {
- if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
+ if (output.blurShaderHorz != null && output.blurShaderVert != null) {
+ if (output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
//Corrupted shader?
return;
}
@@ -231,30 +230,30 @@ public class BackgroundBlur {
*/
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;
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ if (blurStrength < 0.5) return;
requestedBlurs.add(blurStrength);
long currentTime = System.currentTimeMillis();
- if(currentTime - lastBlur > 300) {
+ if (currentTime - lastBlur > 300) {
shouldBlur = true;
- if(currentTime - lastBlur > 400 && forcedUpdate) return;
+ if (currentTime - lastBlur > 400 && forcedUpdate) return;
}
- if(blurOutput.isEmpty()) return;
+ if (blurOutput.isEmpty()) return;
OutputStuff out = blurOutput.get(blurStrength);
- if(out == null) {
+ 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;
+ 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);
+ 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);
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..1581c77c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
@@ -25,9 +25,8 @@ public class ChromaColour {
int[] arr = new int[split.length];
-
- for(int i=0; i<split.length; i++) {
- arr[i] = Integer.parseInt(split[split.length-1-i], RADIX);
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
}
return arr;
}
@@ -48,15 +47,16 @@ public class ChromaColour {
}
public static float getSecondsForSpeed(int speed) {
- return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS;
+ 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();
+ if (startTime < 0) startTime = System.currentTimeMillis();
int[] d = decompose(special);
int chr = d[4];
@@ -67,11 +67,11 @@ public class ChromaColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- if(chr > 0) {
+ if (chr > 0) {
float seconds = getSecondsForSpeed(chr);
- hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds;
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
hsv[0] %= 1;
- if(hsv[0] < 0) hsv[0] += 1;
+ if (hsv[0] < 0) hsv[0] += 1;
}
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
@@ -85,11 +85,10 @@ public class ChromaColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- hsv[0] += degrees/360f;
+ 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..45f7e269 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GlScissorStack.java
@@ -27,10 +27,10 @@ public class GlScissorStack {
right = Math.min(right, this.right);
bottom = Math.min(bottom, this.bottom);
- if(top > bottom) {
+ if (top > bottom) {
top = bottom;
}
- if(left > right) {
+ if (left > right) {
left = right;
}
@@ -40,39 +40,39 @@ public class GlScissorStack {
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);
+ GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale);
}
}
- private static LinkedList<Bounds> boundsStack = new LinkedList<>();
+ private static final LinkedList<Bounds> boundsStack = new LinkedList<>();
public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) {
- if(right < left) {
+ if (right < left) {
int temp = right;
right = left;
left = temp;
}
- if(bottom < top) {
+ if (bottom < top) {
int temp = bottom;
bottom = top;
top = temp;
}
- if(boundsStack.isEmpty()) {
+ if (boundsStack.isEmpty()) {
boundsStack.push(new Bounds(left, top, right, bottom));
} else {
boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom));
}
- if(!boundsStack.isEmpty()) {
+ if (!boundsStack.isEmpty()) {
boundsStack.peek().set(scaledResolution);
}
GL11.glEnable(GL11.GL_SCISSOR_TEST);
}
public static void pop(ScaledResolution scaledResolution) {
- if(!boundsStack.isEmpty()) {
+ if (!boundsStack.isEmpty()) {
boundsStack.pop();
}
- if(boundsStack.isEmpty()) {
+ if (boundsStack.isEmpty()) {
GL11.glDisable(GL11.GL_SCISSOR_TEST);
} else {
boundsStack.peek().set(scaledResolution);
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..aa3d4989 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,11 @@ 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 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..66310dfd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
@@ -15,8 +15,8 @@ public class GuiElementBoolean extends GuiElement {
public int x;
public int y;
private boolean value;
- private int clickRadius;
- private Consumer<Boolean> toggleCallback;
+ private final int clickRadius;
+ private final Consumer<Boolean> toggleCallback;
private boolean previewValue;
private int animation = 0;
@@ -38,7 +38,7 @@ public class GuiElementBoolean extends GuiElement {
this.toggleCallback = toggleCallback;
this.lastMillis = System.currentTimeMillis();
- if(value) animation = 36;
+ if (value) animation = 36;
}
@Override
@@ -52,58 +52,58 @@ public class GuiElementBoolean extends GuiElement {
long deltaMillis = currentMillis - lastMillis;
lastMillis = currentMillis;
boolean passedLimit = false;
- if(previewValue != value) {
- if((previewValue && animation > 12) ||
+ if (previewValue != value) {
+ if ((previewValue && animation > 12) ||
(!previewValue && animation < 24)) {
passedLimit = true;
}
}
- if(previewValue != passedLimit) {
- animation += deltaMillis/10;
+ if (previewValue != passedLimit) {
+ animation += deltaMillis / 10;
} else {
- animation -= deltaMillis/10;
+ animation -= deltaMillis / 10;
}
- lastMillis -= deltaMillis%10;
+ lastMillis -= deltaMillis % 10;
- if(previewValue == value) {
+ if (previewValue == value) {
animation = Math.max(0, Math.min(36, animation));
- } else if(!passedLimit) {
- if(previewValue) {
+ } 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) {
+ 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) {
+ int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36);
+ if (animation < 3) {
buttonLoc = GuiTextures.OFF;
- } else if(animation < 13) {
+ } else if (animation < 13) {
buttonLoc = GuiTextures.ONE;
- } else if(animation < 23) {
+ } else if (animation < 23) {
buttonLoc = GuiTextures.TWO;
- } else if(animation < 33) {
+ } else if (animation < 33) {
buttonLoc = GuiTextures.THREE;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc);
- RenderUtils.drawTexturedRect(x+animation, y, 12, 14);
+ 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()) {
+ 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) {
+ } else if (previewValue == !value) {
value = !value;
toggleCallback.accept(value);
}
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..6d267040 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
@@ -30,18 +30,18 @@ public class GuiElementColour extends GuiElement {
private final GuiElementTextField hexField = new GuiElementTextField("",
GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE);
- private int x;
- private int y;
+ private final int x;
+ private final int y;
private int xSize = 119;
- private int ySize = 89;
+ private final int ySize = 89;
private float wheelAngle = 0;
private float wheelRadius = 0;
private int clickedComponent = -1;
- private Consumer<String> colourChangedCallback;
- private Runnable closeCallback;
+ private final Consumer<String> colourChangedCallback;
+ private final Runnable closeCallback;
private String colour;
private final boolean opacitySlider;
@@ -56,8 +56,8 @@ public class GuiElementColour extends GuiElement {
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.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;
@@ -71,13 +71,13 @@ public class GuiElementColour extends GuiElement {
this.opacitySlider = opacitySlider;
this.valueSlider = valueSlider;
- if(!valueSlider) xSize -= 15;
- if(!opacitySlider) xSize -= 15;
+ if (!valueSlider) xSize -= 15;
+ if (!opacitySlider) xSize -= 15;
}
public void updateAngleAndRadius(float[] hsv) {
this.wheelRadius = hsv[1];
- this.wheelAngle = hsv[0]*360;
+ this.wheelAngle = hsv[0] * 360;
}
public void render() {
@@ -89,27 +89,27 @@ public class GuiElementColour extends GuiElement {
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);
+ 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);
+ 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);
}
}
@@ -117,191 +117,191 @@ public class GuiElementColour extends GuiElement {
}
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;
+ 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();
+ 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;
+ 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);
+ 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);
+ 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) {
+ 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);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
}
int opacityOffset = 0;
- if(opacitySlider) {
+ 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);
-
+ 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);
+ 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);
+ 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,
+ 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));
+ 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 (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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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)+"",
+ 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)+"",
+ 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);
+ 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",
+ 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);
+ 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());
+ 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++) {
+ 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);
+ 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() /
+ float mouseXF = (float) (Mouse.getX() * scaledResolution.getScaledWidth_double() /
Minecraft.getMinecraft().displayWidth);
- float mouseYF = (float)(scaledResolution.getScaledHeight_double() - Mouse.getY() *
+ 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) {
+ 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) {
+ 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) {
+ 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) {
+ if (xWheel > 0 && xWheel < 64) {
+ if (yWheel > 0 && yWheel < 64) {
clickedComponent = 0;
}
}
- int xValue = mouseX - (x+5+64+5);
+ 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) {
+ 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 (opacitySlider) {
+ int xOpacity = mouseX - (x + 5 + 64 + 5 + valueOffset);
- if(xOpacity > 0 && xOpacity < 10) {
+ 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) {
+ 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) {
+ } 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);
@@ -314,7 +314,7 @@ public class GuiElementColour extends GuiElement {
return false;
}
}
- if(Mouse.isButtonDown(0) && clickedComponent >= 0) {
+ 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);
@@ -322,16 +322,16 @@ public class GuiElementColour extends GuiElement {
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);
+ 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;
+ 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();
+ 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;
@@ -341,22 +341,22 @@ public class GuiElementColour extends GuiElement {
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();
+ 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) {
+ if (clickedComponent == 2) {
colour = ChromaColour.special(ChromaColour.getSpeed(colour),
- 255-Math.round(y/64f*255), currentColour);
+ 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);
+ if (clickedComponent == 3) {
+ colour = ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour);
colourChangedCallback.accept(colour);
}
return true;
@@ -365,7 +365,7 @@ public class GuiElementColour extends GuiElement {
}
public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && hexField.getFocus()) {
+ if (Keyboard.getEventKeyState() && hexField.getFocus()) {
if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
hexField.unfocus();
return true;
@@ -374,7 +374,7 @@ public class GuiElementColour extends GuiElement {
hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(hexField.getText().length() > 6) {
+ if (hexField.getText().length() > 6) {
hexField.setText(old);
} else {
try {
@@ -388,13 +388,12 @@ public class GuiElementColour extends GuiElement {
Color c = new Color(rgb);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
updateAngleAndRadius(hsv);
- } catch(Exception e) {};
+ } 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..5b52515d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
@@ -40,7 +40,7 @@ public class GuiElementTextField {
private int customTextColour = 0xffffffff;
private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
- 0 , 0, 0, 0);
+ 0, 0, 0, 0);
private int customBorderColour = -1;
@@ -76,11 +76,11 @@ public class GuiElementTextField {
public String getTextDisplay() {
String textNoColour = getText();
- while(true) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
- if(!matcher.find()) break;
+ if (!matcher.find()) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
}
return textNoColour;
@@ -91,13 +91,13 @@ public class GuiElementTextField {
}
public void setText(String text) {
- if(textField.getText() == null || !textField.getText().equals(text)) {
+ if (textField.getText() == null || !textField.getText().equals(text)) {
textField.setText(text);
}
}
public void setSize(int searchBarXSize, int searchBarYSize) {
- this.searchBarXSize = searchBarXSize;
+ this.searchBarXSize = searchBarXSize;
this.searchBarYSize = searchBarYSize;
}
@@ -112,34 +112,35 @@ public class GuiElementTextField {
public void setFocus(boolean focus) {
this.focus = focus;
- if(!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 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);
+ 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;
+ return bottomTextBox + paddingUnscaled * 2;
}
public int getWidth() {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
- return searchBarXSize + paddingUnscaled*2;
+ return searchBarXSize + paddingUnscaled * 2;
}
private float getScaleFactor(String str) {
- return Math.min(1, (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
+ return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
}
private boolean isScaling() {
@@ -152,60 +153,60 @@ public class GuiElementTextField {
int xComp = mouseX - x;
int yComp = mouseY - y;
- int extraSize = (searchBarYSize-8)/2+8;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
String renderText = prependText + textField.getText();
- int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize);
+ int lineNum = Math.round(((yComp - (searchBarYSize - 8) / 2)) / extraSize);
String text = renderText;
String textNoColour = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
+ if ((options & COLOUR) != 0) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- if(code.isEmpty()) {
+ if (code.isEmpty()) {
text = matcher.replaceFirst("\u00A7r\u00B6");
} else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
}
- while(true) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ 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') {
+ 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);
+ 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)) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < xComp - padding) {
linePos++;
}
}
cursorIndex += linePos;
int pre = StringUtils.cleanColour(prependText).length();
- if(cursorIndex < pre) {
+ if (cursorIndex < pre) {
cursorIndex = 0;
} else {
cursorIndex -= pre;
@@ -215,7 +216,7 @@ public class GuiElementTextField {
}
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 1) {
+ if (mouseButton == 1) {
textField.setText("");
} else {
textField.setCursorPosition(getCursorPos(mouseX, mouseY));
@@ -233,46 +234,46 @@ public class GuiElementTextField {
}
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(focus) {
+ if (focus) {
textField.setSelectionPos(getCursorPos(mouseX, mouseY));
}
}
public void keyTyped(char typedChar, int keyCode) {
- if(focus) {
- if((options & MULTILINE) != 0) { //Carriage return
+ 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) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- if(code.isEmpty()) {
+ if (code.isEmpty()) {
text = matcher.replaceFirst("\u00A7r\u00B6");
} else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
- while(true) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
}
- if(keyCode == 28) {
+ 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);
+ textField.setCursorPosition(pos + 1);
return;
- } else if(keyCode == 200) { //Up
+ } 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);
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
int numLinesBeforeCursor = org.apache.commons.lang3.StringUtils.countMatches(textBeforeCursor, "\n");
@@ -280,13 +281,13 @@ public class GuiElementTextField {
int textBeforeCursorWidth;
String lineBefore;
String thisLineBeforeCursor;
- if(split.length == numLinesBeforeCursor && split.length > 0) {
+ if (split.length == numLinesBeforeCursor && split.length > 0) {
textBeforeCursorWidth = 0;
- lineBefore = split[split.length-1];
+ lineBefore = split[split.length - 1];
thisLineBeforeCursor = "";
- } else if(split.length > 1) {
- thisLineBeforeCursor = split[split.length-1];
- lineBefore = split[split.length-2];
+ } else if (split.length > 1) {
+ thisLineBeforeCursor = split[split.length - 1];
+ lineBefore = split[split.length - 2];
textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
} else {
return;
@@ -294,60 +295,60 @@ public class GuiElementTextField {
String trimmed = Minecraft.getMinecraft().fontRendererObj
.trimStringToWidth(lineBefore, textBeforeCursorWidth);
int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineBefore)) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
linePos++;
}
}
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- -strLenNoColor(lineBefore)-1+linePos;
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ - strLenNoColor(lineBefore) - 1 + linePos;
- if(GuiScreen.isShiftKeyDown()) {
+ if (GuiScreen.isShiftKeyDown()) {
textField.setSelectionPos(newPos);
} else {
textField.setCursorPosition(newPos);
}
- } else if(keyCode == 208) { //Down
+ } 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);
+ 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) {
+ if (split.length == numLinesBeforeCursor) {
thisLineBeforeCursor = "";
textBeforeCursorWidth = 0;
- } else if(split.length > 0) {
- thisLineBeforeCursor = split[split.length-1];
+ } 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];
+ 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)) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
linePos++;
}
}
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- +strLenNoColor(split2[numLinesBeforeCursor])+1+linePos;
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ + strLenNoColor(split2[numLinesBeforeCursor]) + 1 + linePos;
- if(GuiScreen.isShiftKeyDown()) {
+ if (GuiScreen.isShiftKeyDown()) {
textField.setSelectionPos(newPos);
} else {
textField.setCursorPosition(newPos);
@@ -357,47 +358,47 @@ public class GuiElementTextField {
}
String old = textField.getText();
- if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
- if((options & NO_SPACE) != 0 && typedChar == ' ') return;
+ if ((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
+ if ((options & NO_SPACE) != 0 && typedChar == ' ') return;
- if(typedChar == '\u00B6') {
+ 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) == '&') {
+ 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);
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
}
textField.setText(before + "\u00A7" + after);
- textField.setCursorPosition(pos+1);
+ textField.setCursorPosition(pos + 1);
}
}
- } else if(typedChar == '*') {
- int pos = textField.getCursorPosition()-2;
- if(pos >= 0 && pos < textField.getText().length()) {
- if(textField.getText().charAt(pos) == '*') {
+ } 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);
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
}
textField.setText(before + "\u272A" + after);
- textField.setCursorPosition(pos+1);
+ textField.setCursorPosition(pos + 1);
}
}
}
}
- if((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
+ if ((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
}
}
@@ -414,21 +415,21 @@ public class GuiElementTextField {
GlStateManager.disableLighting();
- /**
+ /*
* Search bar
*/
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
+ 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 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) {
+ if (customBorderColour != -1) {
borderColour = customBorderColour;
}
- if((options & DISABLE_BG) == 0) {
+ if ((options & DISABLE_BG) == 0) {
//bar background
Gui.drawRect(x - paddingUnscaled,
y - paddingUnscaled,
@@ -443,114 +444,114 @@ public class GuiElementTextField {
//bar text
String text = renderText;
String textNoColor = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
+ if ((options & COLOUR) != 0) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- if(code.isEmpty()) {
+ if (code.isEmpty()) {
text = matcher.replaceFirst("\u00A7r\u00B6");
} else {
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
}
- while(true) {
+ while (true) {
Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColor);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColor = matcher.replaceFirst("\u00B6"+code);
+ 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);
+ 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);
+ 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);
+ y + (searchBarYSize - 8) / 2 + yOff, customTextColour);
GlScissorStack.pop(scaledresolution);
} else {
- String toRender = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(Utils.chromaStringByColourCode(texts[yOffI]), searchBarXSize-10);
+ 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);
+ y + (searchBarYSize - 8) / 2 + yOff, customTextColour);
}
}
}
- if(focus && System.currentTimeMillis()%1000>500) {
- String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition()+prependText.length());
+ 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)));
+ 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;
+ int yOff = numLinesBeforeCursor * extraSize;
String[] split = textBeforeCursor.split("\n");
int textBeforeCursorWidth;
- if(split.length <= numLinesBeforeCursor || split.length == 0) {
+ if (split.length <= numLinesBeforeCursor || split.length == 0) {
textBeforeCursorWidth = 0;
} else {
- textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale);
+ 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());
+ 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());
+ 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) {
+ 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'
+ 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 (i < prependText.length()) continue;
}
- if(c == '\u00B6') {
+ if (c == '\u00B6') {
sectionSignPrev = true;
- if(i < prependText.length()) continue;
+ 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());
+ 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;
@@ -559,24 +560,24 @@ public class GuiElementTextField {
}
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());
+ 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) {
+ 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);
+ y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale);
}
}
- texX += len*scale;
+ texX += len * scale;
}
}
}
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..f5d8488c 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
@@ -2,7 +2,6 @@ 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..1a69789b 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
@@ -28,15 +28,15 @@ public class GuiPositionEditor extends GuiScreen {
int centerWidth = 176;
int centerHeight = 166;
- float centerWF = centerWidth/2f / (float)width;
- float centerHF = centerHeight/2f / (float)height;
+ 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()) {
+ switch (position.getAnchorX()) {
case MIN: {
left = 0;
right = 0.5f - centerWF;
@@ -53,7 +53,7 @@ public class GuiPositionEditor extends GuiScreen {
break;
}
}
- switch(position.getAnchorY()) {
+ switch (position.getAnchorY()) {
case MIN: {
top = 0;
bottom = 0.5f - centerHF;
@@ -71,8 +71,8 @@ public class GuiPositionEditor extends GuiScreen {
}
}
- Gui.drawRect((int)(left*width), (int)(top*height), (int)(right*width), (int)(bottom*height), 0x40404040);
- Gui.drawRect(x, y, x+200, y+100, 0x80404040);
+ 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
@@ -81,8 +81,8 @@ public class GuiPositionEditor extends GuiScreen {
int x = position.resolveX(scaledResolution, 200);
int y = position.resolveY(scaledResolution, 100);
- if(mouseX > x && mouseX < x+200 &&
- mouseY > y && mouseY < y+100) {
+ if (mouseX > x && mouseX < x + 200 &&
+ mouseY > y && mouseY < y + 100) {
clickedX = mouseX;
clickedY = mouseY;
} else {
@@ -99,7 +99,7 @@ public class GuiPositionEditor extends GuiScreen {
@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(clickedX >= 0 && clickedY >= 0) {
+ if (clickedX >= 0 && clickedY >= 0) {
int deltaX = mouseX - clickedX;
int deltaY = mouseY - clickedY;
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..b1013047 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,23 +1,22 @@
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) {
+ if (keyCode == 0) {
return "NONE";
- } else if(keyCode < 0) {
- return "Button "+(keyCode+101);
+ } else if (keyCode < 0) {
+ return "Button " + (keyCode + 101);
} else {
String keyName = Keyboard.getKeyName(keyCode);
- if(keyName == null) {
+ if (keyName == null) {
keyName = "???";
- } else if(keyName.equalsIgnoreCase("LMENU")) {
+ } else if (keyName.equalsIgnoreCase("LMENU")) {
keyName = "LALT";
- } else if(keyName.equalsIgnoreCase("RMENU")) {
+ } else if (keyName.equalsIgnoreCase("RMENU")) {
keyName = "RALT";
}
return keyName;
@@ -29,20 +28,20 @@ public class KeybindHelper {
}
public static boolean isKeyDown(int keyCode) {
- if(!isKeyValid(keyCode)) {
+ if (!isKeyValid(keyCode)) {
return false;
- } else if(keyCode < 0) {
- return Mouse.isButtonDown(keyCode+100);
+ } else if (keyCode < 0) {
+ return Mouse.isButtonDown(keyCode + 100);
} else {
return Keyboard.isKeyDown(keyCode);
}
}
public static boolean isKeyPressed(int keyCode) {
- if(!isKeyValid(keyCode)) {
+ if (!isKeyValid(keyCode)) {
return false;
- } else if(keyCode < 0) {
- return Mouse.getEventButtonState() && Mouse.getEventButton() == keyCode+100;
+ } 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..270570f8 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
@@ -57,17 +57,17 @@ public class Position {
public int getAbsX(ScaledResolution scaledResolution, int objWidth) {
int width = scaledResolution.getScaledWidth();
- if(centerX) {
- return width/2 + x;
+ if (centerX) {
+ return width / 2 + x;
}
int ret = x;
- if(x < 0) {
+ if (x < 0) {
ret = width + x - objWidth;
}
- if(ret < 0) ret = 0;
- if(ret > width - objWidth) ret = width - objWidth;
+ if (ret < 0) ret = 0;
+ if (ret > width - objWidth) ret = width - objWidth;
return ret;
}
@@ -75,17 +75,17 @@ public class Position {
public int getAbsY(ScaledResolution scaledResolution, int objHeight) {
int height = scaledResolution.getScaledHeight();
- if(centerY) {
- return height/2 + y;
+ if (centerY) {
+ return height / 2 + y;
}
int ret = y;
- if(y < 0) {
+ if (y < 0) {
ret = height + y - objHeight;
}
- if(ret < 0) ret = 0;
- if(ret > height - objHeight) ret = height - objHeight;
+ if (ret < 0) ret = 0;
+ if (ret > height - objHeight) ret = height - objHeight;
return ret;
}
@@ -95,45 +95,45 @@ public class Position {
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;
+ 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;
+ 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;
+ 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;
+ 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 + 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 + screenWidth < EDGE_OFFSET) {
+ deltaX += EDGE_OFFSET - screenWidth - this.x;
+ this.x = EDGE_OFFSET - screenWidth;
}
}
- if(this.x >= 0 && this.x+objWidth/2 > screenWidth/2) {
+ if (this.x >= 0 && this.x + objWidth / 2 > screenWidth / 2) {
this.x -= screenWidth - objWidth;
}
- if(this.x < 0 && this.x+objWidth/2 <= -screenWidth/2) {
+ if (this.x < 0 && this.x + objWidth / 2 <= -screenWidth / 2) {
this.x += screenWidth - objWidth;
}
return deltaX;
@@ -144,45 +144,45 @@ public class Position {
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;
+ 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;
+ 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;
+ 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;
+ 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 + 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 + screenHeight < EDGE_OFFSET) {
+ deltaY += EDGE_OFFSET - screenHeight - this.y;
+ this.y = EDGE_OFFSET - screenHeight;
}
}
- if(this.y >= 0 && this.y-objHeight/2 > screenHeight/2) {
+ if (this.y >= 0 && this.y - objHeight / 2 > screenHeight / 2) {
this.y -= screenHeight - objHeight;
}
- if(this.y < 0 && this.y-objHeight/2 <= -screenHeight/2) {
+ 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..a0029dd8 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
@@ -64,9 +64,9 @@ public class PositionNew {
public int moveX(ScaledResolution scaledResolution, int deltaX, int sizeX) {
int originalX = resolveX(scaledResolution, sizeX);
- AtomicInteger atomicInteger = new AtomicInteger(x+deltaX);
+ AtomicInteger atomicInteger = new AtomicInteger(x + deltaX);
AtomicReference<Anchor> atomicReference = new AtomicReference<>(anchorX);
- move(atomicInteger, atomicReference, anchorY, (int)Math.ceil(sizeX*scaleX), scaledResolution.getScaledWidth(), 176);
+ move(atomicInteger, atomicReference, anchorY, (int) Math.ceil(sizeX * scaleX), scaledResolution.getScaledWidth(), 176);
x = atomicInteger.get();
anchorX = atomicReference.get();
return resolveX(scaledResolution, sizeX) - originalX;
@@ -74,25 +74,25 @@ public class PositionNew {
public int moveY(ScaledResolution scaledResolution, int deltaY, int sizeY) {
int originalY = resolveY(scaledResolution, sizeY);
- AtomicInteger atomicInteger = new AtomicInteger(y+deltaY);
+ AtomicInteger atomicInteger = new AtomicInteger(y + deltaY);
AtomicReference<Anchor> atomicReference = new AtomicReference<>(anchorY);
- move(atomicInteger, atomicReference, anchorY, (int)Math.ceil(sizeY*scaleY), scaledResolution.getScaledHeight(), 166);
+ 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;
+ 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) {
+ 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) {
+ } 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);
@@ -101,33 +101,33 @@ public class PositionNew {
anchor.set(Anchor.MID);
}
- if(centerCoord - elementSize/2 < 0) centerCoord = elementSize/2;
- if(centerCoord + elementSize/2 > screenSize) centerCoord = screenSize - elementSize/2;
+ 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));
+ 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);
+ 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);
+ 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);
+ return Math.round(screenSize * anchor.screenMult + elementSize * anchor.elementMult + guiSize * anchor.guiMult + coord);
}
public void setScaleX(float scaleX) {
- if(allowResize) {
+ if (allowResize) {
this.scaleX = scaleX;
}
}
public void setScaleY(float scaleY) {
- if(allowResize) {
+ if (allowResize) {
this.scaleY = scaleY;
}
}
@@ -141,7 +141,7 @@ public class PositionNew {
}
public void setPinned(boolean pinned) {
- if(allowPinToggle) {
+ if (allowPinToggle) {
this.pinned = pinned;
}
}
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..2611b466 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
@@ -10,6 +10,7 @@ import java.lang.annotation.Target;
public @interface Category {
String name();
+
String desc();
}
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..be8363d5 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
@@ -10,6 +10,7 @@ import java.lang.annotation.Target;
public @interface ConfigEditorButton {
int runnableId();
+
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..e7033f69 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;
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..e878d657 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;
@@ -11,6 +10,7 @@ import java.lang.annotation.Target;
public @interface ConfigEditorDropdown {
String[] values();
+
int initialIndex() default 0;
}
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..4a6fb5be 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;
@@ -11,6 +10,7 @@ import java.lang.annotation.Target;
public @interface ConfigEditorSlider {
float minValue();
+
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..556bbb1e 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;
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..77738abf 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;
@@ -11,7 +10,9 @@ import java.lang.annotation.Target;
public @interface ConfigOption {
String name();
+
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..3ccb3841 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
@@ -22,27 +22,27 @@ public abstract class GuiOptionEditor {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
RenderUtils.drawFloatingRectDark(x, y, width, height, true);
TextRenderUtils.drawStringCenteredScaledMaxWidth(option.name,
- fr, x+width/6, y+13, true, width/3-10, 0xc0c0c0);
+ 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 lineCount = fr.listFormattedStringToWidth(option.desc, width * 2 / 3 - 10).size();
- if(lineCount <= 0) return;
+ if (lineCount <= 0) return;
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.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();
}
@@ -52,11 +52,13 @@ public abstract class GuiOptionEditor {
}
public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY);
+
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 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..7406f2c3 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,11 +11,9 @@ 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 int accordionId;
+ private final int accordionId;
private boolean accordionToggled;
public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) {
@@ -51,27 +47,27 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor {
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();
+ 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();
+ 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);
+ 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()) {
+ if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width &&
+ mouseY > y && mouseY < y + getHeight()) {
accordionToggled = !accordionToggled;
return true;
}
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..8c8c32b6 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
@@ -10,7 +10,7 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor {
public GuiOptionEditorBoolean(ConfigProcessor.ProcessedOption option) {
super(option);
- bool = new GuiElementBoolean(0, 0, (boolean)option.get(), 10, option::set);
+ bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, option::set);
}
@Override
@@ -18,16 +18,16 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor {
super.render(x, y, width);
int height = getHeight();
- bool.x = x+width/6-24;
- bool.y = y+height-7-14;
+ 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;
+ bool.x = x + width / 6 - 24;
+ bool.y = y + height - 7 - 14;
return bool.mouseInput(mouseX, mouseY);
}
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..82d965e3 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,23 +1,20 @@
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 int runnableId;
+ private final int runnableId;
private String buttonText;
- private Config config;
+ private final Config config;
public GuiOptionEditorButton(ConfigProcessor.ProcessedOption option, int runnableId, String buttonText, Config config) {
super(option);
@@ -25,7 +22,7 @@ public class GuiOptionEditorButton extends GuiOptionEditor {
this.config = config;
this.buttonText = buttonText;
- if(this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
+ if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null;
}
@Override
@@ -36,21 +33,21 @@ public class GuiOptionEditorButton extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
- if(buttonText != null) {
+ if (buttonText != null) {
TextRenderUtils.drawStringCenteredScaledMaxWidth(buttonText, Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+height-7-6,
+ 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()) {
+ 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) {
+ 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;
}
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..4cd74e79 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,17 +1,14 @@
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 {
@@ -21,7 +18,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) {
super(option);
- this.chromaColour = (String)option.get();
+ this.chromaColour = (String) option.get();
}
@Override
@@ -33,33 +30,30 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
int r = (argb >> 16) & 0xFF;
int g = (argb >> 8) & 0xFF;
int b = argb & 0xFF;
- GlStateManager.color(r/255f, g/255f, b/255f, 1);
+ 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);
+ 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) {
+ 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;
+ 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) {
+ 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;
@@ -71,11 +65,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(colourElement != null && colourElement.keyboardInput()) {
- return true;
- }
-
- return false;
+ 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..c91f2b6a 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;
@@ -26,8 +24,8 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png");
- private String[] exampleText;
- private List<Integer> activeText;
+ private final String[] exampleText;
+ private final List<Integer> activeText;
private int currentDragging = -1;
private int dragStartIndex = -1;
@@ -49,7 +47,7 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
public int getHeight() {
int height = super.getHeight() + 13;
- for(int strIndex : activeText) {
+ for (int strIndex : activeText) {
String str = exampleText[strIndex];
height += 10 * str.split("\n").length;
}
@@ -65,42 +63,42 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+45-7-14, 48, 16);
+ 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,
+ x + width / 6, y + 45 - 7 - 6,
false, 44, 0xFF303030);
long currentTime = System.currentTimeMillis();
- if(trashHoverTime < 0) {
- float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime)/250f);
+ 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);
+ 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);
+ 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);
+ 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) {
+ 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++) {
+ 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);
+ 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);
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", x + 10, y + 50 + yOff + ySize / 2 - 4, 0xffffff, true);
}
yOff += ySize;
@@ -111,50 +109,50 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
public void renderOverlay(int x, int y, int width) {
super.renderOverlay(x, y, width);
- if(dropdownOpen) {
+ if (dropdownOpen) {
List<Integer> remaining = new ArrayList<>();
- for(int i=0; i<exampleText.length; i++) {
+ 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 dropdownWidth = Math.min(width / 2 - 10, 150);
int left = dragOffsetX;
int top = dragOffsetY;
- int dropdownHeight = -1 + 12*remaining.size();
+ 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
+ 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) {
+ for (int strIndex : remaining) {
String str = exampleText[strIndex];
- if(str.isEmpty()) {
+ if (str.isEmpty()) {
str = "<NONE>";
}
TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."),
- fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0);
+ fr, left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0);
dropdownY += 12;
}
- } else if(currentDragging >= 0) {
+ } 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);
+ 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);
+ float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f);
+ opacity = (int) (opacity * greenBlue);
}
- if(opacity < 20) return;
+ if (opacity < 20) return;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
@@ -165,67 +163,67 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
String[] multilines = str.split("\n");
GlStateManager.enableBlend();
- for(int multilineIndex=0; multilineIndex<multilines.length; multilineIndex++) {
+ 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));
+ 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);
+ 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 &&
+ 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) {
+ 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) {
+ 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();
+ 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 (trashHoverTime > 0) trashHoverTime = -System.currentTimeMillis();
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
int height = getHeight();
- if(dropdownOpen) {
+ if (dropdownOpen) {
List<Integer> remaining = new ArrayList<>();
- for(int i=0; i<exampleText.length; i++) {
+ for (int i = 0; i < exampleText.length; i++) {
remaining.add(i);
}
remaining.removeAll(activeText);
- int dropdownWidth = Math.min(width/2-10, 150);
+ int dropdownWidth = Math.min(width / 2 - 10, 150);
int left = dragOffsetX;
int top = dragOffsetY;
- int dropdownHeight = -1 + 12*remaining.size();
+ int dropdownHeight = -1 + 12 * remaining.size();
- if(mouseX > left && mouseX < left+dropdownWidth &&
+ if (mouseX > left && mouseX < left + dropdownWidth &&
mouseY > top && mouseY < top + dropdownHeight) {
int dropdownY = -1;
- for(int strIndex : remaining) {
- if(mouseY < top+dropdownY+12) {
+ for (int strIndex : remaining) {
+ if (mouseY < top + dropdownY + 12) {
activeText.add(0, strIndex);
- if(remaining.size() == 1) dropdownOpen = false;
+ if (remaining.size() == 1) dropdownOpen = false;
return true;
}
@@ -237,25 +235,25 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
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) {
+ 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;
+ 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) {
+ 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;
+ if (mouseY < y + 50 + yOff + ySize) {
+ dragOffsetX = x + 10 - mouseX;
+ dragOffsetY = y + 50 + yOff - mouseY;
currentDragging = strIndex;
dragStartIndex = i;
@@ -265,11 +263,11 @@ public class GuiOptionEditorDraggableList extends GuiOptionEditor {
i++;
}
}
- } else if(Mouse.getEventButton() == -1 && currentDragging >= 0) {
- int yOff=0;
+ } 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) {
+ for (int strIndex : activeText) {
+ if (dragOffsetY + mouseY + 4 < y + 50 + yOff + 10) {
activeText.remove(dragStartIndex);
activeText.add(i, currentDragging);
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..c003f135 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
@@ -6,9 +6,7 @@ import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
-import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.GL11;
public class GuiOptionEditorDropdown extends GuiOptionEditor {
@@ -19,7 +17,7 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
public GuiOptionEditorDropdown(ConfigProcessor.ProcessedOption option, String[] values, int selected, boolean useOrdinal) {
super(option);
- if(selected >= values.length) selected = values.length;
+ if (selected >= values.length) selected = values.length;
this.values = values;
this.selected = selected;
this.useOrdinal = useOrdinal;
@@ -29,68 +27,67 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
public void render(int x, int y, int width) {
super.render(x, y, width);
- if(!open) {
+ 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;
+ 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) {
+ 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.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);
+ TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false,
+ dropdownWidth - 16, 0xffa0a0a0);
}
}
@Override
public void renderOverlay(int x, int y, int width) {
- if(open) {
+ if (open) {
String selectedString = " - Select - ";
- if(selected >= 0 && selected < values.length) {
+ 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 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 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, 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
+ Gui.drawRect(left + 1, top + 14 - 1, left + dropdownWidth - 1, top + 14, blue); //Bar
int dropdownY = 13;
- for(String option : values) {
- if(option.isEmpty()) {
+ for (String option : values) {
+ if (option.isEmpty()) {
option = "<NONE>";
}
- TextRenderUtils.drawStringScaledMaxWidth(option, fr, left+3, top+3+dropdownY, false, dropdownWidth-6, 0xffa0a0a0);
+ 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.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);
+ TextRenderUtils.drawStringScaledMaxWidth(selectedString, fr, left + 3, top + 3, false,
+ dropdownWidth - 16, 0xffa0a0a0);
}
}
@@ -98,12 +95,12 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
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;
+ 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) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ if (mouseX >= left && mouseX <= left + 80 &&
+ mouseY >= top && mouseY <= top + 14) {
open = !open;
return true;
}
@@ -116,19 +113,19 @@ public class GuiOptionEditorDropdown extends GuiOptionEditor {
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;
+ 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) {
+ 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) {
+ 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) {
+ for (int ordinal = 0; ordinal < values.length; ordinal++) {
+ if (mouseY >= top + 3 + dropdownY && mouseY <= top + 3 + dropdownY + 12) {
selected = ordinal;
- if(useOrdinal) {
+ if (useOrdinal) {
option.set(selected);
} else {
option.set(values[selected]);
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..c1297668 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;
@@ -19,7 +18,7 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png");
private int keyCode;
- private int defaultKeyCode;
+ private final int defaultKeyCode;
private boolean editingKeycode;
public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int keyCode, int defaultKeyCode) {
@@ -36,38 +35,38 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
- RenderUtils.drawTexturedRect(x+width/6-24, y+height-7-14, 48, 16);
+ RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
String keyName = KeybindHelper.getKeyName(keyCode);
- String text = editingKeycode ? "> "+keyName+" <" : keyName;
+ String text = editingKeycode ? "> " + keyName + " <" : keyName;
TextRenderUtils.drawStringCenteredScaledMaxWidth(text,
Minecraft.getMinecraft().fontRendererObj,
- x+width/6, y+height-7-6,
+ 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);
+ 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) {
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
editingKeycode = false;
- keyCode = Mouse.getEventButton()-100;
+ keyCode = Mouse.getEventButton() - 100;
option.set(keyCode);
return true;
}
- if(Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
+ 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) {
+ 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) {
+ 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;
@@ -79,14 +78,14 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(editingKeycode) {
+ if (editingKeycode) {
editingKeycode = false;
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
keyCode = 0;
- } else if(Keyboard.getEventKey() != 0) {
+ } else if (Keyboard.getEventKey() != 0) {
keyCode = Keyboard.getEventKey();
}
- if(keyCode > 256) keyCode = 0;
+ if (keyCode > 256) keyCode = 0;
option.set(keyCode);
return true;
}
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..50e98a1d 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;
@@ -15,13 +14,13 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
public GuiOptionEditorSlider(ConfigProcessor.ProcessedOption option, float minValue, float maxValue, float minStep) {
super(option);
- if(minStep < 0) minStep = 0.01f;
+ if (minStep < 0) minStep = 0.01f;
- float floatVal = ((Number)option.get()).floatValue();
+ float floatVal = ((Number) option.get()).floatValue();
{
String strVal;
- if(floatVal % 1 == 0) {
- strVal = Integer.toString((int)floatVal);
+ if (floatVal % 1 == 0) {
+ strVal = Integer.toString((int) floatVal);
} else {
strVal = Float.toString(floatVal);
}
@@ -33,7 +32,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
option.set(val);
String strVal;
- if(val % 1 == 0) {
+ if (val % 1 == 0) {
strVal = Integer.toString(val.intValue());
} else {
strVal = Float.toString(val);
@@ -49,54 +48,54 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
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;
+ 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.x = x + width / 6 - fullWidth / 2;
+ slider.y = y + height - 7 - 14;
slider.width = sliderWidth;
slider.render();
- if(textField.getFocus()) {
+ if (textField.getFocus()) {
textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY);
- textField.setSize(Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10,
+ 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);
+ 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;
+ 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.x = x + width / 6 - fullWidth / 2;
+ slider.y = y + height - 7 - 14;
slider.width = sliderWidth;
- if(slider.mouseInput(mouseX, mouseY)) {
+ if (slider.mouseInput(mouseX, mouseY)) {
textField.unfocus();
return true;
}
- if(textField.getFocus()) {
- textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10;
+ 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;
+ 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) {
+ 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;
}
@@ -108,18 +107,18 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && textField.getFocus()) {
+ 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)) {
+ if (option.set(f)) {
slider.setValue(f);
} else {
textField.setCustomBorderColour(0xff0000ff);
}
- } catch(Exception e) {
+ } catch (Exception e) {
textField.setCustomBorderColour(0xffff0000);
}
@@ -128,5 +127,4 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
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..b05c3ee3 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,9 +1,7 @@
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;
@@ -15,7 +13,7 @@ public class GuiOptionEditorText extends GuiOptionEditor {
public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) {
super(option);
- textField = new GuiElementTextField((String)option.get(), 0);
+ textField = new GuiElementTextField((String) option.get(), 0);
}
@Override
@@ -23,36 +21,36 @@ public class GuiOptionEditorText extends GuiOptionEditor {
super.render(x, y, width);
int height = getHeight();
- int fullWidth = Math.min(width/3-10, 80);
+ 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 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);
+ 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 fullWidth = Math.min(width / 3 - 10, 80);
- int textFieldX = x+width/6-fullWidth/2;
+ int textFieldX = x + width / 6 - fullWidth / 2;
- if(textField.getFocus()) {
- fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText())+10);
+ if (textField.getFocus()) {
+ fullWidth = Math.max(fullWidth, Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10);
}
- int textFieldY = y+height-7-14;
+ 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) {
+ 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;
}
@@ -64,14 +62,14 @@ public class GuiOptionEditorText extends GuiOptionEditor {
@Override
public boolean keyboardInput() {
- if(Keyboard.getEventKeyState() && textField.getFocus()) {
+ 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) {
+ } catch (Exception e) {
textField.setCustomBorderColour(0xffff0000);
}
@@ -80,5 +78,4 @@ public class GuiOptionEditorText extends GuiOptionEditor {
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..467d2b93 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
@@ -14,7 +14,7 @@ import java.io.IOException;
public class GuiPositionEditor extends GuiScreen {
private final Position position;
- private Position originalPosition;
+ private final Position originalPosition;
private final int elementWidth;
private final int elementHeight;
private final Runnable renderCallback;
@@ -27,9 +27,9 @@ public class GuiPositionEditor extends GuiScreen {
private int guiScaleOverride = -1;
public GuiPositionEditor(Position position, int elementWidth, int elementHeight,
- Runnable renderCallback,
- Runnable positionChangedCallback,
- Runnable closedCallback) {
+ Runnable renderCallback,
+ Runnable positionChangedCallback,
+ Runnable closedCallback) {
this.position = position;
this.originalPosition = position.clone();
this.elementWidth = elementWidth;
@@ -54,7 +54,7 @@ public class GuiPositionEditor extends GuiScreen {
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
scaledResolution = Utils.pushGuiScale(guiScaleOverride);
} else {
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -67,7 +67,7 @@ public class GuiPositionEditor extends GuiScreen {
drawDefaultBackground();
- if(clicked) {
+ if (clicked) {
grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution);
grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
}
@@ -77,28 +77,28 @@ public class GuiPositionEditor extends GuiScreen {
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 (position.isCenterX()) x -= elementWidth / 2;
+ if (position.isCenterY()) y -= elementHeight / 2;
+ Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040);
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
Utils.pushGuiScale(-1);
}
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2, 8, true, 0xffffff);
+ 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);
+ 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) {
+ if (mouseButton == 0) {
ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
scaledResolution = Utils.pushGuiScale(guiScaleOverride);
} else {
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -108,17 +108,17 @@ public class GuiPositionEditor extends GuiScreen {
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 (position.isCenterX()) x -= elementWidth / 2;
+ if (position.isCenterY()) y -= elementHeight / 2;
- if(mouseX >= x && mouseY >= y &&
- mouseX <= x+elementWidth && mouseY <= y+elementHeight) {
+ if (mouseX >= x && mouseY >= y &&
+ mouseX <= x + elementWidth && mouseY <= y + elementHeight) {
clicked = true;
grabbedX = mouseX;
grabbedY = mouseY;
}
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
Utils.pushGuiScale(-1);
}
}
@@ -128,18 +128,18 @@ public class GuiPositionEditor extends GuiScreen {
protected void keyTyped(char typedChar, int keyCode) throws IOException {
Keyboard.enableRepeatEvents(true);
- if(keyCode == Keyboard.KEY_R) {
+ if (keyCode == Keyboard.KEY_R) {
position.set(originalPosition);
- } else if(!clicked) {
+ } 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) {
+ if (keyCode == Keyboard.KEY_DOWN) {
position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_UP) {
+ } else if (keyCode == Keyboard.KEY_UP) {
position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_LEFT) {
+ } else if (keyCode == Keyboard.KEY_LEFT) {
position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
- } else if(keyCode == Keyboard.KEY_RIGHT) {
+ } else if (keyCode == Keyboard.KEY_RIGHT) {
position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft()));
}
}
@@ -156,9 +156,9 @@ public class GuiPositionEditor extends GuiScreen {
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- if(clicked) {
+ if (clicked) {
ScaledResolution scaledResolution;
- if(guiScaleOverride >= 0) {
+ if (guiScaleOverride >= 0) {
scaledResolution = Utils.pushGuiScale(guiScaleOverride);
} else {
scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -170,7 +170,7 @@ public class GuiPositionEditor extends GuiScreen {
grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution);
positionChangedCallback.run();
- if(guiScaleOverride >= 0) {
+ 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..b1581458 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,7 +4,6 @@ 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;
@@ -46,20 +45,20 @@ public class ConfigProcessor {
public Object get() {
try {
return field.get(container);
- } catch(Exception e) {
+ } 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());
+ if (field.getType() == int.class && value instanceof Number) {
+ field.set(container, ((Number) value).intValue());
} else {
field.set(container, value);
}
return true;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
return false;
}
@@ -68,15 +67,15 @@ public class ConfigProcessor {
public static LinkedHashMap<String, ProcessedCategory> create(Config config) {
LinkedHashMap<String, ProcessedCategory> processedConfig = new LinkedHashMap<>();
- for(Field categoryField : config.getClass().getDeclaredFields()) {
+ for (Field categoryField : config.getClass().getDeclaredFields()) {
boolean exposePresent = categoryField.isAnnotationPresent(Expose.class);
boolean categoryPresent = categoryField.isAnnotationPresent(Category.class);
- if(exposePresent && categoryPresent) {
+ if (exposePresent && categoryPresent) {
Object categoryObj;
try {
categoryObj = categoryField.get(config);
- } catch(Exception e) {
+ } catch (Exception e) {
//System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName());
continue;
}
@@ -88,10 +87,10 @@ public class ConfigProcessor {
);
processedConfig.put(categoryField.getName(), cat);
- for(Field optionField : categoryObj.getClass().getDeclaredFields()) {
+ for (Field optionField : categoryObj.getClass().getDeclaredFields()) {
boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class);
- if(optionPresent) {
+ if (optionPresent) {
ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class);
ProcessedOption option = new ProcessedOption(
optionAnnotation.name(),
@@ -100,70 +99,70 @@ public class ConfigProcessor {
optionField,
categoryObj
);
- if(optionField.isAnnotationPresent(ConfigAccordionId.class)) {
+ 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) &&
+ if (optionType.isAssignableFrom(int.class) &&
optionField.isAnnotationPresent(ConfigEditorKeybind.class)) {
ConfigEditorKeybind configEditorAnnotation = optionField.getAnnotation(ConfigEditorKeybind.class);
- editor = new GuiOptionEditorKeybind(option, (int)option.get(), configEditorAnnotation.defaultKey());
+ editor = new GuiOptionEditorKeybind(option, (int) option.get(), configEditorAnnotation.defaultKey());
}
- if(optionField.isAnnotationPresent(ConfigEditorButton.class)) {
+ 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) &&
+ if (optionType.isAssignableFrom(boolean.class) &&
optionField.isAnnotationPresent(ConfigEditorBoolean.class)) {
editor = new GuiOptionEditorBoolean(option);
}
- if(optionType.isAssignableFrom(boolean.class) &&
+ 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)) {
+ 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);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int) option.get(), true);
}
}
- if(optionType.isAssignableFrom(List.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) {
+ 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)) {
+ 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)) {
+ } else if (optionField.isAnnotationPresent(ConfigEditorColour.class)) {
editor = new GuiOptionEditorColour(option);
- } else if(optionField.isAnnotationPresent(ConfigEditorText.class)) {
+ } else if (optionField.isAnnotationPresent(ConfigEditorText.class)) {
editor = new GuiOptionEditorText(option);
}
}
- if(optionType.isAssignableFrom(int.class) ||
+ if (optionType.isAssignableFrom(int.class) ||
optionType.isAssignableFrom(float.class) ||
optionType.isAssignableFrom(double.class)) {
- if(optionField.isAnnotationPresent(ConfigEditorSlider.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)) {
+ if (optionType.isAssignableFrom(String.class)) {
+ if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) {
ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class);
- editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0,false);
+ editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0, false);
}
}
- if(editor == null) {
+ if (editor == null) {
//System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName());
continue;
}
@@ -171,7 +170,7 @@ public class ConfigProcessor {
cat.options.put(optionField.getName(), option);
}
}
- } else if(exposePresent || categoryPresent) {
+ } else if (exposePresent || categoryPresent) {
//System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName());
}
}
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..cc8e9708 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
@@ -19,18 +19,18 @@ public class GuiElementSlider extends GuiElement {
public int width;
private static final int HEIGHT = 16;
- private float minValue;
- private float maxValue;
- private float minStep;
+ private final float minValue;
+ private final float maxValue;
+ private final float minStep;
private float value;
- private Consumer<Float> setCallback;
+ 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;
+ if (minStep < 0) minStep = 0.01f;
this.x = x;
this.y = y;
@@ -52,62 +52,62 @@ public class GuiElementSlider extends GuiElement {
int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
float value = this.value;
- if(clicked) {
- value = (mouseX-x)*(maxValue-minValue)/width+minValue;
+ if (clicked) {
+ value = (mouseX - x) * (maxValue - minValue) / width + minValue;
value = Math.max(minValue, Math.min(maxValue, value));
- value = Math.round(value/minStep)*minStep;
+ value = Math.round(value / minStep) * minStep;
}
- float sliderAmount = Math.max(0, Math.min(1, (value-minValue)/(maxValue-minValue)));
- int sliderAmountI = (int)(width*sliderAmount);
+ 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);
+ Utils.drawTexturedRect(x + width - 4, y, 4, HEIGHT, GL11.GL_NEAREST);
- if(sliderAmountI > 5) {
+ if (sliderAmountI > 5) {
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_on_segment);
- Utils.drawTexturedRect(x+4, y, sliderAmountI-4, HEIGHT, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x + 4, y, sliderAmountI - 4, HEIGHT, GL11.GL_NEAREST);
}
- if(sliderAmountI < width-5) {
+ if (sliderAmountI < width - 5) {
Minecraft.getMinecraft().getTextureManager().bindTexture(slider_off_segment);
- Utils.drawTexturedRect(x+sliderAmountI, y, width-4-sliderAmountI, HEIGHT, GL11.GL_NEAREST);
+ 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);
+ 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);
+ Utils.drawTexturedRect(x + sliderAmountI - 4, y, 8, HEIGHT, GL11.GL_NEAREST);
}
@Override
public boolean mouseInput(int mouseX, int mouseY) {
- if(!Mouse.isButtonDown(0)) {
+ 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;
+ 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);
+ 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;
+ 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;
+ value = Math.round(value / minStep) * minStep;
setCallback.accept(value);
return true;
}
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..6e3ad7d1 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
@@ -25,14 +25,15 @@ public class MiscUtils {
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()) {
+ while (ze != null) {
+ if (!ze.isDirectory()) {
String fileName = ze.getName();
File newFile = new File(dest, fileName);
//create directories for sub directories in zip
@@ -57,8 +58,8 @@ public class MiscUtils {
}
public static void recursiveDelete(File file) {
- if(file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
- for(File child : file.listFiles()) {
+ if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
+ for (File child : file.listFiles()) {
recursiveDelete(child);
}
}
@@ -68,15 +69,17 @@ public class MiscUtils {
private static String currentCursor = null;
public static void resetCursor() {
- if(currentCursor == null) {
+ if (currentCursor == null) {
return;
}
currentCursor = null;
- try { Mouse.setNativeCursor(null); } catch(Exception ignored) {}
+ try {
+ Mouse.setNativeCursor(null);
+ } catch (Exception ignored) {}
}
public static void setCursor(ResourceLocation loc, int hotspotX, int hotspotY) {
- if(currentCursor != null && loc.getResourcePath().equals(currentCursor)) {
+ if (currentCursor != null && loc.getResourcePath().equals(currentCursor)) {
return;
}
currentCursor = loc.getResourcePath();
@@ -84,20 +87,20 @@ public class MiscUtils {
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()) {
+ 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.put(image.getRGB(cursorX, image.getHeight() - 1 - cursorY));
}
}
buffer.flip();
Mouse.setNativeCursor(new Cursor(maxSize, maxSize, hotspotX, hotspotY, 1,
buffer, null));
- } catch(Exception e) {
+ } 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..66458e2f 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
@@ -6,5 +6,4 @@ public class Splitters {
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..80308938 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
@@ -22,13 +22,13 @@ public class StringUtils {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
String trim = fr.trimStringToWidth(str, len);
- if(str.length() != trim.length() && !trim.endsWith(" ")) {
+ if (str.length() != trim.length() && !trim.endsWith(" ")) {
char next = str.charAt(trim.length());
- if(next != ' ') {
+ if (next != ' ') {
String[] split = trim.split(" ");
- String last = split[split.length-1];
- if(last.length() < 8) {
- trim = trim.substring(0, trim.length()-last.length());
+ String last = split[split.length - 1];
+ if (last.length() < 8) {
+ trim = trim.substring(0, trim.length() - last.length());
}
}
}
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..46d00293 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
@@ -7,20 +7,20 @@ public class LerpUtils {
}
public static float sigmoid(float val) {
- return (float)(1/(1 + Math.exp(-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);
+ 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;
+ 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..afd805f6 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
@@ -4,7 +4,7 @@ public class LerpingFloat {
private int timeSpent;
private long lastMillis;
- private int timeToReachTarget;
+ private final int timeToReachTarget;
private float targetValue;
private float lerpValue;
@@ -22,23 +22,23 @@ public class LerpingFloat {
int lastTimeSpent = timeSpent;
this.timeSpent += System.currentTimeMillis() - lastMillis;
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
- float startValue = lerpValue - (targetValue - lerpValue)/fac;
+ float startValue = lerpValue - (targetValue - lerpValue) / fac;
float dist = targetValue - startValue;
- if(dist == 0) return;
+ if (dist == 0) return;
float oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
+ if (distPercentToTarget >= 1) {
lerpValue = targetValue;
} else {
- lerpValue = startValue + dist*distPercentToTarget;
+ lerpValue = startValue + dist * distPercentToTarget;
}
- if(lerpValue == oldLerpValue) {
+ if (lerpValue == oldLerpValue) {
timeSpent = lastTimeSpent;
} else {
this.lastMillis = System.currentTimeMillis();
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..cfb44029 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
@@ -22,23 +22,23 @@ public class LerpingInteger {
int lastTimeSpent = timeSpent;
this.timeSpent += System.currentTimeMillis() - lastMillis;
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
- int startValue = lerpValue - (int)((targetValue - lerpValue)/fac);
+ int startValue = lerpValue - (int) ((targetValue - lerpValue) / fac);
int dist = targetValue - startValue;
- if(dist == 0) return;
+ if (dist == 0) return;
int oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
+ if (distPercentToTarget >= 1) {
lerpValue = targetValue;
} else {
- lerpValue = startValue + (int)(dist*distPercentToTarget);
+ lerpValue = startValue + (int) (dist * distPercentToTarget);
}
- if(lerpValue == oldLerpValue) {
+ if (lerpValue == oldLerpValue) {
timeSpent = lastTimeSpent;
} else {
this.lastMillis = System.currentTimeMillis();
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..6d847928 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
@@ -27,7 +27,7 @@ public class RenderUtils {
public static void drawFloatingRectDark(int x, int y, int width, int height, boolean shadow) {
int alpha = 0xf0000000;
- if(OpenGlHelper.isFramebufferEnabled()) {
+ if (OpenGlHelper.isFramebufferEnabled()) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
BackgroundBlur.renderBlurredBackground(15, scaledResolution.getScaledWidth(),
scaledResolution.getScaledHeight(), x, y, width, height, true);
@@ -38,14 +38,14 @@ public class RenderUtils {
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
+ 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
}
}
@@ -57,27 +57,27 @@ public class RenderUtils {
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
+ 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);
+ 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);
+ 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);
+ 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) {
@@ -99,13 +99,13 @@ public class RenderUtils {
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
worldrenderer
- .pos(x, y+height, 0.0D)
+ .pos(x, y + height, 0.0D)
.tex(uMin, vMax).endVertex();
worldrenderer
- .pos(x+width, y+height, 0.0D)
+ .pos(x + width, y + height, 0.0D)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x+width, y, 0.0D)
+ .pos(x + width, y, 0.0D)
.tex(uMax, vMin).endVertex();
worldrenderer
.pos(x, y, 0.0D)
@@ -117,14 +117,14 @@ public class RenderUtils {
}
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;
+ 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();
@@ -150,7 +150,7 @@ public class RenderUtils {
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) {
+ float partialTicks, Boolean disableDepth) {
int height = 300;
int bottomOffset = 0;
int topOffset = bottomOffset + height;
@@ -172,8 +172,8 @@ public class RenderUtils {
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));
+ 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;
@@ -188,24 +188,24 @@ public class RenderUtils {
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;
+ 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 + 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 + 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 + 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 + 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();
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, 1.0F * alphaMult).endVertex();
tessellator.draw();
GlStateManager.disableCull();
@@ -213,22 +213,22 @@ public class RenderUtils {
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 + 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 + 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.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.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();
+ 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();
@@ -239,7 +239,7 @@ public class RenderUtils {
}
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);
+ AxisAlignedBB bb = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
GlStateManager.disableDepth();
GlStateManager.disableCull();
@@ -256,7 +256,7 @@ public class RenderUtils {
double viewerZ;
Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(aoteInterpPos != null) {
+ if (aoteInterpPos != null) {
viewerX = aoteInterpPos.x;
viewerY = aoteInterpPos.y;
viewerZ = aoteInterpPos.z;
@@ -271,13 +271,9 @@ public class RenderUtils {
double y = block.getY() - viewerY;
double z = block.getZ() - viewerZ;
- double distSq = x*x + y*y + z*z;
+ 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);
- }
+ RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, distSq > 10 * 10);
}
public static void renderBeaconBeamOrBoundingBox(BlockPos block, int rgb, float alphaMult, float partialTicks) {
@@ -286,7 +282,7 @@ public class RenderUtils {
double viewerZ;
Vector3f aoteInterpPos = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(aoteInterpPos != null) {
+ if (aoteInterpPos != null) {
viewerX = aoteInterpPos.x;
viewerY = aoteInterpPos.y;
viewerZ = aoteInterpPos.z;
@@ -301,9 +297,9 @@ public class RenderUtils {
double y = block.getY() - viewerY;
double z = block.getZ() - viewerZ;
- double distSq = x*x + y*y + z*z;
+ double distSq = x * x + y * y + z * z;
- if(distSq > 10*10) {
+ if (distSq > 10 * 10) {
RenderUtils.renderBeaconBeam(x, y, z, rgb, 1.0f, partialTicks, true);
} else {
RenderUtils.renderBoundingBox(x, y, z, rgb, 1.0f, partialTicks);
@@ -324,16 +320,16 @@ public class RenderUtils {
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 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 distSq = x * x + y * y + z * z;
double dist = Math.sqrt(distSq);
- if(distSq > 144) {
- x *= 12/dist;
- y *= 12/dist;
- z *= 12/dist;
+ if (distSq > 144) {
+ x *= 12 / dist;
+ y *= 12 / dist;
+ z *= 12 / dist;
}
GlStateManager.translate(x, y, z);
GlStateManager.translate(0, viewer.getEyeHeight(), 0);
@@ -346,7 +342,7 @@ public class RenderUtils {
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");
+ renderNametag(EnumChatFormatting.YELLOW.toString() + Math.round(dist) + "m");
GlStateManager.popMatrix();
@@ -374,10 +370,10 @@ public class RenderUtils {
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();
+ 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);
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..9a3ac351 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
@@ -15,7 +15,7 @@ import java.util.List;
public class TextRenderUtils {
public static int getCharVertLen(char c) {
- if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
return 5;
} else {
return 7;
@@ -25,9 +25,9 @@ public class TextRenderUtils {
public static float getVerticalHeight(String str) {
str = StringUtils.cleanColour(str);
float height = 0;
- for(int i=0; i<str.length(); i++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
- int charHeight = getCharVertLen(c);
+ int charHeight = getCharVertLen(c);
height += charHeight + 1.5f;
}
return height;
@@ -36,12 +36,12 @@ public class TextRenderUtils {
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++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
- int charHeight = getCharVertLen(c);
+ int charHeight = getCharVertLen(c);
int charWidth = fr.getCharWidth(c);
- fr.drawString(format+c, x+(5-charWidth)/2f, y-7+charHeight, colour, shadow);
+ fr.drawString(format + c, x + (5 - charWidth) / 2f, y - 7 + charHeight, colour, shadow);
y += charHeight + 1.5f;
}
@@ -49,7 +49,7 @@ public class TextRenderUtils {
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;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
drawStringScaled(str, fr, x, y, shadow, colour, factor);
@@ -58,8 +58,8 @@ public class TextRenderUtils {
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;
+ float x2 = x - strLen / 2f;
+ float y2 = y - fr.FONT_HEIGHT / 2f;
GL11.glTranslatef(x2, y2, 0);
fr.drawString(str, 0, 0, colour, shadow);
@@ -68,19 +68,19 @@ public class TextRenderUtils {
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);
+ 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;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
int newLen = Math.min(strLen, len);
- float fontHeight = 8*factor;
+ float fontHeight = 8 * factor;
- drawStringScaled(str, fr, x-newLen/2, y-fontHeight/2, shadow, colour, 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) {
@@ -96,7 +96,7 @@ public class TextRenderUtils {
}
FontRenderer font = stack.getItem().getFontRenderer(stack);
- drawHoveringText(list, mouseX, mouseY, screenWidth, screenHeight, -1, font == null ? fontStd : font);
+ 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) {
@@ -139,7 +139,7 @@ public class TextRenderUtils {
if (needsWrap) {
int wrappedTooltipWidth = 0;
- List<String> wrappedTextLines = new ArrayList<String>();
+ 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);
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..d1344150 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;
@@ -42,11 +32,11 @@ public class CapeManager {
public long lastCapeSynced = 0;
public Pair<NEUCape, String> localCape = null;
- private HashMap<String, Pair<NEUCape, String>> capeMap = new HashMap<>();
+ private final HashMap<String, Pair<NEUCape, String>> capeMap = new HashMap<>();
private int permSyncTries = 5;
private boolean allAvailable = false;
- private HashSet<String> availableCapes = new HashSet<>();
+ private final HashSet<String> availableCapes = new HashSet<>();
public JsonObject lastJsonSync = null;
@@ -114,7 +104,6 @@ public class CapeManager {
new CapeData("tunnel", false, false),
new CapeData("planets", false, false)
-
};
/*private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee",
@@ -129,8 +118,8 @@ public class CapeManager {
}
public void tryUnlockCape(String unlock) {
- for(CapeData data : capes) {
- if(data.capeName.equalsIgnoreCase(unlock)) {
+ for (CapeData data : capes) {
+ if (data.capeName.equalsIgnoreCase(unlock)) {
data.hidden = false;
}
}
@@ -138,7 +127,7 @@ public class CapeManager {
public void tick() {
long currentTime = System.currentTimeMillis();
- if(currentTime - lastCapeUpdate > 60*1000) {
+ if (currentTime - lastCapeUpdate > 60 * 1000) {
lastCapeUpdate = currentTime;
updateCapes();
}
@@ -147,38 +136,36 @@ public class CapeManager {
private void updateCapes() {
NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("activecapes.json", (jsonObject) -> {
- if(jsonObject.get("success").getAsBoolean()) {
+ if (jsonObject.get("success").getAsBoolean()) {
lastJsonSync = jsonObject;
lastCapeSynced = System.currentTimeMillis();
capeMap.clear();
- for(JsonElement active : jsonObject.get("active").getAsJsonArray()) {
- if(active.isJsonObject()) {
+ 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");
- });
+ }, () -> System.out.println("[MBAPI] Update capes errored"));
- if(Minecraft.getMinecraft().thePlayer != null && permSyncTries > 0) {
+ 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()) {
+ if (jsonObject.get("success").getAsBoolean()) {
permSyncTries = 0;
availableCapes.clear();
- for(JsonElement permPlayer : jsonObject.get("perms").getAsJsonArray()) {
- if(permPlayer.isJsonObject()) {
+ 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()) {
+ if (playerUuid != null && playerUuid.equals(uuid)) {
+ for (JsonElement perm : permPlayer.getAsJsonObject().get("perms").getAsJsonArray()) {
+ if (perm.isJsonPrimitive()) {
String cape = perm.getAsString();
- if(cape.equals("*")) {
+ if (cape.equals("*")) {
allAvailable = true;
} else {
availableCapes.add(cape);
@@ -190,9 +177,7 @@ public class CapeManager {
}
}
}
- }, () -> {
- System.out.println("[MBAPI] Update capes errored - perms");
- });
+ }, () -> System.out.println("[MBAPI] Update capes errored - perms"));
}
}
@@ -204,30 +189,30 @@ public class CapeManager {
boolean none = capename == null || capename.equals("null");
updateConfig = updateConfig && playerUUID.equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
- if(updateConfig) {
+ if (updateConfig) {
NotEnoughUpdates.INSTANCE.config.hidden.selectedCape = String.valueOf(capename);
}
- if(updateConfig) {
- if(none) {
+ if (updateConfig) {
+ if (none) {
localCape = null;
} else {
localCape = new MutablePair<>(new NEUCape(capename), capename);
}
- } else if(capeMap.containsKey(playerUUID)) {
- if(none) {
+ } else if (capeMap.containsKey(playerUUID)) {
+ if (none) {
capeMap.remove(playerUUID);
} else {
Pair<NEUCape, String> capePair = capeMap.get(playerUUID);
capePair.setValue(capename);
}
- } else if(!none) {
+ } else if (!none) {
capeMap.put(playerUUID, new MutablePair<>(new NEUCape(capename), capename));
}
}
public String getCape(String player) {
- if(capeMap.containsKey(player)) {
+ if (capeMap.containsKey(player)) {
return capeMap.get(player).getRight();
}
return null;
@@ -236,18 +221,18 @@ public class CapeManager {
private static BiMap<String, EntityPlayer> playerMap = null;
public EntityPlayer getPlayerForUUID(String uuid) {
- if(playerMap == null) {
+ if (playerMap == null) {
return null;
}
- if(playerMap.containsKey(uuid)) {
+ 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) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
framebuffer = new Framebuffer(width, height, true);
} else {
framebuffer.createBindFramebuffer(width, height);
@@ -266,7 +251,7 @@ public class CapeManager {
backgroundFramebuffer = checkFramebufferSizes(backgroundFramebuffer,
width, height);
- if(OpenGlHelper.isFramebufferEnabled() && updateWorldFramebuffer) {
+ 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,
@@ -281,47 +266,48 @@ public class CapeManager {
@SubscribeEvent
public void onWorldLoad(WorldEvent.Unload event) {
- if(playerMap != null) playerMap.clear();
+ if (playerMap != null) playerMap.clear();
}
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Post e) {
- if(e.partialRenderTick == 1.0F) return; //rendering in inventory
+ 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)) {
+ if (Minecraft.getMinecraft().thePlayer != null && uuid.equals(clientUuid)) {
String selCape = NotEnoughUpdates.INSTANCE.config.hidden.selectedCape;
- if(selCape != null && !selCape.isEmpty()) {
- if(localCape == null) {
+ 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")) {
+ 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)) {
+ } else if (!Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.blindness) && capeMap.containsKey(uuid)) {
capeMap.get(uuid).getLeft().onRenderPlayer(e);
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {
+ }
}
public static void onTickSlow() {
- if(Minecraft.getMinecraft().theWorld == null) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
- if(playerMap == null) {
+ if (playerMap == null) {
playerMap = HashBiMap.create(Minecraft.getMinecraft().theWorld.playerEntities.size());
}
playerMap.clear();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
String uuid = player.getUniqueID().toString().replace("-", "");
try {
playerMap.put(uuid, player);
- } catch(IllegalArgumentException ignored){}
+ } catch (IllegalArgumentException ignored) {}
}
}
@@ -330,14 +316,14 @@ public class CapeManager {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.END) return;
- if(Minecraft.getMinecraft().theWorld == null) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
- if(playerMap == null) {
+ if (playerMap == null) {
return;
}
String clientUuid = null;
- if(Minecraft.getMinecraft().thePlayer != null) {
+ if (Minecraft.getMinecraft().thePlayer != null) {
clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "");
}
@@ -345,37 +331,33 @@ public class CapeManager {
Set<String> toRemove = new HashSet<>();
try {
- for(String playerUUID : capeMap.keySet()) {
+ for (String playerUUID : capeMap.keySet()) {
EntityPlayer player;
- if(playerUUID.equals(clientUuid)) {
+ if (playerUUID.equals(clientUuid)) {
player = Minecraft.getMinecraft().thePlayer;
} else {
player = getPlayerForUUID(playerUUID);
}
- if(player != null) {
+ if (player != null) {
String capeName = capeMap.get(playerUUID).getRight();
- if(capeName != null && !capeName.equals("null")) {
- if(player == Minecraft.getMinecraft().thePlayer && hasLocalCape) {
+ 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);
- });
+ capeTicker.submit(() -> capeMap.get(playerUUID).getLeft().onTick(event, player));
} else {
toRemove.add(playerUUID);
}
}
}
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
- if(hasLocalCape) {
+ if (hasLocalCape) {
localCape.getLeft().setCapeTexture(localCape.getValue());
- capeTicker.submit(() -> {
- localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer);
- });
+ capeTicker.submit(() -> localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer));
}
- for(String playerName : toRemove) {
+ for (String playerName : toRemove) {
capeMap.remove(playerName);
}
}
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..0ab08706 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;
@@ -60,13 +54,13 @@ public class CapeNode {
private List<Vector2f> getConstaints() {
List<Vector2f> constaints = new ArrayList<>();
- for(NEUCape.Direction cardinal : cardinals) {
- for(int i=1; i<=2; i++) {
+ 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) {
+ 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)));
+ constaints.add(new Vector2f(iOffset, i * NEUCape.targetDist * (cardinal.yOff == 0 ? horzDistMult : vertDistMult)));
}
}
@@ -78,8 +72,8 @@ public class CapeNode {
loadVec3IntoBuffer(buffer, position);
List<Vector2f> containts = getConstaints();
buffer.put(containts.size());
- for(int i=0; i<8; i++) {
- if(i < containts.size()) {
+ for (int i = 0; i < 8; i++) {
+ if (i < containts.size()) {
loadVec2IntoBuffer(buffer, containts.get(i));
} else {
loadVec2IntoBuffer(buffer, new Vector2f());
@@ -89,7 +83,7 @@ public class CapeNode {
public void readFromBuffer(FloatBuffer buffer) {
readVec3FromBuffer(buffer, position);
- buffer.position(buffer.position()+17);
+ buffer.position(buffer.position() + 17);
}
private void readVec3FromBuffer(FloatBuffer buffer, Vector3f vec) {
@@ -110,8 +104,8 @@ public class CapeNode {
}
public void update() {
- if(!fixed) {
- velocity.y -= gravity * (resistance)/(1-resistance);
+ if (!fixed) {
+ velocity.y -= gravity * (resistance) / (1 - resistance);
float actualResistance = resistance;
/*BlockPos pos = new BlockPos(
@@ -123,7 +117,7 @@ public class CapeNode {
actualResistance = 0.8f;
}*/
- velocity.scale(1-actualResistance);
+ velocity.scale(1 - actualResistance);
Vector3f.add(position, velocity, position);
}
@@ -168,28 +162,28 @@ public class CapeNode {
double dY = position.y - other.position.y;
double dZ = position.z - other.position.z;
- double distSq = dX*dX + dY*dY + dZ*dZ;
+ double distSq = dX * dX + dY * dY + dZ * dZ;
- double factor = (distSq - targetDist*targetDist)/(40*distSq)*strength;
+ double factor = (distSq - targetDist * targetDist) / (40 * distSq) * strength;
factor = Math.max(-0.5f, factor);
dX *= factor;
dY *= factor;
dZ *= factor;
- if(fixed || other.fixed) {
+ if (fixed || other.fixed) {
dX *= 2;
dY *= 2;
dZ *= 2;
}
- if(!fixed) {
+ if (!fixed) {
position.x -= dX;
position.y -= dY;
position.z -= dZ;
}
- if(!other.fixed) {
+ if (!other.fixed) {
other.position.x += dX;
other.position.y += dY;
other.position.z += dZ;
@@ -197,46 +191,46 @@ public class CapeNode {
}
public void resolveStruct(float horzDistMult, boolean opt) {
- for(NEUCape.Direction cardinal : cardinals) {
+ 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);
+ 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}) {
+ 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);
+ 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) {
+ 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);
+ 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;
+ if (normal != null) return normal;
normal = new Vector3f();
- for(int i=0; i<cardinals.length; i++) {
+ for (int i = 0; i < cardinals.length; i++) {
NEUCape.Direction dir1 = cardinals[i];
- NEUCape.Direction dir2 = cardinals[(i+1)%cardinals.length];
+ 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;
+ if (node1 == null || node2 == null) continue;
Vector3f toCapeNode1 = Vector3f.sub(node1.renderPosition, renderPosition, null);
Vector3f toCapeNode2 = Vector3f.sub(node2.renderPosition, renderPosition, null);
@@ -244,31 +238,31 @@ public class CapeNode {
Vector3f.add(normal, cross.normalise(null), normal);
}
float l = normal.length();
- if(l != 0) {
- normal.scale(1f/l);
+ if (l != 0) {
+ normal.scale(1f / l);
}
return normal;
}
public Vector3f sideNormal() {
- if(sideNormal != null) return 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) {
+ for (NEUCape.Direction cardinal : cardinals) {
CapeNode nodeCardinal = getNeighbor(new NEUCape.Offset(cardinal, 1));
- if(nodeCardinal == null) {
+ 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) {
+ 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) {
+ 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);
@@ -276,8 +270,8 @@ public class CapeNode {
}
}
float l = sideNormal.length();
- if(l != 0) {
- sideNormal.scale(0.05f/l);
+ if (l != 0) {
+ sideNormal.scale(0.05f / l);
}
return sideNormal;
}
@@ -296,25 +290,25 @@ public class CapeNode {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- if(nodeDown != null && nodeRight != null && nodeDownRight != null) {
+ if (nodeDown != null && nodeRight != null && nodeDownRight != null) {
//Back
- if((mask & DRAW_MASK_BACK) != 0) {
+ 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}) {
+ 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)
+ .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) {
+ 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}) {
+ 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)
+ 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();
}
@@ -322,16 +316,16 @@ public class CapeNode {
}
}
- if((mask & DRAW_MASK_SIDES) != 0) {
- if(nodeLeft == null || nodeRight == null) {
+ if ((mask & DRAW_MASK_SIDES) != 0) {
+ if (nodeLeft == null || nodeRight == null) {
//Render left/right edge
- if(nodeDown != null) {
+ if (nodeDown != null) {
renderEdge(nodeDown, true);
}
}
- if(nodeUp == null || nodeDown == null) {
+ if (nodeUp == null || nodeDown == null) {
//Render up/down edge
- if(nodeRight != null) {
+ if (nodeRight != null) {
renderEdge(nodeRight, false);
}
}
@@ -355,15 +349,15 @@ public class CapeNode {
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)
+ .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)
+ .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)
+ 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)
+ 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();
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..7f55f2db 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,8 +25,10 @@ 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 {
@@ -37,7 +37,7 @@ public class GuiCosmetics extends GuiScreen {
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 final GuiElementTextField unlockTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
private CosmeticsPage currentPage = CosmeticsPage.CAPES;
private int sizeX;
@@ -50,14 +50,12 @@ public class GuiCosmetics extends GuiScreen {
private List<String> cosmeticsInfoTooltip = null;
-
-
- public GuiCosmetics(){
+ 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());
+ if (cosmeticHelpTextElement.isJsonArray()) {
+ cosmeticsInfoTooltip = gson.fromJson(cosmeticHelpTextElement, new TypeToken<List<String>>() {}.getType());
}
}
@@ -76,14 +74,14 @@ public class GuiCosmetics extends GuiScreen {
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;
+ 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);
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + 2, sizeX - 4, sizeY - 4);
GlStateManager.enableDepth();
GlStateManager.translate(0, 0, 5);
@@ -111,9 +109,9 @@ public class GuiCosmetics extends GuiScreen {
drawCapesPage(mouseX, mouseY, partialTicks);
break;
}
- int helpX = guiLeft+sizeX-20;
- if(mouseX >= helpX && mouseX <= helpX+20 && mouseY >= guiTop-20 && mouseY <= guiTop) {
- if(cosmeticsInfoTooltip != null) {
+ 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);
@@ -124,75 +122,66 @@ public class GuiCosmetics extends GuiScreen {
}
StringBuilder statusMsg = new StringBuilder("Last Sync: ");
- if(CapeManager.INSTANCE.lastCapeSynced == 0) {
+ if (CapeManager.INSTANCE.lastCapeSynced == 0) {
statusMsg.append("Not Synced");
} else {
- statusMsg.append((System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeSynced)/1000).append("s ago");
+ statusMsg.append((System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeSynced) / 1000).append("s ago");
}
statusMsg.append(" - Next Sync: ");
- if(CapeManager.INSTANCE.lastCapeUpdate == 0) {
+ if (CapeManager.INSTANCE.lastCapeUpdate == 0) {
statusMsg.append("ASAP");
} else {
- statusMsg.append(60 - (System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeUpdate)/1000).append("s");
+ 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);
+ 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) {
+ 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);
+ 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) {
+ 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";
- }
+ }
+ 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);
+ guiLeft + sizeX / 2f, guiTop + sizeY + 5 + 10, false, 90, 0);
}
- if(unlockTextField.getFocus() || !unlockTextField.getText().isEmpty()) {
+ 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);
-
-
-
+ 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);
-
-
-
+ 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++) {
+ for (int i = 0; i < CosmeticsPage.values().length; i++) {
CosmeticsPage page = CosmeticsPage.values()[i];
- if(page.stack == null) {
+ if (page.stack == null) {
ignoredTabs++;
continue;
}
boolean pressed = page == currentPage;
- if(pressed == renderPressed) {
- renderTab(page.stack, i-ignoredTabs, pressed);
+ if (pressed == renderPressed) {
+ renderTab(page.stack, i - ignoredTabs, pressed);
}
}
}
@@ -204,25 +193,25 @@ public class GuiCosmetics extends GuiScreen {
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
- int x = guiLeft+xIndex*28;
- int y = guiTop-28;
+ 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;
+ 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);
+ renderBlurredBackground(width, height, x + 2, y + 2, 28 - 4, 28 - 4);
} else {
- renderBlurredBackground(width, height, x+2, y+4, 28-4, 28-4);
+ renderBlurredBackground(width, height, x + 2, y + 4, 28 - 4, 28 - 4);
}
GlStateManager.disableLighting();
@@ -232,16 +221,16 @@ public class GuiCosmetics extends GuiScreen {
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);
+ Utils.drawTexturedRect(x, y, 28, pressed ? 32 : 31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
GlStateManager.enableDepth();
- Utils.drawItemStack(stack, x+6, y+9);
+ 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) {
+ if (unlockTextField.getFocus()) {
+ if (keyCode == Keyboard.KEY_ESCAPE || keyCode == Keyboard.KEY_RETURN) {
CapeManager.INSTANCE.tryUnlockCape(unlockTextField.getText().trim());
unlockTextField.setText("");
unlockTextField.setFocus(false);
@@ -257,8 +246,8 @@ public class GuiCosmetics extends GuiScreen {
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) {
+ if (mouseX > guiLeft + sizeX - 140 & mouseX < guiLeft + sizeX &&
+ mouseY > guiTop + sizeY && mouseY < guiTop + sizeY + 22) {
unlockTextField.mouseClicked(mouseX, mouseY, mouseButton);
}
@@ -275,39 +264,39 @@ public class GuiCosmetics extends GuiScreen {
}
}
}
- 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);
+ 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()) {
+ 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);
+ 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()) {
+ for (CapeManager.CapeData cape : CapeManager.INSTANCE.getCapes()) {
boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape.capeName);
- if(!cape.canShow() && !equipable) continue;
+ 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)) {
+ 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 {
@@ -316,8 +305,8 @@ public class GuiCosmetics extends GuiScreen {
}
return;
- } else if(equipable && mouseY > guiTop + 149 && mouseY < guiTop + 149 + 20) {
- if(cape.capeName.equals(wantToEquipCape)) {
+ } else if (equipable && mouseY > guiTop + 149 && mouseY < guiTop + 149 + 20) {
+ if (cape.capeName.equals(wantToEquipCape)) {
wantToEquipCape = null;
} else {
wantToEquipCape = cape.capeName;
@@ -329,13 +318,13 @@ public class GuiCosmetics extends GuiScreen {
displayIndex++;
}
- if(currentPage == CosmeticsPage.CAPES) {
+ 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);
+ 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) {
+ 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);
@@ -343,7 +332,7 @@ public class GuiCosmetics extends GuiScreen {
try {
String userName = Minecraft.getMinecraft().thePlayer.getName();
- String accessToken = Minecraft.getMinecraft().getSession().getToken();
+ String accessToken = Minecraft.getMinecraft().getSession().getToken();
Random r1 = new Random();
Random r2 = new Random(System.identityHashCode(new Object()));
BigInteger random1Bi = new BigInteger(128, r1);
@@ -352,23 +341,18 @@ public class GuiCosmetics extends GuiScreen {
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");
- });
+ 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, (jsonObject) -> { System.out.println(jsonObject); }, () -> {
- System.out.println("Change cape error");
- });
+ 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) {
+ } catch (Exception e) {
System.out.println("Exception while generating mojang shared secret");
e.printStackTrace();
}
-
}
}
}
@@ -386,96 +370,97 @@ public class GuiCosmetics extends GuiScreen {
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- if(scrollClickedX >= 0) {
+ if (scrollClickedX >= 0) {
float scrollStartX = mouseX - scrollClickedX;
- scroll = (scrollStartX-(guiLeft+15))/371f;
+ scroll = (scrollStartX - (guiLeft + 15)) / 371f;
scroll = Math.max(0, Math.min(1, scroll));
}
}
- private HashMap<String, ResourceLocation> capesLocation = new HashMap<>();
+ 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);
+ 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);
+ 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()) {
+ 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);
+ 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()) {
+ 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.canShow() && !equipable) continue;
- if(capeData.capeName.equals(CapeManager.INSTANCE.getCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")))) {
+ 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)) {
+ } 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,
+ } 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);
+ 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);
+ 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);
+ 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) {
+ 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());
+ 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());
+ 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"));
+ 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);
+ 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.glScissor(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
@@ -489,15 +474,15 @@ public class GuiCosmetics extends GuiScreen {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
@@ -513,49 +498,50 @@ public class GuiCosmetics extends GuiScreen {
* 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) {
+ if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputVert == null) {
+ if (blurOutputVert == null) {
blurOutputVert = new Framebuffer(width, height, false);
blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ 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) {
+ if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
blurOutputVert.createBindFramebuffer(width, height);
blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- if(blurShaderHorz == null) {
+ 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) { }
+ } catch (Exception ignored) {}
}
- if(blurShaderVert == null) {
+ 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) { }
+ } 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);
+ 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();
@@ -573,10 +559,10 @@ public class GuiCosmetics extends GuiScreen {
* 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;
+ 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);
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..2142f1e8 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,8 +24,6 @@ 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 {
@@ -48,21 +35,21 @@ public class NEUCape {
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 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 Random random = new Random();
+ private final 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;
+ 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;
@@ -79,20 +66,20 @@ public class NEUCape {
}
public void setCapeTexture(String capeName) {
- if(this.capeName != null && this.capeName.equalsIgnoreCase(capeName)) return;
+ 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")){
+ if (NotEnoughUpdates.INSTANCE.config.hidden.disableBrokenCapes) {
+ if (capeName.equals("negative")) {
defaultBehaviour = false;
this.capeName = "fade";
this.shaderName = "fade_cape";
}
-
+
}
- if(defaultBehaviour){
+ if (defaultBehaviour) {
this.capeName = capeName;
if (capeName.equalsIgnoreCase("fade")) {
@@ -101,7 +88,7 @@ public class NEUCape {
shaderName = "space_cape";
} else if (capeName.equalsIgnoreCase("mcworld")) {
shaderName = "mcworld_cape";
- } else if(capeName.equalsIgnoreCase("lava") || capeName.equalsIgnoreCase("skyclient")) {
+ } else if (capeName.equalsIgnoreCase("lava") || capeName.equalsIgnoreCase("skyclient")) {
shaderName = "lava_cape";
} else if (capeName.equalsIgnoreCase("lightning")) {
shaderName = "lightning_cape";
@@ -126,29 +113,29 @@ public class NEUCape {
}
private void bindTexture() {
- if(capeName.equalsIgnoreCase("negative")) {
+ if (capeName.equalsIgnoreCase("negative")) {
CapeManager.getInstance().updateWorldFramebuffer = true;
- if(CapeManager.getInstance().backgroundFramebuffer != null) {
+ if (CapeManager.getInstance().backgroundFramebuffer != null) {
CapeManager.getInstance().backgroundFramebuffer.bindFramebufferTexture();
}
- } else if(capeTextures != null && capeTextures.length > 0) {
+ } else if (capeTextures != null && capeTextures.length > 0) {
long currentTime = System.currentTimeMillis();
- if(currentTime - lastFrameUpdate > 100) {
+ if (currentTime - lastFrameUpdate > 100) {
lastFrameUpdate = currentTime / 100 * 100;
currentFrame++;
- if(animMode == ANIM_MODE_PINGPONG) {
- if(capeTextures.length == 1) {
+ 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) {
+ if (currentFrame >= capeTextures.length) {
displayFrame = frameCount - displayFrame;
}
}
- } else if(animMode == ANIM_MODE_LOOP) {
+ } else if (animMode == ANIM_MODE_LOOP) {
currentFrame %= capeTextures.length;
displayFrame = currentFrame;
}
@@ -176,11 +163,11 @@ public class NEUCape {
float vMaxSide = 404 / 1024f;
float vMaxCenter = 419 / 1024f;
- for(int i = 0; i < VERT_NODES; i++) {
+ 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++) {
+ 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;
@@ -191,36 +178,36 @@ public class NEUCape {
node.horzDistMult = 2f + 1f * i / (float) (VERT_NODES - 1);
- if(j == 0 || j == HORZ_NODES - 1) {
+ if (j == 0 || j == HORZ_NODES - 1) {
node.horzSideTexU = 406 / 1024f * i / (float) (VERT_NODES - 1);
- if(j == 0) {
+ if (j == 0) {
node.horzSideTexVTop = 1 - 20 / 1024f;
} else {
node.horzSideTexVTop = 1 - 40 / 1024f;
}
}
- if(i == 0) {
+ if (i == 0) {
node.vertSideTexU = 198 / 1024f * j / (float) (HORZ_NODES - 1);
node.vertSideTexVTop = 1 - 60 / 1024f;
- } else if(i == VERT_NODES - 1) {
+ } 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++) {
+ 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++) {
+ 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
+ if (xNeighbor >= 0 && xNeighbor < HORZ_NODES
&& yNeighbor >= 0 && yNeighbor < VERT_NODES) {
CapeNode neighbor = nodes[xNeighbor + yNeighbor * HORZ_NODES];
node.setNeighbor(offset, neighbor);
@@ -232,7 +219,7 @@ public class NEUCape {
}
public void ensureCapeNodesCreated(EntityPlayer player) {
- if(nodes == null) createCapeNodes(player);
+ if (nodes == null) createCapeNodes(player);
}
public enum Direction {
@@ -256,8 +243,8 @@ public class NEUCape {
public Direction rotateRight90() {
int wantXOff = -yOff;
int wantYOff = xOff;
- for(Direction dir : values()) {
- if(dir.xOff == wantXOff && dir.yOff == wantYOff) {
+ for (Direction dir : values()) {
+ if (dir.xOff == wantXOff && dir.yOff == wantYOff) {
return dir;
}
}
@@ -267,8 +254,8 @@ public class NEUCape {
public Direction rotateLeft90() {
int wantXOff = yOff;
int wantYOff = -xOff;
- for(Direction dir : values()) {
- if(dir.xOff == wantXOff && dir.yOff == wantYOff) {
+ for (Direction dir : values()) {
+ if (dir.xOff == wantXOff && dir.yOff == wantYOff) {
return dir;
}
}
@@ -294,7 +281,7 @@ public class NEUCape {
}
public boolean equals(Object obj) {
- if(obj instanceof Offset) {
+ if (obj instanceof Offset) {
Offset other = (Offset) obj;
return other.direction == direction && other.steps == steps;
}
@@ -309,27 +296,27 @@ public class NEUCape {
private void loadShaderUniforms(ShaderManager shaderManager) {
String shaderId = "capes/" + shaderName + "/" + shaderName;
- if(shaderName.equalsIgnoreCase("fade_cape") || shaderName.equalsIgnoreCase("planets")) {
+ if (shaderName.equalsIgnoreCase("fade_cape") || shaderName.equalsIgnoreCase("planets")) {
shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("space_cape")) {
+ } 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")) {
+ } else if (shaderName.equalsIgnoreCase("mcworld_cape")) {
shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("lava_cape")) {
+ } else if (shaderName.equalsIgnoreCase("lava_cape")) {
shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("tunnel")) {
+ } else if (shaderName.equalsIgnoreCase("tunnel")) {
shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
- } else if(shaderName.equalsIgnoreCase("biscuit_cape") || shaderName.equalsIgnoreCase("shiny_cape")) {
+ } 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")) {
+ } else if (shaderName.equalsIgnoreCase("negative")) {
shaderManager.loadData(shaderId, "screensize", new Vector2f(
Minecraft.getMinecraft().displayWidth,
Minecraft.getMinecraft().displayHeight
));
- } else if(shaderName.equalsIgnoreCase("void")) {
+ } else if (shaderName.equalsIgnoreCase("void")) {
shaderManager.loadData(shaderId, "millis", (int) (System.currentTimeMillis() - startTime));
shaderManager.loadData(shaderId, "screensize", new Vector2f(
Minecraft.getMinecraft().displayWidth,
@@ -343,10 +330,10 @@ public class NEUCape {
public void onRenderPlayer(RenderPlayerEvent.Post e) {
EntityPlayer player = e.entityPlayer;
- if(currentPlayer != null && keepCurrentPlayer && currentPlayer != player) return;
+ if (currentPlayer != null && keepCurrentPlayer && currentPlayer != player) return;
- if(player.getActivePotionEffect(Potion.invisibility) != null) return;
- if(player.isSpectator() || player.isInvisible()) return;
+ if (player.getActivePotionEffect(Potion.invisibility) != null) return;
+ if (player.isSpectator() || player.isInvisible()) return;
ensureCapeNodesCreated(player);
@@ -366,7 +353,7 @@ public class NEUCape {
GlStateManager.disableLighting();
GlStateManager.color(1, 1, 1, 1);
- if(shaderName.equals("mcworld_cape")) {
+ 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 {
@@ -397,21 +384,21 @@ public class NEUCape {
}
public void onTick(TickEvent.ClientTickEvent event, EntityPlayer player) {
- if(player == null) return;
- if(Minecraft.getMinecraft().isGamePaused()) return;
+ if (player == null) return;
+ if (Minecraft.getMinecraft().isGamePaused()) return;
- if(System.currentTimeMillis() - lastRender < 500) {
- if(currentPlayer == null || !keepCurrentPlayer) {
+ if (System.currentTimeMillis() - lastRender < 500) {
+ if (currentPlayer == null || !keepCurrentPlayer) {
keepCurrentPlayer = true;
currentPlayer = player;
- } else if(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++) {
+ 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;
@@ -427,11 +414,10 @@ public class NEUCape {
private static double interpolateRotation(float a, float b, float amount) {
double f;
- for(f = b - a; f < -180.0F; f += 360.0F) {
- ;
+ for (f = b - a; f < -180.0F; f += 360.0F) {
}
- while(f >= 180.0F) {
+ while (f >= 180.0F) {
f -= 360.0F;
}
@@ -441,24 +427,24 @@ public class NEUCape {
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()) {
+ 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) {
+ if (wrapped < -85.0F) {
wrapped = -85.0F;
}
- if(wrapped >= 85.0F) {
+ if (wrapped >= 85.0F) {
wrapped = 85.0F;
}
angle = head - wrapped;
- if(wrapped * wrapped > 2500.0F) {
+ if (wrapped * wrapped > 2500.0F) {
angle += wrapped * 0.2F;
}
}
@@ -483,7 +469,7 @@ public class NEUCape {
float totalDZ = 0;
int totalMovements = 0;
- for(int i = 0; i < HORZ_NODES; i++) {
+ 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];
@@ -519,7 +505,7 @@ public class NEUCape {
float xOff = (float) (Math.cos(angle) * shoulderLength);
float zOff = (float) (Math.sin(angle) * shoulderLength);
- for(int i = 0; i < HORZ_NODES; i++) {
+ 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];
@@ -538,16 +524,16 @@ public class NEUCape {
private void updateCape(EntityPlayer player) {
Vector3f capeTranslation = updateFixedCapeNodes(player);
- if(shaderName.equals("space_cape")) {
+ if (shaderName.equals("space_cape")) {
long currentTime = System.currentTimeMillis();
- if(currentTime - startTime > eventMillis - startTime + eventLength) {
+ 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")) {
+ } else if (shaderName.equals("biscuit_cape") || shaderName.equals("shiny_cape")) {
long currentTime = System.currentTimeMillis();
- if(currentTime - startTime > eventMillis - startTime + eventLength) {
+ if (currentTime - startTime > eventMillis - startTime + eventLength) {
eventMillis = currentTime;
eventLength = random.nextFloat() * 3000 + 3000;
}
@@ -555,10 +541,10 @@ public class NEUCape {
double playerAngle = getPlayerRenderAngle(player, 0);
double deltaAngle = playerAngle - oldPlayerAngle;
- if(deltaAngle > Math.PI) {
+ if (deltaAngle > Math.PI) {
deltaAngle = 2 * Math.PI - deltaAngle;
}
- if(deltaAngle < -Math.PI) {
+ if (deltaAngle < -Math.PI) {
deltaAngle = 2 * Math.PI + deltaAngle;
}
deltaAngleAccum *= 0.5f;
@@ -572,17 +558,17 @@ public class NEUCape {
float capeTransLength = capeTranslation.length();
float capeTranslationFactor = 0f;
- if(capeTransLength > 0.5f) {
+ 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++) {
+ 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) {
+ if (!node.fixed) {
node.position.x += lookDirNorm.x * dot;
node.position.y += lookDirNorm.y * dot;
node.position.z += lookDirNorm.z * dot;
@@ -593,23 +579,23 @@ public class NEUCape {
factor = 0.05f;
}
- if(factor > 0) {
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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) {
+ 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++) {
+ 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) {
+ if (!node.fixed) {
node.position.x += capeDX;
node.position.y += capeDY;
node.position.z += capeDZ;
@@ -625,20 +611,20 @@ public class NEUCape {
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++) {
+ 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()) {
+ if (player.isSneaking()) {
crouchTicks++;
float mult = 0.5f;
- if(crouchTicks < 5) {
+ if (crouchTicks < 5) {
mult = 2f;
}
- for(int y = 0; y < 8; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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);
}
}
@@ -647,13 +633,13 @@ public class NEUCape {
}
Vector3f avgPosition = avgFixedPosition();
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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) {
+ if (delta.lengthSquared() > 5 * 5) {
Vector3f norm = delta.normalise(null);
node.position = Vector3f.add(avgPosition, norm, null);
}
@@ -662,15 +648,15 @@ public class NEUCape {
oldPlayerAngle = playerAngle;
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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++) {
+ 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);
}
}
@@ -686,8 +672,8 @@ public class NEUCape {
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++) {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
nodes[x + y * HORZ_NODES].loadIntoBuffer(buff);
}
}
@@ -699,7 +685,7 @@ public class NEUCape {
}
private void resolveAllCompute() {
- if(ssbo == -1) {
+ if (ssbo == -1) {
generateSSBO();
}
loadSBBO();
@@ -714,7 +700,7 @@ public class NEUCape {
GL20.glUseProgram(program);
- for(int i = 0; i < 30; i++) {
+ for (int i = 0; i < 30; i++) {
GL43.glDispatchCompute(VERT_NODES, 1, 1);
GL42.glMemoryBarrier(GL43.GL_SHADER_STORAGE_BARRIER_BIT);
}
@@ -727,8 +713,8 @@ public class NEUCape {
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++) {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
nodes[x + y * HORZ_NODES].readFromBuffer(buff);
}
}
@@ -737,14 +723,14 @@ public class NEUCape {
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++) {
+ 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) {
+ if (num != 0) {
accum.scale(1f / num);
}
return accum;
@@ -753,14 +739,14 @@ public class NEUCape {
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++) {
+ 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) {
+ if (num != 0) {
accum.scale(1f / num);
}
return accum;
@@ -769,16 +755,16 @@ public class NEUCape {
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++) {
+ 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) {
+ if (node.fixed) {
Vector3f.add(accum, node.renderPosition, accum);
numFixed++;
}
}
}
- if(numFixed != 0) {
+ if (numFixed != 0) {
accum.scale(1f / numFixed);
}
return accum;
@@ -787,29 +773,29 @@ public class NEUCape {
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++) {
+ 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) {
+ if (node.fixed) {
Vector3f.add(accum, node.position, accum);
numFixed++;
}
}
}
- if(numFixed != 0) {
+ 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++) {
+ 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())
+ if (!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
Minecraft.getMinecraft().getFramebuffer().enableStencil();
GL11.glEnable(GL11.GL_STENCIL_TEST);
@@ -820,8 +806,8 @@ public class NEUCape {
GlStateManager.enableDepth();
GL11.glColorMask(false, false, false, false);
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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);
}
}
@@ -834,25 +820,25 @@ public class NEUCape {
private Vector3f getPoint(Vector3f point, Vector3f... vectors) {
Vector3f res = new Vector3f(point);
- for(Vector3f vec : vectors) Vector3f.add(res, vec, res);
+ for (Vector3f vec : vectors) Vector3f.add(res, vec, res);
return res;
}
private static void renderVBO(WorldRenderer worldRenderer) {
- if(worldRenderer != null && worldRenderer.getVertexCount() > 0) {
+ 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++) {
+ 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++) {
+ for (int index = 0; index < list.size(); index++) {
VertexFormatElement vertexformatelement = list.get(index);
vertexformatelement.getUsage().postDraw(vertexformat, index, stride, bytebuffer);
}
@@ -862,7 +848,7 @@ public class NEUCape {
private static WorldRenderer sphereVBO = null;
private void renderNodes() {
- if(capeName.equalsIgnoreCase("planets")) {
+ if (capeName.equalsIgnoreCase("planets")) {
renderBackAndDoFrontStencil();
Vector3f pointNorm = avgNormal();
@@ -872,8 +858,8 @@ public class NEUCape {
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();
+ if (sphereVBO == null || Keyboard.isKeyDown(Keyboard.KEY_K)) {
+ if (sphereVBO != null) sphereVBO.reset();
int arcSegments = 24;
int rotationSegments = 24;
@@ -884,14 +870,14 @@ public class NEUCape {
double diameterUnitArcLen = 0;
double arcAngle = 0;
- for(int i = 0; i < arcSegments; i++) {
+ 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++) {
+ for (int angleI = 0; angleI < rotationSegments; angleI++) {
double angle = Math.PI * 2 * angleI / rotationSegments;
List<Vector3f> arc = new ArrayList<>();
@@ -901,7 +887,7 @@ public class NEUCape {
arc.add(arcPos);
arcAngle = 0;
- for(int segmentI = 0; segmentI < arcSegments; segmentI++) {
+ for (int segmentI = 0; segmentI < arcSegments; segmentI++) {
double deltaZ = Math.sin(arcAngle) * arcLength;
double deltaY = Math.cos(arcAngle) * Math.cos(angle) * arcLength;
@@ -924,8 +910,8 @@ public class NEUCape {
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++) {
+ 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);
@@ -933,10 +919,10 @@ public class NEUCape {
}
}
- for(int angleI = 0; angleI < rotationSegments; angleI++) {
+ for (int angleI = 0; angleI < rotationSegments; angleI++) {
int nextAngleI = angleI + 1;
- if(angleI == rotationSegments - 1) {
+ if (angleI == rotationSegments - 1) {
nextAngleI = 0;
}
@@ -947,7 +933,7 @@ public class NEUCape {
List<Vector3f> thisArc = arcs.get(angleI);
List<Vector3f> nextArc = arcs.get(nextAngleI);
- for(int segmentI = 1; segmentI <= arcSegments; segmentI++) {
+ for (int segmentI = 1; segmentI <= arcSegments; segmentI++) {
Vector3f point1 = thisArc.get(segmentI);
Vector3f point2 = thisArc.get(segmentI - 1);
Vector3f point3 = nextArc.get(segmentI - 1);
@@ -1006,29 +992,29 @@ public class NEUCape {
orbitals.put(mercuryDist, 2);
double delta = Minecraft.getMinecraft().getRenderViewEntity().getRotationYawHead() % 360;
- while(delta < 0) delta += 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);
+ 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);
+ while (nepDelta < 0) nepDelta += 360;
+ if (nepDelta > 250 || nepDelta < 110) orbitals.put(neptuneDist, 4);
GlStateManager.disableDepth();
GlStateManager.enableCull();
- for(int planetId : orbitals.descendingMap().values()) {
+ for (int planetId : orbitals.descendingMap().values()) {
GlStateManager.pushMatrix();
- switch(planetId) {
+ 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);
+ 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);
@@ -1061,12 +1047,11 @@ public class NEUCape {
GlStateManager.popMatrix();
}
-
GlStateManager.disableCull();
GlStateManager.enableDepth();
GL11.glDisable(GL11.GL_STENCIL_TEST);
- } else if(capeName.equalsIgnoreCase("parallax")) {
+ } else if (capeName.equalsIgnoreCase("parallax")) {
renderBackAndDoFrontStencil();
Vector3f pointNorm = avgNormal();
@@ -1129,12 +1114,11 @@ public class NEUCape {
tessellator.draw();
-
GlStateManager.disableCull();
GlStateManager.enableDepth();
GL11.glDisable(GL11.GL_STENCIL_TEST);
- } else if(capeName.equalsIgnoreCase("tunnel")) {
+ } else if (capeName.equalsIgnoreCase("tunnel")) {
renderBackAndDoFrontStencil();
Vector3f pointNorm = avgNormal();
@@ -1147,7 +1131,7 @@ public class NEUCape {
List<Vector2f> edgeCoords = new ArrayList<>();
//Left edge
- for(int y = 0; y < VERT_NODES; y++) {
+ for (int y = 0; y < VERT_NODES; y++) {
edgeNodes.add(nodes[y * HORZ_NODES]);
edgeCoords.add(new Vector2f(0, (float) y / (VERT_NODES - 1)));
}
@@ -1156,14 +1140,14 @@ public class NEUCape {
//Bottom edge
int bottomIndex = VERT_NODES - 1;
int botSize = HORZ_NODES;
- for(int x = 0; x < botSize; x++) {
+ 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--) {
+ 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));
}
@@ -1171,7 +1155,7 @@ public class NEUCape {
edgeCoords.add(null);
//Top edge
int topSize = HORZ_NODES;
- for(int x = topSize - 1; x >= 0; x--) {
+ for (int x = topSize - 1; x >= 0; x--) {
edgeNodes.add(getNode(x, 0));
edgeCoords.add(new Vector2f((float) x / (topSize - 1), 0));
}
@@ -1179,9 +1163,9 @@ public class NEUCape {
GlStateManager.disableDepth();
GlStateManager.enableCull();
CapeNode last = null;
- for(int i = 0; i < edgeNodes.size(); i++) {
+ for (int i = 0; i < edgeNodes.size(); i++) {
CapeNode node = edgeNodes.get(i);
- if(last != null && node != null) {
+ if (last != null && node != null) {
Vector2f lastCoord = edgeCoords.get(i - 1);
Vector2f coord = edgeCoords.get(i);
@@ -1212,8 +1196,8 @@ public class NEUCape {
GL11.glDisable(GL11.GL_STENCIL_TEST);
} else {
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ for (int y = 0; y < VERT_NODES; y++) {
+ for (int x = 0; x < HORZ_NODES; x++) {
nodes[x + y * HORZ_NODES].renderNode();
}
}
@@ -1228,13 +1212,13 @@ public class NEUCape {
Vector3f avgPositionFixed = avgFixedRenderPosition();
Vector3f delta = Vector3f.sub(avgPositionFixed, avgPositionFixedBefore, null);
- if(delta.lengthSquared() > 9) {
+ if (delta.lengthSquared() > 9) {
updateFixedCapeNodes(player);
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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) {
+ if (!node.fixed) {
Vector3f.add(node.renderPosition, delta, node.renderPosition);
node.position.set(node.renderPosition);
node.lastPosition.set(node.renderPosition);
@@ -1248,13 +1232,13 @@ public class NEUCape {
return;
}
- for(int y = 0; y < VERT_NODES; y++) {
- for(int x = 0; x < HORZ_NODES; x++) {
+ 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;
+ if (node.fixed) continue;
Vector3f newPosition = new Vector3f();
newPosition.x = node.lastPosition.x + (node.position.x - node.lastPosition.x) * partialRenderTick;
@@ -1264,18 +1248,18 @@ public class NEUCape {
int length = node.oldRenderPosition.length;
int fps = Minecraft.getDebugFPS();
- if(fps < 50) {
+ if (fps < 50) {
length = 2;
- } else if(fps < 100) {
+ } else if (fps < 100) {
length = 2 + (int) ((fps - 50) / 50f * 3);
}
- if(node.oldRenderPosition[length - 1] == null) {
+ 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++) {
+ for (int i = 0; i < length; i++) {
Vector3f.add(accum, node.oldRenderPosition[i], accum);
Vector3f.add(accum, avgPositionFixed, accum);
}
@@ -1288,9 +1272,9 @@ public class NEUCape {
node.renderPosition = accum;
}
- if(!Minecraft.getMinecraft().isGamePaused()) {
- for(int i = node.oldRenderPosition.length - 1; i >= 0; i--) {
- if(i > 0) {
+ 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);
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..6801b4c8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/ShaderManager.java
@@ -16,8 +16,8 @@ import java.util.HashMap;
public class ShaderManager {
- private ResourceLocation shaderLocation = new ResourceLocation("notenoughupdates:shaders");
- private HashMap<String, Shader> shaderMap = new HashMap<>();
+ private final ResourceLocation shaderLocation = new ResourceLocation("notenoughupdates:shaders");
+ private final HashMap<String, Shader> shaderMap = new HashMap<>();
private static final ShaderManager INSTANCE = new ShaderManager();
@@ -25,7 +25,7 @@ public class ShaderManager {
return INSTANCE;
}
- public class Shader {
+ public static class Shader {
public final int program;
public Shader(int program) {
@@ -34,14 +34,14 @@ public class ShaderManager {
}
public int getShader(String name) {
- if(!shaderMap.containsKey(name)) {
+ if (!shaderMap.containsKey(name)) {
reloadShader(name);
}
return shaderMap.get(name).program;
}
public int loadShader(String name) {
- if(!shaderMap.containsKey(name)) {
+ if (!shaderMap.containsKey(name)) {
reloadShader(name);
}
GL20.glUseProgram(shaderMap.get(name).program);
@@ -51,17 +51,17 @@ public class ShaderManager {
public void loadData(String name, String var, Object value) {
int location = GL20.glGetUniformLocation(shaderMap.get(name).program, var);
- if(value instanceof Integer) {
+ if (value instanceof Integer) {
GL20.glUniform1i(location, (Integer) value);
- } else if(value instanceof Float) {
+ } else if (value instanceof Float) {
GL20.glUniform1f(location, (Float) value);
- } else if(value instanceof Vector2f) {
+ } else if (value instanceof Vector2f) {
Vector2f vec = (Vector2f) value;
GL20.glUniform2f(location, vec.x, vec.y);
- } else if(value instanceof Vector3f) {
+ } else if (value instanceof Vector3f) {
Vector3f vec = (Vector3f) value;
GL20.glUniform3f(location, vec.x, vec.y, vec.z);
- } else if(value instanceof Vector4f) {
+ } else if (value instanceof Vector4f) {
Vector4f vec = (Vector4f) value;
GL20.glUniform4f(location, vec.x, vec.y, vec.z, vec.w);
} else {
@@ -72,7 +72,7 @@ public class ShaderManager {
private void reloadShader(String name) {
int vertex = -1;
String sourceVert = getShaderSource(name, GL20.GL_VERTEX_SHADER);
- if(!sourceVert.isEmpty()) {
+ if (!sourceVert.isEmpty()) {
vertex = GL20.glCreateShader(GL20.GL_VERTEX_SHADER);
GL20.glShaderSource(vertex, sourceVert);
GL20.glCompileShader(vertex);
@@ -84,7 +84,7 @@ public class ShaderManager {
int fragment = -1;
String sourceFrag = getShaderSource(name, GL20.GL_FRAGMENT_SHADER);
- if(!sourceFrag.isEmpty()) {
+ if (!sourceFrag.isEmpty()) {
fragment = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER);
GL20.glShaderSource(fragment, sourceFrag);
GL20.glCompileShader(fragment);
@@ -96,7 +96,7 @@ public class ShaderManager {
int compute = -1;
String sourceCompute = getShaderSource(name, GL43.GL_COMPUTE_SHADER);
- if(!sourceCompute.isEmpty()) {
+ if (!sourceCompute.isEmpty()) {
compute = GL20.glCreateShader(GL43.GL_COMPUTE_SHADER);
GL20.glShaderSource(compute, sourceCompute);
GL20.glCompileShader(compute);
@@ -107,15 +107,15 @@ public class ShaderManager {
}
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);
+ 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 (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));
@@ -130,28 +130,27 @@ public class ShaderManager {
public String getShaderSource(String name, int type) {
String ext = "";
- if(type == GL20.GL_VERTEX_SHADER) {
+ if (type == GL20.GL_VERTEX_SHADER) {
ext = ".vert";
- } else if(type == GL20.GL_FRAGMENT_SHADER) {
+ } else if (type == GL20.GL_FRAGMENT_SHADER) {
ext = ".frag";
- } else if(type == GL43.GL_COMPUTE_SHADER) {
+ } 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()) {
+ 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) {
+ while ((line = br.readLine()) != null) {
source.append(line).append("\n");
}
return source.toString();
- } catch(IOException e) {
- }
+ } 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..e29ccca4 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;
@@ -24,19 +29,19 @@ public class DungeonBlocks {
private static Framebuffer framebufferBlocksTo = null;
private static Framebuffer framebufferBlocksFrom = null;
- private static HashMap<String, Framebuffer> framebuffersDynamicTo = new HashMap<>();
+ private static final HashMap<String, Framebuffer> framebuffersDynamicTo = new HashMap<>();
public static HashMap<String, Framebuffer> framebuffersDynamicFrom = new HashMap<>();
- private static HashSet<String> dynamicUpdated = new HashSet<>();
+ private static final HashSet<String> dynamicUpdated = new HashSet<>();
- private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16);
- private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16);
+ 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()) {
+ if (textureExists()) {
framebufferBlocksFrom.bindFramebufferTexture();
}
}
@@ -44,24 +49,24 @@ public class DungeonBlocks {
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")));
+ (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon")));
}
public static boolean bindModifiedTexture(ResourceLocation location, int colour) {
- if(!isOverriding()) {
+ if (!isOverriding()) {
return false;
}
- if(Utils.disableCustomDungColours) {
+ if (Utils.disableCustomDungColours) {
return false;
}
- if(((colour >> 24) & 0xFF) < 10) {
+ if (((colour >> 24) & 0xFF) < 10) {
return false;
}
- String id = location.getResourceDomain()+":"+location.getResourcePath();
- if(dynamicUpdated.contains(id) && framebuffersDynamicFrom.containsKey(id)) {
+ String id = location.getResourceDomain() + ":" + location.getResourcePath();
+ if (dynamicUpdated.contains(id) && framebuffersDynamicFrom.containsKey(id)) {
framebuffersDynamicFrom.get(id).bindFramebufferTexture();
return true;
}
@@ -108,7 +113,7 @@ public class DungeonBlocks {
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, 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);
}
@@ -128,7 +133,7 @@ public class DungeonBlocks {
GlStateManager.disableBlend();
GlStateManager.enableLighting();
return true;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
@@ -137,7 +142,7 @@ public class DungeonBlocks {
return false;
}
- private static HashMap<ResourceLocation, String> dynamicPreloadMap = new HashMap<>();
+ private static final HashMap<ResourceLocation, String> dynamicPreloadMap = new HashMap<>();
static {
dynamicPreloadMap.put(new ResourceLocation("textures/entity/bat.png"),
@@ -153,13 +158,13 @@ public class DungeonBlocks {
}
public static void tick() {
- if(!isOverriding() || Minecraft.getMinecraft().theWorld == null) {
+ if (!isOverriding() || Minecraft.getMinecraft().theWorld == null) {
return;
}
dynamicUpdated.clear();
- for(Map.Entry<ResourceLocation, String> entry : dynamicPreloadMap.entrySet()) {
+ for (Map.Entry<ResourceLocation, String> entry : dynamicPreloadMap.entrySet()) {
bindModifiedTexture(entry.getKey(), SpecialColour.specialToChromaRGB(entry.getValue()));
}
@@ -200,12 +205,12 @@ public class DungeonBlocks {
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;
+ 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());
+ 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());
@@ -223,7 +228,7 @@ public class DungeonBlocks {
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, 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);
}
@@ -231,7 +236,7 @@ public class DungeonBlocks {
Framebuffer from = checkFramebufferSizes(framebufferBlocksFrom, w, h);
framebufferBlocksFrom = to;
framebufferBlocksTo = from;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
@@ -239,8 +244,8 @@ public class DungeonBlocks {
}
private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if(framebuffer == null) {
+ 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;
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..6f42ab10 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,8 +46,8 @@ 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 {
@@ -86,15 +90,15 @@ public class DungeonMap {
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 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 Map<String, ResourceLocation> playerSkinMap = new HashMap<>();
-
- private class RoomOffset {
+ private static class RoomOffset {
int x;
int y;
@@ -104,19 +108,19 @@ public class DungeonMap {
}
public RoomOffset left() {
- return new RoomOffset(x-1, y);
+ return new RoomOffset(x - 1, y);
}
public RoomOffset right() {
- return new RoomOffset(x+1, y);
+ return new RoomOffset(x + 1, y);
}
public RoomOffset up() {
- return new RoomOffset(x, y-1);
+ return new RoomOffset(x, y - 1);
}
public RoomOffset down() {
- return new RoomOffset(x, y+1);
+ return new RoomOffset(x, y + 1);
}
public RoomOffset[] getNeighbors() {
@@ -141,7 +145,7 @@ public class DungeonMap {
NONE, WALL, CORRIDOR, ROOM_DIVIDER
}
- private class RoomConnection {
+ private static class RoomConnection {
RoomConnectionType type;
Color colour;
@@ -176,39 +180,39 @@ public class DungeonMap {
RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
public void renderNoRotate(int roomSize, int connectorSize, int rotation) {
- if(tickColour != 0) {
+ if (tickColour != 0) {
Color tick = new Color(tickColour, true);
ResourceLocation indicatorTex = null;
- if(tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) {
+ if (tick.getRed() == 255 && tick.getGreen() == 255 && tick.getBlue() == 255) {
indicatorTex = WHITE_CHECK;
- } else if(tick.getRed() == 0 && tick.getGreen() == 124 && tick.getBlue() == 0) {
+ } 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) {
+ } else if (tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) {
indicatorTex = QUESTION;
- } else if(tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) {
+ } else if (tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) {
indicatorTex = CROSS;
}
- if(indicatorTex != null) {
+ 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 (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));
+ 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);
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
}
GlStateManager.pushMatrix();
@@ -217,8 +221,8 @@ public class DungeonMap {
Utils.drawTexturedRect(-5, -5, 10, 10, GL11.GL_NEAREST);
GlStateManager.popMatrix();
- if(!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
- GlStateManager.rotate(rotation-180, 0, 0, 1);
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmOrientCheck) {
+ GlStateManager.rotate(rotation - 180, 0, 0, 1);
}
GlStateManager.translate(-x, -y, 0);
}
@@ -227,25 +231,25 @@ public class DungeonMap {
public void render(int roomSize, int connectorSize) {
ResourceLocation roomTex = null;
- if(colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
+ if (colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
roomTex = ROOM_BROWN;
- } else if(colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } else if (colour.getRed() == 216 && colour.getGreen() == 127 && colour.getBlue() == 51) {
roomTex = ROOM_ORANGE;
}
- if(roomTex != null) {
+ if (roomTex != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex);
GlStateManager.color(1, 1, 1, 1);
Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR);
@@ -253,72 +257,72 @@ public class DungeonMap {
Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
}
- if(fillCorner) {
+ 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++) {
+ for (int k = 0; k < 2; k++) {
RoomConnection connection = down;
- if(k == 1) connection = right;
+ if (k == 1) connection = right;
+
+ if (connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue;
- 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) {
+ 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } 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) {
+ } else if (connection.colour.getRed() == 216 && connection.colour.getGreen() == 127 && connection.colour.getBlue() == 51) {
corridorTex = CORRIDOR_ORANGE;
}
- if(corridorTex == null) {
+ if (corridorTex == null) {
int xOffset = 0;
int yOffset = 0;
int width = 0;
int height = 0;
- if(connection == right) {
+ if (connection == right) {
xOffset = roomSize;
width = connectorSize;
height = roomSize;
- if(connection.type == RoomConnectionType.CORRIDOR) {
+ if (connection.type == RoomConnectionType.CORRIDOR) {
height = 8;
yOffset += 4;
}
- } else if(connection == down) {
+ } else if (connection == down) {
yOffset = roomSize;
width = roomSize;
height = connectorSize;
- if(connection.type == RoomConnectionType.CORRIDOR) {
+ if (connection.type == RoomConnectionType.CORRIDOR) {
width = 8;
xOffset += 4;
}
}
- Gui.drawRect(xOffset, yOffset, xOffset+width, yOffset+height, connection.colour.getRGB());
+ 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);
+ if (connection == right) {
+ GlStateManager.translate(roomSize / 2f, roomSize / 2f, 0);
GlStateManager.rotate(-90, 0, 0, 1);
- GlStateManager.translate(-roomSize/2f, -roomSize/2f, 0);
+ GlStateManager.translate(-roomSize / 2f, -roomSize / 2f, 0);
}
Utils.drawTexturedRect(0, roomSize, roomSize, connectorSize, GL11.GL_NEAREST);
GlStateManager.popMatrix();
@@ -335,8 +339,8 @@ public class DungeonMap {
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) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
framebuffer = new Framebuffer(width, height, true);
} else {
framebuffer.createBindFramebuffer(width, height);
@@ -347,44 +351,45 @@ public class DungeonMap {
}
private static void upload(Shader shader, int width, int height, int scale, float radiusSq) {
- if(shader == null) return;
+ if (shader == null) return;
shader.getShaderManager().getShaderUniformOrDefault("ProjMat").set(projectionMatrix);
- shader.getShaderManager().getShaderUniformOrDefault("InSize").set(width*scale, height*scale);
+ 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("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);
+ 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;
+ int roomSizeOption = Math.round(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmRoomSize);
+ if (roomSizeOption <= 0) return 3;
return 3 + roomSizeOption;
}
- private HashMap<Integer, Float> borderRadiusCache = new HashMap<>();
+ 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)) {
+ 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))) {
+ 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) { }
+ } catch (Exception ignored) {}
borderRadiusCache.put(style, 1f);
return 1f;
@@ -410,7 +415,7 @@ public class DungeonMap {
int minRoomY = 999;
int maxRoomX = -999;
int maxRoomY = -999;
- for(RoomOffset offset : roomMap.keySet()) {
+ for (RoomOffset offset : roomMap.keySet()) {
minRoomX = Math.min(offset.x, minRoomX);
minRoomY = Math.min(offset.y, minRoomY);
maxRoomX = Math.max(offset.x, maxRoomX);
@@ -423,43 +428,43 @@ public class DungeonMap {
int renderConnSize = getRenderConnSize();
MapPosition playerPos = null;
- if(playerEntityMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
+ if (playerEntityMapPositions.containsKey(Minecraft.getMinecraft().thePlayer.getName())) {
playerPos = playerEntityMapPositions.get(Minecraft.getMinecraft().thePlayer.getName());
- } else if(playerMarkerMapPositions.containsKey(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;
+ 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);
+ 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 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);
+ 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) {
+ if (mapShader == null) {
mapShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
"dungeonmap", mapFramebuffer1, mapFramebuffer2);
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Utils.pushGuiScale(-1);
return;
@@ -467,24 +472,25 @@ public class DungeonMap {
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;
+ 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) {
+ if (useFb) {
mapFramebuffer1.framebufferClear();
mapFramebuffer2.framebufferClear();
}
- GlStateManager.pushMatrix(); {
- if(useFb) {
+ GlStateManager.pushMatrix();
+ {
+ if (useFb) {
GlStateManager.matrixMode(5889);
GlStateManager.loadIdentity();
- GlStateManager.ortho(0.0D, mapSizeX*scaleFactor, mapSizeY*scaleFactor, 0.0D, 1000.0D, 3000.0D);
+ 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);
@@ -496,47 +502,47 @@ public class DungeonMap {
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);
+ 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);
+ 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);
+ 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);
+ centerX - mapSizeX / 2, centerY - mapSizeY / 2, mapSizeX, mapSizeY);
BackgroundBlur.markDirty();
- GlStateManager.translate(centerX-mapSizeX/2, centerY-mapSizeY/2, 0);
+ GlStateManager.translate(centerX - mapSizeX / 2, centerY - mapSizeY / 2, 0);
}
GlStateManager.translate(mapCenterX, mapCenterY, 10);
- if(!useFb || NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur > 0.1) {
+ 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);
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterPlayer && playerPos != null) {
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmCenterPlayer && playerPos != null) {
float x = playerPos.getRenderX();
float y = playerPos.getRenderY();
- x -= minRoomX*(renderRoomSize+renderConnSize);
- y -= minRoomY*(renderRoomSize+renderConnSize);
+ x -= minRoomX * (renderRoomSize + renderConnSize);
+ y -= minRoomY * (renderRoomSize + renderConnSize);
GlStateManager.translate(-x, -y, 0);
} else {
- GlStateManager.translate(-roomsSizeX/2, -roomsSizeY/2, 0);
+ GlStateManager.translate(-roomsSizeX / 2, -roomsSizeY / 2, 0);
}
- for(Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
+ 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);
+ int x = (roomOffset.x - minRoomX) * (renderRoomSize + renderConnSize);
+ int y = (roomOffset.y - minRoomY) * (renderRoomSize + renderConnSize);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 0);
@@ -547,22 +553,22 @@ public class DungeonMap {
GlStateManager.popMatrix();
}
- GlStateManager.translate(-mapCenterX+roomsSizeX/2f, -mapCenterY+roomsSizeY/2f, 0);
+ GlStateManager.translate(-mapCenterX + roomsSizeX / 2f, -mapCenterY + roomsSizeY / 2f, 0);
GlStateManager.translate(mapCenterX, mapCenterY, 0);
- GlStateManager.rotate(rotation-180, 0, 0, 1);
+ 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()) {
+ 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)));
+ 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);
@@ -574,20 +580,19 @@ public class DungeonMap {
GlStateManager.popMatrix();
}
-
GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
GlStateManager.translate(mapCenterX, mapCenterY, 0);
- GlStateManager.rotate(-rotation+180, 0, 0, 1);
+ GlStateManager.rotate(-rotation + 180, 0, 0, 1);
GlStateManager.translate(-mapCenterX, -mapCenterY, 0);
- GlStateManager.translate(mapCenterX-roomsSizeX/2f, mapCenterY-roomsSizeY/2f, 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()) {
+ for (Map.Entry<String, MapPosition> entry : playerMarkerMapPositions.entrySet()) {
String name = entry.getKey();
MapPosition pos = entry.getValue();
float x = pos.getRenderX();
@@ -595,7 +600,7 @@ public class DungeonMap {
float angle = pos.rotation;
boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp;
- if(!isFloorOne && playerEntityMapPositions.containsKey(name)) {
+ if (!isFloorOne && playerEntityMapPositions.containsKey(name)) {
MapPosition entityPos = playerEntityMapPositions.get(name);
angle = entityPos.rotation;
@@ -619,23 +624,23 @@ public class DungeonMap {
doInterp = false;
}
- float minU = 3/4f;
+ float minU = 3 / 4f;
float minV = 0;
- if(name.equals(Minecraft.getMinecraft().thePlayer.getName())) {
- minU = 1/4f;
+ if (name.equals(Minecraft.getMinecraft().thePlayer.getName())) {
+ minU = 1 / 4f;
}
- float maxU = minU + 1/4f;
- float maxV = minV + 1/4f;
+ float maxU = minU + 1 / 4f;
+ float maxV = minV + 1 / 4f;
- if(doInterp && playerMarkerMapPositionsLast.containsKey(name)) {
+ 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 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;
@@ -654,31 +659,31 @@ public class DungeonMap {
boolean headLayer = false;
int pixelWidth = 8;
int pixelHeight = 8;
- if(renderRoomSize >= 24) {
+ if (renderRoomSize >= 24) {
pixelWidth = pixelHeight = 12;
}
GlStateManager.color(1, 1, 1, 1);
- if((!NotEnoughUpdates.INSTANCE.config.dungeons.showOwnHeadAsMarker ||
- playerMarkerMapPositions.size() <= 1 || minU != 1/4f) &&
+ 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;
+ minU = 8 / 64f;
+ minV = 8 / 64f;
+ maxU = 16 / 64f;
+ maxV = 16 / 64f;
headLayer = true;
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 2) {
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerHeads >= 2) {
blackBorder = true;
}
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons);
}
- x -= minRoomX*(renderRoomSize+renderConnSize);
- y -= minRoomY*(renderRoomSize+renderConnSize);
+ x -= minRoomX * (renderRoomSize + renderConnSize);
+ y -= minRoomY * (renderRoomSize + renderConnSize);
GlStateManager.pushMatrix();
@@ -692,50 +697,52 @@ public class DungeonMap {
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);
+ 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();
+ 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) {
+ 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();
+ 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) {
+ 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();
+ }
+ GlStateManager.popMatrix();
- if(useFb) {
+ if (useFb) {
Framebuffer renderFromBuffer = mapFramebuffer1;
- if(useShd) {
- GlStateManager.pushMatrix(); {
+ if (useShd) {
+ GlStateManager.pushMatrix();
+ {
try {
upload(mapShader, mapSizeX, mapSizeY, scaleFactor, getBorderRadius());
mapShader.setProjectionMatrix(projectionMatrix);
mapShader.loadShader(0);
renderFromBuffer = mapFramebuffer2;
- } catch(Exception e) {
- }
- } GlStateManager.popMatrix();
+ } catch (Exception ignored) {}
+ }
+ GlStateManager.popMatrix();
}
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
@@ -745,7 +752,7 @@ public class DungeonMap {
GlStateManager.translate(centerX, centerY, 100);
renderFromBuffer.bindFramebufferTexture();
- Utils.drawTexturedRect(-mapSizeX/2, -mapSizeY/2, mapSizeX, mapSizeY,
+ Utils.drawTexturedRect(-mapSizeX / 2, -mapSizeY / 2, mapSizeX, mapSizeY,
0, 1, 1, 0, GL11.GL_NEAREST);
GlStateManager.bindTexture(0);
@@ -756,61 +763,61 @@ public class DungeonMap {
GlStateManager.translate(centerX, centerY, 100);
- if(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmChromaBorder) {
+ if (NotEnoughUpdates.INSTANCE.config.dungeonMap.dmChromaBorder) {
int colour = SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour);
- Gui.drawRect(-mapCenterX-2, -mapCenterY-2, -mapCenterX, -mapCenterY,
+ Gui.drawRect(-mapCenterX - 2, -mapCenterY - 2, -mapCenterX, -mapCenterY,
colour); //topleft
- Gui.drawRect(-mapCenterX-2, mapCenterY+2, -mapCenterX, mapCenterY,
+ Gui.drawRect(-mapCenterX - 2, mapCenterY + 2, -mapCenterX, mapCenterY,
SpecialColour.rotateHue(colour, -180)); //bottomleft
- Gui.drawRect(mapCenterX, -mapCenterY-2, mapCenterX+2, mapCenterY,
+ Gui.drawRect(mapCenterX, -mapCenterY - 2, mapCenterX + 2, mapCenterY,
SpecialColour.rotateHue(colour, -180)); //topright
- Gui.drawRect(mapCenterX, mapCenterY, mapCenterX+2, mapCenterY+2,
+ 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);
+ 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)),
+ 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,
+ 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,
+ Gui.drawRect(-mapCenterX - 2, -mapCenterY, -mapCenterX, mapCenterY,
SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)); //left
- Gui.drawRect(mapCenterX, -mapCenterY, mapCenterX+2, mapCenterY,
+ Gui.drawRect(mapCenterX, -mapCenterY, mapCenterX + 2, mapCenterY,
SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderColour)); //right
- Gui.drawRect(-mapCenterX-2, -mapCenterY-2, mapCenterX+2, -mapCenterY,
+ 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,
+ 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) {
+ 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);
+ Utils.drawTexturedRect(-size / 2, -size / 2, size, size, GL11.GL_NEAREST);
}
GlStateManager.translate(-centerX, -centerY, -100);
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
@@ -824,26 +831,25 @@ public class DungeonMap {
GlStateManager.disableLighting();
}
-
public void updateRoomConnections(RoomOffset roomOffset) {
- if(roomMap.containsKey(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;
+ 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) {
+ 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()) {
+ if (!c.equals(room.colour)) {
+ if (otherPixelColour == c.getRGB()) {
otherPixelFilled++;
} else {
otherPixelFilled--;
- if(otherPixelFilled <= 0) {
+ if (otherPixelFilled <= 0) {
otherPixelFilled = 1;
otherPixelColour = c.getRGB();
}
@@ -854,45 +860,45 @@ public class DungeonMap {
}
room.tickColour = 0;
- if((float)otherPixelFilled/roomSize/connectorSize > 0.05) {
+ if ((float) otherPixelFilled / roomSize / connectorSize > 0.05) {
room.tickColour = otherPixelColour;
}
- for(int k=0; k<4; k++) {
+ 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);
+ 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) {
+ if (k == 0) {
x += i;
y -= j;
- } else if(k == 1) {
- x += roomSize+j-1;
+ } else if (k == 1) {
+ x += roomSize + j - 1;
y += i;
- } else if(k == 2) {
+ } else if (k == 2) {
x += i;
- y += roomSize+j-1;
+ y += roomSize + j - 1;
} else {
x -= j;
y += i;
}
- if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
+ if (x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
Color pixel = colourMap[x][y];
- if(pixel.getAlpha() > 40) {
- if(colour == null) {
+ if (pixel.getAlpha() > 40) {
+ if (colour == null) {
colour = pixel;
totalFilled = 1;
} else {
- if(colour.equals(pixel)) {
+ if (colour.equals(pixel)) {
totalFilled++;
} else {
totalFilled--;
- if(totalFilled <= 0) {
+ if (totalFilled <= 0) {
colour = pixel;
totalFilled = 1;
}
@@ -902,32 +908,32 @@ public class DungeonMap {
}
}
}
- float proportionFilled = (float)totalFilled/roomSize/connectorSize;
+ float proportionFilled = (float) totalFilled / roomSize / connectorSize;
RoomConnectionType type = RoomConnectionType.WALL;
- if(proportionFilled > 0.8) {
+ if (proportionFilled > 0.8) {
type = RoomConnectionType.ROOM_DIVIDER;
- } else if(proportionFilled > 0.1) {
+ } else if (proportionFilled > 0.1) {
type = RoomConnectionType.CORRIDOR;
}
- if(k == 0) {
+ if (k == 0) {
room.up = new RoomConnection(type, colour);
- } else if(k == 1) {
+ } else if (k == 1) {
room.right = new RoomConnection(type, colour);
- } else if(k == 2) {
+ } 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;
+ 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) {
+ if (x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
Color pixel = colourMap[x][y];
- if(pixel.equals(room.colour)) {
+ if (pixel.equals(room.colour)) {
room.fillCorner = true;
}
}
@@ -935,16 +941,16 @@ public class DungeonMap {
}
public void loadNeighbors(RoomOffset room) {
- if(!roomMap.containsKey(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);
+ 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) {
+ 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);
}
@@ -954,13 +960,13 @@ public class DungeonMap {
}
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);
+ 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) {}
+ } catch (Exception ignored) {}
}
}
@@ -981,11 +987,11 @@ public class DungeonMap {
}
public float getRenderX() {
- return roomOffsetX*getRenderRoomSize() + connOffsetX*getRenderConnSize();
+ return roomOffsetX * getRenderRoomSize() + connOffsetX * getRenderConnSize();
}
public float getRenderY() {
- return roomOffsetY*getRenderRoomSize() + connOffsetY*getRenderConnSize();
+ return roomOffsetY * getRenderRoomSize() + connOffsetY * getRenderConnSize();
}
@Override
@@ -1009,16 +1015,17 @@ public class DungeonMap {
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;
+ 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) {
+ if (System.currentTimeMillis() - lastClearCache > 1000) {
roomMap.clear();
searchForPlayers = true;
startRoomX = -1;
@@ -1037,61 +1044,61 @@ public class DungeonMap {
List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
- for(int i=scores.size()-1; i>=0; i--) {
+ 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)")) {
+ if (line.contains("(F1)") || line.contains("(E)") || line.contains("(M1)")) {
isFloorOne = true;
break;
}
}
}
- if(failMap) {
+ if (failMap) {
return;
}
int alphaPixels = 0;
- for(int x=0; x<128; x++) {
- for(int y=0; y<128; y++) {
+ for (int x = 0; x < 128; x++) {
+ for (int y = 0; y < 128; y++) {
Color c = colourMap[x][y];
- if(c == null) {
+ if (c == null) {
return;
- } else if(c.getAlpha() < 50) {
+ } else if (c.getAlpha() < 50) {
alphaPixels++;
}
}
}
- if(alphaPixels < 128*128/10) {
+ 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++) {
+ 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) {
+ 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];
+ 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) {
+ 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));
+ roomSize = Math.max(roomSize, Math.min(xd + 1, yd + 1));
}
- if(xd == 20 && yd == 20) {
- if(roomSize == 0) roomSize = 20;
+ if (xd == 20 && yd == 20) {
+ if (roomSize == 0) roomSize = 20;
startRoomX = x;
startRoomY = y;
}
@@ -1103,56 +1110,56 @@ public class DungeonMap {
}
}
- if(startRoomX < 0 || startRoomY < 0) {
+ 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++) {
+ 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;
+ 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;
+ 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) {
+ 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);
+ connectorSize = Math.min(connectorSize, j - 1);
}
}
}
}
}
- if(connectorSize <= 0) {
+ 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())) {
+ 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())) {
+ if (skin != DefaultPlayerSkin.getDefaultSkin(aplayer.getUniqueID())) {
playerSkinMap.put(player.getName(), skin);
playerIdMap.put(player.getName(), player.getEntityId());
}
@@ -1161,49 +1168,49 @@ public class DungeonMap {
}
playerEntityMapPositions.clear();
- if(usePlayerPositions) {
- for(String playerName : actualPlayers) {
- if(playerIdMap.containsKey(playerName)) {
+ if (usePlayerPositions) {
+ for (String playerName : actualPlayers) {
+ if (playerIdMap.containsKey(playerName)) {
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(playerIdMap.get(playerName));
- if(entity instanceof EntityPlayer) {
+ if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
- float roomX = (float)player.posX / (roomSizeBlocks+1);
- float roomY = (float)player.posZ / (roomSizeBlocks+1);
+ 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
+ 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;
+ playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks - 2)) / 5f;
} else {
- playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-4);
+ 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
+ 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;
+ playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks - 2)) / 5f;
} else {
- playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-4);
+ playerRoomOffsetY += (roomYInBlocks - 2) / (roomSizeBlocks - 4);
}
- playerRoomOffsetX -= startRoomX/(roomSize+connectorSize);
- playerRoomOffsetY -= startRoomY/(roomSize+connectorSize);
- playerConnOffsetX -= startRoomX/(roomSize+connectorSize);
- playerConnOffsetY -= startRoomY/(roomSize+connectorSize);
+ 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;
+ pos.rotation = (player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks) % 360;
+ if (pos.rotation < 0) pos.rotation += 360;
playerEntityMapPositions.put(player.getName(), pos);
}
}
@@ -1212,26 +1219,26 @@ public class DungeonMap {
loadNeighbors(new RoomOffset(0, 0));
updateRoomColours();
- for(RoomOffset offset : roomMap.keySet()) {
+ for (RoomOffset offset : roomMap.keySet()) {
updateRoomConnections(offset);
}
- if(roomMap.isEmpty()) {
+ if (roomMap.isEmpty()) {
failMap = true;
return;
}
- if(mapDecorations != null && mapDecorations.size() > 0) {
+ 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;
+ 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) {
+ if (x < 0 || y < 0 || x > 128 || y > 128) {
continue;
}
@@ -1269,9 +1276,9 @@ public class DungeonMap {
MapPosition pos = new MapPosition(roomsOffsetX, connOffsetX, roomsOffsetY, connOffsetY);
pos.rotation = angle % 360;
- if(pos.rotation < 0) pos.rotation += 360;
+ if (pos.rotation < 0) pos.rotation += 360;
- if(decorations++ <= 6) {
+ if (decorations++ <= 6) {
positions.add(pos);
}
rawPlayerMarkerMapPositions.add(pos);
@@ -1288,7 +1295,7 @@ public class DungeonMap {
}
}
- if(different && positions.size() > 0) {
+ if (different && positions.size() > 0) {
lastLastDecorationsMillis = lastDecorationsMillis;
lastDecorationsMillis = System.currentTimeMillis();
@@ -1360,21 +1367,21 @@ public class DungeonMap {
}
List<Integer> nonUsedIndexes = new ArrayList<>();
- for(int i=0; i<positions.size(); i++) {
- if(!finalUsedIndexes.contains(i)) {
+ 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;
+ 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) {
+ } else if (mapDecorations == null) {
playerMarkerMapPositions.clear();
playerMarkerMapPositionsLast.clear();
@@ -1383,7 +1390,7 @@ public class DungeonMap {
}
}
- if(!roomMap.isEmpty() && startRoomX >= 0 && startRoomY >= 0) {
+ if (!roomMap.isEmpty() && startRoomX >= 0 && startRoomY >= 0) {
render(centerX, centerY);
}
@@ -1397,27 +1404,27 @@ public class DungeonMap {
@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 (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if (!NotEnoughUpdates.INSTANCE.config.dungeonMap.dmEnable) return;
- if(Minecraft.getMinecraft().gameSettings.showDebugInfo ||
+ 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)) {
+ 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) {
+ 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);
@@ -1428,7 +1435,7 @@ public class DungeonMap {
ItemMap map = (ItemMap) stack.getItem();
MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
- if(mapData == null) return;
+ if (mapData == null) return;
decorations = mapData.mapDecorations;
@@ -1494,30 +1501,30 @@ public class DungeonMap {
}
}*/
int players = 0;
- for(ScorePlayerTeam team : Minecraft.getMinecraft().thePlayer.getWorldScoreboard().getTeams()) {
- if(team.getTeamName().startsWith("a") && team.getMembershipCollection().size() == 1) {
+ 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())) {
+ 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;
+ 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);
+ 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,
+ 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){
+ } 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;
@@ -1528,20 +1535,20 @@ public class DungeonMap {
public List<List<String>> permutations(List<String> values) {
List<List<String>> permutations = new ArrayList<>();
- if(values.size() == 1) {
+ if (values.size() == 1) {
permutations.add(values);
return permutations;
}
- for(String first : values) {
+ for (String first : values) {
List<String> newList = new ArrayList<>();
- for(String val : values) {
- if(!val.equals(first)) {
+ for (String val : values) {
+ if (!val.equals(first)) {
newList.add(val);
}
}
- for(List<String> list2 : permutations(newList)) {
+ for (List<String> list2 : permutations(newList)) {
List<String> perm = new ArrayList<>();
perm.add(first);
perm.addAll(list2);
@@ -1560,15 +1567,15 @@ public class DungeonMap {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
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..d79e9840 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;
@@ -33,7 +31,7 @@ public class DungeonWin {
private int life = 0;
private float xVel;
private float yVel;
- private int id;
+ private final int id;
public Confetti(float x, float y, float xVel, float yVel) {
this.x = x;
@@ -43,9 +41,10 @@ public class DungeonWin {
this.xVel = xVel;
this.yVel = yVel;
this.id = rand.nextInt(16);
- this.life = 20+rand.nextInt(10);
+ 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");
@@ -56,8 +55,8 @@ public class DungeonWin {
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 final int WIDTH = 32 * SCALE_FACTOR;
+ private static final int HEIGHT = 16 * SCALE_FACTOR;
private static boolean hideChat = false;
private static long lastDungeonFinish = 0;
@@ -71,63 +70,68 @@ public class DungeonWin {
public static long startTime = 0;
static {
- for(int i=0; i<10; i++) {
- text.add("{PLACEHOLDER DUNGEON STAT #"+i+"}");
+ 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;
+ 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 (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) {
+ if (deltaTime < 1000) {
ScaledResolution sr = Utils.pushGuiScale(2);
int cap = 0;
- switch(TEAM_SCORE.getResourcePath()) {
+ switch (TEAM_SCORE.getResourcePath()) {
case "dungeon_win/splus.png":
- cap = 200; break;
+ cap = 200;
+ break;
case "dungeon_win/s.png":
- cap = 100; break;
+ cap = 100;
+ break;
case "dungeon_win/a.png":
- cap = 50; break;
+ cap = 50;
+ break;
}
- int maxConfetti = Math.min(cap, deltaTime/5);
- while(confetti.size() < maxConfetti) {
+ 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);
+ 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);
+ 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 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;
+ 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) {
+ for (Confetti c : confetti) {
+ if (c.life <= 0) {
toRemove.add(c);
}
}
try {
confetti.removeAll(toRemove);
- } catch(ConcurrentModificationException ignored) {}
+ } catch (ConcurrentModificationException ignored) {}
}
Utils.pushGuiScale(-1);
- for(Confetti c : confetti) {
+ for (Confetti c : confetti) {
c.yVel += 1;
c.xVel /= 1.1f;
c.yVel /= 1.1f;
@@ -139,11 +143,11 @@ public class DungeonWin {
}
}
-
public static void onChatMessage(ClientChatReceivedEvent e) {
- if(e.type == 2) return;
+ if (e.type == 2) return;
- if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) 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());
@@ -151,48 +155,52 @@ public class DungeonWin {
//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) {
+ 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()) {
+ if (matcher.find()) {
lastDungeonFinish = currentTime;
String score = matcher.group(1);
switch (score.toUpperCase()) {
case "S+":
- TEAM_SCORE = SPLUS; break;
+ TEAM_SCORE = SPLUS;
+ break;
case "S":
- TEAM_SCORE = S; break;
+ TEAM_SCORE = S;
+ break;
case "A":
- TEAM_SCORE = A; break;
+ TEAM_SCORE = A;
+ break;
case "B":
- TEAM_SCORE = B; break;
+ TEAM_SCORE = B;
+ break;
case "C":
- TEAM_SCORE = C; break;
+ TEAM_SCORE = C;
+ break;
default:
- TEAM_SCORE = D; break;
+ TEAM_SCORE = D;
+ break;
}
- SES.schedule(()-> {
- NotEnoughUpdates.INSTANCE.sendChatMessage("/showextrastats");
- }, 100L, TimeUnit.MILLISECONDS);
+ SES.schedule(() -> NotEnoughUpdates.INSTANCE.sendChatMessage("/showextrastats"), 100L, TimeUnit.MILLISECONDS);
}
}
}
- if(currentTime - lastDungeonFinish > 100 && currentTime - lastDungeonFinish < 10000) {
- if(hideChat) {
- if(text.size() > 50) text.clear();
+ if (currentTime - lastDungeonFinish > 100 && currentTime - lastDungeonFinish < 10000) {
+ if (hideChat) {
+ if (text.size() > 50) text.clear();
e.setCanceled(true);
- if(unformatted.contains("\u25AC")) {
+ if (unformatted.contains("\u25AC")) {
hideChat = false;
displayWin();
} else {
- if(unformatted.trim().length() > 0) {
+ if (unformatted.trim().length() > 0) {
text.add(e.message.getFormattedText().substring(6).trim());
}
}
} else {
- if(unformatted.contains("\u25AC")) {
+ if (unformatted.contains("\u25AC")) {
hideChat = true;
text.clear();
e.setCanceled(true);
@@ -203,54 +211,55 @@ public class DungeonWin {
}
public static void render(float partialTicks) {
- if(NotEnoughUpdates.INSTANCE.config.dungeons.dungeonWinMillis < 100 || !NotEnoughUpdates.INSTANCE.config.dungeons.enableDungeonWin) return;
+ 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);
+ 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));
+ float alpha = Math.max(0, Math.min(1, 1 - (deltaTime - maxTime + 150) / 150f));
ScaledResolution sr = Utils.pushGuiScale(2);
- if(deltaTime > 600) {
+ 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;
+ 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;
+ bottom = sr.getScaledHeight() / 6f + HEIGHT / 2;
}
- for(int i=0; i<text.size(); i++) {
+ 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)));
+ 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)) {
+ 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));
+ 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);
+ sr.getScaledWidth() / 2, textCenterY, false, (textAlpha << 24) | 0x00FFFFFF);
}
}
}
- for(Confetti c : confetti) {
+ 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);
+ 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);
}
}
@@ -258,62 +267,62 @@ public class DungeonWin {
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);
+ 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);
+ GlStateManager.translate(0, sr.getScaledHeight() / 6f, 0);
}
- if(deltaTime < 200) {
- float scale = deltaTime/200f;
+ 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;
+ } 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;
+ } 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);
+ 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;
+ 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);
+ 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.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);
+ 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) {
+ 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;
+ 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;
+ int x = -WIDTH / 2 + xIndex * SCALE_FACTOR;
+ int y = -HEIGHT / 2 + yIndex * SCALE_FACTOR;
GlStateManager.enableTexture2D();
GlStateManager.enableBlend();
@@ -327,61 +336,61 @@ public class DungeonWin {
//Left
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
worldrenderer
- .pos(x+epsilon, y+SCALE_FACTOR, 0.0D+epsilon)
+ .pos(x + epsilon, y + SCALE_FACTOR, 0.0D + epsilon)
.tex(uMin, vMax).endVertex();
worldrenderer
- .pos(x+epsilon, y, 0.0D+epsilon)
+ .pos(x + epsilon, y, 0.0D + epsilon)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x+epsilon, y, -SCALE_FACTOR*2-epsilon)
+ .pos(x + epsilon, y, -SCALE_FACTOR * 2 - epsilon)
.tex(uMax, vMin).endVertex();
worldrenderer
- .pos(x+epsilon, y+SCALE_FACTOR, -SCALE_FACTOR*2-epsilon)
+ .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)
+ .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)
+ .pos(x + SCALE_FACTOR - epsilon, y, 0.0D + epsilon)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x+SCALE_FACTOR-epsilon, y, -SCALE_FACTOR*2-epsilon)
+ .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)
+ .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)
+ .pos(x + SCALE_FACTOR, y + epsilon, 0.0D + epsilon)
.tex(uMin, vMax).endVertex();
worldrenderer
- .pos(x, y+epsilon, 0.0D+epsilon)
+ .pos(x, y + epsilon, 0.0D + epsilon)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x, y+epsilon, -SCALE_FACTOR*2-epsilon)
+ .pos(x, y + epsilon, -SCALE_FACTOR * 2 - epsilon)
.tex(uMax, vMin).endVertex();
worldrenderer
- .pos(x+SCALE_FACTOR, y+epsilon, -SCALE_FACTOR*2-epsilon)
+ .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)
+ .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)
+ .pos(x, y + SCALE_FACTOR - epsilon, 0.0D + epsilon)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x, y+SCALE_FACTOR-epsilon, -SCALE_FACTOR*2-epsilon)
+ .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)
+ .pos(x + SCALE_FACTOR, y + SCALE_FACTOR - epsilon, -SCALE_FACTOR * 2 - epsilon)
.tex(uMin, vMin).endVertex();
tessellator.draw();
@@ -395,13 +404,13 @@ public class DungeonWin {
GlStateManager.popMatrix();
- for(Confetti c : confetti) {
+ 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);
+ 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);
}
}
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..475e89e9 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,8 +29,9 @@ 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 {
@@ -45,20 +45,20 @@ public class GuiDungeonMapEditor extends GuiScreen {
private int guiLeft;
private int guiTop;
- private List<Button> buttons = new ArrayList<>();
+ private final List<Button> buttons = new ArrayList<>();
- private GuiElementTextField blurField = new GuiElementTextField("", GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
+ private final 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 final int id;
+ private final int x;
+ private final int y;
private String text;
private Color colour = new Color(-1, true);
- private Field option;
+ private final Field option;
private String displayName;
private String desc;
@@ -73,7 +73,7 @@ public class GuiDungeonMapEditor extends GuiScreen {
this.text = text;
this.option = option;
- if(option != null) {
+ if (option != null) {
ConfigOption optionAnnotation = option.getAnnotation(ConfigOption.class);
displayName = optionAnnotation.name();
desc = optionAnnotation.desc();
@@ -81,33 +81,33 @@ public class GuiDungeonMapEditor extends GuiScreen {
}
public List<String> getTooltip() {
- if(option == null) {
+ 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);
+ 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;
+ 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);
+ 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);
+ 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);
+ if (text.length() > 0) {
+ Utils.drawStringCenteredScaledMaxWidth(text, Minecraft.getMinecraft().fontRendererObj, guiLeft + x + 24, guiTop + y + 8, false, 39, 0xFF000000);
}
}
@@ -126,45 +126,45 @@ public class GuiDungeonMapEditor extends GuiScreen {
//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"));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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")));
+ 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) {
+ buttons.add(new Button(28, 84 + 139, 181, "Normal/Scroll", DungeonMapConfig.class.getDeclaredField("dmChromaBorder")));
+ } catch (Exception e) {
e.printStackTrace();
}
@@ -174,8 +174,8 @@ public class GuiDungeonMapEditor extends GuiScreen {
{
double val = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur;
String strVal;
- if(val % 1 == 0) {
- strVal = Integer.toString((int)val);
+ if (val % 1 == 0) {
+ strVal = Integer.toString((int) val);
} else {
strVal = Double.toString(val);
strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
@@ -195,46 +195,70 @@ public class GuiDungeonMapEditor extends GuiScreen {
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) {
+ 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) {
+ switch (id) {
case 6:
- mapDesc = "No Border"; break;
+ mapDesc = "No Border";
+ break;
case 7:
- mapDesc = "Used by custom Resource Packs"; break;
+ mapDesc = "Used by custom Resource Packs";
+ break;
case 8:
- mapDesc = "Simple gray border"; mapCredit = "TomEngMaster"; break;
+ mapDesc = "Simple gray border";
+ mapCredit = "TomEngMaster";
+ break;
case 9:
- mapDesc = "Viney wood border"; mapCredit = "iDevil4Hell"; break;
+ mapDesc = "Viney wood border";
+ mapCredit = "iDevil4Hell";
+ break;
case 10:
- mapDesc = "Steampunk-inspired square border"; mapCredit = "ThatGravyBoat"; break;
+ mapDesc = "Steampunk-inspired square border";
+ mapCredit = "ThatGravyBoat";
+ break;
case 11:
- mapDesc = "Steampunk-inspired circular border"; mapCredit = "ThatGravyBoat"; break;
+ mapDesc = "Steampunk-inspired circular border";
+ mapCredit = "ThatGravyBoat";
+ break;
case 12:
- mapDesc = "Light fade border"; mapCredit = "Qwiken"; break;
+ mapDesc = "Light fade border";
+ mapCredit = "Qwiken";
+ break;
case 13:
- mapDesc = "Simple gray border with red ribbons"; mapCredit = "Sai"; break;
+ mapDesc = "Simple gray border with red ribbons";
+ mapCredit = "Sai";
+ break;
case 14:
- mapDesc = "Paper border"; mapCredit = "KingJames02st"; break;
+ mapDesc = "Paper border";
+ mapCredit = "KingJames02st";
+ break;
case 15:
- mapDesc = "Nether-inspired border"; mapCredit = "DTRW191"; break;
+ mapDesc = "Nether-inspired border";
+ mapCredit = "DTRW191";
+ break;
case 16:
- mapDesc = "Golden ornate border"; mapCredit = "iDevil4Hell"; break;
+ mapDesc = "Golden ornate border";
+ mapCredit = "iDevil4Hell";
+ break;
case 17:
- mapDesc = "Stone dragon border"; mapCredit = "ImperiaL"; break;
+ 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(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);
+ 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();
@@ -246,117 +270,117 @@ public class GuiDungeonMapEditor extends GuiScreen {
this.sizeX = 431;
this.sizeY = 237;
this.guiLeft = (this.width - this.sizeX) / 2;
- this.guiTop = (this.height-this.sizeY)/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);
+ 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);
+ 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);
+ guiLeft + 76, guiTop + 30, false, 137, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Rooms Size", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+60, false, 137, 0xFFB4B4B4);
+ guiLeft + 76, guiTop + 60, false, 137, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Icon Scale", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+90, false, 137, 0xFFB4B4B4);
+ guiLeft + 76, guiTop + 90, false, 137, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Border Style", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+120, false, 137, 0xFFB4B4B4);
+ guiLeft + 76, guiTop + 120, false, 137, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+30, false, 60, 0xFFB4B4B4);
+ guiLeft + 44 + 139, guiTop + 30, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Center", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+30, false, 60, 0xFFB4B4B4);
+ guiLeft + 108 + 139, guiTop + 30, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Rotate", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+59, false, 60, 0xFFB4B4B4);
+ guiLeft + 44 + 139, guiTop + 59, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Icon Style", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+59, false, 60, 0xFFB4B4B4);
+ guiLeft + 108 + 139, guiTop + 59, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Check Orient", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+88, false, 60, 0xFFB4B4B4);
+ guiLeft + 44 + 139, guiTop + 88, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Check Center", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+88, false, 60, 0xFFB4B4B4);
+ guiLeft + 108 + 139, guiTop + 88, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Interpolation", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+117, false, 60, 0xFFB4B4B4);
+ guiLeft + 44 + 139, guiTop + 117, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Compatibility", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+117, false, 60, 0xFFB4B4B4);
+ guiLeft + 108 + 139, guiTop + 117, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Background", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+146, false, 60, 0xFFB4B4B4);
+ guiLeft + 44 + 139, guiTop + 146, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Border", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+146, false, 60, 0xFFB4B4B4);
+ guiLeft + 108 + 139, guiTop + 146, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("BG Blur", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+44+139, guiTop+175, false, 60, 0xFFB4B4B4);
+ guiLeft + 44 + 139, guiTop + 175, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Chroma Type", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+108+139, guiTop+175, false, 60, 0xFFB4B4B4);
+ guiLeft + 108 + 139, guiTop + 175, false, 60, 0xFFB4B4B4);
Utils.drawStringCenteredScaledMaxWidth("Edit Map Position", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+76, guiTop+209, false, 200, 0xFFB4B4B4);
+ 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) {
+ 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(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(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";
+ buttons.get(28 - 6).text = options.dmChromaBorder ? "Scroll" : "Normal";
blurField.setSize(48, 16);
- blurField.render(guiLeft+20+139, guiTop+181);
+ 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,
+ 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));
+ 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,
+ demoMap.renderMap(guiLeft + 357, guiTop + 125, NotEnoughUpdates.INSTANCE.colourMap, decorations, 0,
players, false, partialTicks);
- for(Button button : buttons) {
+ 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) {
+ if (tooltipToDisplay != null) {
Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, 200, Minecraft.getMinecraft().fontRendererObj);
}
Utils.pushGuiScale(-1);
- if(activeColourEditor != null) {
+ if (activeColourEditor != null) {
activeColourEditor.render();
}
}
@@ -366,30 +390,30 @@ public class GuiDungeonMapEditor extends GuiScreen {
float minValue;
float maxValue;
try {
- value = ((Number)option.get(NotEnoughUpdates.INSTANCE.config.dungeonMap)).floatValue();
+ value = ((Number) option.get(NotEnoughUpdates.INSTANCE.config.dungeonMap)).floatValue();
ConfigEditorSlider sliderAnnotation = option.getAnnotation(ConfigEditorSlider.class);
minValue = sliderAnnotation.minValue();
maxValue = sliderAnnotation.maxValue();
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
return;
}
- float sliderAmount = Math.max(0, Math.min(1, (value-minValue)/(maxValue-minValue)));
- int sliderAmountI = (int)(96*sliderAmount);
+ 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,
+ 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,
+ 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,
+ Utils.drawTexturedRect(centerX - 48 + sliderAmountI - 4, centerY - 8, 8, 16,
0, 1, 0, 1, GL11.GL_NEAREST);
}
@@ -397,31 +421,31 @@ public class GuiDungeonMapEditor extends GuiScreen {
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- if(clickedSlider != null) {
+ if (clickedSlider != null) {
float minValue;
float maxValue;
try {
ConfigEditorSlider sliderAnnotation = clickedSlider.getAnnotation(ConfigEditorSlider.class);
minValue = sliderAnnotation.minValue();
maxValue = sliderAnnotation.maxValue();
- } catch(Exception e) {
+ } 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)) {
+ 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));
+ float value = (float) Math.max(minValue, Math.min(maxValue, val));
try {
- if(clickedSlider.getType() == int.class) {
+ 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) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -430,9 +454,9 @@ public class GuiDungeonMapEditor extends GuiScreen {
@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) {
+ 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();
@@ -441,34 +465,34 @@ public class GuiDungeonMapEditor extends GuiScreen {
}
clickedSlider = null;
- if(mouseX >= guiLeft+76-48 && mouseX <= guiLeft+76+48) {
+ if (mouseX >= guiLeft + 76 - 48 && mouseX <= guiLeft + 76 + 48) {
try {
- if(mouseY > guiTop+45-8 && mouseY < guiTop+45+8) {
+ 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) {
+ } 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) {
+ } else if (mouseY > guiTop + 105 - 8 && mouseY < guiTop + 105 + 8) {
clickedSlider = DungeonMapConfig.class.getDeclaredField("dmIconScale");
return;
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
- if(mouseY > guiTop+181 && mouseY < guiTop+181+16) {
- if(mouseX > guiLeft+20+139 && mouseX < guiLeft+20+139+48) {
+ 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);
+ } 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));
+ 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<>();
@@ -478,14 +502,14 @@ public class GuiDungeonMapEditor extends GuiScreen {
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()
+ 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;
}
@@ -498,7 +522,7 @@ public class GuiDungeonMapEditor extends GuiScreen {
public void handleMouseInput() throws IOException {
super.handleMouseInput();
- if(activeColourEditor != null) {
+ 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;
@@ -510,7 +534,7 @@ public class GuiDungeonMapEditor extends GuiScreen {
public void handleKeyboardInput() throws IOException {
super.handleKeyboardInput();
- if(activeColourEditor != null) {
+ if (activeColourEditor != null) {
activeColourEditor.keyboardInput();
}
}
@@ -519,13 +543,13 @@ public class GuiDungeonMapEditor extends GuiScreen {
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
- if(blurField.getFocus()) {
+ if (blurField.getFocus()) {
blurField.keyTyped(typedChar, keyCode);
try {
blurField.setCustomBorderColour(-1);
NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBackgroundBlur = Float.parseFloat(blurField.getText());
- } catch(Exception e) {
+ } catch (Exception e) {
blurField.setCustomBorderColour(Color.RED.getRGB());
}
}
@@ -535,77 +559,94 @@ public class GuiDungeonMapEditor extends GuiScreen {
DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap;
switch (id) {
case 0:
- options.dmBorderSize = 0; break;
+ options.dmBorderSize = 0;
+ break;
case 1:
- options.dmBorderSize = 1; break;
+ options.dmBorderSize = 1;
+ break;
case 2:
- options.dmBorderSize = 2; break;
+ options.dmBorderSize = 2;
+ break;
case 30:
- options.dmBorderSize = 3; break;
+ options.dmBorderSize = 3;
+ break;
case 3:
- options.dmRoomSize = 0; break;
+ options.dmRoomSize = 0;
+ break;
case 4:
- options.dmRoomSize = 1; break;
+ options.dmRoomSize = 1;
+ break;
case 5:
- options.dmRoomSize = 2; break;
+ options.dmRoomSize = 2;
+ break;
case 29:
- options.dmRoomSize = 3; break;
+ options.dmRoomSize = 3;
+ break;
case 18:
- options.dmEnable = !options.dmEnable; break;
+ options.dmEnable = !options.dmEnable;
+ break;
case 19:
- options.dmCenterPlayer = !options.dmCenterPlayer; break;
+ options.dmCenterPlayer = !options.dmCenterPlayer;
+ break;
case 20:
- options.dmRotatePlayer = !options.dmRotatePlayer; break;
+ options.dmRotatePlayer = !options.dmRotatePlayer;
+ break;
case 21:
options.dmPlayerHeads++;
- if(options.dmPlayerHeads > 2) options.dmPlayerHeads = 0; break;
+ if (options.dmPlayerHeads > 2) options.dmPlayerHeads = 0;
+ break;
case 22:
- options.dmOrientCheck = !options.dmOrientCheck; break;
+ options.dmOrientCheck = !options.dmOrientCheck;
+ break;
case 23:
- options.dmCenterCheck = !options.dmCenterCheck; break;
+ options.dmCenterCheck = !options.dmCenterCheck;
+ break;
case 24:
- options.dmPlayerInterp = !options.dmPlayerInterp; break;
+ options.dmPlayerInterp = !options.dmPlayerInterp;
+ break;
case 25:
options.dmCompat++;
- if(options.dmCompat > 2) options.dmCompat = 0;
+ 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;
+ 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;
+ 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;
+ options.dmChromaBorder = !options.dmChromaBorder;
+ break;
default:
- if(id >= 6 && id <= 17) {
- options.dmBorderStyle = id-6; break;
+ 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) {
+ 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) {
+ } 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) {
+ } else if (id == 30) {
return options.dmBorderSize == 3;
}
return false;
@@ -619,15 +660,15 @@ public class GuiDungeonMapEditor extends GuiScreen {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
@@ -637,51 +678,52 @@ public class GuiDungeonMapEditor extends GuiScreen {
}
private double lastBgBlurFactor = -1;
+
private void blurBackground() {
- if(!OpenGlHelper.isFramebufferEnabled()) return;
+ if (!OpenGlHelper.isFramebufferEnabled()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
- if(blurOutputHorz == null) {
+ if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputVert == null) {
+ if (blurOutputVert == null) {
blurOutputVert = new Framebuffer(width, height, false);
blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ 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) {
+ if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
blurOutputVert.createBindFramebuffer(width, height);
blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- if(blurShaderHorz == null) {
+ 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) { }
+ } catch (Exception ignored) {}
}
- if(blurShaderVert == null) {
+ 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) { }
+ } 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);
+ 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();
@@ -699,12 +741,12 @@ public class GuiDungeonMapEditor extends GuiScreen {
* 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;
+ 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;
+ 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);
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..184f1ed0 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,22 +16,17 @@ 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 final String currentProfile;
private SBGamemodes.Gamemode currentGamemode = null;
- private boolean upgradeOverride;
+ private final boolean upgradeOverride;
private int guiLeft = 100;
private int guiTop = 100;
- private int xSize = 200;
- private int ySize = 232;
+ private final int xSize = 200;
+ private final int ySize = 232;
public GuiGamemodes(boolean upgradeOverride) {
this.currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
@@ -34,7 +34,7 @@ public class GuiGamemodes extends GuiScreen {
}
private boolean canChange(int from, int to) {
- if(from >= to) {
+ if (from >= to) {
return true;
} else {
return !currentGamemode.locked || upgradeOverride;
@@ -43,33 +43,33 @@ public class GuiGamemodes extends GuiScreen {
@Override
public void updateScreen() {
- if(this.currentProfile == null) {
+ if (this.currentProfile == null) {
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED+"Couldn't detect current profile. Maybe try later?"));
+ new ChatComponentText(EnumChatFormatting.RED + "Couldn't detect current profile. Maybe try later?"));
}
- if(currentGamemode == null) {
+ if (currentGamemode == null) {
currentGamemode = SBGamemodes.getGamemode();
- if(currentGamemode == null) {
+ if (currentGamemode == null) {
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED+"Couldn't automatically detect current profile." +
+ 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)) {
+ if (!this.currentProfile.equals(currentProfile)) {
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().thePlayer.addChatMessage(
- new ChatComponentText(EnumChatFormatting.RED+"Profile change detected. Closing gamemodes menu."));
+ new ChatComponentText(EnumChatFormatting.RED + "Profile change detected. Closing gamemodes menu."));
}
}
@Override
public void handleKeyboardInput() throws IOException {
- if(Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKeyState() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
SBGamemodes.saveToFile();
}
@@ -77,13 +77,13 @@ public class GuiGamemodes extends GuiScreen {
}
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)) {
+ 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());
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
}
}
}
@@ -96,51 +96,51 @@ public class GuiGamemodes extends GuiScreen {
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- if(mouseButton == 0) {
+ 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) {
+ 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) {
+ } else if (mouseY > guiTop + 50 && mouseY < guiTop + 50 + 16) {
setHC = SBGamemodes.HardcoreMode.HARDCORE;
- } else if(mouseY > guiTop+80 && mouseY < guiTop+80+16) {
+ } else if (mouseY > guiTop + 80 && mouseY < guiTop + 80 + 16) {
setIM = SBGamemodes.IronmanMode.IRONMAN;
- } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) {
+ } else if (mouseY > guiTop + 100 && mouseY < guiTop + 100 + 16) {
setIM = SBGamemodes.IronmanMode.IRONMANPLUS;
- } else if(mouseY > guiTop+120 && mouseY < guiTop+120+16) {
+ } else if (mouseY > guiTop + 120 && mouseY < guiTop + 120 + 16) {
setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMAN;
- } else if(mouseY > guiTop+140 && mouseY < guiTop+140+16) {
+ } else if (mouseY > guiTop + 140 && mouseY < guiTop + 140 + 16) {
setIM = SBGamemodes.IronmanMode.ULTIMATE_IRONMANPLUS;
- } else if(mouseY > guiTop+170 && mouseY < guiTop+170+16) {
+ } else if (mouseY > guiTop + 170 && mouseY < guiTop + 170 + 16) {
setMod = SBGamemodes.MODIFIER_DEVILISH;
- } else if(mouseY > guiTop+190 && mouseY < guiTop+190+16) {
+ } else if (mouseY > guiTop + 190 && mouseY < guiTop + 190 + 16) {
setMod = SBGamemodes.MODIFIER_NOBANK;
- } else if(mouseY > guiTop+210 && mouseY < guiTop+210+16) {
+ } else if (mouseY > guiTop + 210 && mouseY < guiTop + 210 + 16) {
setMod = SBGamemodes.MODIFIER_SMALLISLAND;
}
}
- if(setHC != SBGamemodes.HardcoreMode.NORMAL) {
- if(currentGamemode.hardcoreMode == setHC) {
+ if (setHC != SBGamemodes.HardcoreMode.NORMAL) {
+ if (currentGamemode.hardcoreMode == setHC) {
currentGamemode.hardcoreMode = SBGamemodes.HardcoreMode.NORMAL;
} else {
- if(canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) {
+ if (canChange(currentGamemode.hardcoreMode.ordinal(), setHC.ordinal())) {
currentGamemode.hardcoreMode = setHC;
}
}
- } else if(setIM != SBGamemodes.IronmanMode.NORMAL) {
- if(currentGamemode.ironmanMode == setIM) {
+ } else if (setIM != SBGamemodes.IronmanMode.NORMAL) {
+ if (currentGamemode.ironmanMode == setIM) {
currentGamemode.ironmanMode = SBGamemodes.IronmanMode.NORMAL;
} else {
- if(canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) {
+ if (canChange(currentGamemode.ironmanMode.ordinal(), setIM.ordinal())) {
currentGamemode.ironmanMode = setIM;
}
}
- } else if(setMod != 0) {
- if(canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers^setMod)) {
+ } else if (setMod != 0) {
+ if (canChange(currentGamemode.gamemodeModifiers, currentGamemode.gamemodeModifiers ^ setMod)) {
currentGamemode.gamemodeModifiers ^= setMod;
}
}
@@ -151,157 +151,157 @@ public class GuiGamemodes extends GuiScreen {
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawDefaultBackground();
- guiLeft = (width-xSize)/2;
- guiTop = (height-ySize)/2;
+ 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;
+ if (currentGamemode == null) return;
Utils.drawStringCentered("NEU Skyblock Gamemodes", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+xSize/2f, guiTop+14, false, new Color(64, 64, 64).getRGB());
+ 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.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.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);
+ 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())) {
+ 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);
+ 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) {
+ 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())) {
+ 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);
+ 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) {
+ 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())) {
+ 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);
+ 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) {
+ 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())) {
+ 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);
+ 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) {
+ 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())) {
+ 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);
+ 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) {
+ 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())) {
+ 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);
+ 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) {
+ 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)) {
+ 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);
+ 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) {
+ 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)) {
+ 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);
+ 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) {
+ 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)) {
+ 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);
+ 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) {
+ 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) {
+ if (tooltipToDisplay != null) {
List<String> lines = new ArrayList<>();
- for(String line : tooltipToDisplay.split("\n")) {
- lines.add(EnumChatFormatting.GRAY+line);
+ 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..13d44d14 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java
@@ -32,15 +32,15 @@ public class SBGamemodes {
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_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" +
+ 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" +
+ 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" +
+ 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<>();
@@ -56,15 +56,15 @@ public class SBGamemodes {
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.",
+ 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" +
+ 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;
+ private final String[] exemptions;
HardcoreMode(String display, String... exemptions) {
this.display = display.split("\n")[0];
@@ -73,8 +73,8 @@ public class SBGamemodes {
}
public boolean isExemption(String line) {
- for(String exemption : exemptions) {
- if(line.contains(exemption)) return true;
+ for (String exemption : exemptions) {
+ if (line.contains(exemption)) return true;
}
return false;
}
@@ -82,20 +82,20 @@ public class SBGamemodes {
public enum IronmanMode {
NORMAL("Normal"),
- IRONMAN(EnumChatFormatting.WHITE+"Ironman\n" +
+ 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" +
+ 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).",
+ 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" +
+ 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 are restricted to 1 inventory. (No containers, no echest, no wardrobe).",
"You ", "Auction House", "Auctions Browser", "Auction View", "Bazaar",
"Chest", "Wardrobe", "Weapon Rack", "Shelves");
@@ -110,8 +110,8 @@ public class SBGamemodes {
}
public boolean isBanned(String inventoryName) {
- for(String banned : bannedInventories) {
- if(inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true;
+ for (String banned : bannedInventories) {
+ if (inventoryName.contains(banned + " ") || inventoryName.endsWith(banned)) return true;
}
return false;
}
@@ -120,7 +120,7 @@ public class SBGamemodes {
public static Gamemode getGamemode() {
String currentProfile = SBInfo.getInstance().currentProfile;
- if(currentProfile == null || currentProfile.isEmpty()) return null;
+ if (currentProfile == null || currentProfile.isEmpty()) return null;
return currentGamemode.computeIfAbsent(currentProfile, k -> new Gamemode());
}
@@ -128,24 +128,24 @@ public class SBGamemodes {
public static void loadFromFile() {
File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
File gamemodeFile = new File(configDir,
- "gamemodes/gamemodes-"+Minecraft.getMinecraft().thePlayer.getUniqueID().toString()+".json");
+ "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json");
gamemodeFile.getParentFile().mkdirs();
- if(!gamemodeFile.exists()) {
+ if (!gamemodeFile.exists()) {
return;
}
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(gamemodeFile), StandardCharsets.UTF_8))) {
+ 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) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
public static class GamemodeWrapper {
- private HashMap<String, Gamemode> currentGamemode;
+ private final HashMap<String, Gamemode> currentGamemode;
public GamemodeWrapper(HashMap<String, Gamemode> currentGamemode) {
this.currentGamemode = currentGamemode;
@@ -155,18 +155,18 @@ public class SBGamemodes {
public static void saveToFile() {
File configDir = NotEnoughUpdates.INSTANCE.manager.configLocation;
File gamemodeFile = new File(configDir,
- "gamemodes/gamemodes-"+Minecraft.getMinecraft().thePlayer.getUniqueID().toString()+".json");
+ "gamemodes/gamemodes-" + Minecraft.getMinecraft().thePlayer.getUniqueID().toString() + ".json");
gamemodeFile.getParentFile().mkdirs();
try {
gamemodeFile.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(
+ 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) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -181,7 +181,6 @@ public class SBGamemodes {
return key;
}
-
public static String encrypt(String value) {
try {
Cipher cipher = Cipher.getInstance("AES");
@@ -211,27 +210,27 @@ public class SBGamemodes {
public static void setGamemode(Gamemode gamemode) {
String currentProfile = NotEnoughUpdates.INSTANCE.manager.getCurrentProfile();
- if(currentProfile == null || currentProfile.isEmpty()) return;
+ if (currentProfile == null || currentProfile.isEmpty()) return;
currentGamemode.put(currentProfile, gamemode);
}
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
- if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(!"Your Island".equals(SBInfo.getInstance().location)) 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) {
+ 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()+
+ 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)"));
+ EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" +
+ EnumChatFormatting.AQUA + " if you would like to build further out)"));
event.setCanceled(true);
}
@@ -243,65 +242,61 @@ public class SBGamemodes {
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase != TickEvent.Phase.START) return;
- if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) 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;
- }
+ getGamemode().locked = !(EnumChatFormatting.YELLOW + "Break a log").equals(SBInfo.getInstance().objective);
IronmanMode ironmanMode = getGamemode().ironmanMode;
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
- if(gui instanceof GuiChest) {
+ 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) {
+ 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()+
+ 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.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)"));
+ 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) {
+ } 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()+
+ 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)) {
+ 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"));
+ EnumChatFormatting.AQUA + "You cannot access this inventory/menu because of your"));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(
- " "+ironmanMode.display + EnumChatFormatting.AQUA+" status!"));
+ " " + 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)"));
+ EnumChatFormatting.AQUA + "(Use " + EnumChatFormatting.YELLOW + "/neugamemodes" +
+ EnumChatFormatting.AQUA + " if you would like to downgrade the status)"));
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(""));
}
}
@@ -309,7 +304,7 @@ public class SBGamemodes {
@SubscribeEvent
public void onChatMessage(ClientChatReceivedEvent event) {
- if(event.type != 0) return;
+ if (event.type != 0) return;
/*if(Keyboard.isKeyDown(Keyboard.KEY_K)) {
boolean has = false;
@@ -322,26 +317,26 @@ public class SBGamemodes {
}
if(has) System.out.println("-----END");
}*/
- if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
String message = event.message.getFormattedText();
- if(message.contains("\u2620")) { //Death symbol ( ☠ )
+ if (message.contains("\u2620")) { //Death symbol ( ☠ )
HardcoreMode hardcoreMode = getGamemode().hardcoreMode;
- if(hardcoreMode != HardcoreMode.NORMAL) {
- if(hardcoreMode.isExemption(message)) {
+ 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) {
+ 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"));
+ 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..d8e4ef68 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;
@@ -28,8 +27,8 @@ 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]$";
+ private final String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$";
+ private final String petRegex = ".*?;[0-4]$";
TreeSet<String> items = new TreeSet<>(getItemComparator());
@@ -52,8 +51,8 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
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 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;
@@ -68,43 +67,47 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
}
private boolean loreContains(JsonArray lore, String str) {
- for(int i=0; i<lore.size(); i++) {
+ for (int i = 0; i < lore.size(); i++) {
String line = lore.get(i).getAsString();
- if(line.contains(str)) return true;
+ 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)) {
+ 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) {
+ switch (filterMode) {
case FILTER_WEAPON:
- if(overlay.checkItemType(lore, "SWORD", "BOW", "WAND") < 0) continue;
+ if (overlay.checkItemType(lore, "SWORD", "BOW", "WAND") < 0) continue;
break;
case FILTER_ARMOR:
- if(overlay.checkItemType(lore, "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS") < 0) continue;
+ if (overlay.checkItemType(lore, "HELMET", "CHESTPLATE", "LEGGINGS", "BOOTS") < 0) continue;
break;
case FILTER_ACCESSORY:
- if(overlay.checkItemType(lore, "ACCESSORY") < 0) continue;
+ if (overlay.checkItemType(lore, "ACCESSORY") < 0) continue;
break;
case FILTER_PET:
- if(!internalname.matches(petRegex) || !item.get("displayname").getAsString().contains("[")) continue;
+ if (!internalname.matches(petRegex) || !item.get("displayname").getAsString().contains("["))
+ continue;
break;
case FILTER_DUNGEON:
- if(Utils.checkItemType(lore, true, "DUNGEON") < 0) continue;
+ 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;
+ 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;
+ 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;
+ if (!item.has("slayer_req") || !item.get("slayer_req").getAsString().startsWith("SPIDER"))
+ continue;
break;
}
items.add(internalname);
@@ -121,11 +124,11 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
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 == -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;
+ if (cost1 < cost2) return 1;
+ if (cost1 > cost2) return -1;
return o1.compareTo(o2);
};
@@ -133,17 +136,17 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
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) {
+ if (mouseDown) {
+ if (buttonHover == 0) {
+ if (Mouse.getEventButton() == 0) {
filterMode++;
- if(filterMode >= filterPrettyNames.length) {
+ if (filterMode >= filterPrettyNames.length) {
filterMode = 0;
}
- } else if(Mouse.getEventButton() == 1) {
+ } else if (Mouse.getEventButton() == 1) {
filterMode--;
- if(filterMode < 0) {
- filterMode = filterPrettyNames.length-1;
+ if (filterMode < 0) {
+ filterMode = filterPrettyNames.length - 1;
}
}
}
@@ -152,32 +155,32 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
}
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 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);
+ 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 &&
+ for (String item : items) {
+ if (getAcquiredItems() != null &&
getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
getAcquiredItems().get(manager.getCurrentProfile()).contains(item)) {
own++;
}
}
- return own/(float)total;
+ return own / (float) total;
}
- private EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
+ private final EnumChatFormatting[] rainbow = new EnumChatFormatting[]{
EnumChatFormatting.RED,
EnumChatFormatting.GOLD,
EnumChatFormatting.YELLOW,
@@ -189,13 +192,13 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
private String getCompletednessString() {
float completedness = getCompletedness();
- String text = (int)(completedness*100)+"% Complete";
- if(completedness >= 1) {
+ String text = (int) (completedness * 100) + "% Complete";
+ if (completedness >= 1) {
StringBuilder rainbowText = new StringBuilder();
- for(int i=0; i<text.length(); i++) {
+ 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;
+ int index = (int) (i - System.currentTimeMillis() / 100) % rainbow.length;
+ if (index < 0) index += rainbow.length;
rainbowText.append(rainbow[index]).append(c);
}
text = rainbowText.toString();
@@ -211,39 +214,39 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
buttonHover = -1;
- int totalAvailable = right-left;
+ int totalAvailable = right - left;
int controlPadding = 3;
String[] controls = new String[]{
- "Filter: "+filterPrettyNames[filterMode],
+ "Filter: " + filterPrettyNames[filterMode],
getCompletednessString()};
int numControls = controls.length;
- int available = totalAvailable-(numControls-1)*controlPadding;
- int controlSize = available/numControls;
- int extraPadding = (available%controlSize)/2;
+ 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;
+ 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) {
+ 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());
+ 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());
+ 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;
+ if (getAcquiredItems() == null) return 0;
+ if (!getAcquiredItems().containsKey(manager.getCurrentProfile())) return 0;
return getAcquiredItems().get(manager.getCurrentProfile()).size();
}
@@ -253,10 +256,10 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
- if(itemFramebuffer != null && grayscaleShader != null &&
+ if (itemFramebuffer != null && grayscaleShader != null &&
(itemFramebuffer.framebufferWidth != width || itemFramebuffer.framebufferHeight != height)) {
grayscaleShader.setProjectionMatrix(Utils.createProjectionMatrix(
- width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor()));
+ width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor()));
}
itemFramebuffer = checkFramebufferSizes(itemFramebuffer, width, height,
@@ -282,14 +285,14 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
renderFromImage(itemBGFramebuffer, width, height, left, right, top, bottom);
renderFromImage(itemFramebuffer, width, height, left, right, top, bottom);
- if(grayscaleShader == null) {
+ 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) {
+ width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor()));
+ } catch (Exception e) {
return;
}
}
@@ -313,46 +316,45 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
iterateItemSlots(new ItemSlotConsumer() {
@Override
public void consume(int x, int y, int id) {
- if(id < items.length) {
+ if (id < items.length) {
String internalname = items[id];
- if(id == 0) isTop.set(true);
+ if (id == 0) isTop.set(true);
- int leftI = x-1;
- int rightI = x+17;
- int topI = y-1;
- int bottomI = y+17;
+ 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) {
+ if (mouseX > leftI && mouseX < rightI) {
+ if (mouseY > topI && mouseY < bottomI) {
tooltipToDisplay.set(manager.jsonToStack(manager.getItemInformation().get(internalname), true));
}
}
- if(getAcquiredItems() != null &&
+ 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);
+ 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);
+ }, left + 5, right, top + 1, bottom);
- if(!isTop.get()) {
- if(lowestY.get() == -1) {
+ if (!isTop.get()) {
+ if (lowestY.get() == -1) {
scrollHeight.setValue(0);
} else {
int dist = bottom - lowestY.get() - 10;
- if(dist > 0) {
+ if (dist > 0) {
scrollHeight.setValue(scrollHeight.getValue() - dist);
}
}
@@ -361,7 +363,7 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
itemFramebufferGrayscale.unbindFramebufferTexture();
ItemStack displayStack = tooltipToDisplay.get();
- if(displayStack != null) {
+ if (displayStack != null) {
List<String> text = displayStack.getTooltip(Minecraft.getMinecraft().thePlayer, true);
Utils.drawHoveringText(text, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
}
@@ -369,8 +371,8 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
private String[] getItemList() {
String[] items_arr = new String[items.size()];
- int i=0;
- for(String internalname : items) {
+ int i = 0;
+ for (String internalname : items) {
items_arr[i++] = internalname;
}
return items_arr;
@@ -384,7 +386,7 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
String[] items = getItemList();
iterateItemSlots(new ItemSlotConsumer() {
public void consume(int x, int y, int id) {
- if(id < items.length) {
+ if (id < items.length) {
String internalname = items[id];
ItemStack stack = manager.jsonToStack(manager.getItemInformation().get(internalname));
@@ -401,11 +403,11 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
String[] items = getItemList();
iterateItemSlots(new ItemSlotConsumer() {
public void consume(int x, int y, int id) {
- if(id < items.length) {
+ if (id < items.length) {
String internalname = items[id];
Color color = fgCustomOpacity;
- if(getAcquiredItems() != null &&
+ if (getAcquiredItems() != null &&
getAcquiredItems().containsKey(manager.getCurrentProfile()) &&
getAcquiredItems().get(manager.getCurrentProfile()).contains(internalname)) {
color = fgGold;
@@ -430,11 +432,11 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
* itemPane should be redrawn.
*/
private Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height, int scaleFactor) {
- int sw = width*scaleFactor;
- int sh = height*scaleFactor;
+ int sw = width * scaleFactor;
+ int sh = height * scaleFactor;
- if(framebuffer == null || framebuffer.framebufferWidth != sw || framebuffer.framebufferHeight != sh) {
- if(framebuffer == null) {
+ if (framebuffer == null || framebuffer.framebufferWidth != sw || framebuffer.framebufferHeight != sh) {
+ if (framebuffer == null) {
framebuffer = new Framebuffer(sw, sh, true);
} else {
framebuffer.createBindFramebuffer(sw, sh);
@@ -471,27 +473,27 @@ public class CollectionLogInfoPane extends ScrollableInfoPane {
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);
+ 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 {
+ 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 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) {
+ 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()) {
+ if (++id >= items.size()) {
return;
}
}
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..4c17b8d7 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,7 +22,9 @@ 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;
@@ -60,9 +61,9 @@ public class DevInfoPane extends TextInfoPane {
}*/
//if(true) return text;
- for(String internalname : manager.auctionManager.getItemAuctionInfoKeySet()) {
+ for (String internalname : manager.auctionManager.getItemAuctionInfoKeySet()) {
if (internalname.matches("^.*-[0-9]{1,3}$")) continue;
- if(!manager.getItemInformation().containsKey(internalname)) {
+ if (!manager.getItemInformation().containsKey(internalname)) {
text += internalname + "\n";
}
}
@@ -87,7 +88,7 @@ public class DevInfoPane extends TextInfoPane {
AtomicBoolean running = new AtomicBoolean(false);
ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
- String[] bukkitList = new String[] {
+ String[] bukkitList = new String[]{
"ACACIA_DOOR_ITEM",
"ACACIA_FENCE",
"ACACIA_FENCE_GATE",
@@ -424,116 +425,116 @@ public class DevInfoPane extends TextInfoPane {
};
private void addStack(ItemStack stackToAdd, int depth) {
- if(depth > 16) return;
+ if (depth > 16) return;
String regName2 = stackToAdd.getItem().getRegistryName().replace("minecraft:", "");
String internalname = null;
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName2) ||
+ 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 (internalname == null) return;
- if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
+ if (stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
internalname += "-" + stackToAdd.getItemDamage();
}
- if(manager.getItemInformation().containsKey(internalname)) return;
+ if (manager.getItemInformation().containsKey(internalname)) return;
JsonObject recipeJson = null;
- for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
+ for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
ItemStack out = recipe.getRecipeOutput();
- if(out != null && out.getItem() == stackToAdd.getItem() &&
+ 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[] 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) {
+ 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() ||
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
(stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth+1);
+ addStack(stack, depth + 1);
}
Item stackItem = stack.getItem();
String regName = stackItem.getRegistryName().replace("minecraft:", "");
- for(String bukkit2 : bukkitList) {
- if(bukkit2.equalsIgnoreCase(regName) ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
- stacki += ":"+stack.stackSize;
+ stacki += ":" + stack.stackSize;
}
}
}
- recipeJson.addProperty(y[yi]+x[xi], stacki);
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
}
break;
- } else if(recipe instanceof ShapedOreRecipe) {
+ } 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;
+ 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()) {
+ if (recipeIndex < shaped.getRecipeSize()) {
Object o = shaped.getInput()[recipeIndex];
- if(o instanceof ItemStack) {
+ if (o instanceof ItemStack) {
stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
+ } 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() ||
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
(stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth+1);
+ 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") ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
//stacki += ":"+stack.stackSize;
@@ -542,38 +543,38 @@ public class DevInfoPane extends TextInfoPane {
}
}
- recipeJson.addProperty(y[yi]+x[xi], stacki);
+ 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[] 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()) {
+ if (i < shapeless.recipeItems.size()) {
stack = shapeless.recipeItems.get(i);
}
- if(stack != null) {
- if(stack.getItem() != stackToAdd.getItem() ||
+ 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") ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
//stacki += ":"+stack.stackSize;
@@ -581,49 +582,49 @@ public class DevInfoPane extends TextInfoPane {
}
}
- recipeJson.addProperty(y[yi]+x[xi], stacki);
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
}
break;
- } else if (recipe instanceof ShapelessOreRecipe) {
+ } 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[] 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()) {
+ if (i < shapeless.getRecipeSize()) {
Object o = shapeless.getInput().get(i);
- if(o instanceof ItemStack) {
+ if (o instanceof ItemStack) {
stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
+ } 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() ||
+ if (stack != null) {
+ if (stack.getItem() != stackToAdd.getItem() ||
(stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) {
- addStack(stack, depth+1);
+ 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") ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
//stacki += ":"+stack.stackSize;
@@ -631,7 +632,7 @@ public class DevInfoPane extends TextInfoPane {
}
}
- recipeJson.addProperty(y[yi]+x[xi], stacki);
+ recipeJson.addProperty(y[yi] + x[xi], stacki);
}
break;
}
@@ -639,9 +640,9 @@ public class DevInfoPane extends TextInfoPane {
}
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) {
+ 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);
@@ -649,9 +650,8 @@ public class DevInfoPane extends TextInfoPane {
ea.setString("id", internalname);
res.getTagCompound().setTag("ExtraAttributes", ea);
-
JsonObject json = manager.getJsonForItem(res);
- if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
+ if (stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) {
json.addProperty("parent", internalname.split("-")[0]);
}
@@ -659,7 +659,7 @@ public class DevInfoPane extends TextInfoPane {
json.addProperty("modver", NotEnoughUpdates.VERSION);
json.addProperty("vanilla", true);
- if(recipeJson != null) {
+ if (recipeJson != null) {
json.add("recipe", recipeJson);
json.addProperty("clickcommand", "viewrecipe");
} else {
@@ -670,34 +670,34 @@ public class DevInfoPane extends TextInfoPane {
try {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
- manager.writeJsonDefaultDir(json, internalname+".json");
+ manager.writeJsonDefaultDir(json, internalname + ".json");
manager.loadItem(internalname);
- } catch(IOException e) {}
+ } catch (IOException ignored) {}
}
@Override
public boolean keyboardInput() {
- if(running.get() || true) return false;
- if(Keyboard.isKeyDown(Keyboard.KEY_J)) {
+ if (running.get() || true) return false;
+ if (Keyboard.isKeyDown(Keyboard.KEY_J)) {
running.set(!running.get());
- for(String bukkit : bukkitList) {
+ for (String bukkit : bukkitList) {
String internalname = bukkit.split("@")[0];
- if(true || !manager.getItemInformation().containsKey(internalname)) {
+ if (true || !manager.getItemInformation().containsKey(internalname)) {
//System.out.println("adding vanilla: " + internalname);
String vanilla = internalname.toLowerCase().replace("_item", "");
- if(bukkit.contains("@")) {
+ if (bukkit.contains("@")) {
vanilla = bukkit.split("@")[1];
}
Item item = Item.itemRegistry.getObject(new ResourceLocation(vanilla));
- if(item == null) {
+ if (item == null) {
item = Item.getItemFromBlock(Block.blockRegistry.getObject(new ResourceLocation(vanilla)));
}
- if(item != null) {
+ if (item != null) {
HashMap<Integer, JsonObject> recipeJsonForDamage = new HashMap<>();
- for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
+ for (IRecipe recipe : CraftingManager.getInstance().getRecipeList()) {
ItemStack out = recipe.getRecipeOutput();
- if(out != null && out.getItem() == item) {
+ if (out != null && out.getItem() == item) {
System.out.println("Found recipe for : " + internalname + ":" + recipe);
JsonObject obj = new JsonObject();
@@ -738,46 +738,46 @@ public class DevInfoPane extends TextInfoPane {
obj.addProperty(y[yi] + x[xi], stacki);
}
recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
- } else if(recipe instanceof ShapedOreRecipe) {
+ } 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;
+ 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()) {
+ if (recipeIndex < shaped.getRecipeSize()) {
Object o = shaped.getInput()[recipeIndex];
- if(o instanceof ItemStack) {
+ if (o instanceof ItemStack) {
stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
+ } else if (o instanceof List<?>) {
+ for (Object o2 : (List<?>) o) {
+ if (o2 instanceof ItemStack) {
stack = (ItemStack) o2;
break;
}
}
}
}
- if(stack != null) {
+ 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") ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
//stacki += ":"+stack.stackSize;
@@ -786,36 +786,36 @@ public class DevInfoPane extends TextInfoPane {
}
}
- obj.addProperty(y[yi]+x[xi], stacki);
+ obj.addProperty(y[yi] + x[xi], stacki);
}
- recipeJsonForDamage.put(out.getItemDamage()>32000?0:out.getItemDamage(), obj);
+ 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[] 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()) {
+ if (i < shapeless.recipeItems.size()) {
stack = shapeless.recipeItems.get(i);
}
- if(stack != null) {
+ 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") ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
//stacki += ":"+stack.stackSize;
@@ -823,47 +823,47 @@ public class DevInfoPane extends TextInfoPane {
}
}
- obj.addProperty(y[yi]+x[xi], stacki);
+ obj.addProperty(y[yi] + x[xi], stacki);
}
recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
break;
- } else if (recipe instanceof ShapelessOreRecipe) {
+ } 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[] 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()) {
+ if (i < shapeless.getRecipeSize()) {
Object o = shapeless.getInput().get(i);
- if(o instanceof ItemStack) {
+ if (o instanceof ItemStack) {
stack = (ItemStack) o;
- } else if(o instanceof List<?>) {
- for(Object o2 : (List<?>)o) {
- if(o2 instanceof ItemStack) {
+ } else if (o instanceof List<?>) {
+ for (Object o2 : (List<?>) o) {
+ if (o2 instanceof ItemStack) {
stack = (ItemStack) o2;
break;
}
}
}
}
- if(stack != null) {
+ 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") ||
+ 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) {
+ if (!stacki.isEmpty()) {
+ if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) {
stacki += "-" + stack.getItemDamage();
}
//stacki += ":"+stack.stackSize;
@@ -871,7 +871,7 @@ public class DevInfoPane extends TextInfoPane {
}
}
- obj.addProperty(y[yi]+x[xi], stacki);
+ obj.addProperty(y[yi] + x[xi], stacki);
}
recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj);
break;
@@ -879,10 +879,10 @@ public class DevInfoPane extends TextInfoPane {
}
}
- if(recipeJsonForDamage.isEmpty()) {
+ if (recipeJsonForDamage.isEmpty()) {
ItemStack res = Utils.createItemStack(item,
- EnumChatFormatting.WHITE+item.getItemStackDisplayName(new ItemStack(item)),
- EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON");
+ 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);
@@ -897,15 +897,15 @@ public class DevInfoPane extends TextInfoPane {
json.addProperty("clickcommand", "");
try {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname));
- manager.writeJsonDefaultDir(json, internalname+".json");
+ manager.writeJsonDefaultDir(json, internalname + ".json");
manager.loadItem(internalname);
- } catch(IOException e) {}
+ } catch (IOException ignored) {}
} else {
System.out.println("writing with recipe:" + internalname);
- for(Map.Entry<Integer, JsonObject> entry : recipeJsonForDamage.entrySet()) {
+ 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");
+ 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();
@@ -914,8 +914,8 @@ public class DevInfoPane extends TextInfoPane {
JsonObject json = manager.getJsonForItem(res);
- if(entry.getKey() != 0 && entry.getKey() < 32000) {
- json.addProperty("internalname", internalname+"-"+entry.getKey());
+ if (entry.getKey() != 0 && entry.getKey() < 32000) {
+ json.addProperty("internalname", internalname + "-" + entry.getKey());
json.addProperty("parent", internalname);
} else {
json.addProperty("internalname", internalname);
@@ -927,13 +927,13 @@ public class DevInfoPane extends TextInfoPane {
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");
+ if (entry.getKey() != 0 && entry.getKey() < 32000) {
+ manager.writeJsonDefaultDir(json, internalname + "-" + entry.getKey() + ".json");
} else {
- manager.writeJsonDefaultDir(json, internalname+".json");
+ manager.writeJsonDefaultDir(json, internalname + ".json");
}
manager.loadItem(internalname);
- } catch(IOException e) {}
+ } catch (IOException ignored) {}
}
}
}
@@ -1009,7 +1009,7 @@ public class DevInfoPane extends TextInfoPane {
} catch(IOException e){}
manager.loadItem(item.getKey());
}*/
- }
+ }
/*if(running.get()) {
List<String> add = new ArrayList<>();
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..2626bcad 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/FlipperInfoPane.java
@@ -2,18 +2,20 @@ 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.*;
+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;
+
public class FlipperInfoPane extends InfoPane {
/**
@@ -40,12 +42,12 @@ public class FlipperInfoPane extends InfoPane {
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 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,
+ fr.drawString(title, (leftSide + rightSide - titleLen) / 2, overlay.getBoxPadding() + 5,
Color.WHITE.getRGB());
int y = 0;
@@ -64,16 +66,19 @@ public class FlipperInfoPane extends InfoPane {
y += 10;
int x = 10;
fr.drawString("Min Price: ", x, y, Color.WHITE.getRGB());
- minPrice.render(x, y+10); x += 70;
+ minPrice.render(x, y + 10);
+ x += 70;
fr.drawString("Max Price: ", x, y, Color.WHITE.getRGB());
- maxPrice.render(x, y+10); x += 70;
+ maxPrice.render(x, y + 10);
+ x += 70;
fr.drawString("Price Diff: ", x, y, Color.WHITE.getRGB());
- priceDiff.render(x, y+10); x += 70;
+ 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());
+ 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) {
@@ -93,15 +98,15 @@ public class FlipperInfoPane extends InfoPane {
private int renderParagraph(int width, int height, int startY, String text, Color bg) {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
+ 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);
+ 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;
}
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..a8a98880 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;
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
public class HTMLInfoPane extends TextInfoPane {
- private static WikiModel wikiModel;
+ private static final WikiModel wikiModel;
private final int ZOOM_FACTOR = 2;
private final int IMAGE_WIDTH = 400;
@@ -49,7 +49,7 @@ public class HTMLInfoPane extends TextInfoPane {
private static boolean hasAttemptedDownload = false;
- /**
+ /*
* Creates a wiki model and sets the configuration to work with hypixel-skyblock wikia.
*/
static {
@@ -57,11 +57,11 @@ public class HTMLInfoPane extends TextInfoPane {
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("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}",
+ wikiModel = new WikiModel(conf, "https://hypixel-skyblock.fandom.com/wiki/Special:Filepath/${image}",
"https://hypixel-skyblock.fandom.com/wiki/${title}") {
{
TagNode.addAllowedAttribute("style");
@@ -82,7 +82,7 @@ public class HTMLInfoPane extends TextInfoPane {
public void parseInternalImageLink(String imageNamespace, String rawImageLink) {
rawImageLink = rawImageLink.replaceFirst("\\|x([0-9]+)px", "\\|$1x$1px");
- if(!rawImageLink.split("\\|")[0].toLowerCase().endsWith(".jpg")) {
+ if (!rawImageLink.split("\\|")[0].toLowerCase().endsWith(".jpg")) {
super.parseInternalImageLink(imageNamespace, rawImageLink);
}
}
@@ -95,19 +95,19 @@ public class HTMLInfoPane extends TextInfoPane {
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);
- };
+ 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(
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(f), StandardCharsets.UTF_8))) {
String l;
- while((l = br.readLine()) != null){
+ 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);
+ } 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());
}
@@ -127,18 +127,16 @@ public class HTMLInfoPane extends TextInfoPane {
wiki = "__NOTOC__\n" + wiki; //Remove TOC
try (PrintWriter out = new PrintWriter(new File(manager.configLocation, "debug/parsed.txt"))) {
out.println(wiki);
- } catch (IOException e) {
- }
+ } catch (IOException ignored) {}
String html;
try {
html = wikiModel.render(wiki);
- } catch(IOException e) {
+ } 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) {
- }
+ } catch (IOException ignored) {}
return new HTMLInfoPane(overlay, manager, name, filename, html);
}
@@ -159,44 +157,43 @@ public class HTMLInfoPane extends TextInfoPane {
this.title = name;
String osId;
- if(SystemUtils.IS_OS_WINDOWS) {
+ if (SystemUtils.IS_OS_WINDOWS) {
osId = "win";
- } else if(SystemUtils.IS_OS_MAC) {
+ } else if (SystemUtils.IS_OS_MAC) {
osId = "mac";
- } else if(SystemUtils.IS_OS_LINUX) {
+ } else if (SystemUtils.IS_OS_LINUX) {
osId = "linux";
} else {
- text = EnumChatFormatting.RED+"Unsupported operating system.";
+ 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");
+ 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) {
+ 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() };
+ 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) {}
+ } catch (IOException | InterruptedException ignored) {}
- if(!wkHtmlToImage.exists()) {
- if(hasAttemptedDownload) {
- text = EnumChatFormatting.RED+"Downloading web renderer failed? Or still downloading? Not sure what to do";
- return;
+ 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));
+ 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");
+ 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);
@@ -204,8 +201,8 @@ public class HTMLInfoPane extends TextInfoPane {
FileUtils.copyInputStreamToFile(urlConnection.getInputStream(), itemsZip);
}
- try(InputStream is = new FileInputStream(itemsZip)) {
- manager.unzip(is, manager.configLocation);
+ try (InputStream is = new FileInputStream(itemsZip)) {
+ NEUManager.unzip(is, manager.configLocation);
}
itemsZip.delete();
@@ -215,53 +212,53 @@ public class HTMLInfoPane extends TextInfoPane {
}
});
- text = EnumChatFormatting.YELLOW+"Downloading web renderer... try again soon";
- return;
+ 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");
+ 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()) {
+ if (!tmp.exists()) {
tmp.mkdir();
}
- if(output.exists()) {
+ if (output.exists()) {
try {
imageTemp = ImageIO.read(output);
- text = EnumChatFormatting.RED+"Creating dynamic texture.";
- } catch(IOException e) {
+ text = EnumChatFormatting.RED + "Creating dynamic texture.";
+ } catch (IOException e) {
e.printStackTrace();
- text = EnumChatFormatting.RED+"Failed to read image.";
+ 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;
+ 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(
+ try (PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(input), StandardCharsets.UTF_8)), false)) {
out.println(encodeNonAscii(html));
- } catch(IOException e) {}
+ } catch (IOException ignored) {}
try {
- text = EnumChatFormatting.GRAY+"Rendering webpage (" + name + EnumChatFormatting.RESET+
- EnumChatFormatting.GRAY+"), please wait...";
+ 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()};
+ 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()) +
@@ -274,9 +271,9 @@ public class HTMLInfoPane extends TextInfoPane {
"\" \"" + outputExt.getAbsolutePath() + "\"");*/
rendererES.submit(() -> {
try {
- if(p.waitFor(15, TimeUnit.SECONDS)) {
+ if (p.waitFor(15, TimeUnit.SECONDS)) {
//if(p2.waitFor(5, TimeUnit.SECONDS)) {
- if(overlay.getActiveInfoPane() != this) return;
+ if (overlay.getActiveInfoPane() != this) return;
try {
imageTemp = ImageIO.read(output);
@@ -307,24 +304,24 @@ public class HTMLInfoPane extends TextInfoPane {
imageTemp.setRGB(x, y, col);
}
}*/
- text = EnumChatFormatting.RED+"Creating dynamic texture.";
- } catch(IOException e) {
+ text = EnumChatFormatting.RED + "Creating dynamic texture.";
+ } catch (IOException e) {
e.printStackTrace();
- text = EnumChatFormatting.RED+"Failed to read image.";
+ text = EnumChatFormatting.RED + "Failed to read image.";
return;
}
} else {
- if(overlay.getActiveInfoPane() != this) return;
+ if (overlay.getActiveInfoPane() != this) return;
- text = EnumChatFormatting.RED+"Webpage render timed out (>15sec). Maybe it's too large?";
+ text = EnumChatFormatting.RED + "Webpage render timed out (>15sec). Maybe it's too large?";
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
});
- } catch(IOException e) {
+ } catch (IOException e) {
e.printStackTrace();
- text = EnumChatFormatting.RED+"Failed to exec webpage renderer.";
+ text = EnumChatFormatting.RED + "Failed to exec webpage renderer.";
}
}
}
@@ -334,51 +331,51 @@ public class HTMLInfoPane extends TextInfoPane {
*/
@Override
public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) {
- if(imageTemp != null && imageTexture == null) {
+ 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) {
+ 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 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());
+ 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());
+ 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;
+ 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));
+ 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,
+ 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));
+ Utils.drawTexturedRect(leftSide + overlay.getBoxPadding(), overlay.getBoxPadding() * 2, imageW,
+ (int) (imageHeight / scaleF));
}
GlStateManager.bindTexture(0);
}
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..945b1bbf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java
@@ -9,7 +9,7 @@ import net.minecraft.client.gui.ScaledResolution;
import java.awt.*;
-public abstract class InfoPane extends Gui {
+public abstract class InfoPane extends Gui {
final NEUOverlay overlay;
final NEUManager manager;
@@ -24,16 +24,17 @@ public abstract class InfoPane extends Gui {
public void tick() {}
public abstract void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX,
- int mouseY);
+ int mouseY);
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 void renderDefaultBackground(int width, int height, Color bg) {
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
+ int paneWidth = (int) (width / 3 * overlay.getWidthMult());
+ int rightSide = (int) (width * overlay.getInfoPaneOffsetFactor());
int leftSide = rightSide - paneWidth;
int boxLeft = leftSide + overlay.getBoxPadding() - 5;
@@ -41,8 +42,8 @@ public abstract class InfoPane extends Gui {
BackgroundBlur.renderBlurredBackground(NotEnoughUpdates.INSTANCE.config.itemlist.bgBlurFactor,
width, height,
- boxLeft, overlay.getBoxPadding()-5,
- boxRight-boxLeft, height-overlay.getBoxPadding()*2+10, true);
+ boxLeft, overlay.getBoxPadding() - 5,
+ boxRight - boxLeft, height - overlay.getBoxPadding() * 2 + 10, true);
drawRect(boxLeft, overlay.getBoxPadding() - 5, boxRight,
height - overlay.getBoxPadding() + 5, bg.getRGB());
}
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..fd10d707 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/ScrollableInfoPane.java
@@ -16,18 +16,18 @@ public abstract class ScrollableInfoPane extends InfoPane {
public void tick() {
scrollHeight.tick();
- if(scrollHeight.getValue() < 0) scrollHeight.setValue(0);
+ 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();
- if(dWheel < 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()+SCROLL_AMOUNT);
+ if (dWheel < 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() + SCROLL_AMOUNT);
scrollHeight.resetTimer();
- } else if(dWheel > 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()-SCROLL_AMOUNT);
+ } 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..1761abb3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/TextInfoPane.java
@@ -23,32 +23,32 @@ public class TextInfoPane extends ScrollableInfoPane {
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 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,
+ 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);
+ 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);
+ 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));
+ 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());
+ drawRect(leftSide + overlay.getBoxPadding() - 5, yScroll + overlay.getBoxPadding() - 5,
+ rightSide - overlay.getBoxPadding() + 5, yScroll + bottom, bg.getRGB());
}
public boolean keyboardInput() {
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..326e94a6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElement.java
@@ -5,11 +5,17 @@ import net.minecraft.client.gui.Gui;
public abstract class GuiElement extends Gui {
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) {}
}
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..017b61c9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementButton.java
@@ -4,7 +4,7 @@ import java.awt.*;
public class GuiElementButton extends GuiElementText {
- private Runnable callback;
+ private final Runnable callback;
public GuiElementButton(String text, int colour, Runnable callback) {
super(text, colour);
@@ -28,8 +28,8 @@ public class GuiElementButton extends GuiElementText {
@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);
+ 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..659d6859 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementText.java
@@ -6,7 +6,7 @@ import net.minecraft.client.gui.FontRenderer;
public class GuiElementText extends GuiElement {
protected String text;
- private int colour;
+ private final int colour;
public GuiElementText(String text, int colour) {
this.text = text;
@@ -36,7 +36,7 @@ public class GuiElementText extends GuiElement {
public void render(int x, int y) {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- fr.drawString(text, x, y+6, colour);
+ 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..0d2ef232 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
@@ -34,8 +34,8 @@ public class GuiElementTextField extends GuiElement {
private String prependText = "";
- private GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
- 0 , 0, 0, 0);
+ private final GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj,
+ 0, 0, 0, 0);
private int customBorderColour = -1;
@@ -64,13 +64,13 @@ public class GuiElementTextField extends GuiElement {
}
public void setText(String text) {
- if(textField.getText() == null || !textField.getText().equals(text)) {
+ if (textField.getText() == null || !textField.getText().equals(text)) {
textField.setText(text);
}
}
public void setSize(int searchBarXSize, int searchBarYSize) {
- this.searchBarXSize = searchBarXSize;
+ this.searchBarXSize = searchBarXSize;
this.searchBarYSize = searchBarYSize;
}
@@ -86,25 +86,25 @@ public class GuiElementTextField extends GuiElement {
@Override
public int getHeight() {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
+ 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);
+ int numLines = StringUtils.countMatches(textField.getText(), "\n") + 1;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
+ int bottomTextBox = searchBarYSize + extraSize * (numLines - 1);
- return bottomTextBox + paddingUnscaled*2;
+ return bottomTextBox + paddingUnscaled * 2;
}
@Override
public int getWidth() {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
+ int paddingUnscaled = searchBarPadding / scaledresolution.getScaleFactor();
- return searchBarXSize + paddingUnscaled*2;
+ return searchBarXSize + paddingUnscaled * 2;
}
private float getScaleFactor(String str) {
- return Math.min(1, (searchBarXSize-2)/(float)Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
+ return Math.min(1, (searchBarXSize - 2) / (float) Minecraft.getMinecraft().fontRendererObj.getStringWidth(str));
}
private boolean isScaling() {
@@ -112,8 +112,8 @@ public class GuiElementTextField extends GuiElement {
}
private float getStringWidth(String str) {
- if(isScaling()) {
- return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str)*getScaleFactor(str);
+ if (isScaling()) {
+ return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str) * getScaleFactor(str);
} else {
return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
}
@@ -123,58 +123,57 @@ public class GuiElementTextField extends GuiElement {
int xComp = mouseX - x;
int yComp = mouseY - y;
- int extraSize = (searchBarYSize-8)/2+8;
+ int extraSize = (searchBarYSize - 8) / 2 + 8;
String renderText = prependText + textField.getText();
- int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize);
+ 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) {
+ if ((options & COLOUR) != 0) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
- while(true) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ 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') {
+ 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);
+ 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)) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < xComp - padding) {
linePos++;
}
}
cursorIndex += linePos;
int pre = Utils.cleanColour(prependText).length();
- if(cursorIndex < pre) {
+ if (cursorIndex < pre) {
cursorIndex = 0;
} else {
cursorIndex -= pre;
@@ -185,7 +184,7 @@ public class GuiElementTextField extends GuiElement {
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
- if(mouseButton == 1) {
+ if (mouseButton == 1) {
textField.setText("");
} else {
textField.setCursorPosition(getCursorPos(mouseX, mouseY));
@@ -203,43 +202,43 @@ public class GuiElementTextField extends GuiElement {
}
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- if(focus) {
+ if (focus) {
textField.setSelectionPos(getCursorPos(mouseX, mouseY));
}
}
@Override
public void keyTyped(char typedChar, int keyCode) {
- if(focus) {
- if((options & MULTILINE) != 0) { //Carriage return
+ 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) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
- while(true) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(textNoColour);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColour = matcher.replaceFirst("\u00B6"+code);
+ textNoColour = matcher.replaceFirst("\u00B6" + code);
}
- if(keyCode == 28) {
+ 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);
+ textField.setCursorPosition(pos + 1);
return;
- } else if(keyCode == 200) { //Up
+ } 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);
+ String textBeforeCursor = text.substring(0, textField.getSelectionEnd() + colorCodes * 2);
int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n");
@@ -247,13 +246,13 @@ public class GuiElementTextField extends GuiElement {
int textBeforeCursorWidth;
String lineBefore;
String thisLineBeforeCursor;
- if(split.length == numLinesBeforeCursor && split.length > 0) {
+ if (split.length == numLinesBeforeCursor && split.length > 0) {
textBeforeCursorWidth = 0;
- lineBefore = split[split.length-1];
+ lineBefore = split[split.length - 1];
thisLineBeforeCursor = "";
- } else if(split.length > 1) {
- thisLineBeforeCursor = split[split.length-1];
- lineBefore = split[split.length-2];
+ } else if (split.length > 1) {
+ thisLineBeforeCursor = split[split.length - 1];
+ lineBefore = split[split.length - 2];
textBeforeCursorWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(thisLineBeforeCursor);
} else {
return;
@@ -261,60 +260,60 @@ public class GuiElementTextField extends GuiElement {
String trimmed = Minecraft.getMinecraft().fontRendererObj
.trimStringToWidth(lineBefore, textBeforeCursorWidth);
int linePos = strLenNoColor(trimmed);
- if(linePos != strLenNoColor(lineBefore)) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
linePos++;
}
}
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- -strLenNoColor(lineBefore)-1+linePos;
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ - strLenNoColor(lineBefore) - 1 + linePos;
- if(GuiScreen.isShiftKeyDown()) {
+ if (GuiScreen.isShiftKeyDown()) {
textField.setSelectionPos(newPos);
} else {
textField.setCursorPosition(newPos);
}
- } else if(keyCode == 208) { //Down
+ } 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);
+ 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) {
+ if (split.length == numLinesBeforeCursor) {
thisLineBeforeCursor = "";
textBeforeCursorWidth = 0;
- } else if(split.length > 0) {
- thisLineBeforeCursor = split[split.length-1];
+ } 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];
+ 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)) {
+ 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) {
+ if (trimmedWidth + charWidth / 2 < textBeforeCursorWidth) {
linePos++;
}
}
- int newPos = textField.getSelectionEnd()-strLenNoColor(thisLineBeforeCursor)
- +strLenNoColor(split2[numLinesBeforeCursor])+1+linePos;
+ int newPos = textField.getSelectionEnd() - strLenNoColor(thisLineBeforeCursor)
+ + strLenNoColor(split2[numLinesBeforeCursor]) + 1 + linePos;
- if(GuiScreen.isShiftKeyDown()) {
+ if (GuiScreen.isShiftKeyDown()) {
textField.setSelectionPos(newPos);
} else {
textField.setCursorPosition(newPos);
@@ -324,30 +323,30 @@ public class GuiElementTextField extends GuiElement {
}
String old = textField.getText();
- if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
- if((options & NO_SPACE) != 0 && typedChar == ' ') return;
+ 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) == '&') {
+ 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);
+ if (pos + 2 < textField.getText().length()) {
+ after = textField.getText().substring(pos + 2);
}
textField.setText(before + "\u00A7" + after);
- textField.setCursorPosition(pos+1);
+ textField.setCursorPosition(pos + 1);
}
}
}
}
- if((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
+ if ((options & NUM_ONLY) != 0 && textField.getText().matches("[^0-9.]")) textField.setText(old);
}
}
@@ -364,18 +363,18 @@ public class GuiElementTextField extends GuiElement {
GlStateManager.disableLighting();
- /**
+ /*
* Search bar
*/
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
- if(paddingUnscaled < 1) paddingUnscaled = 1;
+ 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 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) {
+ if (customBorderColour != -1) {
borderColour = customBorderColour;
}
//bar background
@@ -393,91 +392,90 @@ public class GuiElementTextField extends GuiElement {
String text = renderText;
String textNoColor = renderText;
- if((options & COLOUR) != 0) {
- while(true) {
+ if ((options & COLOUR) != 0) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(text);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code);
+ text = matcher.replaceFirst("\u00A7" + code + "\u00B6" + code);
}
}
- while(true) {
+ while (true) {
Matcher matcher = patternControlCode.matcher(textNoColor);
- if(!matcher.find() || matcher.groupCount() < 1) break;
+ if (!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
- textNoColor = matcher.replaceFirst("\u00B6"+code);
+ 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());
+ 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());
+ 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());
+ 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));
+ 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;
+ int yOff = numLinesBeforeCursor * extraSize;
String[] split = textBeforeCursor.split("\n");
int textBeforeCursorWidth;
- if(split.length <= numLinesBeforeCursor || split.length == 0) {
+ if (split.length <= numLinesBeforeCursor || split.length == 0) {
textBeforeCursorWidth = 0;
} else {
- textBeforeCursorWidth = (int)(Minecraft.getMinecraft().fontRendererObj.getStringWidth(split[split.length-1])*scale);
+ 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());
+ 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());
+ 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++) {
+ 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') {
+ 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());
+ 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;
@@ -488,24 +486,24 @@ public class GuiElementTextField extends GuiElement {
//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());
+ 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) {
+ 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);
+ y + searchBarYSize / 2f - scale * 8 / 2f + texY, false, Color.BLACK.getRGB(), scale);
}
}
- texX += len*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..963c04bf 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,44 +22,46 @@ 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 final NEUManager manager;
- private List<GuiElement> options = new ArrayList<>();
- private List<GuiElement> rightOptions = new ArrayList<>();
+ private final List<GuiElement> options = new ArrayList<>();
+ private final List<GuiElement> rightOptions = new ArrayList<>();
- private JsonObject item;
+ private final 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 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")) {
+ if (item.has("nbttag")) {
try {
nbttag = JsonToNBT.getTagFromJson(item.get("nbttag").getAsString());
- } catch(NBTException e) {}
+ } catch (NBTException ignored) {}
}
internalname = internalname == null ? "" : internalname;
@@ -75,7 +79,7 @@ public class NEUItemEditor extends GuiScreen {
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();
+ 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()));
@@ -89,7 +93,7 @@ public class NEUItemEditor extends GuiScreen {
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();
+ 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()));
@@ -100,13 +104,12 @@ public class NEUItemEditor extends GuiScreen {
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);
- }));
+ 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() {
+ final GuiElementButton b = new GuiElementButton("Save to local disk", Color.GREEN.getRGB(), new Runnable() {
public void run() {
- if(save()) {
+ if (save()) {
b.setText("Save to local disk (SUCCESS)");
} else {
b.setText("Save to local disk (FAILED)");
@@ -122,9 +125,7 @@ public class NEUItemEditor extends GuiScreen {
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("Add enchant glint", Color.ORANGE.getRGB(), () -> nbttag.setTag("ench", new NBTTagList())));
resetScrollToTop();
}
@@ -132,11 +133,11 @@ public class NEUItemEditor extends GuiScreen {
public boolean save() {
int damageI = 0;
try {
- damageI = Integer.valueOf(damage.get());
- } catch(NumberFormatException e) {}
+ damageI = Integer.parseInt(damage.get());
+ } catch (NumberFormatException ignored) {}
resyncNbttag();
String[] infoA = info.get().trim().split("\n");
- if(infoA.length == 0 || infoA[0].isEmpty()) {
+ 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"),
@@ -150,15 +151,15 @@ public class NEUItemEditor extends GuiScreen {
public Supplier<String> addTextFieldWithSupplier(String initialText, int options) {
GuiElementTextField textField = new GuiElementTextField(initialText, options);
this.options.add(textField);
- return () -> textField.toString();
+ return textField::toString;
}
public void resyncNbttag() {
- if(nbttag == null) nbttag = new NBTTagCompound();
+ if (nbttag == null) nbttag = new NBTTagCompound();
//Item lore
NBTTagList list = new NBTTagList();
- for(String lore : this.lore.get().split("\n")) {
+ for (String lore : this.lore.get().split("\n")) {
list.appendTag(new NBTTagString(lore));
}
@@ -177,14 +178,14 @@ public class NEUItemEditor extends GuiScreen {
public void resetScrollToTop() {
int totalHeight = PADDING;
- for(GuiElement gui : options) {
+ for (GuiElement gui : options) {
totalHeight += gui.getHeight();
}
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
int height = scaledresolution.getScaledHeight();
- scrollHeight.setValue(totalHeight-height+PADDING);
+ scrollHeight.setValue(totalHeight - height + PADDING);
}
public int calculateYScroll() {
@@ -192,21 +193,21 @@ public class NEUItemEditor extends GuiScreen {
int height = scaledresolution.getScaledHeight();
int totalHeight = PADDING;
- for(GuiElement gui : options) {
+ for (GuiElement gui : options) {
totalHeight += gui.getHeight();
}
- if(scrollHeight.getValue() < 0) scrollHeight.setValue(0);
+ if (scrollHeight.getValue() < 0) scrollHeight.setValue(0);
int yScroll = 0;
- if(totalHeight > height-PADDING) {
- yScroll = totalHeight-height+PADDING-scrollHeight.getValue();
+ if (totalHeight > height - PADDING) {
+ yScroll = totalHeight - height + PADDING - scrollHeight.getValue();
} else {
scrollHeight.setValue(0);
}
- if(yScroll < 0) {
+ if (yScroll < 0) {
yScroll = 0;
- scrollHeight.setValue(totalHeight-height+PADDING);
+ scrollHeight.setValue(totalHeight - height + PADDING);
}
return yScroll;
@@ -226,19 +227,19 @@ public class NEUItemEditor extends GuiScreen {
drawRect(0, 0, width, height, backgroundColour.getRGB());
int yScroll = calculateYScroll();
- if(yScroll > 0){
+ if (yScroll > 0) {
//Render scroll bar
}
- int currentY = PADDING-yScroll;
- for(GuiElement gui : options) {
+ 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);
+ for (GuiElement gui : rightOptions) {
+ gui.render(width - PADDING - gui.getWidth(), currentY);
currentY += gui.getHeight();
}
@@ -247,24 +248,24 @@ public class NEUItemEditor extends GuiScreen {
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());
+ 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) {
+ if (stack.getItem() != null) {
try {
- stack.setItemDamage(Integer.valueOf(damage.get()));
- } catch(NumberFormatException e) {}
+ stack.setItemDamage(Integer.parseInt(damage.get()));
+ } catch (NumberFormatException ignored) {}
resyncNbttag();
stack.setTagCompound(nbttag);
- int scaleFactor = itemSize/16;
+ int scaleFactor = itemSize / 16;
GL11.glPushMatrix();
GlStateManager.scale(scaleFactor, scaleFactor, 1);
- drawItemStack(stack, itemX/scaleFactor, itemY/scaleFactor, null);
+ drawItemStack(stack, itemX / scaleFactor, itemY / scaleFactor, null);
GL11.glPopMatrix();
}
@@ -273,7 +274,7 @@ public class NEUItemEditor extends GuiScreen {
text.add(displayname.get());
text.addAll(Arrays.asList(lore.get().split("\n")));
- Utils.drawHoveringText(text, itemX-20, itemY+itemSize+28, width, height, -1,
+ Utils.drawHoveringText(text, itemX - 20, itemY + itemSize + 28, width, height, -1,
Minecraft.getMinecraft().fontRendererObj);
GlStateManager.disableLighting();
@@ -281,7 +282,7 @@ public class NEUItemEditor extends GuiScreen {
@Override
protected void keyTyped(char typedChar, int keyCode) {
- for(GuiElement gui : options) {
+ for (GuiElement gui : options) {
gui.keyTyped(typedChar, keyCode);
}
}
@@ -292,9 +293,9 @@ public class NEUItemEditor extends GuiScreen {
int width = scaledresolution.getScaledWidth();
int yScroll = calculateYScroll();
- int currentY = PADDING-yScroll;
- for(GuiElement gui : options) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
+ 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;
@@ -303,9 +304,9 @@ public class NEUItemEditor extends GuiScreen {
}
currentY = PADDING;
- for(GuiElement gui : rightOptions) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
- && mouseX > width-PADDING-gui.getWidth()) {
+ for (GuiElement gui : rightOptions) {
+ if (mouseY > currentY && mouseY < currentY + gui.getHeight()
+ && mouseX > width - PADDING - gui.getWidth()) {
gui.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
return;
}
@@ -318,18 +319,18 @@ public class NEUItemEditor extends GuiScreen {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
int maxWidth = 0;
- for(GuiElement gui : options) {
- if(gui.getWidth() > maxWidth) maxWidth = gui.getWidth();
+ for (GuiElement gui : options) {
+ if (gui.getWidth() > maxWidth) maxWidth = gui.getWidth();
}
- if(Mouse.getX() < maxWidth*scaledresolution.getScaleFactor()) {
+ if (Mouse.getX() < maxWidth * scaledresolution.getScaleFactor()) {
int dWheel = Mouse.getEventDWheel();
- if(dWheel < 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()-SCROLL_AMOUNT);
+ if (dWheel < 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() - SCROLL_AMOUNT);
scrollHeight.resetTimer();
- } else if(dWheel > 0) {
- scrollHeight.setTarget(scrollHeight.getTarget()+SCROLL_AMOUNT);
+ } else if (dWheel > 0) {
+ scrollHeight.setTarget(scrollHeight.getTarget() + SCROLL_AMOUNT);
scrollHeight.resetTimer();
}
}
@@ -343,18 +344,18 @@ public class NEUItemEditor extends GuiScreen {
int width = scaledresolution.getScaledWidth();
int yScroll = calculateYScroll();
- int currentY = PADDING-yScroll;
- for(GuiElement gui : options) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
+ 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) {
+ for (GuiElement gui2 : options) {
+ if (gui2 != gui) {
gui2.otherComponentClick();
}
}
- for(GuiElement gui2 : rightOptions) {
- if(gui2 != gui) {
+ for (GuiElement gui2 : rightOptions) {
+ if (gui2 != gui) {
gui2.otherComponentClick();
}
}
@@ -364,17 +365,17 @@ public class NEUItemEditor extends GuiScreen {
}
currentY = PADDING;
- for(GuiElement gui : rightOptions) {
- if(mouseY > currentY && mouseY < currentY+gui.getHeight()
- && mouseX > width-PADDING-gui.getWidth()) {
+ 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) {
+ for (GuiElement gui2 : options) {
+ if (gui2 != gui) {
gui2.otherComponentClick();
}
}
- for(GuiElement gui2 : rightOptions) {
- if(gui2 != gui) {
+ for (GuiElement gui2 : rightOptions) {
+ if (gui2 != gui) {
gui2.otherComponentClick();
}
}
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..27a2991d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java
@@ -35,7 +35,7 @@ public class MBAnchorPoint implements Serializable {
}
public static MBAnchorPoint createFromString(String str) {
- if(str == null || str.split(":").length != 4) {
+ if (str == null || str.split(":").length != 4) {
return null;
}
@@ -44,7 +44,9 @@ public class MBAnchorPoint implements Serializable {
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; }
+ } catch (Exception e) {
+ return null;
+ }
}
@Override
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..2b7e879e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java
@@ -3,10 +3,15 @@ package io.github.moulberry.notenoughupdates.mbgui;
public abstract class MBGuiElement {
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 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..9b27f229 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroup.java
@@ -13,8 +13,7 @@ public abstract class MBGuiGroup extends MBGuiElement {
public int height;
protected HashMap<MBGuiElement, Vector2f> childrenPosition = new HashMap<>();
- public MBGuiGroup() {
- }
+ public MBGuiGroup() {}
public abstract Collection<MBGuiElement> getChildren();
@@ -32,16 +31,15 @@ public abstract class MBGuiGroup extends MBGuiElement {
return height;
}
-
@Override
public void mouseClick(float x, float y, int mouseX, int mouseY) {
Map<MBGuiElement, Vector2f> childrenPos = getChildrenPosition();
- for(MBGuiElement child : getChildren()) {
+ 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);
+ 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);
}
}
}
@@ -49,7 +47,7 @@ public abstract class MBGuiGroup extends MBGuiElement {
@Override
public void mouseClickOutside() {
- for(MBGuiElement child : getChildren()) {
+ for (MBGuiElement child : getChildren()) {
child.mouseClickOutside();
}
}
@@ -58,11 +56,10 @@ public abstract class MBGuiGroup extends MBGuiElement {
public void render(float x, float y) {
Map<MBGuiElement, Vector2f> childrenPos = getChildrenPosition();
- for(MBGuiElement child : getChildren()) {
+ for (MBGuiElement child : getChildren()) {
Vector2f childPos = childrenPos.get(child);
- child.render(x+childPos.x, y+childPos.y);
+ 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..42e18b82 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java
@@ -8,8 +8,8 @@ import java.util.List;
public abstract class MBGuiGroupAligned extends MBGuiGroup {
//Serialized
- private List<MBGuiElement> children;
- private boolean vertical;
+ private final List<MBGuiElement> children;
+ private final boolean vertical;
public MBGuiGroupAligned(List<MBGuiElement> children, boolean vertical) {
this.children = children;
@@ -24,39 +24,39 @@ public abstract class MBGuiGroupAligned extends MBGuiGroup {
}
public void recalculate() {
- for(MBGuiElement child : children) {
+ for (MBGuiElement child : children) {
child.recalculate();
}
- if(vertical) {
+ if (vertical) {
height = 0;
- for(int i=0; i<children.size(); i++) {
+ 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 (i != children.size() - 1) height += getPadding();
}
width = 0;
- for(MBGuiElement child : children) {
+ for (MBGuiElement child : children) {
int childWidth = child.getWidth();
- if(childWidth > width) {
+ if (childWidth > width) {
width = childWidth;
}
}
} else {
width = 0;
- for(int i=0; i<children.size(); i++) {
+ 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();
+ if (i != children.size() - 1) width += getPadding();
}
height = 0;
- for(MBGuiElement child : children) {
+ for (MBGuiElement child : children) {
int childHeight = child.getHeight();
- if(childHeight > height) {
+ 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..8a25124f 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;
@@ -15,10 +15,10 @@ import java.util.*;
public class MBGuiGroupFloating extends MBGuiGroup {
private GuiScreen lastScreen = null;
- private HashMap<MBGuiElement, Vector2f> childrenPositionOffset = new HashMap<>();
+ private final HashMap<MBGuiElement, Vector2f> childrenPositionOffset = new HashMap<>();
//Serialized
- private LinkedHashMap<MBGuiElement, MBAnchorPoint> children;
+ private final LinkedHashMap<MBGuiElement, MBAnchorPoint> children;
public MBGuiGroupFloating(int width, int height, LinkedHashMap<MBGuiElement, MBAnchorPoint> children) {
this.width = width;
@@ -35,10 +35,10 @@ public class MBGuiGroupFloating extends MBGuiGroup {
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 (currentScreen instanceof GuiContainer || currentScreen instanceof GuiItemRecipe
+ || currentScreen instanceof CustomAHGui || NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.isRenderOverAuctionView()) {
- if(lastScreen != currentScreen) {
+ if (lastScreen != currentScreen) {
lastScreen = currentScreen;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -50,7 +50,7 @@ public class MBGuiGroupFloating extends MBGuiGroup {
int guiLeft = -1;
int guiTop = -1;
- if(currentScreen instanceof GuiContainer) {
+ if (currentScreen instanceof GuiContainer) {
GuiContainer currentContainer = (GuiContainer) currentScreen;
try {
@@ -58,14 +58,14 @@ public class MBGuiGroupFloating extends MBGuiGroup {
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) {
+ } 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 ||
+ } 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();
@@ -73,28 +73,28 @@ public class MBGuiGroupFloating extends MBGuiGroup {
guiTop = NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.guiTop;
}
- if(xSize <= 0 && ySize <= 0 && guiLeft <= 0 && guiTop <= 0) {
+ if (xSize <= 0 && ySize <= 0 && guiLeft <= 0 && guiTop <= 0) {
lastScreen = null;
return Collections.unmodifiableMap(childrenPosition);
}
- for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
+ for (Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
MBGuiElement child = entry.getKey();
MBAnchorPoint anchorPoint = entry.getValue();
Vector2f childPos;
- if(childrenPosition.containsKey(child)) {
+ if (childrenPosition.containsKey(child)) {
childPos = new Vector2f(childrenPosition.get(child));
} else {
childPos = new Vector2f();
}
- if(anchorPoint.inventoryRelative) {
+ 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;
+ childPos.x += guiLeft - defGuiLeft + (0.5f - anchorPoint.anchorPoint.x) * xSize;
+ childPos.y += guiTop - defGuiTop + (0.5f - anchorPoint.anchorPoint.y) * ySize;
}
childrenPositionOffset.put(child, childPos);
@@ -110,19 +110,19 @@ public class MBGuiGroupFloating extends MBGuiGroup {
public void recalculate() {
lastScreen = null;
- for(MBGuiElement child : children.keySet()) {
+ for (MBGuiElement child : children.keySet()) {
child.recalculate();
}
- for(Map.Entry<MBGuiElement, MBAnchorPoint> entry : children.entrySet()) {
+ 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;
+ if (anchorPoint.inventoryRelative) {
+ x = width * 0.5f + anchorPoint.offset.x;
+ y = height * 0.5f + anchorPoint.offset.y;
}
childrenPosition.put(child, new Vector2f(x, y));
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..6f8a9a3e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionBINWarning.java
@@ -26,6 +26,7 @@ import java.util.regex.Pattern;
public class AuctionBINWarning extends GuiElement {
private static final AuctionBINWarning INSTANCE = new AuctionBINWarning();
+
public static AuctionBINWarning getInstance() {
return INSTANCE;
}
@@ -39,14 +40,14 @@ public class AuctionBINWarning extends GuiElement {
private int lowestPrice;
private boolean shouldPerformCheck() {
- if(!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning ||
+ if (!NotEnoughUpdates.INSTANCE.config.ahTweaks.enableBINWarning ||
!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
sellingTooltip = null;
showWarning = false;
return false;
}
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiChest &&
SBInfo.getInstance().lastOpenContainerName.startsWith("Create BIN Auction")) {
return true;
} else {
@@ -61,35 +62,34 @@ public class AuctionBINWarning extends GuiElement {
}
public boolean onMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType) {
- if(!shouldPerformCheck()) return false;
+ if (!shouldPerformCheck()) return false;
- if(slotId == 29) {
+ if (slotId == 29) {
GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
sellingPrice = -1;
ItemStack priceStack = chest.inventorySlots.getSlot(31).getStack();
- if(priceStack != null) {
+ if (priceStack != null) {
String displayName = priceStack.getDisplayName();
Matcher priceMatcher = ITEM_PRICE_REGEX.matcher(displayName);
- if(priceMatcher.matches()) {
+ if (priceMatcher.matches()) {
try {
sellingPrice = Integer.parseInt(priceMatcher.group(1).replace(",", ""));
- } catch(NumberFormatException ignored) {
- }
+ } catch (NumberFormatException ignored) {}
}
}
ItemStack sellStack = chest.inventorySlots.getSlot(13).getStack();
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(sellStack);
- if(internalname == null) {
+ if (internalname == null) {
return false;
}
JsonObject itemInfo = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internalname);
- if(itemInfo == null || !itemInfo.has("displayname")) {
+ if (itemInfo == null || !itemInfo.has("displayname")) {
sellingName = internalname;
} else {
sellingName = itemInfo.get("displayname").getAsString();
@@ -99,17 +99,17 @@ public class AuctionBINWarning extends GuiElement {
Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
lowestPrice = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
- if(lowestPrice <= 0) {
- lowestPrice = (int)NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAvgBin(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;
+ 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) {
+ if (sellingPrice > 0 && lowestPrice > 0 && sellingPrice < lowestPrice * factor) {
showWarning = true;
return true;
} else {
@@ -120,7 +120,7 @@ public class AuctionBINWarning extends GuiElement {
}
public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if(shouldShow()) {
+ if (shouldShow()) {
cir.setReturnValue(false);
}
}
@@ -138,60 +138,60 @@ public class AuctionBINWarning extends GuiElement {
Gui.drawRect(0, 0, width, height, 0x80000000);
- RenderUtils.drawFloatingRectDark(width/2-90, height/2-45, 180, 90);
+ 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);
+ 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);
+ width / 2, height / 2 - 45 + 10, false, 170, 0xffff4040);
String lowestPriceStr;
- if(lowestPrice > 999) {
+ if (lowestPrice > 999) {
lowestPriceStr = Utils.shortNumberFormat(lowestPrice, 0);
} else {
- lowestPriceStr = ""+lowestPrice;
+ lowestPriceStr = "" + lowestPrice;
}
String sellingPriceStr;
- if(sellingPrice > 999) {
+ if (sellingPrice > 999) {
sellingPriceStr = Utils.shortNumberFormat(sellingPrice, 0);
} else {
- sellingPriceStr = ""+sellingPrice;
+ sellingPriceStr = "" + sellingPrice;
}
- String sellLine = "\u00a77[ \u00a7r"+sellingName+"\u00a77 ]";
+ 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);
+ 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;
+ 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)",
+ 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);
+ 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);
+ 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);
+ 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) {
+ 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) {
+ 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);
}
}
@@ -205,20 +205,18 @@ public class AuctionBINWarning extends GuiElement {
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) {
+ 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;
}
+ showWarning = false;
}
- if(mouseX < width/2-90 || mouseX > width/2+90 ||
- mouseY < height/2-45 || mouseY > height/2+45) {
+ if (mouseX < width / 2 - 90 || mouseX > width / 2 + 90 ||
+ mouseY < height / 2 - 45 || mouseY > height / 2 + 45) {
showWarning = false;
}
}
@@ -228,8 +226,8 @@ public class AuctionBINWarning extends GuiElement {
@Override
public boolean keyboardInput() {
- if(!Keyboard.getEventKeyState()) {
- if(Keyboard.getEventKey() == Keyboard.KEY_Y || Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ 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);
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..e96555a0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/AuctionSortModeWarning.java
@@ -8,7 +8,6 @@ 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;
@@ -16,6 +15,7 @@ import java.util.List;
public class AuctionSortModeWarning {
private static final AuctionSortModeWarning INSTANCE = new AuctionSortModeWarning();
+
public static AuctionSortModeWarning getInstance() {
return INSTANCE;
}
@@ -28,43 +28,43 @@ public class AuctionSortModeWarning {
}
public void onPostGuiRender() {
- if(isAuctionBrowser()) {
+ if (isAuctionBrowser()) {
GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
ItemStack stack = chest.inventorySlots.getSlot(50).getStack();
- if(stack != null) {
+ 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 ")) {
+ 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")) {
+ 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")) {
+ 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;
+ 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);
+ 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);
+ 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..630cf3dd 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,17 +18,14 @@ 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 {
@@ -53,7 +46,7 @@ public class BetterContainers {
public static long lastRenderMillis = 0;
private static int lastInvHashcode = 0;
- private static int lastHashcodeCheck = 0;
+ private static final int lastHashcodeCheck = 0;
public static HashMap<Integer, ItemStack> itemCache = new HashMap<>();
@@ -153,9 +146,7 @@ public class BetterContainers {
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 lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(EnumChatFormatting.GRAY + "click to disable!");
}
return false;
}
@@ -164,9 +155,7 @@ public class BetterContainers {
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 lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(EnumChatFormatting.GRAY + "click to enable!");
}
return false;
}
@@ -197,21 +186,21 @@ public class BetterContainers {
try {
bufferedImageBase = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(
new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_54.png")).getInputStream());
- } catch(Exception e) {}
+ } 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 e) {}
+ } 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 e) {}
+ } catch(Exception ignored) {}
int horzTexMult = bufferedImageBase.getWidth()/256;
int vertTexMult = bufferedImageBase.getWidth()/256;
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..54700927 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java
@@ -11,29 +11,29 @@ import java.util.regex.Matcher;
public class CollectionLogManager {
- private static CollectionLogManager INSTANCE = new CollectionLogManager();
+ private static final CollectionLogManager INSTANCE = new CollectionLogManager();
public static CollectionLogManager getInstance() {
return INSTANCE;
}
public void onEntityMetadataUpdated(int entityId) {
- System.out.println("entity created:"+entityId);
+ System.out.println("entity created:" + entityId);
WorldClient world = Minecraft.getMinecraft().theWorld;
- if(world != null) {
+ if (world != null) {
Entity entity = world.getEntityByID(entityId);
- if(entity instanceof EntityArmorStand && entity.hasCustomName()) {
+ 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("got name:" + customName);
+ for (CollectionConstant.DropEntry entry : Constants.COLLECTIONLOG.dropdata) {
System.out.println("iter entry");
- if(entry.type.equalsIgnoreCase("itemdrop")) {
+ if (entry.type.equalsIgnoreCase("itemdrop")) {
Matcher matcher = entry.regex.matcher(customName);
- if(matcher.matches()) {
+ if (matcher.matches()) {
System.out.println("Match found!");
- System.out.println("Count: "+matcher.group("count"));
- System.out.println("Name: "+matcher.group("itemname"));
+ 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..f20081ad 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CrystalMetalDetectorSolver.java
@@ -112,11 +112,11 @@ public class CrystalMetalDetectorSolver {
if (possibleBlocks.size() == 1) {
BlockPos block = possibleBlocks.get(0);
- RenderUtils.renderBeaconBeam(block.add(0,1,0), beaconRGB, 1.0f, partialTicks);
+ 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.renderBeaconBeam(block.add(0, 1, 0), beaconRGB, 1.0f, partialTicks);
RenderUtils.renderWayPoint("Possible Treasure Location", block.add(0, 2.5, 0), partialTicks);
}
}
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..9a1b82d4 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,10 +24,10 @@ 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 {
@@ -47,14 +46,14 @@ public class CrystalOverlay {
}
public Set<BlockPos> getCircleOffsets() {
- if(circleOffsets != null) return circleOffsets;
+ 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) {
+ 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));
}
}
@@ -65,12 +64,12 @@ public class CrystalOverlay {
}
public ReverseWorldRenderer getOverlayVBO() {
- if(overlayVBO != null) return overlayVBO;
+ if (overlayVBO != null) return overlayVBO;
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return null;
+ if (p == null) return null;
- if(!crystals.containsKey(this)) {
+ if (!crystals.containsKey(this)) {
return null;
}
@@ -79,21 +78,21 @@ public class CrystalOverlay {
//per block = 8
//total per block = 196
- ReverseWorldRenderer worldRenderer = new ReverseWorldRenderer(196*getCircleOffsets().size());
+ 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()) {
+ 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));
+ 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);
}
@@ -112,7 +111,8 @@ public class CrystalOverlay {
private static double posLastUpdateY;
private static double posLastUpdateZ;
- private static HashMap<String, CrystalType> skullId = new HashMap<>();
+ private static final 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);
@@ -127,62 +127,61 @@ public class CrystalOverlay {
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;
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
+ if (Minecraft.getMinecraft().theWorld == null) return;
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return;
+ if (p == null) return;
long currentTime = System.currentTimeMillis();
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.alwaysShowCrystal) {
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.alwaysShowCrystal) {
displayMillis = currentTime;
} else {
- if(currentTime - displayMillis > 10*1000) {
+ 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")) {
+ if (internal != null) {
+ if (internal.endsWith("_CRYSTAL") && !internal.equals("POWER_CRYSTAL")) {
displayMillis = currentTime;
}
}
- if(displayMillis < 0) {
+ if (displayMillis < 0) {
return;
}
}
-
Set<CrystalType> foundTypes = new HashSet<>();
- for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) {
- if(entity instanceof EntityArmorStand) {
+ for (Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) {
+ if (entity instanceof EntityArmorStand) {
EntityArmorStand armorStand = (EntityArmorStand) entity;
- if(armorStand.isChild() && armorStand.getEquipmentInSlot(4) != null) {
+ if (armorStand.isChild() && armorStand.getEquipmentInSlot(4) != null) {
ItemStack helmet = armorStand.getEquipmentInSlot(4);
- if(helmet.getItem() == Items.skull && helmet.hasTagCompound()) {
+ if (helmet.getItem() == Items.skull && helmet.hasTagCompound()) {
NBTTagCompound tag = helmet.getTagCompound();
- if(tag.hasKey("SkullOwner", 10)) {
+ if (tag.hasKey("SkullOwner", 10)) {
NBTTagCompound skullOwner = tag.getCompoundTag("SkullOwner");
- if(skullOwner.hasKey("Id", 8)) {
+ if (skullOwner.hasKey("Id", 8)) {
String id = skullOwner.getString("Id");
- if(skullId.containsKey(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);
+ BlockPos pos = new BlockPos(armorStand.posX, armorStand.posY + 0.5f, armorStand.posZ);
- if(crystals.containsKey(type)) {
+ if (crystals.containsKey(type)) {
BlockPos old = crystals.get(type);
- if(old.equals(pos)) {
+ if (old.equals(pos)) {
type.updates = 0;
} else {
- if(++type.updates >= 3) {
+ if (++type.updates >= 3) {
type.updates = 0;
crystals.put(type, pos);
}
@@ -202,21 +201,21 @@ public class CrystalOverlay {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
- if(displayMillis < 0) {
+ if (displayMillis < 0) {
return;
}
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return;
+ if (p == null) return;
- if(event.phase == TickEvent.Phase.START) {
+ 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) {
+ if (dX * dX + dY * dY + dZ * dZ < 1) {
return;
}
@@ -224,24 +223,24 @@ public class CrystalOverlay {
posLastUpdateY = p.posY;
posLastUpdateZ = p.posZ;
- for(CrystalType type : crystals.keySet()) {
- if(type == CrystalType.MINING_MINION) {
+ for (CrystalType type : crystals.keySet()) {
+ if (type == CrystalType.MINING_MINION) {
long currentTime = System.currentTimeMillis();
- if(currentTime - lastMiningUpdate < 1000) {
+ if (currentTime - lastMiningUpdate < 1000) {
continue;
}
lastMiningUpdate = currentTime;
}
ReverseWorldRenderer worldRenderer = type.getOverlayVBO();
- if(worldRenderer != null) {
+ if (worldRenderer != null) {
BlockPos crystal = crystals.get(type);
- worldRenderer.setTranslation(0, 0,0 );
+ worldRenderer.setTranslation(0, 0, 0);
worldRenderer.sortVertexData(
- (float)p.posX-crystal.getX(),
- (float)p.posY-crystal.getY(),
- (float)p.posZ-crystal.getZ());
+ (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(),
@@ -254,9 +253,9 @@ public class CrystalOverlay {
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCrystalOverlay) return;
- if(displayMillis < 0) {
+ if (displayMillis < 0) {
return;
}
@@ -272,9 +271,9 @@ public class CrystalOverlay {
GlStateManager.translate(-viewerX, -viewerY, -viewerZ);
GL11.glPolygonOffset(5, 5);
- for(CrystalType type : crystals.keySet()) {
+ for (CrystalType type : crystals.keySet()) {
ReverseWorldRenderer worldRenderer = type.getOverlayVBO();
- if(worldRenderer != null && worldRenderer.getVertexCount() > 0) {
+ if (worldRenderer != null && worldRenderer.getVertexCount() > 0) {
BlockPos crystal = crystals.get(type);
GlStateManager.translate(crystal.getX(), crystal.getY(), crystal.getZ());
@@ -315,57 +314,57 @@ public class CrystalOverlay {
//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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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..e592a503 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,8 +36,8 @@ 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;
@@ -54,7 +47,7 @@ public class CustomItemEffects {
private static final int MAX_BUILDERS_BLOCKS = 241;
- private HashSet<BlockPos> zapperBlocks = new HashSet<>();
+ private final HashSet<BlockPos> zapperBlocks = new HashSet<>();
private boolean zapperDirty = false;
public long aoteUseMillis = 0;
@@ -73,48 +66,48 @@ public class CustomItemEffects {
public long lastMillis = 0;
public Vector3f getCurrentPosition() {
- if(aoteTeleportationMillis <= 0) return null;
+ if (aoteTeleportationMillis <= 0) return null;
return aoteTeleportationCurr;
}
@SubscribeEvent
public void onTick(TickEvent.RenderTickEvent event) {
- if(Minecraft.getMinecraft().thePlayer == null) return;
+ if (Minecraft.getMinecraft().thePlayer == null) return;
zapperDirty = true;
long currentTime = System.currentTimeMillis();
- int delta = (int)(currentTime - lastMillis);
+ int delta = (int) (currentTime - lastMillis);
lastMillis = currentTime;
- if(delta <= 0) return;
+ if (delta <= 0) return;
- if(aoteTeleportationMillis > tpTime*2) {
- aoteTeleportationMillis = tpTime*2;
+ if (aoteTeleportationMillis > tpTime * 2) {
+ aoteTeleportationMillis = tpTime * 2;
}
- if(aoteTeleportationMillis < 0) aoteTeleportationMillis = 0;
+ if (aoteTeleportationMillis < 0) aoteTeleportationMillis = 0;
- if(currentTime - aoteUseMillis > 1000 && aoteTeleportationMillis <= 0) {
+ if (currentTime - aoteUseMillis > 1000 && aoteTeleportationMillis <= 0) {
aoteTeleportationCurr = null;
}
- if(aoteTeleportationCurr != null) {
- if(aoteTeleportationMillis > 0) {
+ if (aoteTeleportationCurr != null) {
+ if (aoteTeleportationMillis > 0) {
int deltaMin = Math.min(delta, aoteTeleportationMillis);
- float factor = deltaMin/(float)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;
+ 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;
+ aoteTeleportationCurr.x -= dX * factor;
+ aoteTeleportationCurr.y -= dY * factor;
+ aoteTeleportationCurr.z -= dZ * factor;
- if(Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(aoteTeleportationCurr.x,
+ if (Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(aoteTeleportationCurr.x,
aoteTeleportationCurr.y, aoteTeleportationCurr.z)).getBlock().getMaterial() != Material.air) {
- aoteTeleportationCurr.y = (float)Math.ceil(aoteTeleportationCurr.y);
+ aoteTeleportationCurr.y = (float) Math.ceil(aoteTeleportationCurr.y);
}
aoteTeleportationMillis -= deltaMin;
@@ -131,21 +124,21 @@ public class CustomItemEffects {
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
- if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
+ 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) {
+ if (internal != null) {
boolean shadowWarp = false;
- if(internal.equals("HYPERION") || internal.equals("VALKYRIE") || internal.equals("SCYLLA") || internal.equals("ASTRAEA")) {
+ if (internal.equals("HYPERION") || internal.equals("VALKYRIE") || internal.equals("SCYLLA") || internal.equals("ASTRAEA")) {
NBTTagCompound tag = held.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea != null && ea.hasKey("ability_scroll", 9)) {
+ 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")) {
+ 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")) {
+ } else if (list.getStringTagAt(i).equals("SHADOW_WARP_SCROLL")) {
shadowWarp = true;
}
}
@@ -153,23 +146,23 @@ public class CustomItemEffects {
}
}
- if(usingEtherwarp) {
+ if (usingEtherwarp) {
lastEtherwarpUse = tick;
}
- if(tpTime <= 0 || Minecraft.getMinecraft().gameSettings.thirdPersonView != 0) return;
+ 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) {
+ if (usingEtherwarp) {
tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillisEtherwarp;
} else {
tpTime = NotEnoughUpdates.INSTANCE.config.itemOverlays.smoothTpMillis;
}
- if(usingEtherwarp || aote || hyp) {
+ if (usingEtherwarp || aote || hyp) {
aoteUseMillis = System.currentTimeMillis();
- if(aoteTeleportationCurr == null) {
+ if (aoteTeleportationCurr == null) {
aoteTeleportationCurr = new Vector3f();
aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX;
aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY;
@@ -182,10 +175,10 @@ public class CustomItemEffects {
@SubscribeEvent
public void onGameTick(TickEvent.ClientTickEvent event) {
- if(event.phase != TickEvent.Phase.END) return;
+ if (event.phase != TickEvent.Phase.END) return;
- if(!usingEtherwarp && wasUsingEtherwarp) {
- if(Minecraft.getMinecraft().thePlayer.rotationYaw > 0) {
+ if (!usingEtherwarp && wasUsingEtherwarp) {
+ if (Minecraft.getMinecraft().thePlayer.rotationYaw > 0) {
Minecraft.getMinecraft().thePlayer.rotationYaw -= 0.000001;
} else {
Minecraft.getMinecraft().thePlayer.rotationYaw += 0.000001;
@@ -194,8 +187,7 @@ public class CustomItemEffects {
wasUsingEtherwarp = usingEtherwarp;
tick++;
- if(tick > Integer.MAX_VALUE/2) tick = 0;
-
+ if (tick > Integer.MAX_VALUE / 2) tick = 0;
}
@@ -209,32 +201,32 @@ public class CustomItemEffects {
private float targetSensMult = 1;
public float getSensMultiplier() {
- if(targetSensMult < 0) {
+ 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;
+ 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++;
+ float partialDelta = partialTicks + tick - lastPartialTicks;
+ if (partialDelta < 0) partialDelta++;
- if(partialDelta > 0) lastPartialDelta = partialDelta;
+ if (partialDelta > 0) lastPartialDelta = partialDelta;
- if(targetFOVMult < 0) {
+ 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;
+ currentFOVMult += deltaFOV * lastPartialDelta * 0.2;
+ if (currentFOVMult < 0.15f) currentFOVMult = 0.15f;
+ if (currentFOVMult > 1) currentFOVMult = 1;
}
lastPartialTicks = partialTicks + tick;
return currentFOVMult;
@@ -247,25 +239,25 @@ public class CustomItemEffects {
@SubscribeEvent
public void onOverlayDrawn(RenderGameOverlayEvent.Post event) {
- if(((event.type == null && Loader.isModLoaded("labymod")) ||
+ 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) {
+ if (usingEtherwarp && NotEnoughUpdates.INSTANCE.config.itemOverlays.enableEtherwarpHelperOverlay) {
String denyTpReason = null;
- if(etherwarpRaycast == null) {
+ if (etherwarpRaycast == null) {
denyTpReason = "Too far!";
} else {
BlockPos pos = etherwarpRaycast.pos;
- if(!etherwarpRaycast.state.getBlock().isCollidable() ||
+ 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() &&
+ 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) {
@@ -274,28 +266,27 @@ public class CustomItemEffects {
}
}
- if(denyTpReason != null) {
+ if (denyTpReason != null) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- Utils.drawStringCentered(EnumChatFormatting.RED+"Can't TP: " + denyTpReason,
+ Utils.drawStringCentered(EnumChatFormatting.RED + "Can't TP: " + denyTpReason,
Minecraft.getMinecraft().fontRendererObj,
- scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
+ 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 &&
+ 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 (hover.getBlock() == Blocks.air) {
- if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ if (heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
HashSet<BlockPos> candidatesOld = new HashSet<>();
@@ -303,53 +294,53 @@ public class CustomItemEffects {
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,
+ 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);
+ candidatesOld, candidatesOldSorted, 999 - MAX_BUILDERS_BLOCKS);
boolean usingDirtWand = false;
int itemCount;
- if(match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) {
+ 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,
+ 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);
+ scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0);
} else {
String pre = EnumChatFormatting.GREEN.toString();
- if(itemCount < candidatesOld.size()) {
+ if (itemCount < candidatesOld.size()) {
pre = EnumChatFormatting.RED.toString();
}
- Utils.drawStringCentered(pre+Math.min(candidatesOld.size(), itemCount)+"/"+
+ 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);
+ scaledResolution.getScaledWidth() / 2f, scaledResolution.getScaledHeight() / 2f + 10, true, 0);
}
- String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+itemCount;
+ 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);
+ 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,
+ 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);
+ 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,
+ scaledResolution.getScaledWidth() / 2f - (itemCountLen + 16) / 2f + 16, scaledResolution.getScaledHeight() / 2f + 10 + 8,
-1,
true);
}
@@ -366,7 +357,7 @@ public class CustomItemEffects {
}
//ethermerge
- private class RaycastResult {
+ private static class RaycastResult {
IBlockState state;
BlockPos pos;
@@ -377,34 +368,34 @@ public class CustomItemEffects {
}
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);
+ 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);
+ 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);
+ int stepCount = (int) Math.ceil(dist / step);
- for(int i=0; i<stepCount; i++) {
+ 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) {
+ if (state.getBlock() != Blocks.air) {
//Back-step
Vector3f.sub(pos, look, pos);
look.scale(0.1f);
- for(int j=0; j<10; j++) {
+ 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) {
+ if (state2.getBlock() != Blocks.air) {
return new RaycastResult(state2, position2);
}
}
@@ -419,8 +410,8 @@ public class CustomItemEffects {
public int countItemsInInventoryAndStorage(ItemStack match) {
int count = 0;
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- if(match.isItemEqual(stack)) {
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (match.isItemEqual(stack)) {
count += stack.stackSize;
}
}
@@ -428,23 +419,23 @@ public class CustomItemEffects {
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
- if(held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ 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++) {
+ 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()) &&
+ 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) {
+ } catch (Exception e) {
return count;
}
}
@@ -454,9 +445,9 @@ public class CustomItemEffects {
}
public boolean hasDirtWand() {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname != null && internalname.equals("INFINIDIRT_WAND")) {
+ if (internalname != null && internalname.equals("INFINIDIRT_WAND")) {
return true;
}
}
@@ -464,24 +455,23 @@ public class CustomItemEffects {
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
- if(held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ 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++) {
+ for (int j = 0; j < items.tagCount(); j++) {
NBTTagCompound buildersItem = items.getCompoundTagAt(j);
- if(buildersItem.getKeySet().size() > 0) {
+ if (buildersItem.getKeySet().size() > 0) {
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalnameFromNBT(buildersItem.getCompoundTag("tag"));
- if(internalname != null && internalname.equals("INFINIDIRT_WAND")) {
+ if (internalname != null && internalname.equals("INFINIDIRT_WAND")) {
return true;
}
}
}
- } catch(Exception e) {
- }
+ } catch (Exception ignored) {}
}
}
@@ -489,6 +479,7 @@ public class CustomItemEffects {
}
private static final List<BlockPos> zapperOffsets = new ArrayList<>();
+
static {
zapperOffsets.add(new BlockPos(0, 0, -1));
zapperOffsets.add(new BlockPos(0, 0, 1));
@@ -497,8 +488,10 @@ public class CustomItemEffects {
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);
@@ -518,7 +511,7 @@ public class CustomItemEffects {
@SubscribeEvent
public void renderBlockOverlay(DrawBlockHighlightEvent event) {
- if(aoteTeleportationCurr != null && aoteTeleportationMillis > 0) {
+ if (aoteTeleportationCurr != null && aoteTeleportationMillis > 0) {
event.setCanceled(true);
}
usingEtherwarp = false;
@@ -529,28 +522,28 @@ public class CustomItemEffects {
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(heldInternal != null) {
+ 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;
+ 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) {
+ 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")) {
+ if (aotv || heldInternal.equals("ETHERWARP_CONDUIT")) {
usingEtherwarp = !aotv;
- if(aotv) {
+ if (aotv) {
NBTTagCompound tag = held.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
usingEtherwarp = ea.hasKey("ethermerge");
}
}
- if(usingEtherwarp) {
+ if (usingEtherwarp) {
int dist = 0;
for (String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound())) {
String cleaned = Utils.cleanColour(line);
@@ -594,14 +587,14 @@ public class CustomItemEffects {
}
}
- if(heldInternal.equals("BLOCK_ZAPPER")) {
+ if (heldInternal.equals("BLOCK_ZAPPER")) {
if (!onPrivateIsland || !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableZapperOverlay ||
event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
zapperBlocks.clear();
return;
}
- if(zapperDirty) {
+ if (zapperDirty) {
zapperDirty = false;
zapperBlocks.clear();
@@ -615,36 +608,36 @@ public class CustomItemEffects {
BlockPos above = pos.add(0, 1, 0);
Block aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock();
- if(!cropBlocksZapper.contains(aboveBlock) && !cropBlocksZapper.contains(block) &&
+ 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++) {
+ for (int i = 0; i < 164; i++) {
zapperBlocks.add(pos);
returnablePositions.remove(pos);
List<BlockPos> availableNeighbors = new ArrayList<>();
- for(BlockPos offset : zapperOffsets) {
+ for (BlockPos offset : zapperOffsets) {
BlockPos newPos = pos.add(offset);
- if(zapperBlocks.contains(newPos)) continue;
+ if (zapperBlocks.contains(newPos)) continue;
IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(newPos);
- if(state != null && state.getBlock() == block) {
+ if (state != null && state.getBlock() == block) {
above = newPos.add(0, 1, 0);
aboveBlock = Minecraft.getMinecraft().theWorld.getBlockState(above).getBlock();
- if(!cropBlocksZapper.contains(aboveBlock)) {
+ if (!cropBlocksZapper.contains(aboveBlock)) {
availableNeighbors.add(newPos);
}
}
}
- if(availableNeighbors.size() >= 2) {
+ if (availableNeighbors.size() >= 2) {
returnablePositions.add(pos);
pos = availableNeighbors.get(0);
- } else if(availableNeighbors.size() == 1) {
+ } else if (availableNeighbors.size() == 1) {
pos = availableNeighbors.get(0);
- } else if(returnablePositions.isEmpty()) {
+ } else if (returnablePositions.isEmpty()) {
break;
} else {
i--;
@@ -653,7 +646,7 @@ public class CustomItemEffects {
}
}
}
- for(BlockPos pos : zapperBlocks) {
+ 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),
@@ -662,10 +655,10 @@ public class CustomItemEffects {
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
- } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableTreecapOverlay &&
+ } 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 (heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35;
if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
GlStateManager.enableBlend();
@@ -674,7 +667,7 @@ public class CustomItemEffects {
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
- if(Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log ||
+ if (Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log ||
Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log2) {
int woods = 0;
@@ -685,8 +678,8 @@ public class CustomItemEffects {
candidatesNew.add(event.target.getBlockPos());
- while(woods < maxWood) {
- if(candidatesNew.isEmpty()) {
+ while (woods < maxWood) {
+ if (candidatesNew.isEmpty()) {
break;
}
@@ -696,20 +689,20 @@ public class CustomItemEffects {
woods += candidates.size();
boolean random = woods > maxWood;
- while(!candidates.isEmpty()) {
+ 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) {
+ 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)) {
+ 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) {
+ if (blockNew == Blocks.log || blockNew == Blocks.log2) {
candidatesNew.add(posNew);
}
}
@@ -721,7 +714,7 @@ public class CustomItemEffects {
block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
- .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.treecapOverlayColour);
}
}
@@ -731,15 +724,15 @@ public class CustomItemEffects {
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
- } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableWandOverlay) {
- if(heldInternal.equals("BUILDERS_WAND") && onPrivateIsland) {
+ } 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) {
+ if (hover.getBlock() == Blocks.air) {
IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos());
Item matchItem = Item.getItemFromBlock(match.getBlock());
- if(matchItem != null) {
+ if (matchItem != null) {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.disableTexture2D();
@@ -750,10 +743,10 @@ public class CustomItemEffects {
getBuildersWandCandidates(player, event.target, event.partialTicks, candidatesOld, candidatesOldSorted, 10);
- ItemStack matchStack = new ItemStack(matchItem, 1,
+ 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()) {
+ if (match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) {
itemCount = candidatesOld.size();
} else {
itemCount = countItemsInInventoryAndStorage(matchStack);
@@ -762,19 +755,19 @@ public class CustomItemEffects {
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) {
+ 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);
+ drawBlock((int) bb.minX, (int) bb.minY, (int) bb.minZ + 1, match, event.partialTicks, 0.75f);
}
}
- for(BlockPos candidate : candidatesOld) {
+ 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)
@@ -791,10 +784,10 @@ public class CustomItemEffects {
}
}
}
- } else if(heldInternal.equals("INFINIDIRT_WAND") && event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ } 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) {
+ if (hoverState.getBlock() == Blocks.air) {
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.disableTexture2D();
@@ -803,7 +796,7 @@ public class CustomItemEffects {
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(),
+ 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)
@@ -814,60 +807,60 @@ public class CustomItemEffects {
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
- } else if((heldInternal.equals("WATER_BUCKET") || heldInternal.equals("MAGICAL_WATER_BUCKET") && NotEnoughUpdates.INSTANCE.config.itemOverlays.enablePrismapumpOverlay && onPrivateIsland) &&
+ } 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)) {
+ 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 (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) {
+ if (Math.abs(renderPos.getX()) > 128) {
break;
}
- if(Math.abs(renderPos.getY()) > 255) {
+ if (Math.abs(renderPos.getY()) > 255) {
break;
}
- if(Math.abs(renderPos.getZ()) > 128) {
+ 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) {
+ if (renderState.getBlock() != Blocks.air && renderState.getBlock() != Blocks.water &&
+ renderState.getBlock() != Blocks.flowing_water) {
break;
}
- if(yOff != 0) {
+ if (yOff != 0) {
verticalSources.add(renderPos);
} else {
IBlockState belowState = Minecraft.getMinecraft().theWorld.getBlockState(renderPos.add(0, -1, 0));
- if(belowState.getBlock() == Blocks.air) {
+ 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);
+ 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;
+ float distSq = xDist * xDist + yDist * yDist + zDist * zDist;
- watersSorted.computeIfAbsent(distSq, k->new HashMap<>()).put(renderPos, facing);
+ watersSorted.computeIfAbsent(distSq, k -> new HashMap<>()).put(renderPos, facing);
}
}
@@ -883,12 +876,12 @@ public class CustomItemEffects {
GlStateManager.disableTexture2D();
GlStateManager.depthMask(true);
- for(HashMap<BlockPos, EnumFacing> blockPoses : watersSorted.values()) {
- for(Map.Entry<BlockPos, EnumFacing> entry : blockPoses.entrySet()) {
+ 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);
+ .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");
}
}
@@ -896,25 +889,25 @@ public class CustomItemEffects {
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
- } else if((heldInternal.equals("HOE_OF_GREAT_TILLING") || heldInternal.equals("HOE_OF_GREATER_TILLING") && onPrivateIsland) &&
+ } 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) {
+ 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++) {
+ 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) {
+ 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);
@@ -943,45 +936,45 @@ public class CustomItemEffects {
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;
+ 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()) {
+ 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;
+ 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);
+ 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)) ||
+ 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) {
+ 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)) {
+ if (!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) {
IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew);
- if(blockNew == match) {
+ if (blockNew == match) {
candidatesNew.add(posNew);
}
}
@@ -997,9 +990,9 @@ public class CustomItemEffects {
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;
+ 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();
@@ -1014,10 +1007,10 @@ public class CustomItemEffects {
GlStateManager.cullFace(GL11.GL_BACK);
GlStateManager.pushMatrix();
- GlStateManager.translate(x-d0, y-d1, z-d2);
+ GlStateManager.translate(x - d0, y - d1, z - d2);
int i = state.getBlock().getRenderType();
- if(i == 3) {
+ if (i == 3) {
IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(state, Minecraft.getMinecraft().theWorld, null);
Block block = state.getBlock();
@@ -1039,7 +1032,7 @@ public class CustomItemEffects {
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
- GlStateManager.translate(-x+d0, -y+d1, -z+d2);
+ GlStateManager.translate(-x + d0, -y + d1, -z + d2);
GlStateManager.popMatrix();
}
@@ -1054,7 +1047,7 @@ public class CustomItemEffects {
worldrenderer.putColor4(c);
Vec3i vec3i = bakedquad.getFace().getDirectionVec();
- worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
+ worldrenderer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
tessellator.draw();
}
}
@@ -1069,7 +1062,7 @@ public class CustomItemEffects {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
- GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha);
+ GlStateManager.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha);
//vertical
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
@@ -1085,8 +1078,7 @@ public class CustomItemEffects {
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);
+ 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);
@@ -1102,8 +1094,7 @@ public class CustomItemEffects {
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);
+ 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();
@@ -1121,7 +1112,7 @@ public class CustomItemEffects {
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.color(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f * alpha);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
@@ -1130,7 +1121,7 @@ public class CustomItemEffects {
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
- switch(facing) {
+ 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();
@@ -1173,9 +1164,9 @@ public class CustomItemEffects {
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);
+ 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);
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..81fc62ac 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;
@@ -55,13 +41,13 @@ public class CustomSkulls implements IResourceManagerReloadListener {
return INSTANCE;
}
- private ResourceLocation atlas = new ResourceLocation("notenoughupdates:custom_skull_textures_atlas");
- private ResourceLocation configuration = new ResourceLocation("notenoughupdates:custom_skull_textures/customskull.json");
+ 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.<ResourceLocation, TextureAtlasSprite>newHashMap();
+ protected final Map<ResourceLocation, TextureAtlasSprite> sprites = Maps.newHashMap();
private final FaceBakery faceBakery = new FaceBakery();
private final ModelSkeletonHead humanoidHead = new ModelHumanoidHead();
@@ -70,7 +56,7 @@ public class CustomSkulls implements IResourceManagerReloadListener {
private final Gson gson = new GsonBuilder().create();
- private class CustomSkull {
+ private static class CustomSkull {
private ModelBlock model;
private IBakedModel modelBaked;
@@ -81,16 +67,16 @@ public class CustomSkulls implements IResourceManagerReloadListener {
public void onResourceManagerReload(IResourceManager resourceManager) {
customSkulls.clear();
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
+ 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;
+ if (json == null) return;
- for(Map.Entry<String, JsonElement> entry : json.entrySet()) {
- if(entry.getValue().isJsonObject()) {
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ if (entry.getValue().isJsonObject()) {
JsonObject obj = entry.getValue().getAsJsonObject();
- if(obj.has("model")) {
+ if (obj.has("model")) {
String location = obj.get("model").getAsString();
ResourceLocation loc = new ResourceLocation("notenoughupdates:custom_skull_textures/" + location + ".json");
@@ -98,7 +84,7 @@ public class CustomSkulls implements IResourceManagerReloadListener {
skull.model = ModelBlock.deserialize(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream()));
customSkulls.put(entry.getKey(), skull);
- } else if(obj.has("texture")) {
+ } else if (obj.has("texture")) {
String location = obj.get("texture").getAsString();
ResourceLocation loc = new ResourceLocation("notenoughupdates:custom_skull_textures/" + location + ".png");
@@ -114,26 +100,23 @@ public class CustomSkulls implements IResourceManagerReloadListener {
loadSprites();
- for(CustomSkull skull : customSkulls.values()) {
- if(skull.model != null) {
+ 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) {
- }
+ } catch (Exception ignored) {}
}
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);
- }
+ 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);
@@ -143,8 +126,8 @@ public class CustomSkulls implements IResourceManagerReloadListener {
protected Set<ResourceLocation> getAllTextureLocations() {
Set<ResourceLocation> set = new HashSet<>();
- for(CustomSkull skull : customSkulls.values()) {
- if(skull.model != null) {
+ for (CustomSkull skull : customSkulls.values()) {
+ if (skull.model != null) {
set.addAll(getTextureLocations(skull.model));
}
}
@@ -153,10 +136,10 @@ public class CustomSkulls implements IResourceManagerReloadListener {
}
protected Set<ResourceLocation> getTextureLocations(ModelBlock modelBlock) {
- Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
+ Set<ResourceLocation> set = Sets.newHashSet();
- for(BlockPart blockpart : modelBlock.getElements()) {
- for(BlockPartFace blockpartface : blockpart.mapFaces.values()) {
+ for (BlockPart blockpart : modelBlock.getElements()) {
+ for (BlockPartFace blockpartface : blockpart.mapFaces.values()) {
ResourceLocation resourcelocation = new ResourceLocation("notenoughupdates", modelBlock.resolveTextureName(blockpartface.texture));
set.add(resourcelocation);
}
@@ -170,12 +153,12 @@ public class CustomSkulls implements IResourceManagerReloadListener {
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()) {
+ 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())) {
+ 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));
@@ -199,7 +182,7 @@ public class CustomSkulls implements IResourceManagerReloadListener {
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.ITEM);
- for(EnumFacing enumfacing : EnumFacing.values()) {
+ for (EnumFacing enumfacing : EnumFacing.values()) {
this.renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color);
}
@@ -210,7 +193,7 @@ public class CustomSkulls implements IResourceManagerReloadListener {
private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color) {
int i = 0;
- for(int j = quads.size(); i < j; ++i) {
+ for (int j = quads.size(); i < j; ++i) {
BakedQuad bakedquad = quads.get(i);
int k = color;
@@ -220,22 +203,22 @@ public class CustomSkulls implements IResourceManagerReloadListener {
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) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.disableSkullRetexturing) {
return false;
}
- if(placedDirection != EnumFacing.UP || skullType != 3) {
+ if (placedDirection != EnumFacing.UP || skullType != 3) {
return false;
}
- if(skullOwner == null || skullOwner.getId() == null) {
+ if (skullOwner == null || skullOwner.getId() == null) {
return false;
}
CustomSkull skull = customSkulls.get(skullOwner.getId().toString());
- if(skull == null) {
+ if (skull == null) {
return false;
}
- if(skull.modelBaked != null && skull.model != null) {
+ if (skull.modelBaked != null && skull.model != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(atlas);
GlStateManager.pushMatrix();
GlStateManager.disableCull();
@@ -250,7 +233,7 @@ public class CustomSkulls implements IResourceManagerReloadListener {
GlStateManager.translate(0, 0.25f, 0);
- if(xOffset == -0.5 && yOffset == 0 && zOffset == -0.5 && rotationDeg == 180) {
+ if (xOffset == -0.5 && yOffset == 0 && zOffset == -0.5 && rotationDeg == 180) {
skull.model.getAllTransforms().applyTransform(ItemCameraTransforms.TransformType.HEAD);
} else {
skull.model.getAllTransforms().applyTransform(mostRecentTransformType);
@@ -260,8 +243,8 @@ public class CustomSkulls implements IResourceManagerReloadListener {
renderModel(skull.modelBaked, 0xffffffff);
GlStateManager.popMatrix();
- } else if(skull.texture != null) {
- if( Minecraft.getMinecraft().getTextureManager().getTexture(skull.texture) == null) {
+ } 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());
@@ -271,14 +254,14 @@ public class CustomSkulls implements IResourceManagerReloadListener {
public void loadTexture(IResourceManager resourceManager) {
TextureUtil.allocateTexture(this.getGlTextureId(), size, size);
- int[] rgb = new int[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) {}
+ } catch (IOException ignored) {}
}
Minecraft.getMinecraft().getTextureManager().bindTexture(skull.texture);
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..5f3a5afa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java
@@ -9,7 +9,6 @@ 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;
@@ -21,18 +20,18 @@ public class DamageCommas {
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_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();
+ if (!entity.hasCustomName()) return entity.getDisplayName();
IChatComponent name = entity.getDisplayName();
- if(NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 0) return name;
+ if (NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 0) return name;
- if(replacementMap.containsKey(entity)) {
+ if (replacementMap.containsKey(entity)) {
ChatComponentText component = replacementMap.get(entity);
- if(component == null) return name;
+ if (component == null) return name;
return component;
}
@@ -44,17 +43,17 @@ public class DamageCommas {
String suffix;
Matcher matcherCrit = PATTERN_CRIT.matcher(formatted);
- if(matcherCrit.matches()) {
+ if (matcherCrit.matches()) {
crit = true;
numbers = StringUtils.cleanColour(matcherCrit.group(1));
- prefix = "\u00a7f"+STAR;
- suffix = "\u00a7f"+STAR+matcherCrit.group(2);
+ prefix = "\u00a7f" + STAR;
+ suffix = "\u00a7f" + STAR + matcherCrit.group(2);
} else {
Matcher matcherNoCrit = PATTERN_NO_CRIT.matcher(formatted);
- if(matcherNoCrit.matches()) {
+ if (matcherNoCrit.matches()) {
numbers = matcherNoCrit.group(1);
prefix = "\u00A77";
- suffix = "\u00A7r"+matcherNoCrit.group(2);
+ suffix = "\u00A7r" + matcherNoCrit.group(2);
} else {
replacementMap.put(entity, null);
return name;
@@ -66,22 +65,22 @@ public class DamageCommas {
try {
int number = Integer.parseInt(numbers);
- if(number > 999 && NotEnoughUpdates.INSTANCE.config.misc.damageIndicatorStyle == 2) {
+ 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) {
+ } catch (NumberFormatException e) {
replacementMap.put(entity, null);
return name;
}
- if(crit) {
+ if (crit) {
StringBuilder newFormattedCrit = new StringBuilder();
int colourIndex = 0;
- for(char c : newFormatted.toString().toCharArray()) {
- if(c == ',') {
+ for (char c : newFormatted.toString().toCharArray()) {
+ if (c == ',') {
newFormattedCrit.append(EnumChatFormatting.GRAY);
} else {
newFormattedCrit.append(coloursHypixel[colourIndex++ % coloursHypixel.length]);
@@ -92,23 +91,23 @@ public class DamageCommas {
newFormatted = newFormattedCrit;
}
- ChatComponentText finalComponent = new ChatComponentText(prefix+newFormatted.toString()+suffix);
+ ChatComponentText finalComponent = new ChatComponentText(prefix + newFormatted + suffix);
replacementMap.put(entity, finalComponent);
return finalComponent;
- /*if(formatted.startsWith("\u00A7f\u2727")) System.out.println(formatted);
+ /*if (formatted.startsWith("\u00A7f\u2727")) System.out.println(formatted);
- if(formatted.length() >= 7 && (formatted.startsWith("\u00A7f\u2727") || formatted.startsWith("\u00A7f\u2694")) &&
+ 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 +115,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 +126,11 @@ 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 +138,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,16 +183,16 @@ 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;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java
index b05c430d..8be1fae8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java
@@ -1,33 +1,30 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
-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.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.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
public class DwarvenMinesTextures {
@@ -50,45 +47,45 @@ public class DwarvenMinesTextures {
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;
+ 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;
+ 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) {
+ if (titanium) {
IBlockState plus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(1, 0, 0));
- if(plus.getBlock() == Blocks.double_stone_slab) {
+ 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) {
+ 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) {
+ if (above.getBlock() == Blocks.stone_slab) {
return 1;
}
}
- if(titanium || (state.getBlock() == Blocks.stained_hardened_clay && state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) ||
+ 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) {
+ 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))) {
+ 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()) {
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
String coord = entry.getKey();
String[] split = coord.split("_");
int left = Integer.parseInt(split[0]);
@@ -96,53 +93,53 @@ public class DwarvenMinesTextures {
ignoredChunks.add(new ChunkCoordIntPair(left, right));
}
}
- } catch(Exception e) {
+ } 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));
+ 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)) {
+ if (ignoredChunks.contains(pair)) {
return 1;
}
- if(titanium) {
+ if (titanium) {
return 2;
}
- if(!loadedChunkData.containsKey(pair)) {
+ 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");
+ 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))) {
+ 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()) {
+ 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()) {
+ if (entry.getValue().isJsonPrimitive()) {
JsonPrimitive prim = entry.getValue().getAsJsonPrimitive();
- if(prim.isBoolean()) {
+ if (prim.isBoolean()) {
ignore = new IgnoreColumn(true, 0, 0);
- } else if(prim.isNumber()) {
+ } else if (prim.isNumber()) {
int y = prim.getAsInt();
ignore = new IgnoreColumn(false, y, y);
}
- } else if(entry.getValue().isJsonArray()) {
+ } else if (entry.getValue().isJsonArray()) {
JsonArray arr = entry.getValue().getAsJsonArray();
- if(arr.size() == 2) {
+ if (arr.size() == 2) {
int min = arr.get(0).getAsInt();
int max = arr.get(1).getAsInt();
ignore = new IgnoreColumn(false, min, max);
@@ -154,29 +151,29 @@ public class DwarvenMinesTextures {
}
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
loadedChunkData.put(pair, null);
}
}
- if(loadedChunkData.get(pair) != null) {
+ if (loadedChunkData.get(pair) != null) {
HashMap<ChunkCoordIntPair, IgnoreColumn> map = loadedChunkData.get(pair);
- if(map == null) {
+ 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;
+ 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) {
+ if (ignore != null) {
+ if (ignore.always) {
return 1;
} else {
int y = pos.getY();
- if(y >= ignore.minY && y <= ignore.maxY) {
+ if (y >= ignore.minY && y <= ignore.maxY) {
return 1;
}
}
@@ -195,26 +192,26 @@ public class DwarvenMinesTextures {
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 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()) {
+ if (file.exists()) {
col = 0x00ff00;
- if(Keyboard.isKeyDown(Keyboard.KEY_K)) {
+ 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);
+ 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));
@@ -227,68 +224,67 @@ public class DwarvenMinesTextures {
//Don't render clay - mesaPlateau_F
public static void tick() {
- if(!NotEnoughUpdates.INSTANCE.config.mining.dwarvenTextures) return;
+ 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) {
+ 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 (Minecraft.getMinecraft().theWorld == null) return;
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) 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;
+ int playerX = (int) Minecraft.getMinecraft().thePlayer.posX;
+ int playerZ = (int) Minecraft.getMinecraft().thePlayer.posZ;
-
- if(Keyboard.isKeyDown(Keyboard.KEY_C)) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_C)) {
ignoredBlocks.clear();
whitelistBlocks.clear();
}
- if(Keyboard.isKeyDown(Keyboard.KEY_R)) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_R)) {
ignoredChunks.clear();
}
- if(Keyboard.isKeyDown(Keyboard.KEY_P)) {
+ 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()) {
+ 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()) {
+ 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()) {
+ 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()) {
+ if (!whitelistMap.containsKey(columnEntry.getKey()) || whitelistMap.get(columnEntry.getKey()).isEmpty()) {
subChunkObj.addProperty(columnId, true);
- } else if(!columnEntry.getValue().isEmpty()) {
+ } else if (!columnEntry.getValue().isEmpty()) {
JsonArray whitelistedBlocksInColumn = new JsonArray();
int min = 300;
int max = 0;
- for(BlockPos pos : columnEntry.getValue()) {
+ for (BlockPos pos : columnEntry.getValue()) {
int y = pos.getY();
- if(y < min) {
+ if (y < min) {
min = y;
}
- if(y > max) {
+ if (y > max) {
max = y;
}
}
whitelistedBlocksInColumn.add(new JsonPrimitive(min));
whitelistedBlocksInColumn.add(new JsonPrimitive(max));
- if(min < max) {
+ if (min < max) {
subChunkObj.add(columnId, whitelistedBlocksInColumn);
} else {
subChunkObj.addProperty(columnId, min);
@@ -296,13 +292,13 @@ public class DwarvenMinesTextures {
}
}
try {
- File file = new File("C:/Users/James/Desktop/testfolder/"+chunkId+".json");
+ 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))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(subChunkObj));
}
- } catch(IOException ignored) {
+ } catch (IOException ignored) {
ignored.printStackTrace();
}
}
@@ -312,76 +308,76 @@ public class DwarvenMinesTextures {
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))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(obj));
}
- } catch(IOException ignored) {
+ } catch (IOException ignored) {
ignored.printStackTrace();
}
}
- for(int xC=-10; xC<=10; xC++) {
+ 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);
+ for (int zC = -10; zC <= 10; zC++) {
+ ChunkCoordIntPair pair = new ChunkCoordIntPair(playerX / 16 + xC, playerZ / 16 + zC);
- if(!ignoredChunks.contains(pair)) {
+ 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);
+ 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.air) add = true;
- if(state != null && ((state.getBlock() == Blocks.stained_hardened_clay &&
+ 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 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) {
+ if (tot == 1) {
BlockPos pos2 = pos.add(xO, yO, zO);
IBlockState state2 = Minecraft.getMinecraft().theWorld.getBlockState(pos2);
- if(state2 == null) {
+ if (state2 == null) {
continue out;
- } else if(state2.getBlock() == Blocks.air) {
+ } else if (state2.getBlock() == Blocks.air) {
hasAir = true;
}
}
}
}
}
- if(!hasAir) continue;
+ 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) {
+ 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) {
+ 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);
+ } 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;
}
@@ -389,9 +385,9 @@ public class DwarvenMinesTextures {
}
}
}
- if(!found) {
- ignoredBlocks.computeIfAbsent(pair, k->new HashMap<>())
- .computeIfAbsent(column, k-> new HashSet<>()).add(pos);
+ 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..dec3f7d7 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,7 +29,8 @@ import java.util.regex.Pattern;
public class DwarvenMinesWaypoints {
- private HashMap<String, Vector3f> waypointsMap = new HashMap<>();
+ private final 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));
@@ -63,14 +57,15 @@ public class DwarvenMinesWaypoints {
}
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);
+ 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 enum Emissary {
@@ -85,6 +80,7 @@ public class DwarvenMinesWaypoints {
String name;
int minMilestone;
Vector3f loc;
+
Emissary(String name, int minMilestone, Vector3f loc) {
this.name = name;
this.minMilestone = minMilestone;
@@ -101,15 +97,15 @@ public class DwarvenMinesWaypoints {
@SubscribeEvent
public void onChat(ClientChatReceivedEvent event) {
Matcher matcherGhast = ghastRegex.matcher(event.message.getFormattedText());
- if(matcherGhast.find()) {
+ if (matcherGhast.find()) {
dynamicLocation = Utils.cleanColour(matcherGhast.group(1).trim());
- dynamicName = EnumChatFormatting.GOLD+"Powder Ghast";
+ dynamicName = EnumChatFormatting.GOLD + "Powder Ghast";
dynamicMillis = System.currentTimeMillis();
} else {
Matcher matcherStar = fallenStarRegex.matcher(event.message.getFormattedText());
- if(matcherStar.find()) {
+ if (matcherStar.find()) {
dynamicLocation = Utils.cleanColour(matcherStar.group(1).trim());
- dynamicName = EnumChatFormatting.DARK_PURPLE+"Fallen Star";
+ dynamicName = EnumChatFormatting.DARK_PURPLE + "Fallen Star";
dynamicMillis = System.currentTimeMillis();
}
}
@@ -119,37 +115,42 @@ public class DwarvenMinesWaypoints {
public void onTick(TickEvent.ClientTickEvent event) {
emissaryRemovedDistSq = -1;
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
-
+ 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;
+ if (hidden == null) return;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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++) {
+ 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")) {
+ 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) {
+ 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;
+ 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;
@@ -164,21 +165,21 @@ public class DwarvenMinesWaypoints {
@SubscribeEvent
public void onRenderSpecial(RenderLivingEvent.Specials.Pre<EntityArmorStand> event) {
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
+ if (SBInfo.getInstance().getLocation() == null) return;
+ if (!SBInfo.getInstance().getLocation().equals("mining_3")) return;
- if(commissionFinished && event.entity instanceof EntityArmorStand) {
+ 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)) {
+ 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) {
+ if (Math.abs(distSq - emissaryRemovedDistSq) < 1) {
event.setCanceled(true);
}
- } else if(emissaryNames.contains(name)) {
+ } 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) {
+ if (distSq >= 12 * 12) {
emissaryRemovedDistSq = distSq;
event.setCanceled(true);
}
@@ -186,35 +187,34 @@ public class DwarvenMinesWaypoints {
}
}
-
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
- if(SBInfo.getInstance().getLocation() == null) return;
- if(!SBInfo.getInstance().getLocation().equals("mining_3")) return;
+ 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)) {
+ 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(locWaypoint >= 1) {
- for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) {
- if(locWaypoint >= 2) {
- RenderUtils.renderWayPoint(EnumChatFormatting.AQUA+entry.getKey(), entry.getValue(), event.partialTicks);
+ 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);
+ 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);
+ RenderUtils.renderWayPoint(EnumChatFormatting.AQUA + entry.getKey(), entry.getValue(), event.partialTicks);
}
}
}
@@ -224,31 +224,31 @@ public class DwarvenMinesWaypoints {
commissionFinished = NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints >= 2;
- if(NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return;
+ if (NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return;
- if(!commissionFinished) {
- for(float f : MiningOverlay.commissionProgress.values()) {
+ if (!commissionFinished) {
+ for (float f : MiningOverlay.commissionProgress.values()) {
if (f >= 1) {
commissionFinished = true;
break;
}
}
}
- if(commissionFinished) {
- for(Emissary emissary : Emissary.values()) {
+ if (commissionFinished) {
+ for (Emissary emissary : Emissary.values()) {
NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
- if(hidden != null) {
- if(hidden.commissionMilestone >= emissary.minMilestone) {
+ 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,
+ 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..6e7dfc20 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/EnchantingSolvers.java
@@ -32,6 +32,7 @@ public class EnchantingSolvers {
}
private static final NBTTagCompound enchTag = new NBTTagCompound();
+
static {
enchTag.setTag("ench", new NBTTagList());
}
@@ -39,7 +40,7 @@ public class EnchantingSolvers {
//Chronomatron
private static boolean addToChronomatron = false;
private static boolean chronomatronStartSeq = false;
- private static List<String> chronomatronOrder = new ArrayList<>();
+ private static final List<String> chronomatronOrder = new ArrayList<>();
private static int chronomatronReplayIndex = 0;
private static int lastChronomatronSize = 0;
private static long millisLastClick = 0;
@@ -55,37 +56,37 @@ public class EnchantingSolvers {
}
}
- private static Map<Integer, UltrasequencerItem> ultraSequencerOrder = new HashMap<>();
+ private static final Map<Integer, UltrasequencerItem> ultraSequencerOrder = new HashMap<>();
private static int ultrasequencerReplayIndex = 0;
//Superpairs
- private static Map<Integer, ItemStack> superpairStacks = new HashMap<>();
+ private static final 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<>();
+ 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()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
return;
}
- if(event.gui instanceof GuiChest) {
+ 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")) {
+ if (!lower.contains("stakes")) {
+ if (lower.startsWith("chronomatron")) {
currentSolver = SolverType.CHRONOMATRON;
- } else if(lower.startsWith("ultrasequencer")) {
+ } else if (lower.startsWith("ultrasequencer")) {
currentSolver = SolverType.ULTRASEQUENCER;
- } else if(lower.startsWith("superpairs")) {
+ } else if (lower.startsWith("superpairs")) {
currentSolver = SolverType.SUPERPAIRS;
}
}
@@ -93,45 +94,45 @@ public class EnchantingSolvers {
}
public static ItemStack overrideStack(IInventory inventory, int slotIndex, ItemStack stack) {
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
return null;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
return null;
}
- if(stack != null && stack.getDisplayName() != null) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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) {
+ if (lower != inventory) {
return null;
}
String displayName = stack.getDisplayName();
- if(currentSolver == SolverType.CHRONOMATRON) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
+ 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()) {
+ if (yepClock && (addToChronomatron && chronomatronOrder.size() >= lastChronomatronSize + 1)) {
+ if (chronomatronReplayIndex < chronomatronOrder.size()) {
String chronomatronCurrent = chronomatronOrder.get(chronomatronReplayIndex);
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) ||
+ 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));
+ chronomatronCurrent.equals(chronomatronOrder.get(chronomatronReplayIndex - 1));
- if(chronomatronCurrent.equals(displayName)) {
- if(!lastSame || currentTime - millisLastClick > 300) {
+ 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());
@@ -142,9 +143,9 @@ public class EnchantingSolvers {
return retStack;
}
} else {
- if(chronomatronReplayIndex+1 < chronomatronOrder.size()) {
- String chronomatronNext = chronomatronOrder.get(chronomatronReplayIndex+1);
- if(chronomatronNext.equals(displayName)) {
+ 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;
@@ -158,20 +159,20 @@ public class EnchantingSolvers {
}
}
- } else if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
+ } 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()) {
+ 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) {
+ if (item.containerIndex == slotIndex) {
ItemStack newStack = item.stack;
- if(solveIndex == ultrasequencerReplayIndex) {
+ if (solveIndex == ultrasequencerReplayIndex) {
newStack.setTagCompound(enchTag);
} else {
newStack.setTagCompound(null);
@@ -184,8 +185,8 @@ public class EnchantingSolvers {
return retStack;
}
}
- } else if(currentSolver == SolverType.SUPERPAIRS) {
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
+ } else if (currentSolver == SolverType.SUPERPAIRS) {
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
superpairStacks.containsKey(slotIndex)) {
return superpairStacks.get(slotIndex);
}
@@ -196,77 +197,77 @@ public class EnchantingSolvers {
}
public static boolean onStackRender(ItemStack stack, IInventory inventory, int slotIndex, int x, int y) {
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
return false;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
return false;
}
- if(stack != null && stack.getDisplayName() != null) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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) {
+ if (lower != inventory) {
return false;
}
- if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
+ 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()) {
+ 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) {
+ if (item.containerIndex == slotIndex) {
int meta = 0;
- if(solveIndex == ultrasequencerReplayIndex) {
+ if (solveIndex == ultrasequencerReplayIndex) {
meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNext;
- } else if(solveIndex == ultrasequencerReplayIndex+1) {
+ } 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 (meta > 0) {
+ Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, meta - 1), x, y);
}
- if(NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNumbers &&
+ if (NotEnoughUpdates.INSTANCE.config.enchantingSolvers.seqNumbers &&
solveIndex >= ultrasequencerReplayIndex) {
- int w = Minecraft.getMinecraft().fontRendererObj.getStringWidth((solveIndex+1)+"");
+ 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);
+ 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) {
+ } else if (currentSolver == SolverType.SUPERPAIRS) {
int meta = 0;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass) &&
superpairStacks.containsKey(slotIndex)) {
- if(possibleMatches.contains(slotIndex)) {
+ if (possibleMatches.contains(slotIndex)) {
meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supPossible;
} else {
meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supUnmatched;
}
} else {
- if(powerupMatches.contains(slotIndex)) {
+ if (powerupMatches.contains(slotIndex)) {
meta = NotEnoughUpdates.INSTANCE.config.enchantingSolvers.supPower;
- } else if(successfulMatches.contains(slotIndex)) {
+ } 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);
+ if (meta > 0) {
+ Utils.drawItemStack(new ItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane), 1, meta - 1), x, y);
}
}
}
@@ -275,38 +276,38 @@ public class EnchantingSolvers {
}
public static boolean onStackClick(ItemStack stack, int windowId, int slotId, int mouseButtonClicked, int mode) {
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
return false;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
return false;
}
- if(stack != null && stack.getDisplayName() != null) {
+ if (stack != null && stack.getDisplayName() != null) {
String displayName = stack.getDisplayName();
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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) {
+ 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))) {
+ if (timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone) ||
+ (yepClock && (!addToChronomatron || chronomatronOrder.size() < lastChronomatronSize + 1))) {
return true;
- } else if(yepClock) {
+ } else if (yepClock) {
long currentTime = System.currentTimeMillis();
- if(currentTime - millisLastClick < 150) {
+ if (currentTime - millisLastClick < 150) {
return true;
}
- if(chronomatronReplayIndex < chronomatronOrder.size()) {
+ if (chronomatronReplayIndex < chronomatronOrder.size()) {
String chronomatronCurrent = chronomatronOrder.get(chronomatronReplayIndex);
/*if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.preventMisclicks ||
chronomatronCurrent.equals(displayName)) {
@@ -315,7 +316,7 @@ public class EnchantingSolvers {
2, mode, Minecraft.getMinecraft().thePlayer);
millisLastClick = currentTime;
}*/
- if(chronomatronCurrent.equals(displayName)) {
+ if (chronomatronCurrent.equals(displayName)) {
chronomatronReplayIndex++;
}
Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
@@ -324,16 +325,16 @@ public class EnchantingSolvers {
}
return true;
}
- } else if(currentSolver == SolverType.ULTRASEQUENCER) {
- ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory()-5);
- if(timerStack == null) {
+ } 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) {
+ if (yepClock) {
UltrasequencerItem current = ultraSequencerOrder.get(ultrasequencerReplayIndex);
- if(current == null) {
+ if (current == null) {
return true;
}
long currentTime = System.currentTimeMillis();
@@ -345,8 +346,8 @@ public class EnchantingSolvers {
2, mode, Minecraft.getMinecraft().thePlayer);
millisLastClick = currentTime;
}*/
- if(currentTime - millisLastClick > 150) {
- if(current.containerIndex == slotId) {
+ if (currentTime - millisLastClick > 150) {
+ if (current.containerIndex == slotId) {
ultrasequencerReplayIndex++;
}
Minecraft.getMinecraft().playerController.windowClick(windowId, slotId,
@@ -357,7 +358,7 @@ public class EnchantingSolvers {
} else {
return true;
}
- } else if(currentSolver == SolverType.SUPERPAIRS) {
+ } else if (currentSolver == SolverType.SUPERPAIRS) {
lastSlotClicked = slotId;
}
}
@@ -366,22 +367,22 @@ public class EnchantingSolvers {
}
public static void processInventoryContents(boolean fromTick) {
- if(currentSolver != SolverType.CHRONOMATRON && !fromTick) return;
+ if (currentSolver != SolverType.CHRONOMATRON && !fromTick) return;
- if(!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
+ if (!NotEnoughUpdates.INSTANCE.config.enchantingSolvers.enableEnchantingSolvers) {
return;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
return;
}
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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) {
+ if (currentSolver == SolverType.CHRONOMATRON) {
ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
if (timerStack == null) {
return;
@@ -426,49 +427,49 @@ public class EnchantingSolvers {
chronomatronStartSeq = true;
addToChronomatron = true;
}
- if(currentSolver == SolverType.ULTRASEQUENCER) {
+ if (currentSolver == SolverType.ULTRASEQUENCER) {
ItemStack timerStack = lower.getStackInSlot(lower.getSizeInventory() - 5);
if (timerStack == null) {
return;
}
- if(timerStack.getItem() == Item.getItemFromBlock(Blocks.glowstone)) {
+ 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);
+ 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));
+ ultraSequencerOrder.put(stack.stackSize - 1, new UltrasequencerItem(stack, index));
}
}
}
} else {
ultraSequencerOrder.clear();
}
- if(currentSolver == SolverType.SUPERPAIRS) {
+ 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 == 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) {
+ 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")) {
+ if (list.getStringTagAt(i).toLowerCase().contains("powerup")) {
powerupMatches.add(index);
continue out;
}
@@ -479,20 +480,20 @@ public class EnchantingSolvers {
int numMatches = 0;
for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
ItemStack stack2 = lower.getStackInSlot(index2);
- if(stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
+ 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)) {
+ if ((!oddMatches || index != lastSlotClicked) && !successfulMatches.contains(index)) {
for (int index2 = 0; index2 < lower.getSizeInventory(); index2++) {
- if(index == index2) continue;
- if(oddMatches && index2 == lastSlotClicked) continue;
+ if (index == index2) continue;
+ if (oddMatches && index2 == lastSlotClicked) continue;
ItemStack stack2 = lower.getStackInSlot(index2);
- if(stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
+ if (stack2 != null && stack2.getDisplayName().equals(stack.getDisplayName()) &&
stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage()) {
successfulMatches.add(index);
successfulMatches.add(index2);
@@ -500,15 +501,15 @@ public class EnchantingSolvers {
}
}
} else {
- if(superpairStacks.containsKey(index) && superpairStacks.get(index) != null &&
+ 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 (index == index2) continue;
- if(superpairStacks.containsKey(index2) && superpairStacks.get(index2) != null) {
+ if (superpairStacks.containsKey(index2) && superpairStacks.get(index2) != null) {
ItemStack stack2 = superpairStacks.get(index2);
- if(stack1.getDisplayName().equals(stack2.getDisplayName()) &&
+ if (stack1.getDisplayName().equals(stack2.getDisplayName()) &&
stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage()) {
possibleMatches.add(index);
possibleMatches.add(index2);
@@ -527,13 +528,12 @@ public class EnchantingSolvers {
}
}
-
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
- if(NotEnoughUpdates.INSTANCE.config.enchantingSolvers.hideTooltips &&
+ 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(" ")) {
+ if (internal == null && event.toolTip.size() > 0 && !event.toolTip.get(0).trim().replaceAll("\\(#.+\\)$", "").trim().contains(" ")) {
event.toolTip.clear();
}
}
@@ -541,11 +541,11 @@ public class EnchantingSolvers {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
currentSolver = SolverType.NONE;
}
- if(event.phase != TickEvent.Phase.END) {
+ if (event.phase != TickEvent.Phase.END) {
return;
}
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..95dde052 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java
@@ -8,11 +8,11 @@ import io.github.moulberry.notenoughupdates.commands.SimpleCommand;
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.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;
@@ -36,21 +36,21 @@ public class FairySouls {
}
public static void load(File file, Gson gson) {
- if(file.exists()) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ 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()) {
+ for (Map.Entry<String, List<Number>> entry : foundSoulsList.entrySet()) {
HashSet<Integer> set = new HashSet<>();
- for(Number n : entry.getValue()) {
+ for (Number n : entry.getValue()) {
set.add(n.intValue());
}
foundSouls.put(entry.getKey(), set);
}
return;
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
}
foundSouls = new HashMap<>();
}
@@ -59,34 +59,34 @@ public class FairySouls {
try {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(gson.toJson(foundSouls));
}
- } catch(IOException ignored) {}
+ } catch (IOException ignored) {}
}
@SubscribeEvent
public void onChatReceived(ClientChatReceivedEvent event) {
- if(currentSoulList == null) return;
+ if (currentSoulList == null) return;
- if(event.message.getFormattedText().equals("\u00A7r\u00A7dYou have already found that Fairy Soul!\u00A7r") ||
+ 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;
+ if (location == null) return;
int closestIndex = -1;
- double closestDistSq = 10*10;
- for(int i=0; i<currentSoulList.size(); i++) {
+ 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) {
+ if (distSq < closestDistSq) {
closestDistSq = distSq;
closestIndex = i;
}
}
- if(closestIndex != -1) {
+ if (closestIndex != -1) {
Set<Integer> found = foundSouls.computeIfAbsent(location, k -> new HashSet<>());
found.add(closestIndex);
}
@@ -94,32 +94,32 @@ public class FairySouls {
}
public static void tick() {
- if(!enabled) return;
+ if (!enabled) return;
- if(Minecraft.getMinecraft().theWorld == null) {
+ if (Minecraft.getMinecraft().theWorld == null) {
currentSoulList = null;
return;
}
JsonObject fairySouls = Constants.FAIRYSOULS;
- if(fairySouls == null) return;
+ if (fairySouls == null) return;
String location = SBInfo.getInstance().getLocation();
- if(location == null) {
+ if (location == null) {
currentSoulList = null;
return;
}
- if(currentSoulList == null) {
- if(fairySouls.has(location) && fairySouls.get(location).isJsonArray()) {
+ 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++) {
+ for (int i = 0; i < locations.size(); i++) {
try {
String coord = locations.get(i).getAsString();
String[] split = coord.split(",");
- if(split.length == 3) {
+ if (split.length == 3) {
String xS = split[0];
String yS = split[1];
String zS = split[2];
@@ -128,20 +128,21 @@ public class FairySouls {
int y = Integer.parseInt(yS);
int z = Integer.parseInt(zS);
- currentSoulList.add(new BlockPos(x, y , z));
+ currentSoulList.add(new BlockPos(x, y, z));
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {
+ }
}
}
}
- if(currentSoulList != null && !currentSoulList.isEmpty()) {
+ 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;
+ 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());
@@ -151,26 +152,25 @@ public class FairySouls {
int maxSouls = 15;
int souls = 0;
currentSoulListClose = new ArrayList<>();
- for(BlockPos pos : distanceSqMap.values()) {
+ for (BlockPos pos : distanceSqMap.values()) {
currentSoulListClose.add(pos);
- if(++souls >= maxSouls) break;
+ if (++souls >= maxSouls) break;
}
}
}
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
- if(!enabled) return;
+ if (!enabled) return;
String location = SBInfo.getInstance().getLocation();
- if(location == null) return;
- if(currentSoulList == null || currentSoulList.isEmpty()) return;
+ 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);
+ for (BlockPos currentSoul : currentSoulListClose) {
RenderUtils.renderBeaconBeamOrBoundingBox(currentSoul, rgb, 1.0f, event.partialTicks);
}
}
@@ -188,10 +188,10 @@ public class FairySouls {
}
}
- private static SimpleCommand.ProcessCommandRunnable fairysoulRunnable = new SimpleCommand.ProcessCommandRunnable() {
+ private static final SimpleCommand.ProcessCommandRunnable fairysoulRunnable = new SimpleCommand.ProcessCommandRunnable() {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if(args.length != 1) {
+ if (args.length != 1) {
printHelp();
return;
}
@@ -203,39 +203,39 @@ public class FairySouls {
return;
case "on":
case "enable":
- print(EnumChatFormatting.DARK_PURPLE+"Enabled fairy soul waypoints");
+ print(EnumChatFormatting.DARK_PURPLE + "Enabled fairy soul waypoints");
enabled = true;
return;
case "off":
case "disable":
- print(EnumChatFormatting.DARK_PURPLE+"Disabled fairy soul waypoints");
+ 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");
+ 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++) {
+ for (int i = 0; i < currentSoulList.size(); i++) {
found.add(i);
}
- print(EnumChatFormatting.DARK_PURPLE+"Marked all fairy souls as 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");
+ 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");
+ print(EnumChatFormatting.DARK_PURPLE + "Marked all fairy souls as not found");
foundSouls.remove(location);
}
return;
}
- print(EnumChatFormatting.RED+"Unknown subcommand: " + subcommand);
+ print(EnumChatFormatting.RED + "Unknown subcommand: " + subcommand);
}
};
@@ -245,16 +245,16 @@ public class FairySouls {
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_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(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("");
}
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..cb946426 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,39 +11,35 @@ 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];
+ 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");
+ 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) {
+ 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);
@@ -58,13 +48,13 @@ public class FancyPortals {
GlStateManager.loadIdentity();
GlStateManager.translate(3.5F, 3.5F, -1.0F);
GlStateManager.rotate(-90, 1, 0, 0);
- } else if(perspectiveId <= 4) {
+ } 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.rotate(perspectiveId * 90, 0, 1, 0);
GlStateManager.translate(0, -3.5f, 0);
} else {
GlStateManager.matrixMode(5889);
@@ -84,7 +74,7 @@ public class FancyPortals {
private static WorldRenderer surfaceWorldRenderer = null;
private static WorldRenderer getSurfaceWorldRenderer() {
- if(surfaceWorldRenderer != null && !Keyboard.isKeyDown(Keyboard.KEY_O)) {
+ if (surfaceWorldRenderer != null && !Keyboard.isKeyDown(Keyboard.KEY_O)) {
return surfaceWorldRenderer;
}
@@ -94,35 +84,35 @@ public class FancyPortals {
}
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 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);
+ 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;
+ 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();
+ 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 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++) {
+ 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);
+ drawPoint(worldRenderer, x, y + 1);
+ drawPoint(worldRenderer, x + 1, y + 1);
+ drawPoint(worldRenderer, x + 1, y);
}
}
@@ -132,7 +122,7 @@ public class FancyPortals {
private static long overridingRenderMillis = -1;
public static void onRespawnPacket(S07PacketRespawn packet) {
- if(true) return;
+ if (true) return;
if (packet.getDimensionID() != Minecraft.getMinecraft().thePlayer.dimension) {
overridingRenderMillis = System.currentTimeMillis();
}
@@ -143,22 +133,22 @@ public class FancyPortals {
}
public static boolean shouldRenderWorldOverlay() {
- if(overridingRenderMillis > 0) {
- if(Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
+ 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) {
+ for (RenderGlobal.ContainerLocalRenderInformation info : renderGlobal.renderInfos) {
CompiledChunk compiledchunk = info.renderChunk.compiledChunk;
if (compiledchunk != CompiledChunk.DUMMY && !compiledchunk.isEmpty()) {
- if(++loaded >= 5) {
+ if (++loaded >= 5) {
overridingRenderMillis = -1;
return false;
}
}
}
}
- if(System.currentTimeMillis() - overridingRenderMillis > 1000) {
+ if (System.currentTimeMillis() - overridingRenderMillis > 1000) {
overridingRenderMillis = -1;
return false;
}
@@ -168,8 +158,8 @@ public class FancyPortals {
}
public static void onUpdateCameraAndRender(float partialTicks, long nanoTime) {
- if(overridingRenderMillis > 0) {
- if(Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
+ if (overridingRenderMillis > 0) {
+ if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null) {
Minecraft.getMinecraft().thePlayer.timeInPortal = 0.3f;
Minecraft.getMinecraft().thePlayer.prevTimeInPortal = 0.3f;
}
@@ -194,36 +184,40 @@ public class FancyPortals {
}
private static void renderWorld() {
- for(int i=5; i>=0; i--) {
+ 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);
+ if (i != 0) GlStateManager.translate(0, -3.49, 0);
switch (i) {
case 1:
- GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); break;
+ GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
+ break;
case 2:
- GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); break;
+ GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
+ break;
case 3:
- GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); break;
+ GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
+ break;
case 5:
- GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); break;
+ GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
+ break;
case 0:
- GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); break;
+ 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(0, 0, 3.49);
- if(i != 0) {
+ if (i != 0) {
GlStateManager.translate(-3.5f, -3.5f, 0);
WorldRenderer worldRenderer = getSurfaceWorldRenderer();
VertexFormat vertexformat = worldRenderer.getVertexFormat();
@@ -254,8 +248,8 @@ public class FancyPortals {
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
- if(true) return;
- if(!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
+ if (true) return;
+ if (!Minecraft.getMinecraft().getFramebuffer().isStencilEnabled())
Minecraft.getMinecraft().getFramebuffer().enableStencil();
GL11.glEnable(GL11.GL_STENCIL_TEST);
@@ -275,23 +269,22 @@ public class FancyPortals {
double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks;
GlStateManager.pushMatrix();
- GlStateManager.translate(-viewerX+12+5/16f, -viewerY+100, -viewerZ+39);
+ 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);
+ 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);
+ GlStateManager.translate(-viewerX + 12, -viewerY + 100, -viewerZ + 37.5f);
renderWorld();
@@ -299,5 +292,4 @@ public class FancyPortals {
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..8e712012 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;
@@ -54,6 +53,7 @@ public class FishingHelper {
FISH_INCOMING,
FISH_HOOKED
}
+
public PlayerWarningState warningState = PlayerWarningState.NOTHING;
private int hookedWarningStateTicks = 0;
@@ -66,11 +66,14 @@ public class FishingHelper {
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 (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;
+ 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();
@@ -79,9 +82,9 @@ public class FishingHelper {
float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f;
- float centerOffset = 0.5f/8f;
+ 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);
+ 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);
@@ -91,15 +94,15 @@ public class FishingHelper {
}
public void addEntity(int entityId, Entity entity) {
- if(entity instanceof EntityFishHook) {
+ if (entity instanceof EntityFishHook) {
hookEntities.put(entityId, (EntityFishHook) entity);
- if(((EntityFishHook) entity).angler == Minecraft.getMinecraft().thePlayer) {
+ 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);
+ if (delay > 0 && delay < 500) {
+ if (delay > 300) delay = 300;
+ pingDelayList.add(0, (int) delay);
}
}
}
@@ -117,14 +120,14 @@ public class FishingHelper {
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
- if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR &&
- event.entityPlayer == Minecraft.getMinecraft().thePlayer) {
+ 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) {
+ if (heldItem != null && heldItem.getItem() == Items.fishing_rod) {
long currentTime = System.currentTimeMillis();
- if(currentTime - lastCastRodMillis > 500) {
+ if (currentTime - lastCastRodMillis > 500) {
lastCastRodMillis = currentTime;
}
}
@@ -133,35 +136,36 @@ public class FishingHelper {
}
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 (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);
+ 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) {
+ for (int delay : pingDelayList) {
totalMS += delay;
}
int averageMS = totalMS / pingDelayList.size();
- pingDelayTicks = (int)Math.floor(averageMS/50f);
+ pingDelayTicks = (int) Math.floor(averageMS / 50f);
}
}
- if(hookedWarningStateTicks > 0) {
+ if (hookedWarningStateTicks > 0) {
hookedWarningStateTicks--;
warningState = PlayerWarningState.FISH_HOOKED;
} else {
warningState = PlayerWarningState.NOTHING;
- if(Minecraft.getMinecraft().thePlayer.fishEntity != null) {
+ 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)) {
+ for (Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
+ if (entry.getKey().particleNum >= 3 && entry.getValue().contains(fishEntityId)) {
warningState = PlayerWarningState.FISH_INCOMING;
break;
}
@@ -170,21 +174,21 @@ public class FishingHelper {
}
}
- if(tickCounter++ >= 20) {
+ 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) {
+ 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 ||
+ 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());
@@ -199,28 +203,28 @@ public class FishingHelper {
double angleX = Math.toDegrees(Math.acos(xOffset / 0.04f));
double angleZ = Math.toDegrees(Math.asin(zOffset / 0.04f));
- if(xOffset < 0) {
+ if (xOffset < 0) {
angleZ = 180 - angleZ;
}
- if(zOffset < 0) {
+ if (zOffset < 0) {
angleX = 360 - angleX;
}
angleX %= 360;
angleZ %= 360;
- if(angleX < 0) angleX += 360;
- if(angleZ < 0) 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;
+ if (dist < -180) dist += 360;
+ if (dist > 180) dist -= 360;
- return angleZ + dist/2;
+ 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;
+ if (dist > 180) dist = 360 - dist;
return dist <= range;
}
@@ -234,25 +238,25 @@ public class FishingHelper {
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) {
+ 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);
+ double dist = Math.sqrt(dX * dX + dZ * dZ);
- if(dist < 0.2) {
+ if (dist < 0.2) {
return HookPossibleRet.EITHER;
} else {
- float angleAllowance = (float)Math.toDegrees(Math.atan2(0.03125f, dist))*1.5f;
+ 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 (angleHook < 0) angleHook += 360;
- if(checkAngleWithinRange(angle1, angleHook, angleAllowance)) {
+ if (checkAngleWithinRange(angle1, angleHook, angleAllowance)) {
return HookPossibleRet.ANGLE1;
- } else if(checkAngleWithinRange(angle2, angleHook, angleAllowance)) {
+ } else if (checkAngleWithinRange(angle2, angleHook, angleAllowance)) {
return HookPossibleRet.ANGLE2;
}
}
@@ -264,101 +268,100 @@ public class FishingHelper {
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;
+ 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;
+ 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 &&
+ 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()) {
+ if (hookEntities.isEmpty()) {
return false;
}
-
- if((particleType == EnumParticleTypes.WATER_WAKE|| particleType == EnumParticleTypes.SMOKE_NORMAL) && Math.abs(yOffset - 0.01f) < 0.001f) {
+ 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;
+ 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) {
+ if (ret == HookPossibleRet.ANGLE1) {
possibleHooks1.add(hook.getEntityId());
- } else if(ret == HookPossibleRet.ANGLE2) {
+ } else if (ret == HookPossibleRet.ANGLE2) {
possibleHooks2.add(hook.getEntityId());
- } else if(ret == HookPossibleRet.EITHER) {
+ } else if (ret == HookPossibleRet.EITHER) {
possibleHooks1.add(hook.getEntityId());
possibleHooks2.add(hook.getEntityId());
}
}
- if(!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) {
+ if (!possibleHooks1.isEmpty() || !possibleHooks2.isEmpty()) {
long currentTime = System.currentTimeMillis();
boolean isMainPlayer = false;
boolean foundChain = false;
- for(Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
+ for (Map.Entry<WakeChain, List<Integer>> entry : chains.entrySet()) {
WakeChain chain = entry.getKey();
- if(currentTime - chain.lastUpdate > 200) continue;
+ if (currentTime - chain.lastUpdate > 200) continue;
double updateAngle;
List<Integer> possibleHooks;
- if(checkAngleWithinRange(chain.currentAngle, angle1, 16)) {
+ if (checkAngleWithinRange(chain.currentAngle, angle1, 16)) {
possibleHooks = possibleHooks1;
updateAngle = angle1;
- } else if(checkAngleWithinRange(chain.currentAngle, angle2, 16)) {
+ } else if (checkAngleWithinRange(chain.currentAngle, angle2, 16)) {
possibleHooks = possibleHooks2;
updateAngle = angle2;
} else {
continue;
}
- if(!Collections.disjoint(entry.getValue(), possibleHooks)) {
+ if (!Collections.disjoint(entry.getValue(), possibleHooks)) {
HashSet<Integer> newHooks = new HashSet<>();
- for(int hookEntityId : possibleHooks) {
- if(entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) {
+ for (int hookEntityId : possibleHooks) {
+ if (entry.getValue().contains(hookEntityId) && chain.distances.containsKey(hookEntityId)) {
EntityFishHook entity = hookEntities.get(hookEntityId);
- if(entity != null && !entity.isDead) {
+ 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 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) &&
+ 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 &&
+ 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;
+ 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")) {{
@@ -377,17 +380,17 @@ public class FishingHelper {
}
hookedWarningStateTicks = 12;
- } else if(newDistance >= 0.4f + 0.1f*pingDelayTicks && NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning) {
- if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds &&
+ } 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;
+ 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));
+ pitch = calculatePitchFromDistance((float) newDistance - (0.3f + 0.1f * pingDelayTicks));
repeat = false;
repeatDelay = 0;
attenuationType = ISound.AttenuationType.NONE;
@@ -410,16 +413,16 @@ public class FishingHelper {
}
}
- if(newHooks.isEmpty()) {
+ if (newHooks.isEmpty()) {
continue;
}
entry.getValue().retainAll(newHooks);
chain.distances.keySet().retainAll(newHooks);
- for(int i : entry.getValue()) {
+ for (int i : entry.getValue()) {
EntityFishHook hook = hookEntities.get(i);
- if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
+ if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
isMainPlayer = true;
break;
}
@@ -433,47 +436,46 @@ public class FishingHelper {
}
}
-
- if(!foundChain) {
+ if (!foundChain) {
possibleHooks1.removeAll(possibleHooks2);
- if(!possibleHooks1.isEmpty()) {
- for(int i : possibleHooks1) {
+ if (!possibleHooks1.isEmpty()) {
+ for (int i : possibleHooks1) {
EntityFishHook hook = hookEntities.get(i);
- if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
+ if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
isMainPlayer = true;
break;
}
}
WakeChain chain = new WakeChain(currentTime, angle1, x, z);
- for(int hookEntityId : possibleHooks1) {
+ for (int hookEntityId : possibleHooks1) {
EntityFishHook entity = hookEntities.get(hookEntityId);
- if(entity != null && !entity.isDead) {
+ if (entity != null && !entity.isDead) {
double dX = entity.posX - x;
double dZ = entity.posZ - z;
- double newDistance = Math.sqrt(dX*dX + dZ*dZ);
+ 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) {
+ } else if (!possibleHooks2.isEmpty()) {
+ for (int i : possibleHooks2) {
EntityFishHook hook = hookEntities.get(i);
- if(hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
+ if (hook != null && hook.angler == Minecraft.getMinecraft().thePlayer) {
isMainPlayer = true;
break;
}
}
WakeChain chain = new WakeChain(currentTime, angle2, x, z);
- for(int hookEntityId : possibleHooks2) {
+ for (int hookEntityId : possibleHooks2) {
EntityFishHook entity = hookEntities.get(hookEntityId);
- if(entity != null && !entity.isDead) {
+ if (entity != null && !entity.isDead) {
double dX = entity.posX - x;
double dZ = entity.posZ - z;
- double newDistance = Math.sqrt(dX*dX + dZ*dZ);
+ double newDistance = Math.sqrt(dX * dX + dZ * dZ);
chain.distances.put(hookEntityId, newDistance);
}
}
@@ -483,25 +485,25 @@ public class FishingHelper {
int particleTypeI;
String particleCustomColour;
- if(isMainPlayer) {
+ if (isMainPlayer) {
particleTypeI = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleType;
particleCustomColour = NotEnoughUpdates.INSTANCE.config.fishing.yourParticleColour;
- } else if(NotEnoughUpdates.INSTANCE.config.fishing.hideOtherPlayerAll) {
+ } 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) {
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.enableCustomParticles) {
return false;
}
int argb = SpecialColour.specialToChromaRGB(particleCustomColour);
- if(particleTypeI == 0) {
+ if (particleTypeI == 0) {
return false;
- } else if(particleTypeI == 1) {
+ } else if (particleTypeI == 1) {
return true;
}
@@ -512,20 +514,20 @@ public class FishingHelper {
return true;
}
- if(i >= 2) {
+ 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;
+ double distSq = xDist * xDist + yDist * yDist + zDist * zDist;
- if(distSq < 32*32) {
+ if (distSq < 32 * 32) {
boolean customColour = false;
double yVel = 0;
- switch(particleTypeI) {
+ switch (particleTypeI) {
case 2:
particleType = EnumParticleTypes.FIREWORKS_SPARK;
customColour = true;
@@ -553,7 +555,7 @@ public class FishingHelper {
break;
}
- if(customColour && (((argb >> 24) & 0xFF) < 10)) {
+ if (customColour && (((argb >> 24) & 0xFF) < 10)) {
return true;
}
@@ -563,7 +565,7 @@ public class FishingHelper {
fx.motionY = yVel;
fx.motionZ = Math.random() * 0.02 - 0.01;
- if(customColour) {
+ if (customColour) {
float red = ((argb >> 16) & 0xFF) / 255f;
float green = ((argb >> 8) & 0xFF) / 255f;
float blue = (argb & 0xFF) / 255f;
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..8edc97c8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
@@ -11,13 +11,15 @@ 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<>();
+ private static final Map<ItemStack, Float> durabilityOverrideMap = new HashMap<>();
public static long pickaxeUseCooldownMillisRemaining = -1;
private static long treecapitatorCooldownMillisRemaining = -1;
private static long lastMillis = 0;
@@ -30,8 +32,8 @@ public class ItemCooldowns {
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent event) {
- if(event.phase == TickEvent.Phase.END && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
- if(tickCounter++ >= 20*10) {
+ if (event.phase == TickEvent.Phase.END && NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (tickCounter++ >= 20 * 10) {
tickCounter = 0;
pickaxeCooldown = -1;
}
@@ -39,7 +41,7 @@ public class ItemCooldowns {
long currentTime = System.currentTimeMillis();
Long key;
- while((key = blocksClicked.floorKey(currentTime - 1500)) != null) {
+ while ((key = blocksClicked.floorKey(currentTime - 1500)) != null) {
blocksClicked.remove(key);
}
@@ -48,10 +50,10 @@ public class ItemCooldowns {
durabilityOverrideMap.clear();
- if(pickaxeUseCooldownMillisRemaining >= 0) {
+ if (pickaxeUseCooldownMillisRemaining >= 0) {
pickaxeUseCooldownMillisRemaining -= millisDelta;
}
- if(treecapitatorCooldownMillisRemaining >= 0) {
+ if (treecapitatorCooldownMillisRemaining >= 0) {
treecapitatorCooldownMillisRemaining -= millisDelta;
}
}
@@ -60,20 +62,20 @@ public class ItemCooldowns {
@SubscribeEvent
public void onWorldUnload(WorldEvent.Load event) {
blocksClicked.clear();
- if(pickaxeCooldown > 0) pickaxeUseCooldownMillisRemaining = 60*1000;
+ if (pickaxeCooldown > 0) pickaxeUseCooldownMillisRemaining = 60 * 1000;
pickaxeCooldown = -1;
}
- public static long getTreecapCooldownWithPet(){
- if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCooldownInItemDurability){
+ 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)
+ pet.petType.equalsIgnoreCase("monkey") &&
+ pet.rarity.equals(PetInfoOverlay.Rarity.LEGENDARY)
) {
return 2000 - (int) (2000 * (0.005 * (int) pet.petLevel.level));
}
@@ -89,9 +91,9 @@ public class ItemCooldowns {
public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
BlockPos pos = packetIn.getBlockPosition();
- if(blocksClicked.containsValue(pos)) {
+ if (blocksClicked.containsValue(pos)) {
IBlockState oldState = Minecraft.getMinecraft().theWorld.getBlockState(pos);
- if(oldState.getBlock() != packetIn.getBlockState().getBlock()) {
+ if (oldState.getBlock() != packetIn.getBlockState().getBlock()) {
onBlockMined(pos);
}
}
@@ -100,50 +102,45 @@ public class ItemCooldowns {
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 &&
+ 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 " +
+ private static final 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 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 == null) return false;
- if(internalname.endsWith("_PICKAXE")) {
+ 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")){
+ } 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;
- }
- return false;
+ } 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()) {
+ 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())) {
+ if (isPickaxe(internalname)) {
+ for (String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound())) {
Matcher matcher = PICKAXE_COOLDOWN_LORE_REGEX.matcher(line);
- if(matcher.find()) {
+ if (matcher.find()) {
try {
pickaxeCooldown = Integer.parseInt(matcher.group(1));
return;
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
}
}
@@ -153,53 +150,52 @@ public class ItemCooldowns {
}
}
-
@SubscribeEvent
public void onChatMessage(ClientChatReceivedEvent event) {
- if(pickaxeCooldown != 0 && PICKAXE_ABILITY_REGEX.matcher(event.message.getFormattedText()).matches() && NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) {
+ if (pickaxeCooldown != 0 && PICKAXE_ABILITY_REGEX.matcher(event.message.getFormattedText()).matches() && NotEnoughUpdates.INSTANCE.config.itemOverlays.pickaxeAbility) {
updatePickaxeCooldown();
- pickaxeUseCooldownMillisRemaining = pickaxeCooldown*1000;
+ pickaxeUseCooldownMillisRemaining = pickaxeCooldown * 1000;
}
}
public static float getDurabilityOverride(ItemStack stack) {
- if(Minecraft.getMinecraft().theWorld == null) return -1;
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return -1;
+ if (Minecraft.getMinecraft().theWorld == null) return -1;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return -1;
- if(durabilityOverrideMap.containsKey(stack)) {
+ if (durabilityOverrideMap.containsKey(stack)) {
return durabilityOverrideMap.get(stack);
}
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
+ if (internalname == null) {
durabilityOverrideMap.put(stack, -1f);
return -1;
}
- if(isPickaxe(internalname)) {
+ if (isPickaxe(internalname)) {
updatePickaxeCooldown();
- if(pickaxeUseCooldownMillisRemaining < 0) {
+ if (pickaxeUseCooldownMillisRemaining < 0) {
durabilityOverrideMap.put(stack, -1f);
return -1;
}
- if(pickaxeUseCooldownMillisRemaining > pickaxeCooldown*1000) {
+ if (pickaxeUseCooldownMillisRemaining > pickaxeCooldown * 1000) {
return stack.getItemDamage();
}
- float dura = (float)(pickaxeUseCooldownMillisRemaining/(pickaxeCooldown*1000.0));
+ 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) {
+ } else if (internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE")) {
+ if (treecapitatorCooldownMillisRemaining < 0) {
durabilityOverrideMap.put(stack, -1f);
return -1;
}
- if(treecapitatorCooldownMillisRemaining > getTreecapCooldownWithPet()) {
+ if (treecapitatorCooldownMillisRemaining > getTreecapCooldownWithPet()) {
return stack.getItemDamage();
}
- float dura = (treecapitatorCooldownMillisRemaining/(float)getTreecapCooldownWithPet());
+ float dura = (treecapitatorCooldownMillisRemaining / (float) getTreecapCooldownWithPet());
durabilityOverrideMap.put(stack, dura);
return dura;
}
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..a67bb5d6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java
@@ -41,7 +41,7 @@ public class ItemCustomizeManager {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static ItemDataMap itemDataMap = new ItemDataMap();
- private static HashMap<Integer, String> itemUuidCache = new HashMap<>();
+ private static final HashMap<Integer, String> itemUuidCache = new HashMap<>();
public static class ItemDataMap {
public HashMap<String, ItemData> itemData = new HashMap<>();
@@ -86,7 +86,7 @@ public class ItemCustomizeManager {
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F);
- float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.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);
@@ -95,7 +95,7 @@ public class ItemCustomizeManager {
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 8.0F, 8.0F);
- float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.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);
@@ -122,8 +122,7 @@ public class ItemCustomizeManager {
float f1 = 0.5F;
GlStateManager.color(f1, f1, f1, 1.0F);
- for (int i = 0; i < 2; ++i)
- {
+ for (int i = 0; i < 2; ++i) {
GlStateManager.disableLighting();
float red = ((color >> 16) & 0xFF) / 255f;
@@ -136,8 +135,8 @@ public class ItemCustomizeManager {
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.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();
}
@@ -156,14 +155,14 @@ public class ItemCustomizeManager {
}
public static boolean render3DGlint(String customEnchantGlint, float existed, Runnable renderModelCallback) {
- if(customEnchantGlint != null) {
+ 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;
+ 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);
@@ -174,7 +173,7 @@ public class ItemCustomizeManager {
}
public static boolean renderEffectHook(String customEnchantGlint, Consumer<Integer> renderModelCallback) {
- if(customEnchantGlint != null) {
+ if (customEnchantGlint != null) {
int colour = ChromaColour.specialToChromaRGB(customEnchantGlint);
float[] hsv = Color.RGBtoHSB((colour >> 16) & 0xff, (colour >> 8) & 0xff, colour & 0xff, null);
@@ -183,7 +182,7 @@ public class ItemCustomizeManager {
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;
+ 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);
@@ -196,7 +195,7 @@ public class ItemCustomizeManager {
}
public static ResourceLocation getCustomGlintTexture() {
- if(!loadedCustomGlintTexture) {
+ if (!loadedCustomGlintTexture) {
loadedCustomGlintTexture = true;
final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
@@ -205,11 +204,11 @@ public class ItemCustomizeManager {
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++) {
+ 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 avgRGB = ((((argb >> 16) & 0xff) + ((argb >> 8) & 0xff) + (argb & 0xff)) / 3) & 0xff;
int newArgb = (avgRGB << 24) | (avgRGB << 16) | (avgRGB << 8) | avgRGB;
@@ -218,7 +217,7 @@ public class ItemCustomizeManager {
}
Minecraft.getMinecraft().getTextureManager().loadTexture(CUSTOM_GLINT_TEXTURE, new DynamicTexture(newGlint));
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
CUSTOM_GLINT_TEXTURE = RES_ITEM_GLINT;
}
@@ -227,11 +226,11 @@ public class ItemCustomizeManager {
}
private static String getUuidForItem(ItemStack stack) {
- if(!stack.hasTagCompound()) return null;
+ if (!stack.hasTagCompound()) return null;
int nbtHash = stack.getTagCompound().hashCode();
- if(itemUuidCache.containsKey(nbtHash)) {
+ if (itemUuidCache.containsKey(nbtHash)) {
return itemUuidCache.get(nbtHash);
}
@@ -242,11 +241,11 @@ public class ItemCustomizeManager {
}
public static ItemData getDataForItem(ItemStack stack) {
- if(stack == null) return null;
+ if (stack == null) return null;
String uuid = getUuidForItem(stack);
- if(uuid == null) {
+ if (uuid == null) {
return null;
} else {
return itemDataMap.itemData.get(uuid);
@@ -259,10 +258,10 @@ public class ItemCustomizeManager {
}
public static void loadCustomization(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ 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) {
+ } catch (Exception ignored) {}
+ if (itemDataMap == null) {
itemDataMap = new ItemDataMap();
}
}
@@ -270,10 +269,10 @@ public class ItemCustomizeManager {
public static void saveCustomization(File file) {
try {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(GSON.toJson(itemDataMap));
}
- } catch(Exception ignored) {}
+ } 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..d0716c3c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemRarityHalo.java
@@ -38,18 +38,18 @@ public class ItemRarityHalo {
private static int oldScaledResolution = 0;
public static void onItemRender(ItemStack stack, int x, int y) {
- if(x == 0 && y == 0) return;
+ if (x == 0 && y == 0) return;
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
NotEnoughUpdates neu = NotEnoughUpdates.INSTANCE;
- if(!neu.isOnSkyblock()) return;
+ if (!neu.isOnSkyblock()) return;
//if(neu.manager.config.itemHighlightOpacity.value <= 1) return;
- if(neu.manager.getInternalNameForItem(stack) == null) return;
+ if (neu.manager.getInternalNameForItem(stack) == null) return;
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int size = 16*scaledresolution.getScaleFactor();
+ int size = 16 * scaledresolution.getScaleFactor();
- if(projectionMatrix == null) {
+ if (projectionMatrix == null) {
projectionMatrix = Utils.createProjectionMatrix(size, size);
}
@@ -57,13 +57,13 @@ public class ItemRarityHalo {
itemFramebuffer2 = checkFramebufferSizes(itemFramebuffer2, size, size);
try {
- if(colourShader == null) {
+ if (colourShader == null) {
colourShader = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
"setrgbtoalpha", itemFramebuffer1, itemFramebuffer2);
upload(colourShader, size, size);
}
- if(blurShaderHorz == null) {
+ if (blurShaderHorz == null) {
blurShaderHorz = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
"blur", itemFramebuffer2, itemFramebuffer1);
blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
@@ -72,7 +72,7 @@ public class ItemRarityHalo {
upload(blurShaderHorz, size, size);
}
- if(blurShaderVert == null) {
+ if (blurShaderVert == null) {
blurShaderVert = new Shader(new NEUResourceManager(Minecraft.getMinecraft().getResourceManager()),
"blur", itemFramebuffer1, itemFramebuffer2);
blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
@@ -80,9 +80,11 @@ public class ItemRarityHalo {
blurShaderVert.getShaderManager().getShaderUniform("AlphaMult").set(2f);
upload(blurShaderVert, size, size);
}
- } catch(Exception e) { return; }
+ } catch (Exception e) {
+ return;
+ }
- if(oldScaledResolution != scaledresolution.getScaleFactor()) {
+ if (oldScaledResolution != scaledresolution.getScaleFactor()) {
resetItemHaloCache();
oldScaledResolution = scaledresolution.getScaleFactor();
}
@@ -91,24 +93,25 @@ public class ItemRarityHalo {
IntBuffer currentViewport = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_VIEWPORT, currentViewport);
try {
- if(!itemHaloTexMap.containsKey(stack)) {
+ 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));
+ 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));
+ 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.pushMatrix();
+ {
GlStateManager.matrixMode(5889);
GlStateManager.loadIdentity();
GlStateManager.ortho(0.0D, size, size, 0.0D, 1000.0D, 3000.0D);
@@ -127,17 +130,22 @@ public class ItemRarityHalo {
itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
itemRender.zLevel = zLevel;
RenderHelper.disableStandardItemLighting();
- } GlStateManager.popMatrix();
-
- GlStateManager.pushMatrix(); {
- GL45.glTextureBarrier(); GL11.glFlush(); GL11.glFinish();
+ }
+ 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.popMatrix();
GlStateManager.matrixMode(5889);
GlStateManager.loadIdentity();
@@ -161,7 +169,7 @@ public class ItemRarityHalo {
Utils.drawTexturedRect(x, y, 16, 16,
0, 1, 1, 0, GL11.GL_NEAREST);
GlStateManager.bindTexture(0);
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
OpenGlHelper.glBindFramebuffer(OpenGlHelper.GL_FRAMEBUFFER, currentBuffer);
GlStateManager.viewport(currentViewport.get(), currentViewport.get(), currentViewport.get(), currentViewport.get());
@@ -169,8 +177,8 @@ public class ItemRarityHalo {
}
private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) {
- if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
- if(framebuffer == null) {
+ if (framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
+ if (framebuffer == null) {
framebuffer = new Framebuffer(width, height, true);
} else {
framebuffer.createBindFramebuffer(width, height);
@@ -182,14 +190,14 @@ public class ItemRarityHalo {
public static void resetItemHaloCache() {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int size = 16*scaledresolution.getScaleFactor();
+ int size = 16 * scaledresolution.getScaleFactor();
- for(int tex : itemHaloTexMap.values()) {
+ for (int tex : itemHaloTexMap.values()) {
TextureUtil.deleteTexture(tex);
}
itemHaloTexMap.clear();
- if(NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ if (NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
projectionMatrix = Utils.createProjectionMatrix(size, size);
upload(colourShader, size, size);
upload(blurShaderHorz, size, size);
@@ -198,11 +206,11 @@ public class ItemRarityHalo {
}
private static void upload(Shader shader, int width, int height) {
- if(shader == null) return;
+ 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);
+ shader.getShaderManager().getShaderUniformOrDefault("ScreenSize").set((float) width, (float) height);
}
private static void executeShader(Shader shader) {
@@ -216,9 +224,9 @@ public class ItemRarityHalo {
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);
+ 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);
@@ -235,9 +243,9 @@ public class ItemRarityHalo {
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, 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();
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..390b36ef 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;
@@ -32,39 +31,39 @@ public class MiningStuff {
private static long titaniumNotifMillis = 0;
private static Minecraft mc;
-
- public MiningStuff(){
+ public MiningStuff() {
mc = Minecraft.getMinecraft();
}
public static void processBlockChangePacket(S23PacketBlockChange packetIn) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
return;
}
IBlockState state = packetIn.getBlockState();
- if(SBInfo.getInstance().getLocation() != null &&
+ 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()) {
+ for (Map.Entry<String, Float> entry : MiningOverlay.commissionProgress.entrySet()) {
String s = entry.getKey();
- if(s.contains("Titanium")) {
- if(entry.getValue() == 1f){
+ 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;
+ 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) {
+ if (distSq < 12 * 12) {
titaniumNotifMillis = System.currentTimeMillis();
}
return;
@@ -73,20 +72,20 @@ public class MiningStuff {
}
}
- private static BlockPos[] getAttachedBlocks(BlockPos block){
+ 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);
+ 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){
+ private static boolean checkIfAnyIsAir(BlockPos[] blocks) {
for (BlockPos block : blocks) {
- if(mc.theWorld.getBlockState(block).getBlock() instanceof BlockAir){
+ if (mc.theWorld.getBlockState(block).getBlock() instanceof BlockAir) {
return true;
}
}
@@ -95,15 +94,15 @@ public class MiningStuff {
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent.Post event) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) {
return;
}
- if(titaniumNotifMillis <= 0) return;
+ if (titaniumNotifMillis <= 0) return;
- int delta = (int)(System.currentTimeMillis() - titaniumNotifMillis);
+ int delta = (int) (System.currentTimeMillis() - titaniumNotifMillis);
int notifLen = 5000;
int fadeLen = 500;
- if(delta > 0 && delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if (delta > 0 && delta < notifLen && event.type == RenderGameOverlayEvent.ElementType.ALL) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledResolution.getScaledWidth();
int height = scaledResolution.getScaledHeight();
@@ -112,35 +111,34 @@ public class MiningStuff {
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.pushMatrix();
- GlStateManager.translate((float)(width / 2), (float)(height / 2), 0.0F);
+ 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));
+ 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 (delta < fadeLen) {
+ alpha = delta * 255 / fadeLen;
+ } else if (delta > notifLen - fadeLen) {
+ alpha = (notifLen - delta) * 255 / fadeLen;
}
- if(alpha > 10) {
+ if (alpha > 10) {
TextRenderUtils.drawStringCenteredScaledMaxWidth("Titanium has spawned nearby!", Minecraft.getMinecraft().fontRendererObj,
- 0, 0, true, width/4-20, colour | (colour << 8) | (colour << 16) | (alpha << 24));
+ 0, 0, true, width / 4 - 20, colour | (colour << 8) | (colour << 16) | (alpha << 24));
}
-
GlStateManager.popMatrix();
}
}
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent event) {
- if(overlayLoc == null) return;
+ if (overlayLoc == null) return;
Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
@@ -148,12 +146,12 @@ public class MiningStuff {
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);
+ 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));
@@ -168,28 +166,28 @@ public class MiningStuff {
@SubscribeEvent
public void onChatRecevied(ClientChatReceivedEvent event) {
- if(!NotEnoughUpdates.INSTANCE.config.mining.puzzlerSolver) {
+ if (!NotEnoughUpdates.INSTANCE.config.mining.puzzlerSolver) {
overlayLoc = null;
return;
}
- if(event.message.getFormattedText().startsWith("\u00A7e[NPC] \u00A7dPuzzler") &&
+ 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++) {
+ for (int i = 0; i < clean.length(); i++) {
char c = clean.charAt(i);
- if(c == '\u25C0') { //Left
+ if (c == '\u25C0') { //Left
pos = pos.add(1, 0, 0);
- } else if(c == '\u25B2') { //Up
+ } else if (c == '\u25B2') { //Up
pos = pos.add(0, 0, 1);
- } else if(c == '\u25BC') { //Down
+ } else if (c == '\u25BC') { //Down
pos = pos.add(0, 0, -1);
- } else if(c == '\u25B6') { //Right
+ } else if (c == '\u25B6') { //Right
pos = pos.add(-1, 0, 0);
} else {
return;
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..e234c458 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java
@@ -6,10 +6,8 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
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;
@@ -36,17 +34,17 @@ public class NPCRetexturing implements IResourceManagerReloadListener {
}
}
- private HashMap<AbstractClientPlayer, Skin> skinOverrideCache = new HashMap<>();
- private HashMap<String, Skin> skinMap = new HashMap<>();
+ private final HashMap<AbstractClientPlayer, Skin> skinOverrideCache = new HashMap<>();
+ private final HashMap<String, Skin> skinMap = new HashMap<>();
private boolean gettingSkin = false;
public Skin getSkin(AbstractClientPlayer player) {
- if(gettingSkin) return null;
+ if (gettingSkin) return null;
- if(player.getUniqueID().version() == 4) return null;
+ if (player.getUniqueID().version() == 4) return null;
- if(skinOverrideCache.containsKey(player)) {
+ if (skinOverrideCache.containsKey(player)) {
return skinOverrideCache.get(player);
}
@@ -54,7 +52,7 @@ public class NPCRetexturing implements IResourceManagerReloadListener {
ResourceLocation loc = player.getLocationSkin();
gettingSkin = false;
- if(skinMap.containsKey(loc.getResourcePath())) {
+ if (skinMap.containsKey(loc.getResourcePath())) {
Skin skin = skinMap.get(loc.getResourcePath());
skinOverrideCache.put(player, skin);
return skin;
@@ -72,25 +70,23 @@ public class NPCRetexturing implements IResourceManagerReloadListener {
public void onResourceManagerReload(IResourceManager resourceManager) {
skinMap.clear();
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
+ 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()) {
+ 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);
+ skinMap.put("skins/" + entry.getKey(), skin);
}
}
- } catch(Exception e) {
- }
+ } 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..5a6d9532 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NullzeeSphere.java
@@ -31,10 +31,10 @@ public class NullzeeSphere {
public static ReverseWorldRenderer overlayVBO = null;
public ReverseWorldRenderer getOverlayVBO() {
- if(overlayVBO != null) return overlayVBO;
+ if (overlayVBO != null) return overlayVBO;
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return null;
+ if (p == null) return null;
//per vertex = 6
//per size = 4
@@ -43,20 +43,20 @@ public class NullzeeSphere {
Set<BlockPos> circleOffsets = getCircleOffsets(size);
- ReverseWorldRenderer worldRenderer = new ReverseWorldRenderer(196*circleOffsets.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) {
+ 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
+ overlayPos.getX() + 1,
+ overlayPos.getY() + 1,
+ overlayPos.getZ() + 1
).expand(0.001f, 0.001f, 0.001f);
uploadFilledBoundingBox(bb, 1f, col, worldRenderer);
}
@@ -68,12 +68,12 @@ public class NullzeeSphere {
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)) {
+ 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));
}
}
@@ -91,17 +91,17 @@ public class NullzeeSphere {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if(!enabled) return;
+ if (!enabled) return;
EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
- if(p == null) return;
+ if (p == null) return;
- if(event.phase == TickEvent.Phase.START) {
+ 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) {
+ if (dX * dX + dY * dY + dZ * dZ < 1) {
return;
}
@@ -110,18 +110,18 @@ public class NullzeeSphere {
posLastUpdateZ = p.posZ;
long currentTime = System.currentTimeMillis();
- if(currentTime - lastUpdate < 250) {
+ if (currentTime - lastUpdate < 250) {
return;
}
lastUpdate = currentTime;
ReverseWorldRenderer worldRenderer = getOverlayVBO();
- if(worldRenderer != null) {
- worldRenderer.setTranslation(0, 0,0 );
+ 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());
+ (float) p.posX - centerPos.getX(),
+ (float) p.posY - centerPos.getY(),
+ (float) p.posZ - centerPos.getZ());
}
}
@@ -129,7 +129,7 @@ public class NullzeeSphere {
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
- if(!enabled) return;
+ if (!enabled) return;
Entity viewer = Minecraft.getMinecraft().getRenderViewEntity();
double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks;
@@ -144,7 +144,7 @@ public class NullzeeSphere {
GL11.glPolygonOffset(5, 5);
ReverseWorldRenderer worldRenderer = getOverlayVBO();
- if(worldRenderer != null && worldRenderer.getVertexCount() > 0) {
+ if (worldRenderer != null && worldRenderer.getVertexCount() > 0) {
GlStateManager.translate(centerPos.getX(), centerPos.getY(), centerPos.getZ());
VertexFormat vertexformat = worldRenderer.getVertexFormat();
@@ -178,57 +178,57 @@ public class NullzeeSphere {
//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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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();
+ .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..fc5fdef8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -31,7 +31,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.*;
@@ -78,8 +77,8 @@ public class PetInfoOverlay extends TextOverlay {
}
public static Rarity getRarityFromColor(EnumChatFormatting chatFormatting) {
- for(int i = 0; i < Rarity.values().length; i++) {
- if(Rarity.values()[i].chatFormatting.equals(chatFormatting))
+ for (int i = 0; i < Rarity.values().length; i++) {
+ if (Rarity.values()[i].chatFormatting.equals(chatFormatting))
return Rarity.values()[i];
}
return COMMON;
@@ -112,7 +111,7 @@ public class PetInfoOverlay extends TextOverlay {
private static long lastUpdate = 0;
private static float levelXpLast = 0;
- private static LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private static final LinkedList<Float> xpGainQueue = new LinkedList<>();
private static float xpGainHourLast = -1;
private static float xpGainHour = -1;
private static int pauseCountdown = 0;
@@ -122,10 +121,11 @@ public class PetInfoOverlay extends TextOverlay {
private int xpAddTimer = 0;
public static void loadConfig(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ 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) {
+ } catch (Exception ignored) {
+ }
+ if (config == null) {
config = new PetConfig();
}
}
@@ -133,10 +133,10 @@ public class PetInfoOverlay extends TextOverlay {
public static void saveConfig(File file) {
try {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(GSON.toJson(config));
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
public static void clearPet() {
@@ -157,24 +157,24 @@ public class PetInfoOverlay extends TextOverlay {
}
public static Pet getCurrentPet2() {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.dualPets) return null;
- if(config.selectedPet == config.selectedPet2) return null;
+ 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;
+ if (pet == null) return 0;
try {
return Float.parseFloat(df.format(pet.petLevel.levelPercentage * 100f));
- } catch(Exception ignored) {
+ } catch (Exception ignored) {
return 0;
}
}
private static int getIdForPet(Pet pet) {
- for(Map.Entry<Integer, Pet> entry : config.petMap.entrySet()) {
- if(entry.getValue() == pet) {
+ for (Map.Entry<Integer, Pet> entry : config.petMap.entrySet()) {
+ if (entry.getValue() == pet) {
return entry.getKey();
}
}
@@ -183,7 +183,7 @@ public class PetInfoOverlay extends TextOverlay {
private static int getClosestPetIndex(String petType, int petId, String petItem, float petLevel) {
Pet pet = getClosestPet(petType, petId, petItem, petLevel);
- if(pet == null) {
+ if (pet == null) {
return -1;
} else {
return getIdForPet(pet);
@@ -192,50 +192,50 @@ public class PetInfoOverlay extends TextOverlay {
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) {
+ for (Pet pet : config.petMap.values()) {
+ if (pet.petType.equals(petType) && pet.rarity.petId == petId) {
pets.add(pet);
}
}
- if(pets == null || pets.isEmpty()) {
+ if (pets == null || pets.isEmpty()) {
return null;
}
- if(pets.size() == 1) {
+ 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) ||
+ for (Pet pet : pets) {
+ if ((searchItem == null && pet.petItem == null) ||
(searchItem != null && searchItem.equals(pet.petItem))) {
itemMatches.add(pet);
}
}
- if(itemMatches.size() == 1) {
+ if (itemMatches.size() == 1) {
return itemMatches.iterator().next();
}
- if(itemMatches.size() > 1) {
+ if (itemMatches.size() > 1) {
pets = itemMatches;
}
float closestXp = -1;
Pet closestPet = null;
- for(Pet pet : pets) {
+ for (Pet pet : pets) {
float distXp = Math.abs(pet.petLevel.level - petLevel);
- if(closestPet == null || distXp < closestXp) {
+ if (closestPet == null || distXp < closestXp) {
closestXp = distXp;
closestPet = pet;
}
}
- if(closestPet != null) {
+ if (closestPet != null) {
return closestPet;
} else {
return pets.iterator().next();
@@ -246,25 +246,24 @@ public class PetInfoOverlay extends TextOverlay {
JsonObject skillInfo = profile.getSkillInfo(profile.getLatestProfile());
JsonObject invInfo = profile.getInventoryInfo(profile.getLatestProfile());
JsonObject profileInfo = profile.getProfileInformation(profile.getLatestProfile());
- if(invInfo != null && profileInfo != null) {
+ 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;
+ for (JsonElement talisman : invInfo.get("talisman_bag").getAsJsonArray()) {
+ if (talisman.isJsonNull()) continue;
String internalName = talisman.getAsJsonObject().get("internalname").getAsString();
- if(internalName.startsWith("BEASTMASTER_CREST")) {
+ if (internalName.startsWith("BEASTMASTER_CREST")) {
hasBeastmasterCrest = true;
try {
Rarity talismanRarity = Rarity.valueOf(internalName.replace("BEASTMASTER_CREST_", ""));
- if(talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer)
+ if (talismanRarity.beastcreatMultiplyer > currentBeastRarity.beastcreatMultiplyer)
currentBeastRarity = talismanRarity;
- } catch(Exception ignored) {
- }
+ } catch (Exception ignored) {}
}
}
- if(hasBeastmasterCrest) {
- if(stats.has("mythos_kills")) {
+ 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;
@@ -274,7 +273,7 @@ public class PetInfoOverlay extends TextOverlay {
}
}
}
- if(skillInfo != null) config.tamingLevel = skillInfo.get("level_skill_taming").getAsInt();
+ if (skillInfo != null) config.tamingLevel = skillInfo.get("level_skill_taming").getAsInt();
//JsonObject petObject = profile.getPetsInfo(profile.getLatestProfile());
/*JsonObject petsJson = Constants.PETS;
if(petsJson != null) {
@@ -337,8 +336,8 @@ public class PetInfoOverlay extends TextOverlay {
private float interp(float now, float last) {
float interp = now;
- if(last >= 0 && last != now) {
- float factor = (System.currentTimeMillis()-lastUpdate)/1000f;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
factor = LerpUtils.clampZeroOne(factor);
interp = last + (now - last) * factor;
}
@@ -347,8 +346,8 @@ public class PetInfoOverlay extends TextOverlay {
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;
+ 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("_", " "));
@@ -362,16 +361,16 @@ public class PetInfoOverlay extends TextOverlay {
+ EnumChatFormatting.YELLOW + " (" + getLevelPercent(currentPet) + "%)";
float xpGain;
- if(!secondPet) {
+ if (!secondPet) {
xpGain = interp(xpGainHour, xpGainHourLast);
} else {
xpGain = xpGainHourSecondPet;
}
- if(xpGain < 0) xpGain = 0;
+ if (xpGain < 0) xpGain = 0;
String xpGainString = EnumChatFormatting.AQUA + "XP/h: " +
EnumChatFormatting.YELLOW + roundFloat(xpGain);
- if(!secondPet && xpGain > 0 && levelXp != levelXpLast) {
- if(pauseCountdown <= 0) {
+ if (!secondPet && xpGain > 0 && levelXp != levelXpLast) {
+ if (pauseCountdown <= 0) {
xpGainString += EnumChatFormatting.RED + " (PAUSED)";
} else {
pauseCountdown--;
@@ -382,10 +381,10 @@ public class PetInfoOverlay extends TextOverlay {
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) {
+ 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) {
+ if (json != null) {
String name = NotEnoughUpdates.INSTANCE.manager.jsonToStack(json).getDisplayName();
petItemStr = EnumChatFormatting.AQUA + "Held Item: " + name;
}
@@ -393,27 +392,27 @@ public class PetInfoOverlay extends TextOverlay {
String etaStr = null;
String etaMaxStr = null;
- if(currentPet.petLevel.level < 100) {
+ 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";
+ 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);
+ 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)) {
+ 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";
+ 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);
+ etaMaxStr = EnumChatFormatting.AQUA + "Until L100: " +
+ EnumChatFormatting.YELLOW + Utils.prettyTime((long) (remainingMax) * 1000 * 60 * 60 / (long) xpGain);
}
}
}
@@ -421,24 +420,32 @@ public class PetInfoOverlay extends TextOverlay {
List<String> strings = new ArrayList<>();
- for(int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
- switch(index) {
+ for (int index : NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText) {
+ switch (index) {
case 0:
- strings.add(petName); break;
+ strings.add(petName);
+ break;
case 1:
- strings.add(lvlStringShort); break;
+ strings.add(lvlStringShort);
+ break;
case 2:
- strings.add(lvlString); break;
+ strings.add(lvlString);
+ break;
case 3:
- strings.add(xpGainString); break;
+ strings.add(xpGainString);
+ break;
case 4:
- strings.add(totalXpString); break;
+ strings.add(totalXpString);
+ break;
case 5:
- strings.add(petItemStr); break;
+ strings.add(petItemStr);
+ break;
case 6:
- if(etaStr != null) strings.add(etaStr); break;
+ if (etaStr != null) strings.add(etaStr);
+ break;
case 7:
- if(etaMaxStr != null) strings.add(etaMaxStr); break;
+ if (etaMaxStr != null) strings.add(etaMaxStr);
+ break;
}
}
@@ -448,7 +455,7 @@ public class PetInfoOverlay extends TextOverlay {
@Override
public void updateFrequent() {
Pet currentPet = getCurrentPet();
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo || currentPet == null) {
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo || currentPet == null) {
overlayStrings = null;
} else {
overlayStrings = new ArrayList<>();
@@ -456,7 +463,7 @@ public class PetInfoOverlay extends TextOverlay {
overlayStrings.addAll(createStringsForPet(currentPet, false));
Pet currentPet2 = getCurrentPet2();
- if(currentPet2 != null) {
+ if (currentPet2 != null) {
overlayStrings.add("");
overlayStrings.addAll(createStringsForPet(currentPet2, true));
}
@@ -465,19 +472,19 @@ public class PetInfoOverlay extends TextOverlay {
}
public void update() {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo && !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck) {
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.enablePetInfo && !NotEnoughUpdates.INSTANCE.config.itemOverlays.enableMonkeyCheck) {
overlayStrings = null;
return;
}
int updateTime = 60000;
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
ProfileApiSyncer.getInstance().requestResync("petinfo", updateTime, () -> {}, PetInfoOverlay::getAndSetPet);
}
Pet currentPet = getCurrentPet();
- if(currentPet == null) {
+ if (currentPet == null) {
overlayStrings = null;
} else {
lastUpdate = System.currentTimeMillis();
@@ -491,15 +498,15 @@ public class PetInfoOverlay extends TextOverlay {
float level = 1;
float currentLevelRequirement = 0;
- for(int i=offset; i<offset+99; i++) {
+ for (int i = offset; i < offset + 99; i++) {
currentLevelRequirement = levels.get(i).getAsFloat();
xpTotal += currentLevelRequirement;
level += 1;
}
- if(level <= 0) {
+ if (level <= 0) {
level = 1;
- } else if(level > 100) {
+ } else if (level > 100) {
level = 100;
}
GuiProfileViewer.PetLevel levelObj = new GuiProfileViewer.PetLevel();
@@ -507,8 +514,8 @@ public class PetInfoOverlay extends TextOverlay {
levelObj.currentLevelRequirement = currentLevelRequirement;
levelObj.maxXP = xpTotal;
levelObj.levelPercentage = 1;
- levelObj.levelXp = currentLevelRequirement-5;
- levelObj.totalXp = xpTotal-5;
+ levelObj.levelXp = currentLevelRequirement - 5;
+ levelObj.totalXp = xpTotal - 5;
return levelObj;
}
@@ -520,12 +527,12 @@ public class PetInfoOverlay extends TextOverlay {
boolean addLevel = true;
- for(int i=offset; i<offset+99; i++) {
- if(addLevel) {
+ for (int i = offset; i < offset + 99; i++) {
+ if (addLevel) {
currentLevelRequirement = levels.get(i).getAsFloat();
xpTotal += currentLevelRequirement;
- if(currentLevelRequirement >= xpMaxThisLevel) {
+ if (currentLevelRequirement >= xpMaxThisLevel) {
addLevel = false;
} else {
exp += currentLevelRequirement;
@@ -536,25 +543,25 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- level += xpThisLevel/currentLevelRequirement;
- if(level <= 0) {
+ level += xpThisLevel / currentLevelRequirement;
+ if (level <= 0) {
level = 1;
- } else if(level > 100) {
+ } 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.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"));
+ 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;
}
@@ -564,20 +571,20 @@ public class PetInfoOverlay extends TextOverlay {
GuiProfileViewer.PetLevel level = null;
Matcher petNameMatcher = PET_NAME_PATTERN.matcher(name);
- if(petNameMatcher.matches()) {
+ 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)) {
+ for (EnumChatFormatting formatting : EnumChatFormatting.values()) {
+ if (formatting.toString().equals("\u00a7" + colChar)) {
col = formatting;
break;
}
}
rarity = Rarity.COMMON;
- if(col != EnumChatFormatting.RESET) {
+ if (col != EnumChatFormatting.RESET) {
rarity = Rarity.getRarityFromColor(col);
}
@@ -585,30 +592,30 @@ public class PetInfoOverlay extends TextOverlay {
.replaceAll("[^\\w ]", "").trim()
.replace(" ", "_").toUpperCase();
}
- if(petType == null || rarity == null) {
+ if (petType == null || rarity == null) {
return null;
}
- for(String line : lore) {
+ for (String line : lore) {
Matcher xpLineMatcher = XP_LINE_PATTERN.matcher(Utils.cleanColour(line));
- if(line.startsWith("\u00a76Held Item: ")) {
+ if (line.startsWith("\u00a76Held Item: ")) {
String after = line.substring("\u00a76Held Item: ".length());
- if(itemMap == null) {
+ if (itemMap == null) {
itemMap = new HashMap<>();
- for(Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) {
+ for (Map.Entry<String, JsonObject> entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) {
boolean petItem = false;
- if(entry.getKey().startsWith("PET_ITEM_")) {
+ if (entry.getKey().startsWith("PET_ITEM_")) {
petItem = true;
} else {
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
- if(stack.hasTagCompound()) {
+ if (stack.hasTagCompound()) {
String[] itemLore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- for(String itemLoreLine : itemLore) {
- if(itemLoreLine.contains("PET ITEM")) {
+ for (String itemLoreLine : itemLore) {
+ if (itemLoreLine.contains("PET ITEM")) {
petItem = true;
break;
}
@@ -616,17 +623,17 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- if(petItem) {
+ if (petItem) {
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(entry.getValue());
itemMap.put(stack.getDisplayName().replace("\u00a7f\u00a7f", ""), entry.getKey());
}
}
}
- if(itemMap.containsKey(after)) {
+ if (itemMap.containsKey(after)) {
heldItem = itemMap.get(after);
}
- } else if(xpLineMatcher.matches()) {
+ } else if (xpLineMatcher.matches()) {
String xpThisLevelS = xpLineMatcher.group(1);
String xpMaxThisLevelS = xpLineMatcher.group(2).toLowerCase();
@@ -634,26 +641,32 @@ public class PetInfoOverlay extends TextOverlay {
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;
+ 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);
+ 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")) {
+ } catch (NumberFormatException ignored) {}
+ } else if (line.equals("\u00a7b\u00a7lMAX LEVEL")) {
level = getMaxLevel(Constants.PETS.get("pet_levels").getAsJsonArray(), rarity.petOffset);
}
}
- if(level != null) {
+ if (level != null) {
Pet pet = new Pet();
pet.petItem = heldItem;
pet.petLevel = level;
@@ -672,43 +685,43 @@ public class PetInfoOverlay extends TextOverlay {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
+ 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) {
+ if (lower.getSizeInventory() >= 54) {
int page = 0;
int maxPage = 1;
boolean isPets = false;
- if(containerName.equals("Pets")) {
+ if (containerName.equals("Pets")) {
isPets = true;
} else {
Matcher matcher = PET_CONTAINER_PAGE.matcher(containerName);
- if(matcher.matches()) {
+ if (matcher.matches()) {
try {
- page = Integer.parseInt(matcher.group(1))-1;
+ page = Integer.parseInt(matcher.group(1)) - 1;
maxPage = Integer.parseInt(matcher.group(2));
isPets = true;
- } catch(NumberFormatException ignored) {}
+ } catch (NumberFormatException ignored) {}
}
}
- if(isPets) {
+ if (isPets) {
boolean hasItem = false;
- for(int i=0; i<lower.getSizeInventory(); i++) {
- if(lower.getStackInSlot(i) != null) {
+ for (int i = 0; i < lower.getSizeInventory(); i++) {
+ if (lower.getStackInSlot(i) != null) {
hasItem = true;
break;
}
}
- if(!hasItem) return;
+ if (!hasItem) return;
Set<Integer> clear = new HashSet<>();
- for(int i : config.petMap.keySet()) {
- if(i >= maxPage*28) {
+ for (int i : config.petMap.keySet()) {
+ if (i >= maxPage * 28) {
clear.add(i);
}
}
@@ -716,43 +729,43 @@ public class PetInfoOverlay extends TextOverlay {
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;
+ 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;
+ 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()) {
+ if (stackNext == null || !stackNext.hasTagCompound()) {
int old = removeMap.getOrDefault(petIndex, 0);
- if(old >= 20) {
+ if (old >= 20) {
config.petMap.remove(petIndex);
} else {
removeSet.add(petIndex);
- removeMap.put(petIndex, old+1);
+ removeMap.put(petIndex, old + 1);
}
}
}
} else {
String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
Pet pet = getPetFromStack(stack.getDisplayName(), lore);
- if(pet != null) {
+ if (pet != null) {
config.petMap.put(petIndex, pet);
- if(currentTime - lastPetSelect > 500) {
+ if (currentTime - lastPetSelect > 500) {
boolean foundDespawn = false;
- for(String line : lore) {
- if(line.equals("\u00a77\u00a7cClick to despawn ")) {
+ for (String line : lore) {
+ if (line.equals("\u00a77\u00a7cClick to despawn ")) {
config.selectedPet = petIndex;
foundDespawn = true;
break;
}
}
- if(foundDespawn && config.selectedPet == petIndex) {
+ if (foundDespawn && config.selectedPet == petIndex) {
clearPet();
}
}
@@ -767,14 +780,14 @@ public class PetInfoOverlay extends TextOverlay {
@Override
protected Vector2f getSize(List<String> strings) {
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return super.getSize(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);
+ 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);
}
@@ -782,18 +795,18 @@ public class PetInfoOverlay extends TextOverlay {
public void renderDummy() {
super.renderDummy();
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROCK;0");
- if(petItem != null) {
+ if (petItem != null) {
Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y;
+ 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.translate(x - 2, y - 2, 0);
GlStateManager.scale(2, 2, 1);
Utils.drawItemStack(stack, 0, 0);
GlStateManager.popMatrix();
@@ -805,44 +818,44 @@ public class PetInfoOverlay extends TextOverlay {
super.render();
Pet currentPet = getCurrentPet();
- if(currentPet == null) {
+ if (currentPet == null) {
overlayStrings = null;
return;
}
- if(overlayStrings == null) {
+ if (overlayStrings == null) {
return;
}
- if(!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
+ if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayIcon) return;
JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet.petType + ";" + currentPet.rarity.petId);
- if(petItem != null) {
+ if (petItem != null) {
Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y;
+ 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.translate(x - 2, y - 2, 0);
GlStateManager.scale(2, 2, 1);
Utils.drawItemStack(stack, 0, 0);
GlStateManager.popMatrix();
}
Pet currentPet2 = getCurrentPet2();
- if(currentPet2 != null) {
+ if (currentPet2 != null) {
JsonObject petItem2 = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(currentPet2.petType + ";" + currentPet2.rarity.petId);
- if(petItem2 != null) {
+ 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;
+ 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.translate(x - 2, y - 2, 0);
GlStateManager.scale(2, 2, 1);
Utils.drawItemStack(stack, 0, 0);
GlStateManager.popMatrix();
@@ -851,66 +864,66 @@ public class PetInfoOverlay extends TextOverlay {
}
public static float getBoostMultiplier(String boostName) {
- if(boostName == null) return 1;
+ if (boostName == null) return 1;
boostName = boostName.toLowerCase();
- if(boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
+ if (boostName.equalsIgnoreCase("PET_ITEM_ALL_SKILLS_BOOST_COMMON")) {
return 1.1f;
- } else if(boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
+ } else if (boostName.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
return 1.2f;
- } else if(boostName.endsWith("epic")) {
+ } else if (boostName.endsWith("epic")) {
return 1.5f;
- } else if(boostName.endsWith("rare")) {
+ } else if (boostName.endsWith("rare")) {
return 1.4f;
- } else if(boostName.endsWith("uncommon")) {
+ } else if (boostName.endsWith("uncommon")) {
return 1.3f;
- } else if(boostName.endsWith("common")) {
+ } 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");
+ 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;
+ 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) {
+ 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) {
+ if (lower.getSizeInventory() >= 54 && windowId == container.windowId) {
int page = 0;
boolean isPets = false;
- if(containerName.equals("Pets")) {
+ if (containerName.equals("Pets")) {
isPets = true;
} else {
Matcher matcher = PET_CONTAINER_PAGE.matcher(containerName);
- if(matcher.matches()) {
+ if (matcher.matches()) {
try {
- page = Integer.parseInt(matcher.group(1))-1;
+ page = Integer.parseInt(matcher.group(1)) - 1;
isPets = true;
- } catch(NumberFormatException ignored) {}
+ } catch (NumberFormatException ignored) {}
}
}
- if(isPets) {
+ 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;
+ int newSelected = (slotId - 10) - (slotId - 10) / 9 * 2 + page * 28;
lastPetSelect = System.currentTimeMillis();
- if(isRemoving) {
- if(newSelected == config.selectedPet) {
+ if (isRemoving) {
+ if (newSelected == config.selectedPet) {
clearPet();
- } else if(config.selectedPet > newSelected) {
+ } else if (config.selectedPet > newSelected) {
config.selectedPet--;
}
} else {
@@ -918,7 +931,7 @@ public class PetInfoOverlay extends TextOverlay {
String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
Pet pet = getPetFromStack(stack.getDisplayName(), lore);
- if(pet != null) {
+ if (pet != null) {
config.petMap.put(config.selectedPet, pet);
}
}
@@ -928,27 +941,28 @@ public class PetInfoOverlay extends TextOverlay {
}
public static float getXpGain(Pet pet, float xp, String xpType) {
- if(pet.petLevel.level >= 100) return 0;
+ 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;
+ 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)) {
+ if (pet.petXpType != null && !pet.petXpType.equalsIgnoreCase(xpType)) {
xp = xp / 3f;
- if(xpType.equalsIgnoreCase("alchemy") || xpType.equalsIgnoreCase("enchanting")) {
+ if (xpType.equalsIgnoreCase("alchemy") || xpType.equalsIgnoreCase("enchanting")) {
xp = xp / 4f;
}
}
- if(xpType.equalsIgnoreCase("mining") || xpType.equalsIgnoreCase("fishing")) {
+ if (xpType.equalsIgnoreCase("mining") || xpType.equalsIgnoreCase("fishing")) {
xp = xp * 1.5f;
}
- if(pet.petItem != null) {
+ if (pet.petItem != null) {
Matcher petItemMatcher = XP_BOOST_PATTERN.matcher(pet.petItem);
- if((petItemMatcher.matches() && petItemMatcher.group(1).equalsIgnoreCase(xpType))
+ if ((petItemMatcher.matches() && petItemMatcher.group(1).equalsIgnoreCase(xpType))
|| pet.petItem.equalsIgnoreCase("ALL_SKILLS_SUPER_BOOST")) {
xp = xp * getBoostMultiplier(pet.petItem);
}
@@ -957,6 +971,7 @@ public class PetInfoOverlay extends TextOverlay {
}
private final HashMap<String, Float> skillInfoMapLast = new HashMap<>();
+
public void updatePetLevels() {
HashMap<String, XPInformation.SkillInfo> skillInfoMap = XPInformation.getInstance().getSkillInfoMap();
@@ -965,16 +980,16 @@ public class PetInfoOverlay extends TextOverlay {
float totalGain = 0;
Pet currentPet = getCurrentPet();
- for(Map.Entry<String, XPInformation.SkillInfo> entry : skillInfoMap.entrySet()) {
- if(entry.getValue().level == 50 && entry.getValue().fromApi) continue;
+ 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())) {
+ if (skillInfoMapLast.containsKey(entry.getKey())) {
float skillXpLast = skillInfoMapLast.get(entry.getKey());
- if(skillXpLast <= 0) {
+ if (skillXpLast <= 0) {
skillInfoMapLast.put(entry.getKey(), skillXp);
- } else if(skillXp > skillXpLast) {
+ } else if (skillXp > skillXpLast) {
lastXpGain = currentTime;
float deltaXp = skillXp - skillXpLast;
@@ -990,8 +1005,8 @@ public class PetInfoOverlay extends TextOverlay {
}
xpGainHourLast = xpGainHour;
- if(xpAddTimer > 0 || totalGain > 0) {
- if(totalGain > 0) {
+ if (xpAddTimer > 0 || totalGain > 0) {
+ if (totalGain > 0) {
xpAddTimer = 10;
} else {
xpAddTimer--;
@@ -1000,37 +1015,37 @@ public class PetInfoOverlay extends TextOverlay {
currentPet.petLevel.totalXp += totalGain;
xpGainQueue.add(0, totalGain);
- while(xpGainQueue.size() > 30) {
+ while (xpGainQueue.size() > 30) {
xpGainQueue.removeLast();
}
- if(xpGainQueue.size() > 1) {
+ if (xpGainQueue.size() > 1) {
float tot = 0;
float greatest = 0;
- for(float f : xpGainQueue) {
+ for (float f : xpGainQueue) {
tot += f;
greatest = Math.max(greatest, f);
}
- xpGainHour = (tot-greatest)*(60*60)/(xpGainQueue.size()-1);
+ xpGainHour = (tot - greatest) * (60 * 60) / (xpGainQueue.size() - 1);
}
}
JsonObject petsJson = Constants.PETS;
- if(currentPet != null && petsJson != null) {
+ 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);
+ 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];
+ 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;
}
@@ -1039,7 +1054,7 @@ public class PetInfoOverlay extends TextOverlay {
@SubscribeEvent
public void switchWorld(WorldEvent.Load event) {
- if(NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
ProfileApiSyncer.getInstance().requestResync("petinfo_quick", 10000, () -> {
}, PetInfoOverlay::getAndSetPet);
}
@@ -1052,26 +1067,26 @@ public class PetInfoOverlay extends TextOverlay {
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onTooltip(ItemTooltipEvent event) {
- for(String line : event.toolTip) {
- if(line.startsWith("\u00a7o\u00a77[Lvl ")) {
+ for (String line : event.toolTip) {
+ if (line.startsWith("\u00a7o\u00a77[Lvl ")) {
lastItemHovered = null;
String after = line.substring("\u00a7o\u00a77[Lvl ".length());
- if(after.contains("]")) {
+ if (after.contains("]")) {
String levelStr = after.split("]")[0];
try {
lastLevelHovered = Integer.parseInt(levelStr.trim());
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
- } else if(line.startsWith("\u00a75\u00a7o\u00a76Held Item: ")) {
+ } else if (line.startsWith("\u00a75\u00a7o\u00a76Held Item: ")) {
String after = line.substring("\u00a75\u00a7o\u00a76Held Item: ".length());
- if(itemMap == null) {
+ 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") ||
+ 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());
@@ -1079,40 +1094,40 @@ public class PetInfoOverlay extends TextOverlay {
}
}
- if(itemMap.containsKey(after)) {
+ 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) {
+ 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()) {
+ if (autopetMatcher.matches()) {
try {
lastLevelHovered = Integer.parseInt(autopetMatcher.group(1));
- } catch(NumberFormatException ignored) {}
+ } 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)) {
+ for (EnumChatFormatting formatting : EnumChatFormatting.values()) {
+ if (formatting.toString().equals("\u00a7" + colChar)) {
col = formatting;
break;
}
}
Rarity rarity = Rarity.COMMON;
- if(col != EnumChatFormatting.RESET) {
+ if (col != EnumChatFormatting.RESET) {
rarity = Rarity.getRarityFromColor(col);
}
@@ -1121,13 +1136,13 @@ public class PetInfoOverlay extends TextOverlay {
.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 +
+ 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")) {
+ } else if (chatMessage.toLowerCase().startsWith("you despawned your")) {
clearPet();
- } else if(chatMessage.toLowerCase().contains("switching to profile")) {
+ } else if (chatMessage.toLowerCase().contains("switching to profile")) {
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..3837cfe8 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,32 +19,25 @@ 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();
@@ -81,38 +73,44 @@ public class SlotLocking {
private Slot realSlot = null;
- public void setRealSlot(Slot slot){
+ public void setRealSlot(Slot slot) {
realSlot = slot;
}
- public Slot getRealSlot(){ return realSlot;}
+ public Slot getRealSlot() {return realSlot;}
public void loadConfig(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
+ 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) {
+ } catch (Exception ignored) {}
+ if (config == null) {
config = new SlotLockingConfig();
}
}
- public void changedSlot(int slotNumber){
+ public void changedSlot(int slotNumber) {
int pingModifier = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSwapDelay;
- if(pingModifier == 0){ return; };
- if(!isSlotIndexLocked(slotNumber)){ return;}
+ 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){
+ if (i != slotNumber && slotChanges[i] != 0 && (slotChanges[i] + (long) pingModifier) > currentTimeMilis) {
slotChanges[i] = 0;
}
}
slotChanges[slotNumber] = currentTimeMilis;
}
- public boolean isSwapedSlotLocked(){
+ public boolean isSwapedSlotLocked() {
int pingModifier = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSwapDelay;
- if(pingModifier == 0){ return false; };
+ if (pingModifier == 0) {
+ return false;
+ }
long currentTimeMilis = System.currentTimeMillis();
for (int i = 0; i < slotChanges.length; i++) {
@@ -123,32 +121,33 @@ public class SlotLocking {
return false;
}
- private long[] slotChanges = new long[9];
+ 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))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
writer.write(GSON.toJson(config));
}
- } catch(Exception ignored) {
- ignored.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
private LockedSlot[] getDataForProfile() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking)
+ return null;
String profileName = SBInfo.getInstance().currentProfile;
- if(profileName == null) profileName = "generic";
+ if (profileName == null) profileName = "generic";
SlotLockProfile profile = config.profileData.computeIfAbsent(profileName,
- k->new SlotLockProfile());
+ k -> new SlotLockProfile());
- if(profile.currentProfile < 0) profile.currentProfile = 0;
- if(profile.currentProfile >= 9) profile.currentProfile = 8;
+ if (profile.currentProfile < 0) profile.currentProfile = 0;
+ if (profile.currentProfile >= 9) profile.currentProfile = 8;
- if(profile.slotLockData[profile.currentProfile] == null) {
+ if (profile.slotLockData[profile.currentProfile] == null) {
profile.slotLockData[profile.currentProfile] = new SlotLockData();
}
@@ -156,13 +155,13 @@ public class SlotLocking {
}
private LockedSlot getLockedSlot(LockedSlot[] lockedSlots, int index) {
- if(lockedSlots == null) {
+ if (lockedSlots == null) {
return DEFAULT_LOCKED_SLOT;
}
LockedSlot slot = lockedSlots[index];
- if(slot == null) {
+ if (slot == null) {
return DEFAULT_LOCKED_SLOT;
}
@@ -171,16 +170,16 @@ public class SlotLocking {
@SubscribeEvent(priority = EventPriority.LOW)
public void keyboardInput(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
return;
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ 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()) {
+ if (!lockKeyHeld && KeybindHelper.isKeyPressed(key) && !Keyboard.isRepeatEvent()) {
final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
final int scaledWidth = scaledresolution.getScaledWidth();
final int scaledHeight = scaledresolution.getScaledHeight();
@@ -188,14 +187,14 @@ public class SlotLocking {
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) {
+ if (slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) {
int slotNum = slot.getSlotIndex();
- if(slotNum >= 0 && slotNum <= 39) {
+ if (slotNum >= 0 && slotNum <= 39) {
boolean isHotbar = slotNum < 9;
boolean isInventory = !isHotbar && slotNum < 36;
boolean isArmor = !isHotbar && !isInventory;
- if(isInventory || isArmor) {
+ if (isInventory || isArmor) {
pairingSlot = slot;
} else {
pairingSlot = null;
@@ -203,17 +202,17 @@ public class SlotLocking {
LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots != null) {
- if(lockedSlots[slotNum] == null) {
+ 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;
+ 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;
@@ -232,9 +231,9 @@ public class SlotLocking {
}
}
- if(isHotbar && lockedSlots[slotNum].locked) {
- for(int i = 9; i <= 39; i++) {
- if(lockedSlots[i] != null && lockedSlots[i].boundTo == slotNum) {
+ if (isHotbar && lockedSlots[slotNum].locked) {
+ for (int i = 9; i <= 39; i++) {
+ if (lockedSlots[i] != null && lockedSlots[i].boundTo == slotNum) {
lockedSlots[i].boundTo = -1;
}
}
@@ -244,22 +243,22 @@ public class SlotLocking {
}
}
lockKeyHeld = KeybindHelper.isKeyDown(key);
- if(!lockKeyHeld) {
+ if (!lockKeyHeld) {
pairingSlot = null;
}
}
@SubscribeEvent(priority = EventPriority.LOW)
public void mouseEvent(GuiScreenEvent.MouseInputEvent.Pre event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
return;
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
return;
}
GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && lockKeyHeld && pairingSlot != null) {
+ 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();
@@ -267,23 +266,23 @@ public class SlotLocking {
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) {
+ if (slot != null && slot.getSlotIndex() != 8 && slot.inventory == Minecraft.getMinecraft().thePlayer.inventory) {
int slotNum = slot.getSlotIndex();
- if(slotNum >= 0 && slotNum <= 39) {
+ 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) {
+ if (isHotbar && slotNum != pairingNum) {
LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots != null) {
- if(lockedSlots[slotNum] == null) {
+ if (lockedSlots != null) {
+ if (lockedSlots[slotNum] == null) {
lockedSlots[slotNum] = new LockedSlot();
}
- if(!lockedSlots[slotNum].locked) {
- if(lockedSlots[pairingNum] == null) {
+ if (!lockedSlots[slotNum].locked) {
+ if (lockedSlots[pairingNum] == null) {
lockedSlots[pairingNum] = new LockedSlot();
}
@@ -298,8 +297,8 @@ public class SlotLocking {
} else {
int pairingNum = pairingSlot.getSlotIndex();
LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots != null && lockedSlots[pairingNum] != null) {
- if(lockedSlots[pairingNum].boundTo >= 0) {
+ if (lockedSlots != null && lockedSlots[pairingNum] != null) {
+ if (lockedSlots[pairingNum].boundTo >= 0) {
lockedSlots[lockedSlots[pairingNum].boundTo] = null;
}
lockedSlots[pairingNum] = null;
@@ -309,20 +308,20 @@ public class SlotLocking {
}
public void toggleLock(int lockIndex) {
- if(lockIndex == 8) return;
+ if (lockIndex == 8) return;
LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots != null) {
- if(lockedSlots[lockIndex] == null) {
+ 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;
+ 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;
@@ -341,9 +340,9 @@ public class SlotLocking {
}
}
- if(lockIndex < 9 && lockedSlots[lockIndex].locked) {
- for(int i = 9; i <= 39; i++) {
- if(lockedSlots[i] != null && lockedSlots[i].boundTo == lockIndex) {
+ 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;
}
}
@@ -353,25 +352,25 @@ public class SlotLocking {
@SubscribeEvent(priority = EventPriority.LOW)
public void drawScreenEvent(GuiScreenEvent.DrawScreenEvent.Post event) {
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotBinding && !event.isCanceled() && pairingSlot != null && lockKeyHeld) {
+ 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) {
+ if (lockedSlot.boundTo >= 0 && lockedSlot.boundTo < 8) {
return;
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ 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 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) {
+ if (x2 > x1 - 8 && x2 < x1 + 8 &&
+ y2 > y1 - 8 && y2 < y1 + 8) {
return;
}
@@ -380,7 +379,7 @@ public class SlotLocking {
}
private void drawLinkArrow(int x1, int y1, int x2, int y2) {
- GlStateManager.color(0x33/255f, 0xee/255f, 0xdd/255f, 1f);
+ GlStateManager.color(0x33 / 255f, 0xee / 255f, 0xdd / 255f, 1f);
GlStateManager.disableLighting();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableTexture2D();
@@ -406,35 +405,35 @@ public class SlotLocking {
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
int lines = 6;
- for(int i=0; i<lines; i++) {
+ 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();
+ 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) {
+ if (locked == null) {
return;
- } else if(locked.locked || (clickType == 2 && SlotLocking.getInstance().isSlotIndexLocked(clickedButton))) {
+ } 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) {
+ } 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) {
+ if (boundSlot == null) {
return;
}
LockedSlot boundLocked = getLockedSlot(boundSlot);
int id = slotIn.getSlotIndex();
- if(id >= 9 && locked.boundTo >= 0 && locked.boundTo < 8) {
- if(!boundLocked.locked) {
+ 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) {
+ if (boundLocked == DEFAULT_LOCKED_SLOT) {
LockedSlot[] lockedSlots = getDataForProfile();
lockedSlots[locked.boundTo] = new LockedSlot();
lockedSlots[locked.boundTo].boundTo = id;
@@ -442,23 +441,23 @@ public class SlotLocking {
boundLocked.boundTo = id;
}
}
- } else if(id >= 0 && id < 8 && locked.boundTo >= 9 && locked.boundTo <= 39) {
- if(boundLocked.locked || 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) {
+ } 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) {
+ if (locked != null) {
+ if (locked.locked) {
GlStateManager.translate(0, 0, 400);
Minecraft.getMinecraft().getTextureManager().bindTexture(LOCK);
GlStateManager.color(1, 1, 1, 0.5f);
@@ -467,8 +466,8 @@ public class SlotLocking {
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)) {
+ } 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;
@@ -480,13 +479,13 @@ public class SlotLocking {
int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1;
Slot boundSlot = container.inventorySlots.getSlotFromInventory(Minecraft.getMinecraft().thePlayer.inventory, locked.boundTo);
- if(boundSlot == null) {
+ if (boundSlot == null) {
return;
}
boolean hoverOverSlot = container.isMouseOverSlot(slot, mouseX, mouseY);
- if(hoverOverSlot || slot.getSlotIndex() >= 9) {
+ if (hoverOverSlot || slot.getSlotIndex() >= 9) {
Minecraft.getMinecraft().getTextureManager().bindTexture(BOUND);
GlStateManager.color(1, 1, 1, 0.7f);
GlStateManager.depthMask(false);
@@ -495,23 +494,23 @@ public class SlotLocking {
GlStateManager.enableBlend();
//Rerender Text over Top
- if(slot.getStack() != null) {
+ 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;
+ } 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 (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) {
+ if (hoverOverSlot) {
LockedSlot boundLocked = getLockedSlot(boundSlot);
- if(boundLocked == null || boundLocked.locked ||
+ if (boundLocked == null || boundLocked.locked ||
(boundSlot.getSlotIndex() >= 9 && boundLocked.boundTo != slot.getSlotIndex())) {
locked.boundTo = -1;
return;
@@ -525,38 +524,38 @@ public class SlotLocking {
GlStateManager.enableBlend();
//Rerender Text over Top
- if(boundSlot.getStack() != null) {
+ 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;
+ 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;
+ 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;
+ 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);
+ 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)) {
+ } 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;
@@ -567,39 +566,40 @@ public class SlotLocking {
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;
+ 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 (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) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking)
+ return null;
+ if (slot == null) {
return null;
}
- if(slot.inventory != Minecraft.getMinecraft().thePlayer.inventory) {
+ if (slot.inventory != Minecraft.getMinecraft().thePlayer.inventory) {
return null;
}
int index = slot.getSlotIndex();
- if(index < 0 || index > 39) {
+ if (index < 0 || index > 39) {
return null;
}
return getLockedSlotIndex(index);
}
public LockedSlot getLockedSlotIndex(int index) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) {
return null;
}
LockedSlot[] lockedSlots = getDataForProfile();
- if(lockedSlots == null) {
+ if (lockedSlots == null) {
return null;
}
return getLockedSlot(lockedSlots, index);
@@ -615,6 +615,5 @@ public class SlotLocking {
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..1cc34412 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;
@@ -58,12 +59,12 @@ public class StorageManager {
NBTTagCompound tag = JsonToNBT.getTagFromJson(JSON_FIX_REGEX.matcher(object.toString()).replaceAll("$1:"));
Item item;
- if(tag.hasKey("id", 8)) {
+ if (tag.hasKey("id", 8)) {
item = Item.getByNameOrId(tag.getString("id"));
} else {
item = Item.getItemById(tag.getShort("id"));
}
- if(item == null) {
+ if (item == null) {
return null;
}
int stackSize = tag.getInteger("Count");
@@ -71,13 +72,13 @@ public class StorageManager {
ItemStack stack = new ItemStack(item, stackSize, damage);
- if(tag.hasKey("tag")) {
+ if (tag.hasKey("tag")) {
NBTTagCompound itemTag = tag.getCompoundTag("tag");
stack.setTagCompound(itemTag);
}
return stack;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
@@ -99,7 +100,7 @@ public class StorageManager {
} else if (tag instanceof NBTTagList) {
NBTTagList listTag = (NBTTagList) tag;
JsonArray jsonArray = new JsonArray();
- for(int i=0; i<listTag.tagCount(); i++) {
+ for (int i = 0; i < listTag.tagCount(); i++) {
jsonArray.add(loadJson(listTag.get(i)));
}
return jsonArray;
@@ -107,19 +108,19 @@ public class StorageManager {
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]));
+ 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(int i=0; i<arr.length; i++) {
- jsonArray.add(new JsonPrimitive(arr[i]));
+ for (byte b : arr) {
+ jsonArray.add(new JsonPrimitive(b));
}
return jsonArray;
- }else if (tag instanceof NBTTagShort) {
+ } else if (tag instanceof NBTTagShort) {
return new JsonPrimitive(((NBTTagShort) tag).getShort());
} else if (tag instanceof NBTTagInt) {
return new JsonPrimitive(((NBTTagInt) tag).getInt());
@@ -131,8 +132,8 @@ public class StorageManager {
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 if (tag instanceof NBTTagString) {
+ return new JsonPrimitive(((NBTTagString) tag).getString());
} else {
return new JsonPrimitive("Broken_Json_Deserialize_Tag");
}
@@ -142,7 +143,7 @@ public class StorageManager {
return INSTANCE;
}
- private AtomicInteger searchId = new AtomicInteger(0);
+ private final AtomicInteger searchId = new AtomicInteger(0);
public static class StoragePage {
public ItemStack[] items = new ItemStack[45];
@@ -182,7 +183,7 @@ public class StorageManager {
public int desiredStoragePage = -1;
public long storageOpenSwitchMillis = 0;
- private ItemStack[] missingBackpackStacks = new ItemStack[18];
+ private final ItemStack[] missingBackpackStacks = new ItemStack[18];
private boolean shouldRenderStorageOverlayCached = false;
@@ -190,10 +191,10 @@ public class StorageManager {
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))) {
+ 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) {
+ } catch (Exception ignored) {}
+ if (storageConfig == null) {
storageConfig = new StorageConfig();
}
}
@@ -201,21 +202,21 @@ public class StorageManager {
public void saveConfig(File file) {
try {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)), StandardCharsets.UTF_8))) {
+ 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();
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
public ItemStack getMissingBackpackStack(int storageId) {
- if(missingBackpackStacks[storageId] != null) {
+ if (missingBackpackStacks[storageId] != null) {
return missingBackpackStacks[storageId];
}
ItemStack stack = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
- "\u00a7cEmpty Backpack Slot "+(storageId+1), 12,
+ "\u00a7cEmpty Backpack Slot " + (storageId + 1), 12,
"",
"\u00a7eLeft-click a backpack",
"\u00a7eitem on this slot to place",
@@ -224,24 +225,24 @@ public class StorageManager {
missingBackpackStacks[storageId] = stack;
return stack;
}
-
+
public boolean shouldRenderStorageOverlay(String containerName) {
- if(!NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
+ if (!NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
shouldRenderStorageOverlayCached = false;
return false;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
shouldRenderStorageOverlayCached = false;
return false;
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
shouldRenderStorageOverlayCached = false;
return false;
}
- if(getCurrentWindowId() != -1 && getCurrentPageId() != -1) {
+ if (getCurrentWindowId() != -1 && getCurrentPageId() != -1) {
shouldRenderStorageOverlayCached = true;
return true;
}
@@ -255,28 +256,28 @@ public class StorageManager {
}
private StoragePage[] getPagesForProfile() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return null;
- if(SBInfo.getInstance().currentProfile == null) return null;
+ 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;
+ if (pageIndex == -1) return null;
StoragePage[] pages = getPagesForProfile();
- if(pages == null) return null;
+ if (pages == null) return null;
- if(createPage && pages[pageIndex] == null) pages[pageIndex] = new StoragePage();
+ if (createPage && pages[pageIndex] == null) pages[pageIndex] = new StoragePage();
return pages[pageIndex];
}
public void removePage(int pageIndex) {
- if(pageIndex == -1) return;
+ if (pageIndex == -1) return;
StoragePage[] pages = getPagesForProfile();
- if(pages == null) return;
+ if (pages == null) return;
pages[pageIndex] = null;
}
@@ -287,13 +288,13 @@ public class StorageManager {
private void setItemSlot(int index, ItemStack item) {
StoragePage page = getCurrentPage();
- if(page != null) {
+ if (page != null) {
page.items[index] = item;
}
}
public int getCurrentPageId() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
currentStoragePage = -1;
return -1;
}
@@ -302,62 +303,62 @@ public class StorageManager {
}
public int getCurrentWindowId() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
currentStoragePage = -1;
return -1;
}
- GuiChest chest = (GuiChest)Minecraft.getMinecraft().currentScreen;
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
return chest.inventorySlots.windowId;
}
public void sendToPage(int page) {
- if(desiredStoragePage != getCurrentPageId() &&
+ if (desiredStoragePage != getCurrentPageId() &&
System.currentTimeMillis() - storageOpenSwitchMillis < 100) return;
- if(getCurrentPageId() == page) return;
+ if (getCurrentPageId() == page) return;
- if(page == 0) {
+ if (page == 0) {
NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest");
- } else if(getCurrentWindowId() != -1 && onStorageMenu) {
- if(page < 9) {
- sendMouseClick(getCurrentWindowId(), 9+page);
+ } else if (getCurrentWindowId() != -1 && onStorageMenu) {
+ if (page < 9) {
+ sendMouseClick(getCurrentWindowId(), 9 + page);
} else {
- sendMouseClick(getCurrentWindowId(), 27+page-MAX_ENDER_CHEST_PAGES);
+ 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))) {
+ if (currentStoragePage >= 0 && (onEnderchest || (onStorage))) {
int currentPageDisplay = getDisplayIdForStorageId(currentStoragePage);
int desiredPageDisplay = getDisplayIdForStorageId(page);
- if(onEnderchest && desiredPageDisplay > currentPageDisplay) {
+ if (onEnderchest && desiredPageDisplay > currentPageDisplay) {
boolean isLastPage = true;
- for(int pageN=page+1; pageN<MAX_ENDER_CHEST_PAGES; pageN++) {
- if(getDisplayIdForStorageId(pageN) >= 0) {
+ for (int pageN = page + 1; pageN < MAX_ENDER_CHEST_PAGES; pageN++) {
+ if (getDisplayIdForStorageId(pageN) >= 0) {
isLastPage = false;
break;
}
}
- if(isLastPage) {
+ if (isLastPage) {
sendMouseClick(getCurrentWindowId(), 8);
return;
}
}
- if(onStorage && page == MAX_ENDER_CHEST_PAGES) {
+ if (onStorage && page == MAX_ENDER_CHEST_PAGES) {
sendMouseClick(getCurrentWindowId(), 5);
return;
- } else if(onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size()-1) {
+ } else if (onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size() - 1) {
sendMouseClick(getCurrentWindowId(), 8);
return;
} else {
int delta = desiredPageDisplay - currentPageDisplay;
- if(delta == -1) {
+ if (delta == -1) {
sendMouseClick(getCurrentWindowId(), 6);
return;
- } else if(delta == 1) {
+ } else if (delta == 1) {
sendMouseClick(getCurrentWindowId(), 7);
return;
}
@@ -367,7 +368,7 @@ public class StorageManager {
storageOpenSwitchMillis = System.currentTimeMillis();
desiredStoragePage = page;
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage-8));
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage - 8));
}
}
@@ -379,9 +380,9 @@ public class StorageManager {
}
public int getDisplayIdForStorageId(int storageId) {
- if(storageId < 0) return -1;
- for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMap.entrySet()) {
- if(entry.getValue() == storageId) {
+ if (storageId < 0) return -1;
+ for (Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMap.entrySet()) {
+ if (entry.getValue() == storageId) {
return entry.getKey();
}
}
@@ -389,9 +390,9 @@ public class StorageManager {
}
public int getDisplayIdForStorageIdRender(int storageId) {
- if(storageId < 0) return -1;
- for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
- if(entry.getValue() == storageId) {
+ if (storageId < 0) return -1;
+ for (Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
+ if (entry.getValue() == storageId) {
return entry.getKey();
}
}
@@ -399,11 +400,11 @@ public class StorageManager {
}
public boolean onAnyClick() {
- if(onStorageMenu && desiredStoragePage >= 0) {
- if(desiredStoragePage < 9) {
- sendMouseClick(getCurrentWindowId(), 9+desiredStoragePage);
+ if (onStorageMenu && desiredStoragePage >= 0) {
+ if (desiredStoragePage < 9) {
+ sendMouseClick(getCurrentWindowId(), 9 + desiredStoragePage);
} else {
- sendMouseClick(getCurrentWindowId(), 27+desiredStoragePage-MAX_ENDER_CHEST_PAGES);
+ sendMouseClick(getCurrentWindowId(), 27 + desiredStoragePage - MAX_ENDER_CHEST_PAGES);
}
desiredStoragePage = -1;
return true;
@@ -413,7 +414,7 @@ public class StorageManager {
public void openWindowPacket(S2DPacketOpenWindow packet) {
shouldRenderStorageOverlayCached = false;
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
String windowTitle = Utils.cleanColour(packet.getWindowTitle().getUnformattedText());
@@ -423,34 +424,34 @@ public class StorageManager {
currentStoragePage = -1;
onStorageMenu = false;
- if(windowTitle.trim().equals("Storage")) {
+ if (windowTitle.trim().equals("Storage")) {
onStorageMenu = true;
- } else if(matcher.matches()) {
+ } else if (matcher.matches()) {
int page = Integer.parseInt(matcher.group(1));
- if(page > 0 && page <= 18) {
- currentStoragePage = page-1+MAX_ENDER_CHEST_PAGES;
+ if (page > 0 && page <= 18) {
+ currentStoragePage = page - 1 + MAX_ENDER_CHEST_PAGES;
int displayId = getDisplayIdForStorageId(currentStoragePage);
- if(displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
+ if (displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
StoragePage spage = getCurrentPage();
- if(spage != null) {
- spage.rows = packet.getSlotCount()/9 - 1;
+ if (spage != null) {
+ spage.rows = packet.getSlotCount() / 9 - 1;
}
}
- } else if(matcherEchest.matches()) {
+ } else if (matcherEchest.matches()) {
int page = Integer.parseInt(matcherEchest.group(1));
- if(page > 0 && page <= 9) {
- currentStoragePage = page-1;
+ if (page > 0 && page <= 9) {
+ currentStoragePage = page - 1;
int displayId = getDisplayIdForStorageId(currentStoragePage);
- if(displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
+ if (displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
StoragePage spage = getCurrentPage();
- if(spage != null) {
- spage.rows = packet.getSlotCount()/9 - 1;
+ if (spage != null) {
+ spage.rows = packet.getSlotCount() / 9 - 1;
}
}
} else {
@@ -466,53 +467,53 @@ public class StorageManager {
}
public void setSlotPacket(S2FPacketSetSlot packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_149175_c()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_149175_c()) return;
- if(getCurrentPageId() != -1) {
+ 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());
+ 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) {
+ } 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;
+ if (slot >= 9 && slot < 18) {
+ int index = slot - 9;
boolean changed = false;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
stack.getMetadata() == 14) {
- if(storagePresent[index]) changed = true;
+ if (storagePresent[index]) changed = true;
storagePresent[index] = false;
removePage(index);
} else {
- if(!storagePresent[index]) changed = true;
+ if (!storagePresent[index]) changed = true;
storagePresent[index] = true;
getPage(index, true).backpackDisplayStack = stack;
}
- if(changed) {
- synchronized(storageConfig.displayToStorageIdMap) {
+ 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]) {
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
storageConfig.displayToStorageIdMap.put(displayIndex, i);
- if(lastSearch != null && !lastSearch.isEmpty()){
+ if (lastSearch != null && !lastSearch.isEmpty()) {
StoragePage page = getPage(i, false);
- if(page != null) {
+ if (page != null) {
updateSearchForPage(lastSearch, page);
- if(page.matchesSearch) {
+ if (page.matchesSearch) {
storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
@@ -523,36 +524,36 @@ public class StorageManager {
}
}
}
-
- if(slot >= 27 && slot < 45) {
- int index = (slot-27)%9 + (slot-27)/9*9 + MAX_ENDER_CHEST_PAGES;
+
+ 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;
+ 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;
+ if (!storagePresent[index]) changed = true;
storagePresent[index] = true;
getPage(index, true).backpackDisplayStack = stack;
}
- if(changed) {
- synchronized(storageConfig.displayToStorageIdMap) {
+ 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]) {
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
storageConfig.displayToStorageIdMap.put(displayIndex, i);
- if(lastSearch != null && !lastSearch.isEmpty()){
+ if (lastSearch != null && !lastSearch.isEmpty()) {
StoragePage page = getPage(i, false);
- if(page != null) {
+ if (page != null) {
updateSearchForPage(lastSearch, page);
- if(page.matchesSearch) {
+ if (page.matchesSearch) {
storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
@@ -567,32 +568,32 @@ public class StorageManager {
}
public void updateSearchForPage(String searchStr, StoragePage page) {
- if(page == null) {
+ if (page == null) {
return;
}
- if(page.rows <= 0) {
+ if (page.rows <= 0) {
page.matchesSearch = true;
return;
}
- if(page.searchedId > searchId.get()) {
+ if (page.searchedId > searchId.get()) {
page.searchedId = -1;
return;
}
- if(page.searchedId == searchId.get()) {
+ if (page.searchedId == searchId.get()) {
return;
}
page.searchedId = searchId.get();
- if(searchStr == null || searchStr.trim().isEmpty()) {
+ if (searchStr == null || searchStr.trim().isEmpty()) {
page.matchesSearch = true;
return;
}
- for(ItemStack stack : page.items) {
- if(stack != null && NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchStr)) {
+ for (ItemStack stack : page.items) {
+ if (stack != null && NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchStr)) {
page.matchesSearch = true;
return;
}
@@ -601,21 +602,21 @@ public class StorageManager {
}
public void searchDisplay(String searchStr) {
- if(storagePresent == null) return;
+ if (storagePresent == null) return;
- synchronized(storageConfig.displayToStorageIdMapRender) {
+ 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]) {
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
StoragePage page = getPage(i, false);
- if(page != null) {
- if(page.rows > 0) {
+ if (page != null) {
+ if (page.rows > 0) {
updateSearchForPage(searchStr, page);
- if(page.matchesSearch) {
+ if (page.matchesSearch) {
storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
} else {
@@ -630,16 +631,16 @@ public class StorageManager {
}
public void setItemsPacket(S30PacketWindowItems packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_148911_c()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_148911_c()) return;
- if(getCurrentPageId() != -1) {
+ 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]);
+ 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]);
}
}
@@ -647,19 +648,19 @@ public class StorageManager {
}
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 (!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) {
+ if (getCurrentPageId() != -1) {
StoragePage page = getCurrentPage();
- if(page == null) return;
+ 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));
+ 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..ed08ebe2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StreamerMode.java
@@ -2,9 +2,6 @@ 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;
@@ -14,15 +11,15 @@ public class StreamerMode {
public static String filterLobbyNames(String line) {
Matcher matcher = lobbyPattern.matcher(line);
- if(matcher.find() && matcher.groupCount() == 2) {
+ 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 lobbyNum = Long.parseLong(lobbyId.substring(0, lobbyId.length() - 1));
- long obfLobbyNum = (lobbyNum*9182739 + 11) % 500;
- char obfLobbyLetter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt((int)(obfLobbyNum%26));
+ 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);
+ line = line.replaceAll("(mini|mega|m|M)([0-9]{1,3}[A-Z])", lobbyType + obfLobbyNum + obfLobbyLetter);
}
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..90c59013 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SunTzu.java
@@ -16,9 +16,9 @@ public class SunTzu {
private static boolean enabled = false;
private static int quoteNum = 0;
- private static Random rand = new Random();
+ private static final Random rand = new Random();
- private static String[] quotes = new String[] {
+ 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.",
@@ -46,10 +46,10 @@ public class SunTzu {
}
public static void randomizeQuote() {
- for(int i=0; i<3; i++) {
+ for (int i = 0; i < 3; i++) {
int newQuote = rand.nextInt(quotes.length);
- if(newQuote != quoteNum) {
+ if (newQuote != quoteNum) {
quoteNum = newQuote;
return;
}
@@ -62,23 +62,23 @@ public class SunTzu {
@SubscribeEvent
public void onOverlayDrawn(RenderGameOverlayEvent event) {
- if(enabled && ((event.type == null && Loader.isModLoaded("labymod")) ||
- event.type == RenderGameOverlayEvent.ElementType.ALL)) {
- if(Minecraft.getMinecraft().gameSettings.showDebugInfo ||
+ 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);
+ 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);
+ Minecraft.getMinecraft().fontRendererObj.drawString(EnumChatFormatting.GOLD + sunTzu,
+ sr.getScaledWidth() / 2f + 100 - sunTzuLength, 15 + height, 0, true);
Utils.pushGuiScale(-1);
}
@@ -89,5 +89,4 @@ public class SunTzu {
randomizeQuote();
}
-
}
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..d3b24e2c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java
@@ -48,36 +48,36 @@ public class AccessoryBagOverlay {
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",
+ 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)",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.anvil), EnumChatFormatting.DARK_AQUA + "Total Stat Bonuses (from reforges)",
0),
- Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Duplicates",
+ Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA + "Duplicates",
8),
- Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA+"Missing",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA + "Missing",
0),
- Utils.createItemStack(Item.getItemFromBlock(Blocks.redstone_block), EnumChatFormatting.DARK_AQUA+"Optimizer",
+ 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) {
+ 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")) {
+ if (!containerName.trim().startsWith("Accessory Bag")) {
return false;
}
} else {
return false;
}
- if(!Mouse.getEventButtonState()) return false;
+ if (!Mouse.getEventButtonState()) return false;
try {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -92,47 +92,47 @@ public class AccessoryBagOverlay {
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 + 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 (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;
+ 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) {
+ 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) {
+ } 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 (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) {
+ if (mouseY > y + 32 && mouseY < y + 43) {
forceCC = set;
- } else if(mouseY > y+52 && mouseY < y+63) {
+ } else if (mouseY > y + 52 && mouseY < y + 63) {
forceAS = set;
- } else if(mouseY > y+72 && mouseY < y+83) {
+ } else if (mouseY > y + 72 && mouseY < y + 83) {
useGodPot = set;
- } else if(mouseY > y+92 && mouseY < y+103) {
+ } else if (mouseY > y + 92 && mouseY < y + 103) {
allowShaded = set;
}
}
}
return true;
- } catch(Exception e) {
+ } catch (Exception e) {
return false;
}
}
@@ -151,104 +151,107 @@ public class AccessoryBagOverlay {
private static Set<Integer> pagesVisited = new HashSet<>();
public static void renderVisitOverlay(int x, int y) {
- Utils.drawStringCenteredScaledMaxWidth("Please visit all", Minecraft.getMinecraft().fontRendererObj, x+40, y+78, true, 70, -1);
- Utils.drawStringCenteredScaledMaxWidth("pages of the bag", Minecraft.getMinecraft().fontRendererObj, x+40, y+86, true, 70, -1);
+ Utils.drawStringCenteredScaledMaxWidth("Please visit all", 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) {
+ if (talismanCountRarity == null) {
talismanCountRarity = new TreeMap<>();
- for(ItemStack stack : accessoryStacks) {
+ for (ItemStack stack : accessoryStacks) {
int rarity = getRarity(stack);
- if(rarity >= 0) {
- talismanCountRarity.put(rarity, talismanCountRarity.getOrDefault(rarity, 0)+1);
+ if (rarity >= 0) {
+ talismanCountRarity.put(rarity, talismanCountRarity.getOrDefault(rarity, 0) + 1);
}
}
}
- Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
+ 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()) {
+ 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);
+ 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) {
+ if (totalStats == null) {
totalStats = new PlayerStats.Stats();
- for(ItemStack stack : accessoryStacks) {
- if(stack != null) totalStats.add(getStatForItem(stack, STAT_PATTERN_MAP, true));
+ 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,
+ 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++) {
+ 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;
+ 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);
+ 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) {
+ if (reforgeStats == null) {
reforgeStats = new PlayerStats.Stats();
- for(ItemStack stack : accessoryStacks) {
- if(stack != null) reforgeStats.add(getStatForItem(stack, STAT_PATTERN_MAP_BONUS, false));
+ 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,
+ 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++) {
+ 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;
+ 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);
+ 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) {
+ if (duplicates == null) {
JsonObject misc = Constants.MISC;
- if(misc == null) {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
+ 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,
+ 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;
}
@@ -257,23 +260,23 @@ public class AccessoryBagOverlay {
duplicates = new HashSet<>();
Set<String> prevInternalnames = new HashSet<>();
- for(ItemStack stack : accessoryStacks) {
+ for (ItemStack stack : accessoryStacks) {
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(prevInternalnames.contains(internalname)) {
+ if (prevInternalnames.contains(internalname)) {
duplicates.add(stack);
continue;
}
prevInternalnames.add(internalname);
- if(talisman_upgrades.has(internalname)) {
+ if (talisman_upgrades.has(internalname)) {
JsonArray upgrades = talisman_upgrades.get(internalname).getAsJsonArray();
- for(ItemStack stack2 : accessoryStacks) {
- if(stack != stack2) {
+ for (ItemStack stack2 : accessoryStacks) {
+ if (stack != stack2) {
String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack2);
- for(int j=0; j<upgrades.size(); j++) {
+ for (int j = 0; j < upgrades.size(); j++) {
String upgrade = upgrades.get(j).getAsString();
- if(internalname2.equals(upgrade)) {
+ if (internalname2.equals(upgrade)) {
duplicates.add(stack);
break;
}
@@ -283,44 +286,45 @@ public class AccessoryBagOverlay {
}
}
}
- if(duplicates.isEmpty()) {
- Utils.drawStringCenteredScaledMaxWidth("No Duplicates", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
+ 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,
+ 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) {
+ 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;
+ Utils.renderShadowedString(s, x + 40, y + 20 + 11 * yIndex, 70);
+ if (duplicates.size() > 11) {
+ if (++yIndex >= 10) break;
} else {
- if(++yIndex >= 11) break;
+ if (++yIndex >= 11) break;
}
}
-
- if(duplicates.size() > 11) {
- Utils.drawStringCenteredScaledMaxWidth("+" + (duplicates.size()-10) + " More",
- Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70,
+
+ 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) {
+ if (missing == null) {
JsonObject misc = Constants.MISC;
- if(misc == null) {
- Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
+ 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,
+ 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;
}
@@ -329,23 +333,23 @@ public class AccessoryBagOverlay {
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) {
+ 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) {
+ 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()) {
+ 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++) {
+ for (int j = 0; j < upgrades.size(); j++) {
String upgrade = upgrades.get(j).getAsString();
- if(internalname.equals(upgrade)) {
+ if (internalname.equals(upgrade)) {
missingInternal.remove(talisman_upgrade_element.getKey());
break;
}
@@ -356,14 +360,14 @@ public class AccessoryBagOverlay {
missingInternal.sort(getItemComparator());
Set<String> missingDisplayNames = new HashSet<>();
- for(String internal : missingInternal) {
+ for (String internal : missingInternal) {
boolean hasDup = false;
- if(talisman_upgrades.has(internal)) {
+ if (talisman_upgrades.has(internal)) {
JsonArray upgrades = talisman_upgrades.get(internal).getAsJsonArray();
- for(int j=0; j<upgrades.size(); j++) {
+ for (int j = 0; j < upgrades.size(); j++) {
String upgrade = upgrades.get(j).getAsString();
- if(missingInternal.contains(upgrade)) {
+ if (missingInternal.contains(upgrade)) {
hasDup = true;
break;
}
@@ -372,26 +376,26 @@ public class AccessoryBagOverlay {
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(internal), false);
- if(missingDisplayNames.contains(stack.getDisplayName())) continue;
+ if (missingDisplayNames.contains(stack.getDisplayName())) continue;
missingDisplayNames.add(stack.getDisplayName());
- if(hasDup) {
- stack.setStackDisplayName(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,
+ 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,
+ 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) {
+ int marqueeOffset = (int) (currentTime / 500 % 100);
+ for (ItemStack missingStack : missing) {
String s = missingStack.getDisplayName();
//int marueeOffset
@@ -402,24 +406,24 @@ public class AccessoryBagOverlay {
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++) {
+ 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(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;
+ 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 (++yIndex >= 11) break;
}
}
- if(missing.size() > 11) {
+ if (missing.size() > 11) {
Utils.drawStringCenteredScaledMaxWidth("Show All",
- Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70,
+ Minecraft.getMinecraft().fontRendererObj, x + 40, y + 16 + 121, false, 70,
new Color(80, 80, 80).getRGB());
final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -428,22 +432,22 @@ public class AccessoryBagOverlay {
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) {
+ 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) {
+ 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) {
+ 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) {
+ for (int i = 0; i < missing.size(); i++) {
+ if (i % 3 == 0 && i > 0) {
text.add(line.toString());
line = new StringBuilder();
}
@@ -451,13 +455,13 @@ public class AccessoryBagOverlay {
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) {
+ 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) {
+ int remainder = (int) ((padNum % 1) * 4);
+ while (padNum >= 1) {
+ if (remainder > 0) {
name.append(EnumChatFormatting.BOLD).append(" ");
remainder--;
} else {
@@ -467,22 +471,22 @@ public class AccessoryBagOverlay {
}
}
line.append('\u00A7').append(Utils.getPrimaryColourCode(missing.get(i).getDisplayName()));
- if(i < 9) {
- line.append((char)('\u2776'+i)).append(' ');
+ if (i < 9) {
+ line.append((char) ('\u2776' + i)).append(' ');
} else {
line.append("\u2b24 ");
}
line.append(name);
- if(i % 3 < 2) line.append(" ");
+ if (i % 3 < 2) line.append(" ");
}
GlStateManager.pushMatrix();
- GlStateManager.scale(2f/scaledresolution.getScaleFactor(), 2f/scaledresolution.getScaleFactor(), 1);
+ 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);
+ mouseX * scaledresolution.getScaleFactor() / 2,
+ mouseY * scaledresolution.getScaleFactor() / 2,
+ scaledWidth * scaledresolution.getScaleFactor() / 2,
+ scaledHeight * scaledresolution.getScaleFactor() / 2, -1, Minecraft.getMinecraft().fontRendererObj);
GlStateManager.popMatrix();
}
}
@@ -496,62 +500,62 @@ public class AccessoryBagOverlay {
private static int mainWeapon = 1;
public static void renderOptimizerOverlay(int x, int y) {
- Utils.drawStringCenteredScaledMaxWidth("Optimizer", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
+ 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 + 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 + 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 + 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 + 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);
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+
+ 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,
+ Minecraft.getMinecraft().fontRendererObj, x + 40, y + 117,
true, 70, new Color(80, 80, 80).getRGB());
}
@@ -559,41 +563,43 @@ public class AccessoryBagOverlay {
return (o1, o2) -> {
float cost1;
JsonObject o1Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1);
- if(o1Auc != null && o1Auc.has("price")) {
+ 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")) {
+ 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 == -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;
+ if (cost1 < cost2) return -1;
+ if (cost1 > cost2) return 1;
return o1.compareTo(o2);
};
}
+
private static boolean inAccessoryBag = false;
- public static boolean isInAccessoryBag(){
+
+ public static boolean isInAccessoryBag() {
return inAccessoryBag;
}
- public static void renderOverlay() {
+ public static void renderOverlay() {
inAccessoryBag = false;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest && NEUEventListener.inventoryLoaded) {
+ 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")) {
+ if (containerName.trim().startsWith("Accessory Bag")) {
inAccessoryBag = true;
try {
int xSize = (int) Utils.getField(GuiContainer.class, eventGui, "xSize", "field_146999_f");
@@ -601,105 +607,111 @@ public class AccessoryBagOverlay {
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)) {
+ if (accessoryStacks.isEmpty()) {
+ for (ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if (stack != null && isAccessory(stack)) {
accessoryStacks.add(stack);
}
}
}
- if(containerName.trim().contains("(")) {
+ 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)) {
+ 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++) {
+ 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) {
+ if (stack != null) {
hasStack = true;
- if(isAccessory(stack)) {
+ if (isAccessory(stack)) {
accessoryStacks.add(stack);
}
}
}
}
- if(hasStack) pagesVisited.add(currentPageNumber);
+ 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()) {
+ 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);
+ Utils.drawTexturedRect(guiLeft + xSize + 3, guiTop, 80, 149, 0, 80 / 256f, 0, 149 / 256f, GL11.GL_NEAREST);
- renderVisitOverlay(guiLeft+xSize+3, guiTop);
+ renderVisitOverlay(guiLeft + xSize + 3, guiTop);
return;
}
- } else if(pagesVisited.isEmpty()) {
+ } 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++) {
+ 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) {
+ if (stack != null) {
hasStack = true;
- if(isAccessory(stack)) {
+ if (isAccessory(stack)) {
accessoryStacks.add(stack);
}
}
}
}
- if(hasStack) pagesVisited.add(1);
+ if (hasStack) pagesVisited.add(1);
}
GlStateManager.disableLighting();
- for(int i=0; i<=TAB_MISSING; i++) {
- if(i != currentTab) {
+ 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);
+ 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);
+ 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);
+ 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);
+ 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;
+ renderBasicOverlay(guiLeft + xSize + 3, guiTop);
+ return;
case TAB_TOTAL:
- renderTotalStatsOverlay(guiLeft+xSize+3, guiTop); return;
+ renderTotalStatsOverlay(guiLeft + xSize + 3, guiTop);
+ return;
case TAB_BONUS:
- renderReforgeStatsOverlay(guiLeft+xSize+3, guiTop); return;
+ renderReforgeStatsOverlay(guiLeft + xSize + 3, guiTop);
+ return;
case TAB_DUP:
- renderDuplicatesOverlay(guiLeft+xSize+3, guiTop); return;
+ renderDuplicatesOverlay(guiLeft + xSize + 3, guiTop);
+ return;
case TAB_MISSING:
- renderMissingOverlay(guiLeft+xSize+3, guiTop); return;
+ renderMissingOverlay(guiLeft + xSize + 3, guiTop);
+ return;
case TAB_OPTIMIZER:
- renderOptimizerOverlay(guiLeft+xSize+3, guiTop); return;
+ renderOptimizerOverlay(guiLeft + xSize + 3, guiTop);
+ return;
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -754,20 +766,21 @@ 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 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);
@@ -784,24 +797,24 @@ public class AccessoryBagOverlay {
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 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);
@@ -817,24 +830,25 @@ public class AccessoryBagOverlay {
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) {
+ if (internalname == null) {
return stats;
}
- if(tag != null) {
+ 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()) {
+ for (Map.Entry<String, Pattern> entry : patternMap.entrySet()) {
Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
- if(matcher.find()) {
+ if (matcher.find()) {
float bonus = Float.parseFloat(matcher.group(1));
stats.addStat(entry.getKey(), bonus);
}
@@ -843,14 +857,14 @@ public class AccessoryBagOverlay {
}
}
- if(!addExtras) return stats;
+ if (!addExtras) return stats;
- if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
+ 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)) {
+ if (internalname.equals("NEW_YEAR_CAKE_BAG") && tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
byte[] bytes = null;
@@ -861,10 +875,10 @@ public class AccessoryBagOverlay {
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) {
+ 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)) {
+ 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"));
@@ -873,7 +887,7 @@ public class AccessoryBagOverlay {
}
}
stats.addStat(PlayerStats.HEALTH, cakes.size());
- } catch(IOException e) {
+ } catch (IOException e) {
e.printStackTrace();
return stats;
}
@@ -884,7 +898,7 @@ public class AccessoryBagOverlay {
return stats;
}
-// private static String[] rarityArr = new String[] {
+ // private static String[] rarityArr = new String[] {
// "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", "SUPREME"
// };
// private static String[] rarityArrC = new String[] {
@@ -900,24 +914,24 @@ public class AccessoryBagOverlay {
// };
public static int checkItemType(ItemStack stack, boolean contains, String... typeMatches) {
NBTTagCompound tag = stack.getTagCompound();
- if(tag != null) {
+ 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--) {
+ 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])) {
+ 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])) {
+ } else if (line.trim().contains(rarity + " DUNGEON " + typeMatches[j])) {
return j;
}
} else {
- if(line.trim().endsWith(rarity + " " + typeMatches[j])) {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
return j;
- } else if(line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
+ } else if (line.trim().endsWith(rarity + " DUNGEON " + typeMatches[j])) {
return j;
}
}
@@ -928,13 +942,14 @@ public class AccessoryBagOverlay {
}
return -1;
}
+
private static int checkItemType(JsonArray lore, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
+ 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])) {
+ for (String rarity : Utils.rarityArr) {
+ for (int j = 0; j < typeMatches.length; j++) {
+ if (line.trim().endsWith(rarity + " " + typeMatches[j])) {
return j;
}
}
@@ -942,21 +957,21 @@ public class AccessoryBagOverlay {
}
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) {
+ 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])) {
+ for (int j = 0; j < Utils.rarityArrC.length; j++) {
+ if (line.contains(Utils.rarityArrC[j])) {
return j;
}
}
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..2ed1e2fb 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,13 +35,13 @@ 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;
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.help;
+
public class CalendarOverlay {
private static final ResourceLocation BACKGROUND = new ResourceLocation("notenoughupdates:calendar/background.png");
@@ -66,7 +65,7 @@ public class CalendarOverlay {
private int xSize = 168;
private int ySize = 170;
- private class SBEvent {
+ private static class SBEvent {
String id;
String display;
ItemStack stack;
@@ -88,7 +87,7 @@ public class CalendarOverlay {
private int jingleIndex = -1;
- private TreeMap<Long, Set<SBEvent>> eventMap = new TreeMap<>();
+ private final TreeMap<Long, Set<SBEvent>> eventMap = new TreeMap<>();
private List<String> jfFavouriteSelect = null;
private int jfFavouriteSelectIndex = 0;
private int jfFavouriteSelectX = 0;
@@ -98,16 +97,17 @@ public class CalendarOverlay {
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 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 long DA_OFFSET = 1000*60*55;
- private static long JF_OFFSET = 1000*60*15;
+ 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;
- private static ItemStack DA_STACK;
- private static ItemStack JF_STACK;
static {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("event_id", "dark_auction");
@@ -125,25 +125,29 @@ public class CalendarOverlay {
long offset = 0;
StringBuilder numS = new StringBuilder();
- for(int timeIndex=0; timeIndex<time.length(); timeIndex++) {
+ for (int timeIndex = 0; timeIndex < time.length(); timeIndex++) {
char c = time.charAt(timeIndex);
- if(c >= '0' && c <= '9') {
+ if (c >= '0' && c <= '9') {
numS.append(c);
} else {
try {
int num = Integer.parseInt(numS.toString());
switch (c) {
case 'd':
- offset += num * DAY; continue;
+ offset += num * DAY;
+ continue;
case 'h':
- offset += num * HOUR; continue;
+ offset += num * HOUR;
+ continue;
case 'm':
- offset += num * MINUTE; continue;
+ offset += num * MINUTE;
+ continue;
case 's':
- offset += num * SECOND; continue;
+ offset += num * SECOND;
+ continue;
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
numS = new StringBuilder();
}
}
@@ -151,14 +155,14 @@ public class CalendarOverlay {
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
+ 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 (event.phase != TickEvent.Phase.START) return;
- if(jingleIndex == 0) {
+ if (jingleIndex == 0) {
if (NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
new ResourceLocation("notenoughupdates:calendar_notif_jingle")
@@ -167,59 +171,59 @@ public class CalendarOverlay {
new ResourceLocation("notenoughupdates:calendar_notif_in")
));
}
- jingleIndex = -15*20;
- } else if(jingleIndex >= 1) {
+ 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 = -15 * 20;
+ } else if (jingleIndex < -1) {
jingleIndex++;
}
- if(jingleIndex == -20*6-10) {
- if(NotEnoughUpdates.INSTANCE.config.calendar.eventNotificationSounds) {
+ 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) {
+ if (farmingEventTypes == null) {
farmingEventTypes = NotEnoughUpdates.INSTANCE.manager.getJsonFromFile(new File(NotEnoughUpdates.INSTANCE.manager.configLocation,
"farmingEventTypes.json"));
- if(farmingEventTypes == null) {
+ if (farmingEventTypes == null) {
farmingEventTypes = new JsonObject();
}
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
jfFavouriteSelect = null;
- if(eventMap.isEmpty() || eventMap.size() <= 20) {
+ 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));
+ 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) {
+ 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();
+ 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());
+ for (JsonElement e : arr) {
+ jf.desc.add(EnumChatFormatting.YELLOW + "\u25CB " + e.getAsString());
jf.id += ":" + e.getAsString();
}
}
- eventMap.computeIfAbsent(jfEvent, k->new HashSet<>()).add(jf);
+ eventMap.computeIfAbsent(jfEvent, k -> new HashSet<>()).add(jf);
}
}
}
@@ -231,7 +235,7 @@ public class CalendarOverlay {
String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText();
Matcher matcher = CALENDAR_PATTERN.matcher(Utils.cleanColour(containerName));
- if(farmingEventTypes != null && matcher.matches()) {
+ if (farmingEventTypes != null && matcher.matches()) {
try {
int year = Integer.parseInt(matcher.group(2));
int skyblockDays = year * 12 * 31;
@@ -241,98 +245,98 @@ public class CalendarOverlay {
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;
+ 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;
+ skyblockDays += 10 * 31;
}
- if(month.startsWith("Early")) {
+ if (month.startsWith("Early")) {
skyblockDays -= 31;
- } else if(month.startsWith("Late")) {
+ } else if (month.startsWith("Late")) {
skyblockDays += 31;
}
- long start = SKYBLOCK_START + skyblockDays*20*MINUTE;
+ 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);
+ 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) {
+ if (item.getTagCompound() != null) {
NBTTagCompound tag = item.getTagCompound();
- if(tag.hasKey("display", 10)) {
+ 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++) {
+ for (int j = 0; j < list.tagCount(); j++) {
String line = list.getStringTagAt(j);
- if(line.startsWith(EnumChatFormatting.YELLOW+"\u25CB")) {
+ 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() ||
+ 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) {
+ if (changed) {
File f = new File(NotEnoughUpdates.INSTANCE.manager.configLocation,
"farmingEventTypes.json");
NotEnoughUpdates.INSTANCE.manager.writeJson(farmingEventTypes, f);
}
}
- } catch(Exception ignored) {
- ignored.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
- if(!enabled) {
+ if (!enabled) {
jfFavouriteSelect = null;
- if(eventMap.isEmpty() || eventMap.size() <= 20) {
+ 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));
+ 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) {
+ 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();
+ 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());
+ for (JsonElement e : arr) {
+ jf.desc.add(EnumChatFormatting.YELLOW + "\u25CB " + e.getAsString());
jf.id += ":" + e.getAsString();
}
}
- eventMap.computeIfAbsent(jfEvent, k->new HashSet<>()).add(jf);
+ eventMap.computeIfAbsent(jfEvent, k -> new HashSet<>()).add(jf);
}
}
}
return;
}
- if(!containerName.trim().equals("Calendar and Events")) {
+ if (!containerName.trim().equals("Calendar and Events")) {
setEnabled(false);
return;
}
@@ -340,47 +344,47 @@ public class CalendarOverlay {
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));
+ 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) {
+ 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();
+ 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());
+ for (JsonElement e : arr) {
+ jf.desc.add(EnumChatFormatting.YELLOW + "\u25CB " + e.getAsString());
jf.id += ":" + e.getAsString();
}
}
- eventMap.computeIfAbsent(jfEvent, k->new HashSet<>()).add(jf);
+ 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;
+ 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) {
+ if (item != null && item.getTagCompound() != null) {
NBTTagCompound tag = item.getTagCompound();
- if(tag.hasKey("display", 10)) {
+ 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)) {
+ if (first.startsWith(startsInText)) {
String time = Utils.cleanColour(first.substring(startsInText.length()));
long eventTime = currentTime + getTimeOffset(time);
@@ -388,21 +392,21 @@ public class CalendarOverlay {
List<String> desc = new ArrayList<>();
boolean foundBreak = false;
- for(int index=1; index<list.tagCount(); index++) {
+ for (int index = 1; index < list.tagCount(); index++) {
String line = list.getStringTagAt(index);
- if(foundBreak) {
+ if (foundBreak) {
desc.add(line);
} else {
- if(line.startsWith(lastsForText)) {
+ if (line.startsWith(lastsForText)) {
String lastsForS = Utils.cleanColour(line.substring(lastsForText.length()));
lastsFor = getTimeOffset(lastsForS);
}
- if(Utils.cleanColour(line).trim().length() == 0) {
+ if (Utils.cleanColour(line).trim().length() == 0) {
foundBreak = true;
}
}
}
- eventMap.computeIfAbsent(eventTime, k->new HashSet<>()).add(new SBEvent(
+ eventMap.computeIfAbsent(eventTime, k -> new HashSet<>()).add(new SBEvent(
getIdForDisplayName(item.getDisplayName()), item.getDisplayName(),
item, desc, lastsFor));
}
@@ -424,7 +428,6 @@ public class CalendarOverlay {
.replace(" ", "_");
}
-
@SubscribeEvent
public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -433,17 +436,17 @@ public class CalendarOverlay {
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 &&
+ if (!enabled) {
+ if (Mouse.getEventButtonState() && NotEnoughUpdates.INSTANCE.config.calendar.showEventTimerInInventory &&
Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
xSize = 168;
ySize = 20;
- guiLeft = (width - xSize)/2;
+ guiLeft = (width - xSize) / 2;
guiTop = 5;
- if(mouseX >= guiLeft && mouseX <= guiLeft+xSize) {
- if(mouseY >= guiTop && mouseY <= guiTop+ySize) {
+ if (mouseX >= guiLeft && mouseX <= guiLeft + xSize) {
+ if (mouseY >= guiTop && mouseY <= guiTop + ySize) {
ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neucalendar");
}
}
@@ -452,14 +455,14 @@ public class CalendarOverlay {
return;
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ 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")) {
+ if (!containerName.trim().equals("Calendar and Events")) {
setEnabled(false);
return;
}
@@ -471,8 +474,8 @@ public class CalendarOverlay {
guiLeft = (width - xSize) / 2;
guiTop = (height - ySize) / 2;
- if(Mouse.getEventButtonState()) {
- if(jfFavouriteSelect != null) {
+ if (Mouse.getEventButtonState()) {
+ if (jfFavouriteSelect != null) {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int arrowLen = fr.getStringWidth("> ");
int selectSizeX = 0;
@@ -487,18 +490,18 @@ public class CalendarOverlay {
}
selectSizeX += +10;
- if(mouseX > jfFavouriteSelectX && mouseX < jfFavouriteSelectX + selectSizeX &&
- mouseY > jfFavouriteSelectY && mouseY < jfFavouriteSelectY + 18 + jfFavouriteSelect.size() * 10) {
- jfFavouriteSelectIndex = Math.max(0, (mouseY - jfFavouriteSelectY - 5)/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) {
+ if (jfFavouriteSelectIndex == 0) {
id = "jacob_farming";
- } else if(jfFavouriteSelectIndex-1 < jfFavouriteSelect.size()) {
- id = "jacob_farming:"+jfFavouriteSelect.get(jfFavouriteSelectIndex-1);
+ } else if (jfFavouriteSelectIndex - 1 < jfFavouriteSelect.size()) {
+ id = "jacob_farming:" + jfFavouriteSelect.get(jfFavouriteSelectIndex - 1);
}
- if(id != null) {
+ if (id != null) {
if (eventFavourites.contains(id)) {
eventFavourites.remove(id);
} else {
@@ -509,9 +512,9 @@ public class CalendarOverlay {
jfFavouriteSelect = null;
}
}
- if(mouseY >= guiTop+26 && mouseY <= guiTop+26+141) {
- if(mouseX >= guiLeft+151 && mouseX <= guiLeft+151+14) {
- if(mouseY <= guiTop+26+70) {
+ 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 {
@@ -525,8 +528,8 @@ public class CalendarOverlay {
@SubscribeEvent
public void onGuiScreenKeyboard(GuiScreenEvent.KeyboardInputEvent.Pre event) {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
- if(jfFavouriteSelect != null) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (jfFavouriteSelect != null) {
jfFavouriteSelect = null;
event.setCanceled(true);
}
@@ -560,34 +563,34 @@ public class CalendarOverlay {
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) {
+ if (Keyboard.getEventKeyState()) {
+ if (jfFavouriteSelect != null) {
+ if (keyPressed == Keyboard.KEY_DOWN) {
jfFavouriteSelectIndex++;
- jfFavouriteSelectIndex %= jfFavouriteSelect.size()+1;
- } else if(keyPressed == Keyboard.KEY_UP) {
+ 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) {
+ 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) {
+ if (jfFavouriteSelectIndex == 0) {
id = "jacob_farming";
- } else if(jfFavouriteSelectIndex-1 < jfFavouriteSelect.size()) {
- id = "jacob_farming:"+jfFavouriteSelect.get(jfFavouriteSelectIndex-1);
+ } else if (jfFavouriteSelectIndex - 1 < jfFavouriteSelect.size()) {
+ id = "jacob_farming:" + jfFavouriteSelect.get(jfFavouriteSelectIndex - 1);
}
- if(id != null) {
+ if (id != null) {
if (eventFavourites.contains(id)) {
eventFavourites.remove(id);
} else {
eventFavourites.add(id);
}
}
- } else if(keyPressed == Keyboard.KEY_LEFT ||
+ } else if (keyPressed == Keyboard.KEY_LEFT ||
keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
jfFavouriteSelect = null;
}
- } else if(keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
+ } else if (keyPressed == NotEnoughUpdates.INSTANCE.manager.keybindFavourite.getKeyCode()) {
String id = null;
//Daily Events
@@ -626,9 +629,9 @@ public class CalendarOverlay {
if (id != null) {
String[] split = id.split(":");
- if(split.length > 1 && split[0].equals("jacob_farming")) {
+ if (split.length > 1 && split[0].equals("jacob_farming")) {
jfFavouriteSelect = new ArrayList<>();
- for(int i=1; i<split.length; i++) {
+ for (int i = 1; i < split.length; i++) {
jfFavouriteSelect.add(split[i]);
}
jfFavouriteSelectIndex = 0;
@@ -650,11 +653,11 @@ public class CalendarOverlay {
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiDraw(RenderGameOverlayEvent.Post event) {
- if(NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications &&
+ 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()) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) && NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
long currentTime = System.currentTimeMillis();
long timeUntilNext = 0;
@@ -666,28 +669,28 @@ public class CalendarOverlay {
//Daily Events
out:
- for(Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for(SBEvent sbEvent : sbEvents.getValue()) {
+ for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
+ for (SBEvent sbEvent : sbEvents.getValue()) {
long timeUntilMillis = sbEvents.getKey() - currentTime;
- if(timeUntilMillis < -10*SECOND) {
+ if (timeUntilMillis < -10 * SECOND) {
continue;
}
- if(firstEvent == null) {
+ 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])) {
+ 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 (eventFavourites.isEmpty() || eventFavourites.contains(split[0]) || containsId) {
nextEvent = sbEvent;
timeUntilNext = timeUntilMillis;
break out;
@@ -695,7 +698,7 @@ public class CalendarOverlay {
}
}
- if(nextEvent != null) {
+ if (nextEvent != null) {
renderToast(nextEvent, timeUntilNext);
}
}
@@ -705,22 +708,22 @@ public class CalendarOverlay {
}
public boolean renderToast(SBEvent event, long timeUntil) {
- if(!NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications) {
+ if (!NotEnoughUpdates.INSTANCE.config.calendar.eventNotifications) {
return false;
}
long currentTime = System.currentTimeMillis();
- if(currentTime - spookyStart > 0 && currentTime - spookyStart < HOUR &&
+ 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) {
+ 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;
+ if (event.id.equals("dark_auction")) {
+ timeUntil -= 30 * 1000;
}
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
@@ -730,20 +733,20 @@ public class CalendarOverlay {
int ySize = 32;
int xSize = 160;
- int guiLeft = (width - xSize)/2;
+ int guiLeft = (width - xSize) / 2;
int guiTop = 5;
boolean preNotification = false;
- long preNotificationTime = SECOND*NotEnoughUpdates.INSTANCE.config.calendar.startingSoonTime;
+ long preNotificationTime = SECOND * NotEnoughUpdates.INSTANCE.config.calendar.startingSoonTime;
- if(preNotificationTime > 500 && timeUntil > 500) {
+ if (preNotificationTime > 500 && timeUntil > 500) {
timeUntil = timeUntil - preNotificationTime;
preNotification = true;
}
- if(timeUntil < 500 && timeUntil > -8500) {
- if(jingleIndex == -1) {
- if(preNotification) {
+ if (timeUntil < 500 && timeUntil > -8500) {
+ if (jingleIndex == -1) {
+ if (preNotification) {
jingleIndex = 1;
} else {
jingleIndex = 0;
@@ -752,34 +755,33 @@ public class CalendarOverlay {
float offset;
float factor = 0;
- if(timeUntil > 0) {
- factor = (timeUntil/500f);
- } else if(timeUntil < -8000) {
- factor = -((timeUntil+8000)/500f);
+ 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;
+ 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);
+ Utils.drawItemStack(event.stack, guiLeft + 6, 8);
GlStateManager.translate(0, -y, 0);
- if(preNotification) {
- String starting = EnumChatFormatting.YELLOW+"Event Starting in "+prettyTime(preNotificationTime, true)+"!";
+ 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);
+ fr.drawString(starting, Math.max(guiLeft + 23, width / 2f - startingWidth / 2f), y + 7, -1, false);
} else {
- Utils.drawStringCentered(EnumChatFormatting.YELLOW+"Event Starting Now!", fr, width/2, y+11, false, -1);
+ Utils.drawStringCentered(EnumChatFormatting.YELLOW + "Event Starting Now!", 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);
-
+ fr.drawString(event.display, Math.max(guiLeft + 23, width / 2f - displayWidth / 2f), y + 17, -1, false);
return true;
}
@@ -788,7 +790,7 @@ public class CalendarOverlay {
@SubscribeEvent
public void onGuiScreenDrawTimer(GuiScreenEvent.BackgroundDrawnEvent event) {
- if(!drawTimerForeground) {
+ if (!drawTimerForeground) {
drawTimer();
}
GlStateManager.color(1, 1, 1, 1);
@@ -797,7 +799,7 @@ public class CalendarOverlay {
@SubscribeEvent
public void onGuiScreenDrawTimer(GuiScreenEvent.DrawScreenEvent.Post event) {
- if(drawTimerForeground) {
+ if (drawTimerForeground) {
drawTimer();
}
}
@@ -805,7 +807,7 @@ public class CalendarOverlay {
public void drawTimer() {
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, 10);
- if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer && NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiContainer && NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledResolution.getScaledWidth();
int height = scaledResolution.getScaledHeight();
@@ -827,74 +829,74 @@ public class CalendarOverlay {
List<String> eventFavourites = NotEnoughUpdates.INSTANCE.config.hidden.eventFavourites;
- guiLeft = (width - xSize)/2;
+ guiLeft = (width - xSize) / 2;
guiTop = 5;
//Daily Events
out:
- for(Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for(SBEvent sbEvent : sbEvents.getValue()) {
+ for (Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
+ for (SBEvent sbEvent : sbEvents.getValue()) {
long timeUntilMillis = sbEvents.getKey() - currentTime;
- if(timeUntilMillis < -10*SECOND) {
+ if (timeUntilMillis < -10 * SECOND) {
continue;
}
- if(sbEvent.id.equals("spooky_festival")) {
- if(sbEvents.getKey() > currentTime-HOUR && (sbEvents.getKey() < spookyStart || spookyStart == 0)) {
+ 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") &&
+ if (nextMajorEvent == null && !sbEvent.id.split(":")[0].equals("jacob_farming") &&
!sbEvent.id.equals("dark_auction")) {
nextMajorEvent = sbEvent;
timeUntilMajor = timeUntilMillis;
}
- if(firstEvent == null) {
+ 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])) {
+ 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) {
+ if (eventFavourites.isEmpty() || eventFavourites.contains(split[0]) || containsId) {
+ if (nextEvent == null) {
nextEvent = sbEvent;
timeUntilNext = timeUntilMillis;
}
- if(nextFavourites.size() < 3) {
+ if (nextFavourites.size() < 3) {
nextFavourites.add(sbEvent);
nextFavouritesTime.add(timeUntilMillis);
}
}
- if(nextFavourites.size() >= 3 && nextMajorEvent != null) {
+ if (nextFavourites.size() >= 3 && nextMajorEvent != null) {
break out;
}
}
}
- if(nextEvent == null && firstEvent != null) {
+ if (nextEvent == null && firstEvent != null) {
String[] split = firstEvent.id.split(":");
- if(eventFavourites.contains(split[0])) {
+ if (eventFavourites.contains(split[0])) {
nextEvent = firstEvent;
timeUntilNext = timeUntilFirst;
}
}
- if(nextEvent != null) {
+ 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) {
+ if (!toastRendered && !enabled && NotEnoughUpdates.INSTANCE.config.calendar.showEventTimerInInventory) {
List<String> tooltipToDisplay = null;
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
@@ -903,76 +905,75 @@ public class CalendarOverlay {
GlStateManager.disableLighting();
GlStateManager.disableColorMaterial();
- renderBlurredBackground(10, width, height, guiLeft+3, guiTop+3, xSize-6, ySize-6);
+ 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: ";
+ String nextS = EnumChatFormatting.YELLOW + "Next: ";
int nextSLen = fr.getStringWidth(nextS);
- fr.drawString(nextS, guiLeft+8, guiTop+6, -1, false);
+ fr.drawString(nextS, guiLeft + 8, guiTop + 6, -1, false);
- String until = " "+EnumChatFormatting.YELLOW+prettyTime(timeUntilNext, false);
+ String until = " " + EnumChatFormatting.YELLOW + prettyTime(timeUntilNext, false);
int untilLen = fr.getStringWidth(until);
- fr.drawString(until, guiLeft+xSize-8-untilLen, guiTop+6, -1, false);
+ fr.drawString(until, guiLeft + xSize - 8 - untilLen, guiTop + 6, -1, false);
- int eventTitleLen = xSize-16-untilLen-nextSLen;
+ int eventTitleLen = xSize - 16 - untilLen - nextSLen;
int displayWidth = fr.getStringWidth(nextEvent.display);
int spaceLen = fr.getCharWidth(' ');
- if(displayWidth > eventTitleLen) {
+ if (displayWidth > eventTitleLen) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor((guiLeft+8+nextSLen)*scaledResolution.getScaleFactor(),
+ GL11.glScissor((guiLeft + 8 + nextSLen) * scaledResolution.getScaleFactor(),
0,
- eventTitleLen*scaledResolution.getScaleFactor(),
+ 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);
+ 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);
+ 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);
+ fr.drawString(nextEvent.display, guiLeft + 8 + nextSLen, guiTop + 6, -1, false);
}
}
- if(mouseX > guiLeft && mouseX < guiLeft+168) {
- if(mouseY > guiTop && mouseY < guiTop+20) {
+ if (mouseX > guiLeft && mouseX < guiLeft + 168) {
+ if (mouseY > guiTop && mouseY < guiTop + 20) {
tooltipToDisplay = new ArrayList<>();
- for(int i=0; i<nextFavourites.size(); i++) {
+ 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+
+ 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) {
+ if (sbEvent.id.split(":")[0].equals("jacob_farming") && sbEvent.desc != null) {
tooltipToDisplay.addAll(sbEvent.desc);
}
- if(nextMajorEvent != null || i < nextFavourites.size()-1) {
+ if (nextMajorEvent != null || i < nextFavourites.size() - 1) {
tooltipToDisplay.add("");
}
}
- if(nextMajorEvent != null) {
- tooltipToDisplay.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Next Major:");
+ 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+
+ 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) {
+ if (tooltipToDisplay != null) {
drawTimerForeground = true;
GlStateManager.translate(0, 0, 100);
Utils.drawHoveringText(tooltipToDisplay, mouseX, Math.max(17, mouseY), width, height, -1, fr);
@@ -985,27 +986,26 @@ public class CalendarOverlay {
GlStateManager.popMatrix();
}
- private void renderBlurredBackground(float blurStrength, int screenWidth, int screenHeight,
- int x, int y, int blurWidth, int blurHeight) {
+ 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);
+ 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)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
return;
}
- if(!enabled) {
+ 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")) {
+ if (!containerName.trim().equals("Calendar and Events")) {
setEnabled(false);
return;
}
@@ -1023,15 +1023,15 @@ public class CalendarOverlay {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledResolution.getScaledWidth();
int height = scaledResolution.getScaledHeight();
- guiLeft = (width - xSize)/2;
- guiTop = (height - ySize)/2;
+ 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);
+ 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);
@@ -1040,38 +1040,41 @@ public class CalendarOverlay {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- fr.drawString("Daily", guiLeft+29, guiTop+30, 0xffffaa00);
+ fr.drawString("Daily", guiLeft + 29, guiTop + 30, 0xffffaa00);
int specialLen = fr.getStringWidth("Special");
- fr.drawString("Special", guiLeft+139-specialLen, guiTop+30, 0xffffaa00);
+ fr.drawString("Special", guiLeft + 139 - specialLen, guiTop + 30, 0xffffaa00);
ItemStack mayorStack = cc.getLowerChestInventory().getStackInSlot(46);
- if(mayorStack != null) {
+ if (mayorStack != null) {
String mayor = mayorStack.getDisplayName();
float verticalHeight = Utils.getVerticalHeight(mayor);
- Utils.drawStringVertical(mayor, fr, guiLeft+8, guiTop+96-verticalHeight/2,
+ Utils.drawStringVertical(mayor, fr, guiLeft + 8, guiTop + 96 - verticalHeight / 2,
false, -1);
}
- String calendar = EnumChatFormatting.GREEN+"Calendar";
+ String calendar = EnumChatFormatting.GREEN + "Calendar";
float calendarHeight = Utils.getVerticalHeight(calendar);
- Utils.drawStringVertical(calendar, fr, guiLeft+xSize-12, guiTop+60-calendarHeight/2,
+ Utils.drawStringVertical(calendar, fr, guiLeft + xSize - 12, guiTop + 60 - calendarHeight / 2,
false, -1);
- String rewards = EnumChatFormatting.GOLD+"Rewards";
+ String rewards = EnumChatFormatting.GOLD + "Rewards";
float rewardsHeight = Utils.getVerticalHeight(rewards);
- Utils.drawStringVertical(rewards, fr, guiLeft+xSize-12, guiTop+132-rewardsHeight/2,
+ 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) {
+ 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);
+ 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);
+ if (rewardsStack != null)
+ tooltipToDisplay = rewardsStack.getTooltip(Minecraft.getMinecraft().thePlayer, false);
}
}
}
@@ -1085,73 +1088,73 @@ public class CalendarOverlay {
//Daily Events
int index = 0;
out:
- for(Map.Entry<Long, Set<SBEvent>> sbEvents : eventMap.entrySet()) {
- for(SBEvent sbEvent : sbEvents.getValue()) {
+ 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);
+ 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)) {
+ 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()) {
+ if (index >= 21) {
+ if (nextEvent != null) break;
+ if (eventFavourites.isEmpty()) {
nextEvent = sbEvent;
timeUntilNext = timeUntilMillis;
- } else if(eventFavourites.contains(sbEvent.id)) {
+ } else if (eventFavourites.contains(sbEvent.id)) {
nextEvent = sbEvent;
timeUntilNext = timeUntilMillis;
}
continue;
}
- if(firstEvent == null) {
+ 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])) {
+ for (int i = 1; i < split.length; i++) {
+ if (eventFavourites.contains(split[0] + ":" + split[i])) {
containsId = true;
break;
}
}
- if(eventFavourites.isEmpty()) {
- if(nextEvent == null) {
+ if (eventFavourites.isEmpty()) {
+ if (nextEvent == null) {
nextEvent = sbEvent;
timeUntilNext = timeUntilMillis;
}
- } else if(eventFavourites.contains(split[0]) || containsId) {
- if(nextEvent == null) {
+ } 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);
+ 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));
+ Utils.drawItemStackWithText(sbEvent.stack, x, y, "" + (index + 1));
- if(mouseX >= x && mouseX <= x+16) {
- if(mouseY >= y && mouseY <= y+16) {
+ 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+
+ 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) {
+ if (sbEvent.desc != null) {
tooltipToDisplay.add("");
tooltipToDisplay.addAll(sbEvent.desc);
}
@@ -1163,10 +1166,10 @@ public class CalendarOverlay {
}
//Special Events
- for(int i=0; i<21; i++) {
- int itemIndex = 10+i+(i/7)*2;
+ for (int i = 0; i < 21; i++) {
+ int itemIndex = 10 + i + (i / 7) * 2;
ItemStack item = cc.getLowerChestInventory().getStackInSlot(itemIndex);
- if(item == null) continue;
+ if (item == null) continue;
String eventId = getIdForDisplayName(item.getDisplayName());
@@ -1174,66 +1177,66 @@ public class CalendarOverlay {
tag.setString("event_id", eventId);
item.setTagCompound(tag);
- int x = guiLeft+89+17*(i%3);
- int y = guiTop+44+17*(i/3);
+ int x = guiLeft + 89 + 17 * (i % 3);
+ int y = guiTop + 44 + 17 * (i / 3);
- if(eventFavourites.contains(eventId)) {
+ if (eventFavourites.contains(eventId)) {
GlStateManager.depthMask(false);
GlStateManager.translate(0, 0, -2);
- Gui.drawRect(x, y, x+16, y+16, 0xcfffbf49);
+ Gui.drawRect(x, y, x + 16, y + 16, 0xcfffbf49);
GlStateManager.translate(0, 0, 2);
GlStateManager.depthMask(true);
}
- Utils.drawItemStackWithText(item, x, y, ""+(i+1));
+ Utils.drawItemStackWithText(item, x, y, "" + (i + 1));
- if(mouseX >= x && mouseX <= x+16) {
- if(mouseY >= y && mouseY <= y+16) {
+ if (mouseX >= x && mouseX <= x + 16) {
+ if (mouseY >= y && mouseY <= y + 16) {
tooltipToDisplay = item.getTooltip(Minecraft.getMinecraft().thePlayer, false);
}
}
}
- if(nextEvent == null) {
+ if (nextEvent == null) {
nextEvent = firstEvent;
timeUntilNext = timeUntilFirst;
}
- if(nextEvent != null) {
- String nextS = EnumChatFormatting.YELLOW+"Next: ";
+ if (nextEvent != null) {
+ String nextS = EnumChatFormatting.YELLOW + "Next: ";
int nextSLen = fr.getStringWidth(nextS);
- fr.drawString(nextS, guiLeft+8, guiTop+6, -1, false);
+ fr.drawString(nextS, guiLeft + 8, guiTop + 6, -1, false);
- String until = " "+EnumChatFormatting.YELLOW+prettyTime(timeUntilNext, false);
+ String until = " " + EnumChatFormatting.YELLOW + prettyTime(timeUntilNext, false);
int untilLen = fr.getStringWidth(until);
- fr.drawString(until, guiLeft+xSize-8-untilLen, guiTop+6, -1, false);
+ fr.drawString(until, guiLeft + xSize - 8 - untilLen, guiTop + 6, -1, false);
- int eventTitleLen = xSize-16-untilLen-nextSLen;
+ int eventTitleLen = xSize - 16 - untilLen - nextSLen;
int displayWidth = fr.getStringWidth(nextEvent.display);
int spaceLen = fr.getCharWidth(' ');
- if(displayWidth > eventTitleLen) {
+ if (displayWidth > eventTitleLen) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor((guiLeft+8+nextSLen)*scaledResolution.getScaleFactor(),
+ GL11.glScissor((guiLeft + 8 + nextSLen) * scaledResolution.getScaleFactor(),
0,
- eventTitleLen*scaledResolution.getScaleFactor(),
+ 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);
+ 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);
+ fr.drawString(nextEvent.display, guiLeft + 8 + nextSLen, guiTop + 6, -1, false);
}
- if(mouseX > guiLeft && mouseX < guiLeft+168) {
- if(mouseY > guiTop && mouseY < guiTop+20) {
+ 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+
+ 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) {
+ if (nextEvent.desc != null) {
tooltipToDisplay.add("");
tooltipToDisplay.addAll(nextEvent.desc);
}
@@ -1243,39 +1246,39 @@ public class CalendarOverlay {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(help);
- Utils.drawTexturedRect(guiLeft+xSize-18, guiTop+ySize+2, 16, 16, GL11.GL_LINEAR);
+ 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) {
+ 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");
+ 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) {
+ if (jfFavouriteSelect != null) {
int arrowLen = fr.getStringWidth("> ");
int selectSizeX = 0;
- int selectStringIndex=0;
- for(String s : jfFavouriteSelect) {
+ int selectStringIndex = 0;
+ for (String s : jfFavouriteSelect) {
int sWidth = fr.getStringWidth(s);
- if(selectStringIndex+1 == jfFavouriteSelectIndex) sWidth += arrowLen;
- if(sWidth > selectSizeX) {
+ if (selectStringIndex + 1 == jfFavouriteSelectIndex) sWidth += arrowLen;
+ if (sWidth > selectSizeX) {
selectSizeX = sWidth;
}
selectStringIndex++;
@@ -1284,40 +1287,40 @@ public class CalendarOverlay {
GlStateManager.translate(0, 0, 19);
- Gui.drawRect(jfFavouriteSelectX+2, jfFavouriteSelectY+2, jfFavouriteSelectX+selectSizeX+2,
- jfFavouriteSelectY+18+jfFavouriteSelect.size()*10+2, 0xa0000000);
+ 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);
+ 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);
+ 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(all, jfFavouriteSelectX + 5, jfFavouriteSelectY + 5, 0xff000000);
}
- fr.drawString(EnumChatFormatting.BLACK+"> ", jfFavouriteSelectX+6,
- jfFavouriteSelectY+10*jfFavouriteSelectIndex+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)
+ 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);
+ 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) {
+ } else if (tooltipToDisplay != null) {
Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
}
@@ -1332,20 +1335,20 @@ public class CalendarOverlay {
long days = (millis / 1000 / 60 / 60 / 24);
String endsIn = "";
- if(millis < 0) {
+ if (millis < 0) {
endsIn += "Now!";
- } else if(minutes == 0 && hours == 0 && days == 0) {
+ } else if (minutes == 0 && hours == 0 && days == 0) {
endsIn += seconds + "s";
- } else if(hours==0 && days==0) {
- if(trimmed && seconds == 0) {
+ } 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) {
+ } else if (days == 0) {
+ if (hours <= 6) {
+ if (trimmed && seconds == 0) {
+ if (minutes == 0) {
endsIn += hours + "h";
} else {
endsIn += hours + "h" + minutes + "m";
@@ -1371,15 +1374,15 @@ public class CalendarOverlay {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
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..2b92a86c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiCustomEnchant.java
@@ -80,24 +80,24 @@ public class GuiCustomEnchant extends Gui {
this.displayLore = displayLore;
this.level = level;
- if(Constants.ENCHANTS != null) {
- if(checkConflicts && Constants.ENCHANTS.has("enchant_pools")) {
+ 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++) {
+ 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++) {
+ for (int j = 0; j < pool.size(); j++) {
String enchIdPoolElement = pool.get(j).getAsString();
- if(enchId.equalsIgnoreCase(enchIdPoolElement)) {
+ if (enchId.equalsIgnoreCase(enchIdPoolElement)) {
hasThis = true;
- } else if(playerEnchantIds.containsKey(enchIdPoolElement)) {
+ } else if (playerEnchantIds.containsKey(enchIdPoolElement)) {
hasApplied = true;
}
- if(hasThis && hasApplied) {
+ if (hasThis && hasApplied) {
this.conflicts = true;
break out;
}
@@ -105,16 +105,16 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
+ if (level >= 1 && Constants.ENCHANTS.has("enchants_xp_cost")) {
JsonObject allCosts = Constants.ENCHANTS.getAsJsonObject("enchants_xp_cost");
- if(allCosts.has(enchId)) {
+ 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();
+ 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;
}
@@ -138,7 +138,7 @@ public class GuiCustomEnchant extends Gui {
public int rotationDeg;
}
- private List<ExperienceOrb> orbs = new ArrayList<>();
+ private final List<ExperienceOrb> orbs = new ArrayList<>();
private int orbTargetX = 0;
private int orbTargetY = 0;
@@ -162,16 +162,16 @@ public class GuiCustomEnchant extends Gui {
private int removingEnchantPlayerLevel = -1;
- private GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
+ private final GuiElementTextField searchField = new GuiElementTextField("", GuiElementTextField.SCISSOR_TEXT);
- private HashMap<String, Integer> playerEnchantIds = new HashMap<>();
+ private final 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 final List<Enchantment> applicable = new ArrayList<>();
+ private final List<Enchantment> removable = new ArrayList<>();
- private HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
+ private final HashMap<Integer, Enchantment> enchanterEnchLevels = new HashMap<>();
private Enchantment enchanterCurrentEnch = null;
public Random random = new Random();
@@ -179,10 +179,10 @@ public class GuiCustomEnchant extends Gui {
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 final LerpingInteger leftScroll = new LerpingInteger(0, 150);
+ private final LerpingInteger rightScroll = new LerpingInteger(0, 150);
- private LerpingFloat arrowAmount = new LerpingFloat(0, 100);
+ private final LerpingFloat arrowAmount = new LerpingFloat(0, 100);
private static final int X_SIZE = 364;
private static final int Y_SIZE = 215;
@@ -204,7 +204,7 @@ public class GuiCustomEnchant extends Gui {
containerName != null &&
NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() &&
containerName.equalsIgnoreCase("Enchant Item");
- if(!shouldOverrideFast) {
+ if (!shouldOverrideFast) {
currentState = EnchantState.NO_ITEM;
applicable.clear();
removable.clear();
@@ -214,8 +214,9 @@ public class GuiCustomEnchant extends Gui {
}
private int tickCounter = 0;
+
public void tick() {
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
ContainerChest cc = (ContainerChest) chest.inventorySlots;
ItemStack stack = cc.getLowerChestInventory().getStackInSlot(23);
@@ -225,51 +226,51 @@ public class GuiCustomEnchant extends Gui {
int lastPage = currentPage;
this.lastState = currentState;
- if(enchantGuideStack != null && enchantGuideStack.getItem() != Items.book && enchantingItem != null) {
+ 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) {
+ } 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) {
+ } else if (stack.getItem() != Items.dye) {
ItemStack sanityCheckStack = cc.getLowerChestInventory().getStackInSlot(12);
- if(sanityCheckStack == null || sanityCheckStack.getItem() == Items.enchanted_book) {
+ 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) {
+ } else if (stack.getItemDamage() == 1) {
currentState = EnchantState.INVALID_ITEM;
} else {
currentState = EnchantState.NO_ITEM;
}
- if(currentState == EnchantState.HAS_ITEM) {
+ if (currentState == EnchantState.HAS_ITEM) {
ItemStack pageUpStack = cc.getLowerChestInventory().getStackInSlot(17);
ItemStack pageDownStack = cc.getLowerChestInventory().getStackInSlot(35);
- if(pageUpStack != null && pageDownStack != null) {
+ 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) {
+ if (!downIsGlass) {
try {
- page = Integer.parseInt(Utils.getRawTooltip(pageDownStack).get(1).substring(11))-1;
- expectedMaxPage = page+1;
- } catch(Exception ignored) {}
+ page = Integer.parseInt(Utils.getRawTooltip(pageDownStack).get(1).substring(11)) - 1;
+ expectedMaxPage = page + 1;
+ } catch (Exception ignored) {}
}
- if(page == -1 && !upIsGlass) {
+ if (page == -1 && !upIsGlass) {
try {
- page = Integer.parseInt(Utils.getRawTooltip(pageUpStack).get(1).substring(11))+1;
+ page = Integer.parseInt(Utils.getRawTooltip(pageUpStack).get(1).substring(11)) + 1;
expectedMaxPage = page;
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
- if(page == -1) {
+ if (page == -1) {
currentPage = 1;
} else {
currentPage = page;
@@ -278,19 +279,19 @@ public class GuiCustomEnchant extends Gui {
}
List<ExperienceOrb> toRemove = new ArrayList<>();
- for(ExperienceOrb orb : orbs) {
- float targetDeltaX = guiLeft+orbTargetX - orb.x;
- float targetDeltaY = guiTop+orbTargetY - orb.y;
+ 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);
+ float length = (float) Math.sqrt(targetDeltaX * targetDeltaX + targetDeltaY * targetDeltaY);
- if(length < 8 && orb.xVel*orb.xVel+orb.yVel*orb.yVel < 20) {
+ 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 += targetDeltaX * 2 / length;
+ orb.yVel += targetDeltaY * 2 / length;
orb.xVel *= 0.90;
orb.yVel *= 0.90;
@@ -302,45 +303,45 @@ public class GuiCustomEnchant extends Gui {
}
orbs.removeAll(toRemove);
- if(++tickCounter >= 20) {
+ if (++tickCounter >= 20) {
tickCounter = 0;
}
boolean updateItems = tickCounter == 0;
- if(currentState == EnchantState.ADDING_ENCHANT) {
- if(arrowAmount.getTarget() != 1) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
+ if (arrowAmount.getTarget() != 1) {
arrowAmount.setTarget(1);
arrowAmount.resetTimer();
}
} else {
- if(arrowAmount.getTarget() != 0) {
+ 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)) {
+ 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) {
+ if (updateItems && currentState != EnchantState.SWITCHING_DONT_UPDATE) {
enchanterEnchLevels.clear();
- if(enchantingItem != null) {
+ if (enchantingItem != null) {
playerEnchantIds.clear();
NBTTagCompound tag = enchantingItem.getTagCompound();
- if(tag != null) {
+ if (tag != null) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea != null) {
+ if (ea != null) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
playerEnchantIds.put(enchId, enchantments.getInteger(enchId));
}
}
@@ -348,46 +349,46 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(currentState == EnchantState.ADDING_ENCHANT) {
+ if (currentState == EnchantState.ADDING_ENCHANT) {
removingEnchantPlayerLevel = -1;
boolean updateLevel = enchanterCurrentEnch == null;
- for(int i=0; i<27; i++) {
+ 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) {
+ if (book != null && book.getItem() == Items.enchanted_book) {
NBTTagCompound tagBook = book.getTagCompound();
- if(tagBook != null) {
+ if (tagBook != null) {
NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
- if(ea != null) {
+ if (ea != null) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
String name = Utils.cleanColour(book.getDisplayName());
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
+ } 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)) {
+ if (removingEnchantPlayerLevel == -1 && playerEnchantIds.containsKey(enchId)) {
removingEnchantPlayerLevel = playerEnchantIds.get(enchId);
}
- if(removingEnchantPlayerLevel >= 0 && enchantment.level < removingEnchantPlayerLevel) {
+ if (removingEnchantPlayerLevel >= 0 && enchantment.level < removingEnchantPlayerLevel) {
continue;
}
- if(enchanterCurrentEnch == null) {
+ if (enchanterCurrentEnch == null) {
enchanterCurrentEnch = enchantment;
- } else if(updateLevel) {
- if(removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) {
+ } else if (updateLevel) {
+ if (removingEnchantPlayerLevel < 0 && enchantment.level > enchanterCurrentEnch.level) {
enchanterCurrentEnch = enchantment;
- } else if(removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) {
+ } else if (removingEnchantPlayerLevel >= 0 && enchantment.level < enchanterCurrentEnch.level) {
enchanterCurrentEnch = enchantment;
}
}
@@ -399,10 +400,10 @@ public class GuiCustomEnchant extends Gui {
}
}
}
- if(enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) {
- for(String line : enchanterCurrentEnch.displayLore) {
+ if (enchanterCurrentEnch != null && removingEnchantPlayerLevel >= 0) {
+ for (String line : enchanterCurrentEnch.displayLore) {
Matcher matcher = XP_COST_PATTERN.matcher(line);
- if(matcher.find()) {
+ if (matcher.find()) {
enchanterCurrentEnch.xpCost = Integer.parseInt(matcher.group(1));
}
}
@@ -415,36 +416,36 @@ public class GuiCustomEnchant extends Gui {
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;
+ 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) {
+ if (book != null) {
NBTTagCompound tagBook = book.getTagCompound();
- if(tagBook != null) {
+ if (tagBook != null) {
NBTTagCompound ea = tagBook.getCompoundTag("ExtraAttributes");
- if(ea != null) {
+ if (ea != null) {
NBTTagCompound enchantments = ea.getCompoundTag("enchantments");
- if(enchantments != null) {
- for(String enchId : enchantments.getKeySet()) {
+ if (enchantments != null) {
+ for (String enchId : enchantments.getKeySet()) {
String name = Utils.cleanColour(book.getDisplayName());
- if(searchField.getText().trim().isEmpty() ||
+ if (searchField.getText().trim().isEmpty() ||
name.toLowerCase().contains(searchField.getText().trim().toLowerCase())) {
- if(name.equalsIgnoreCase("Bane of Arthropods")) {
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
name = "Blast Prot";
- } else if(name.equalsIgnoreCase("Luck of the Sea")) {
+ } else if (name.equalsIgnoreCase("Luck of the Sea")) {
name = "Luck of Sea";
}
- if(playerEnchantIds.containsKey(enchId)) {
+ if (playerEnchantIds.containsKey(enchId)) {
Enchantment enchantment = new Enchantment(slotIndex, name, enchId,
Utils.getRawTooltip(book), playerEnchantIds.get(enchId), false, false);
- if(!enchantment.overMaxLevel) {
+ if (!enchantment.overMaxLevel) {
removable.add(enchantment);
}
} else {
@@ -453,7 +454,7 @@ public class GuiCustomEnchant extends Gui {
applicable.add(enchantment);
}
} else {
- if(playerEnchantIds.containsKey(enchId)) {
+ if (playerEnchantIds.containsKey(enchId)) {
searchRemovedFromRemovable = true;
} else {
searchRemovedFromApplicable = true;
@@ -469,8 +470,8 @@ public class GuiCustomEnchant extends Gui {
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());
+ Comparator.comparingInt(e -> mult * e.xpCost) :
+ (c1, c2) -> mult * c1.enchId.toLowerCase().compareTo(c2.enchId.toLowerCase());
removable.sort(comparator);
applicable.sort(comparator);
}
@@ -480,7 +481,7 @@ public class GuiCustomEnchant extends Gui {
//Update book model state
if (lastState != currentState) {
while (true) {
- this.pageOpenRandom += (float)(this.random.nextInt(4) - this.random.nextInt(4));
+ 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;
@@ -504,32 +505,31 @@ public class GuiCustomEnchant extends Gui {
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) {
+ 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<String> list = Lists.newArrayList(options);
list.add(0, "");
- list.add(0, EnumChatFormatting.GREEN+title);
+ list.add(0, EnumChatFormatting.GREEN + title);
return list;
}
public void render(float partialTicks) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
long currentTime = System.currentTimeMillis();
int playerXpLevel = Minecraft.getMinecraft().thePlayer.experienceLevel;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
ContainerChest cc = (ContainerChest) chest.inventorySlots;
leftScroll.tick();
@@ -542,8 +542,8 @@ public class GuiCustomEnchant extends Gui {
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;
+ guiLeft = (width - X_SIZE) / 2;
+ guiTop = (height - Y_SIZE) / 2;
List<String> tooltipToDisplay = null;
boolean disallowClick = false;
@@ -558,71 +558,71 @@ public class GuiCustomEnchant extends Gui {
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);
+ 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);
+ 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;
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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;
+ 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);
+ 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);
+ 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");
+ 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);
+ 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);
+ 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");
@@ -633,215 +633,215 @@ public class GuiCustomEnchant extends Gui {
//Left scroll bar
{
int offset;
- if(applicable.size() <= 6) {
+ if (applicable.size() <= 6) {
offset = 0;
- } else if(isScrollingLeft && clickedScrollOffset >= 0) {
+ } else if (isScrollingLeft && clickedScrollOffset >= 0) {
offset = mouseY - clickedScrollOffset;
- if(offset < 0) offset = 0;
- if(offset > 96-15) offset = 96-15;
+ 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)));
+ 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);
+ 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) {
+ if (removable.size() <= 6) {
offset = 0;
- } else if(!isScrollingLeft && clickedScrollOffset >= 0) {
+ } else if (!isScrollingLeft && clickedScrollOffset >= 0) {
offset = mouseY - clickedScrollOffset;
- if(offset < 0) offset = 0;
- if(offset > 96-15) offset = 96-15;
+ 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)));
+ 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);
+ 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) {
+ if (currentState == EnchantState.INVALID_ITEM) {
GlStateManager.disableDepth();
Utils.drawStringCentered("This item can't", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+88, true, 0xffff5555);
+ guiLeft + X_SIZE / 2, guiTop + 88, true, 0xffff5555);
Utils.drawStringCentered("be enchanted", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+X_SIZE/2, guiTop+98, true, 0xffff5555);
+ guiLeft + X_SIZE / 2, guiTop + 98, true, 0xffff5555);
GlStateManager.enableDepth();
}
//Enchant arrow
- if(arrowAmount.getValue() > 0) {
+ 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);
+ 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);
+ 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) {
+ 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);
+ guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555);
Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+38, true, 0xffff5555);
+ guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555);
Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+48, true, 0xffff5555);
+ 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) {
+ 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);
+ guiLeft + 8 + 48, guiTop + 28, true, 0xffff5555);
Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+38, true, 0xffff5555);
+ guiLeft + 8 + 48, guiTop + 38, true, 0xffff5555);
Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+8+48, guiTop+48, true, 0xffff5555);
+ guiLeft + 8 + 48, guiTop + 48, true, 0xffff5555);
}
- if(applicable.isEmpty() && removable.isEmpty() && searchRemovedFromRemovable) {
+ if (applicable.isEmpty() && removable.isEmpty() && searchRemovedFromRemovable) {
Utils.drawStringCentered("Can't find that", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+28, true, 0xffff5555);
+ guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555);
Utils.drawStringCentered("enchant, perhaps", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+38, true, 0xffff5555);
+ guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555);
Utils.drawStringCentered("it is on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+48, true, 0xffff5555);
+ 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) {
+ 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);
+ guiLeft + 248 + 48, guiTop + 28, true, 0xffff5555);
Utils.drawStringCentered("enchants on", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+38, true, 0xffff5555);
+ guiLeft + 248 + 48, guiTop + 38, true, 0xffff5555);
Utils.drawStringCentered("this page...", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+248+48, guiTop+48, true, 0xffff5555);
+ 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;
+ 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;
+ if (applicable.size() <= index) break;
Enchantment ench = applicable.get(index);
- int top = guiTop-(leftScroll.getValue()%16)+18+16*i;
+ 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;
+ 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);
+ 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) {
+ if (mouseX > guiLeft + 8 && mouseX <= guiLeft + 8 + 96 &&
+ mouseY > top && mouseY <= top + 16) {
disallowClick = true;
- if(ench.displayLore != null) {
+ if (ench.displayLore != null) {
tooltipToDisplay = ench.displayLore;
}
}
- String levelStr = ""+ench.xpCost;
+ String levelStr = "" + ench.xpCost;
int colour = 0xc8ff8f;
- if(ench.xpCost > playerXpLevel) {
+ 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(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);
+ 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;
+ 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;
+ if (removable.size() <= index) break;
Enchantment ench = removable.get(index);
- int top = guiTop-(rightScroll.getValue()%16)+18+16*i;
+ int top = guiTop - (rightScroll.getValue() % 16) + 18 + 16 * i;
int vOffset = enchanterCurrentEnch != null && enchanterCurrentEnch.enchId.equals(ench.enchId) ? 16 : 0;
- int textOffset = vOffset/16;
+ 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);
+ 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) {
+ if (mouseX > guiLeft + 248 && mouseX <= guiLeft + 248 + 96 &&
+ mouseY > top && mouseY <= top + 16) {
disallowClick = true;
- if(ench.displayLore != null) {
+ if (ench.displayLore != null) {
tooltipToDisplay = ench.displayLore;
}
}
- String levelStr = ""+ench.xpCost;
- if(ench.xpCost < 0) levelStr = "?";
+ String levelStr = "" + ench.xpCost;
+ if (ench.xpCost < 0) levelStr = "?";
int colour = 0xc8ff8f;
- if(ench.xpCost > playerXpLevel) {
+ 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(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);
+ 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);
+ 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);
+ for (int i = 0; i < 36; i++) {
+ int itemX = guiLeft + 102 + 18 * (i % 9);
+ int itemY = guiTop + 133 + 18 * (i / 9);
- if(i >= 27) {
+ 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);
+ 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) {
+ if (mouseX >= itemX && mouseX < itemX + 18 &&
+ mouseY >= itemY && mouseY < itemY + 18) {
itemHoverX = itemX;
itemHoverY = itemY;
hoverLocked = SlotLocking.getInstance().isSlotLocked(slot);
- if(slot.getHasStack()) {
+ if (slot.getHasStack()) {
tooltipToDisplay = slot.getStack().getTooltip(Minecraft.getMinecraft().thePlayer,
Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
}
@@ -849,158 +849,158 @@ public class GuiCustomEnchant extends Gui {
}
//Search bar
- if(currentState == EnchantState.HAS_ITEM) {
- if(searchField.getText().isEmpty() && !searchField.getFocus()) {
+ 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;
+ 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;
+ 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);
+ 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) {
+ if (mouseX > left + 16 && mouseX <= left + 96 &&
+ mouseY > top && mouseY <= top + 16) {
disallowClick = true;
- if(enchanterCurrentEnch.displayLore != null) {
+ if (enchanterCurrentEnch.displayLore != null) {
tooltipToDisplay = enchanterCurrentEnch.displayLore;
}
}
//Enchant cost
- String levelStr = ""+enchanterCurrentEnch.xpCost;
- if(enchanterCurrentEnch.xpCost < 0) levelStr = "?";
+ String levelStr = "" + enchanterCurrentEnch.xpCost;
+ if (enchanterCurrentEnch.xpCost < 0) levelStr = "?";
int colour = 0xc8ff8f;
- if(enchanterCurrentEnch.xpCost > playerXpLevel) {
+ 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);
+ 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")) {
+ if (name.equalsIgnoreCase("Bane of Arthropods")) {
name = "Bane of Arth.";
- } else if(name.equalsIgnoreCase("Projectile Protection")) {
+ } else if (name.equalsIgnoreCase("Projectile Protection")) {
name = "Projectile Prot";
- } else if(name.equalsIgnoreCase("Blast Protection")) {
+ } else if (name.equalsIgnoreCase("Blast Protection")) {
name = "Blast Prot";
- } else if(name.equalsIgnoreCase("Luck of the Sea")) {
+ } else if (name.equalsIgnoreCase("Luck of the Sea")) {
name = "Luck of Sea";
}
- Utils.drawStringCentered(name, Minecraft.getMinecraft().fontRendererObj, guiLeft+X_SIZE/2, top+8, true, 0xffffffdd);
+ Utils.drawStringCentered(name, Minecraft.getMinecraft().fontRendererObj, guiLeft + X_SIZE / 2, top + 8, true, 0xffffffdd);
- if(isChangingEnchLevel) {
+ 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);
+ 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 = "?";
+ 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);
+ 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) {
+ if (removingEnchantPlayerLevel >= 0) {
+ if (removingEnchantPlayerLevel == enchanterCurrentEnch.level) {
confirmText = "Remove";
- } else if(enchanterCurrentEnch.level > removingEnchantPlayerLevel) {
+ } else if (enchanterCurrentEnch.level > removingEnchantPlayerLevel) {
confirmText = "Upgrade";
} else {
confirmText = "Bad Level";
}
}
- if(System.currentTimeMillis() - confirmButtonAnimTime < 500 && !(playerXpLevel < enchanterCurrentEnch.xpCost)) {
+ 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.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);
+ 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.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);
+ 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);
+ 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) {
+ 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.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);
+ 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.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);
+ 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) {
+ 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) {
+ if (enchanterCurrentEnch.displayLore != null) {
tooltipToDisplay = enchanterCurrentEnch.displayLore;
}
- } else if(mouseX > guiLeft+X_SIZE/2+1 && mouseX <= guiLeft+X_SIZE/2+1+48) {
+ } 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) {
+ if (isChangingEnchLevel) {
tooltipToDisplay = null;
List<Enchantment> before = new ArrayList<>();
List<Enchantment> after = new ArrayList<>();
- for(Enchantment ench : enchanterEnchLevels.values()) {
- if(ench.level < enchanterCurrentEnch.level) {
+ for (Enchantment ench : enchanterEnchLevels.values()) {
+ if (ench.level < enchanterCurrentEnch.level) {
before.add(ench);
- } else if(ench.level > enchanterCurrentEnch.level) {
+ } else if (ench.level > enchanterCurrentEnch.level) {
after.add(ench);
}
}
@@ -1011,55 +1011,55 @@ public class GuiCustomEnchant extends Gui {
int bSize = before.size();
int aSize = after.size();
GlStateManager.disableDepth();
- for(int i=0; i<bSize+aSize; i++) {
+ for (int i = 0; i < bSize + aSize; i++) {
Enchantment ench;
int yIndex;
- if(i < bSize) {
+ if (i < bSize) {
ench = before.get(i);
- yIndex = -i-1;
+ yIndex = -i - 1;
} else {
- ench = after.get(i-bSize);
- yIndex = i-bSize+1;
+ 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) {
+ if (i == bSize) {
type = 2;
- } else if(i == 0) {
+ } else if (i == 0) {
type = 1;
}
- if(mouseX > left+96 && mouseX <= left+96+16 &&
- mouseY > top+16*yIndex && mouseY <= top+16*yIndex+16) {
+ 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);
+ 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);
+ 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;
+ 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);
+ 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) {
+ 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");
@@ -1069,35 +1069,35 @@ public class GuiCustomEnchant extends Gui {
//Item enchant input
ItemStack itemEnchantInput = cc.getSlot(19).getStack();
- if(itemEnchantInput != null && itemEnchantInput.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ if (itemEnchantInput != null && itemEnchantInput.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
itemEnchantInput = enchantingItem;
}
{
- int itemX = guiLeft+174;
- int itemY = guiTop+58;
+ int itemX = guiLeft + 174;
+ int itemY = guiTop + 58;
- if(itemEnchantInput == null) {
+ 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);
+ 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) {
+ if (mouseX >= itemX && mouseX < itemX + 18 &&
+ mouseY >= itemY && mouseY < itemY + 18) {
itemHoverX = itemX;
itemHoverY = itemY;
- if(itemEnchantInput != null) {
+ if (itemEnchantInput != null) {
tooltipToDisplay = itemEnchantInput.getTooltip(Minecraft.getMinecraft().thePlayer,
Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
}
}
}
- if(!isChangingEnchLevel && itemHoverX >= 0 && itemHoverY >= 0) {
+ if (!isChangingEnchLevel && itemHoverX >= 0 && itemHoverY >= 0) {
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16,
@@ -1112,36 +1112,36 @@ public class GuiCustomEnchant extends Gui {
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.disableDepth();
- for(ExperienceOrb orb : orbs) {
+ 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);
+ 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);
+ ((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) {
+ 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,
+ } else if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1,
Minecraft.getMinecraft().fontRendererObj);
}
GlStateManager.translate(0, 0, -300);
@@ -1154,25 +1154,25 @@ public class GuiCustomEnchant extends Gui {
this.orbTargetY = targetY;
Random rand = new Random();
- for(int i=0; i<EXPERIENCE_ORB_COUNT; i++) {
+ 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.xVel = rand.nextFloat() * 20 - 10;
+ orb.yVel = rand.nextFloat() * 20 - 10;
orb.type = baseType;
float typeRand = rand.nextFloat();
- if(typeRand < 0.6) {
+ if (typeRand < 0.6) {
orb.type += 0;
- } else if(typeRand < 0.9) {
+ } else if (typeRand < 0.9) {
orb.type += 1;
} else {
orb.type += 2;
}
- orb.rotationDeg = rand.nextInt(4)*90;
+ orb.rotationDeg = rand.nextInt(4) * 90;
orbs.add(orb);
}
@@ -1205,7 +1205,7 @@ public class GuiCustomEnchant extends Gui {
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;
+ pageAngle2 = (pageAngle2 - (float) MathHelper.truncateDoubleToInt(pageAngle2)) * 1.6F - 0.3F;
if (pageAngle1 < 0.0F) pageAngle1 = 0.0F;
if (pageAngle1 > 1.0F) pageAngle1 = 1.0F;
@@ -1228,137 +1228,136 @@ public class GuiCustomEnchant extends Gui {
}
public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if(shouldOverrideFast && currentState != EnchantState.ADDING_ENCHANT) {
+ if (shouldOverrideFast && currentState != EnchantState.ADDING_ENCHANT) {
boolean playerInv = slot.inventory == Minecraft.getMinecraft().thePlayer.inventory;
int slotId = slot.getSlotIndex();
- if(playerInv && slotId < 36) {
+ if (playerInv && slotId < 36) {
slotId -= 9;
- if(slotId < 0) slotId += 36;
+ if (slotId < 0) slotId += 36;
- int itemX = guiLeft+102+18*(slotId%9);
- int itemY = guiTop+133+18*(slotId/9);
+ int itemX = guiLeft + 102 + 18 * (slotId % 9);
+ int itemY = guiTop + 133 + 18 * (slotId / 9);
- if(slotId >= 27) {
+ if (slotId >= 27) {
itemY += 4;
}
- if(mouseX >= itemX && mouseX < itemX+18 &&
- mouseY >= itemY && mouseY < itemY+18) {
+ 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);
+ } 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;
+ 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) {
+ 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) {
+ } 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);
+ 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);
+ 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);
+ 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);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(click);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
chest.inventorySlots.windowId, click, 0, 0, stack, transactionID));
- return true;
}
+ 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) {
+ 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)) {
+ } 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;
+ } 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);
+ 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);
+ 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);
+ 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);
+ } 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);
+ 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);
+ 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);
+ 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) {
+ } else if (mouseX > left + 96 && mouseX <= left + 96 + 16) {
+ if (!isChangingEnchLevel) {
+ if (mouseY > top && mouseY < top + 16) {
isChangingEnchLevel = true;
return true;
}
@@ -1366,10 +1365,10 @@ public class GuiCustomEnchant extends Gui {
List<Enchantment> before = new ArrayList<>();
List<Enchantment> after = new ArrayList<>();
- for(Enchantment ench : enchanterEnchLevels.values()) {
- if(ench.level < enchanterCurrentEnch.level) {
+ for (Enchantment ench : enchanterEnchLevels.values()) {
+ if (ench.level < enchanterCurrentEnch.level) {
before.add(ench);
- } else if(ench.level > enchanterCurrentEnch.level) {
+ } else if (ench.level > enchanterCurrentEnch.level) {
after.add(ench);
}
}
@@ -1379,18 +1378,18 @@ public class GuiCustomEnchant extends Gui {
int bSize = before.size();
int aSize = after.size();
- for(int i=0; i<bSize+aSize; i++) {
+ for (int i = 0; i < bSize + aSize; i++) {
Enchantment ench;
int yIndex;
- if(i < bSize) {
- yIndex = -i-1;
+ if (i < bSize) {
+ yIndex = -i - 1;
ench = before.get(i);
} else {
- yIndex = i-bSize+1;
- ench = after.get(i-bSize);
+ yIndex = i - bSize + 1;
+ ench = after.get(i - bSize);
}
- if(mouseY > top+16*yIndex && mouseY <= top+16*yIndex+16) {
+ if (mouseY > top + 16 * yIndex && mouseY <= top + 16 * yIndex + 16) {
enchanterCurrentEnch = ench;
isChangingEnchLevel = false;
return true;
@@ -1399,35 +1398,35 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(isChangingEnchLevel) {
+ if (isChangingEnchLevel) {
isChangingEnchLevel = false;
return true;
}
}
}
- if(!Mouse.getEventButtonState() && Mouse.getEventButton() < 0 && clickedScrollOffset != -1) {
+ if (!Mouse.getEventButtonState() && Mouse.getEventButton() < 0 && clickedScrollOffset != -1) {
LerpingInteger lerpingInteger = isClickedScrollLeft ? leftScroll : rightScroll;
List<Enchantment> enchantsList = isClickedScrollLeft ? applicable : removable;
- if(enchantsList.size() > 6) {
+ 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;
+ 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;
+ 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;
+ 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;
@@ -1464,27 +1463,27 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(Mouse.getEventButton() == 0) {
- if(Mouse.getEventButtonState()) {
- if(mouseX > guiLeft+104 && mouseX < guiLeft+104+12) {
+ if (Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButtonState()) {
+ if (mouseX > guiLeft + 104 && mouseX < guiLeft + 104 + 12) {
int offset;
- if(applicable.size() <= 6) {
+ if (applicable.size() <= 6) {
offset = 0;
} else {
- offset = Math.round((96-15) * (leftScroll.getValue() / (float)((applicable.size()-6)*16)));
+ offset = Math.round((96 - 15) * (leftScroll.getValue() / (float) ((applicable.size() - 6) * 16)));
}
- if(mouseY >= guiTop+18+offset && mouseY < guiTop+18+offset+15) {
+ if (mouseY >= guiTop + 18 + offset && mouseY < guiTop + 18 + offset + 15) {
isClickedScrollLeft = true;
clickedScrollOffset = mouseY - offset;
}
- } else if(mouseX > guiLeft+344 && mouseX < guiLeft+344+12) {
+ } else if (mouseX > guiLeft + 344 && mouseX < guiLeft + 344 + 12) {
int offset;
- if(removable.size() <= 6) {
+ if (removable.size() <= 6) {
offset = 0;
} else {
- offset = Math.round((96-15) * (rightScroll.getValue() / (float)((removable.size()-6)*16)));
+ offset = Math.round((96 - 15) * (rightScroll.getValue() / (float) ((removable.size() - 6) * 16)));
}
- if(mouseY >= guiTop+18+offset && mouseY < guiTop+18+offset+15) {
+ if (mouseY >= guiTop + 18 + offset && mouseY < guiTop + 18 + offset + 15) {
isClickedScrollLeft = false;
clickedScrollOffset = mouseY - offset;
}
@@ -1494,33 +1493,33 @@ public class GuiCustomEnchant extends Gui {
}
}
- if(mouseY > guiTop+18 && mouseY < guiTop+18+96) {
- if(mouseX > guiLeft+8 && mouseX < guiLeft+8+96) {
- if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState() &&
+ 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++) {
+ for (int i = 0; i < 7; i++) {
int index = i + leftScroll.getValue() / 16;
- if(applicable.size() <= index) break;
+ if (applicable.size() <= index) break;
int top = guiTop - (leftScroll.getValue() % 16) + 18 + 16 * i;
- if(mouseX > guiLeft + 8 && mouseX <= guiLeft + 8 + 96 &&
+ 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 (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
- if(currentState == EnchantState.HAS_ITEM) {
+ 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);
+ 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) {
+ } 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);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
@@ -1533,32 +1532,32 @@ public class GuiCustomEnchant extends Gui {
}
isScrollingLeft = true;
- } else if(mouseX > guiLeft+248 && mouseX < guiLeft+248+96) {
- if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState() &&
+ } 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++) {
+ for (int i = 0; i < 7; i++) {
int index = i + rightScroll.getValue() / 16;
- if(removable.size() <= index) break;
+ if (removable.size() <= index) break;
int top = guiTop - (rightScroll.getValue() % 16) + 18 + 16 * i;
- if(mouseX > guiLeft + 248 && mouseX <= guiLeft + 248 + 96 &&
+ 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 (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
+ GuiContainer chest = ((GuiContainer) Minecraft.getMinecraft().currentScreen);
- if(currentState == EnchantState.HAS_ITEM) {
+ 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);
+ 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) {
+ } 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);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
@@ -1572,9 +1571,9 @@ public class GuiCustomEnchant extends Gui {
isScrollingLeft = false;
}
}
- if(Mouse.getEventDWheel() != 0) {
+ if (Mouse.getEventDWheel() != 0) {
int scroll = Mouse.getEventDWheel();
- if(scroll > 0) {
+ if (scroll > 0) {
scroll = -16;
} else {
scroll = 16;
@@ -1583,28 +1582,28 @@ public class GuiCustomEnchant extends Gui {
LerpingInteger lerpingInteger = isScrollingLeft ? leftScroll : rightScroll;
int elementsCount = isScrollingLeft ? applicable.size() : removable.size();
- int max = (elementsCount-6)*16;
+ int max = (elementsCount - 6) * 16;
- int newTarget = lerpingInteger.getTarget()+scroll;
- if(newTarget > max) newTarget = max;
- if(newTarget < 0) newTarget = 0;
+ int newTarget = lerpingInteger.getTarget() + scroll;
+ if (newTarget > max) newTarget = max;
+ if (newTarget < 0) newTarget = 0;
- if(newTarget != lerpingInteger.getTarget()) {
+ 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);
+ 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);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
@@ -1616,16 +1615,16 @@ public class GuiCustomEnchant extends Gui {
}
}
}
- 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);
+ 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);
+ ItemStack stack = ((ContainerChest) chest.inventorySlots).getLowerChestInventory().getStackInSlot(48);
Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C0EPacketClickWindow(
chest.inventorySlots.windowId, 48, 0, 0, stack, transactionID));
@@ -1640,8 +1639,8 @@ public class GuiCustomEnchant extends Gui {
}
public boolean keyboardInput() {
- if(currentState == EnchantState.HAS_ITEM && searchField.getFocus()) {
- if(Keyboard.getEventKeyState()) {
+ if (currentState == EnchantState.HAS_ITEM && searchField.getFocus()) {
+ if (Keyboard.getEventKeyState()) {
searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
}
return true;
@@ -1649,6 +1648,6 @@ public class GuiCustomEnchant extends Gui {
return Keyboard.getEventKey() != Keyboard.KEY_ESCAPE &&
(!NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking ||
- Keyboard.getEventKey() != NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey);
+ 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..6ba0b34b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java
@@ -5,17 +5,14 @@ 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;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -34,8 +31,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex;
-
public class GuiEnchantColour extends GuiScreen {
public static final ResourceLocation custom_ench_colour = new ResourceLocation("notenoughupdates:custom_ench_colour.png");
@@ -51,34 +46,34 @@ public class GuiEnchantColour extends GuiScreen {
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 final HashMap<Integer, String> comparators = new HashMap<>();
+ private final HashMap<Integer, String> modifiers = new HashMap<>();
+ private final List<GuiElementTextField[]> guiElementTextFields = new ArrayList<>();
private List<String> enchantNamesPretty = null;
- private JsonArray enchantPresets = null;
+ private final JsonArray enchantPresets = null;
- private LerpingInteger scroll = new LerpingInteger(0, 100);
- private LerpingInteger scrollSideBar = new LerpingInteger(0, 100);
+ 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 Gson gson = new Gson();
+ private final 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) {
+ if (enchantNamesPretty == null) {
JsonObject enchantsJson = Constants.ENCHANTS;
- if(!enchantsJson.has("enchants_pretty")) {
+ 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++) {
+ for (int i = 0; i < pretty.size(); i++) {
enchantNamesPretty.add(pretty.get(i).getAsString());
}
}
@@ -96,11 +91,10 @@ public class GuiEnchantColour extends GuiScreen {
List<String> enchantColours = getEnchantColours();
- ySize = 53+25*enchantColours.size();
- guiLeft = (width-xSize)/2;
-
+ ySize = 53 + 25 * enchantColours.size();
+ guiLeft = (width - xSize) / 2;
- if(ySize > height) {
+ if (ySize > height) {
if (scroll.getTarget() > 0) {
scroll.setTarget(0);
@@ -111,28 +105,28 @@ public class GuiEnchantColour extends GuiScreen {
guiTop = scroll.getValue();
} else {
- guiTop = (height-ySize)/2;
+ 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);
+ 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);
+ 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);
+ Utils.drawStringCentered("Add Ench Colour", fontRendererObj, guiLeft + xSize / 2 + 1, guiTop + ySize - 20, false, 4210752);
int yIndex = 0;
- for(String str : enchantColours) {
+ 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);
+ 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);
@@ -142,24 +136,24 @@ public class GuiEnchantColour extends GuiScreen {
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));
+ if (colourCode.length() > 1) colourCode = String.valueOf(colourCode.toLowerCase().charAt(0));
+ if (comparator.length() > 1) comparator = String.valueOf(comparator.toLowerCase().charAt(0));
- Utils.drawStringCentered(comparator, fontRendererObj, guiLeft+96, guiTop+33+25*yIndex, false, 4210752);
+ Utils.drawStringCentered(comparator, fontRendererObj, guiLeft + 96, guiTop + 33 + 25 * yIndex, false, 4210752);
- if(guiElementTextFields.size() <= yIndex) {
+ if (guiElementTextFields.size() <= yIndex) {
guiElementTextFields.add(new GuiElementTextField[3]);
}
- if(guiElementTextFields.get(yIndex)[0] == null) {
+ 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) {
+ if (guiElementTextFields.get(yIndex)[1] == null) {
guiElementTextFields.get(yIndex)[1] = new GuiElementTextField(comparison,
- GuiElementTextField.SCALE_TEXT|GuiElementTextField.NUM_ONLY|GuiElementTextField.NO_SPACE);
+ GuiElementTextField.SCALE_TEXT | GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE);
guiElementTextFields.get(yIndex)[1].setSize(20, 20);
}
- if(guiElementTextFields.get(yIndex)[2] == null) {
+ if (guiElementTextFields.get(yIndex)[2] == null) {
guiElementTextFields.get(yIndex)[2] = new GuiElementTextField(colourCode, GuiElementTextField.SCALE_TEXT);
guiElementTextFields.get(yIndex)[2].setSize(20, 20);
}
@@ -168,22 +162,22 @@ public class GuiEnchantColour extends GuiScreen {
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);
+ 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.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.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.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);
+ if ((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) {
+ Minecraft.getMinecraft().fontRendererObj.drawString("\u00a7l\u2713", guiLeft + 196, guiTop + 23 + 25 * yIndex + 10, 0xff202020, true);
}
yIndex++;
@@ -191,10 +185,10 @@ public class GuiEnchantColour extends GuiScreen {
renderSideBar(mouseX, mouseY, partialTicks);
}
- private void renderSideBar(int mouseX, int mouseY, float partialTicks){
- ySizeSidebar = 24*(2);
+ private void renderSideBar(int mouseX, int mouseY, float partialTicks) {
+ ySizeSidebar = 24 * (2);
- if(ySizeSidebar > height) {
+ if (ySizeSidebar > height) {
if (scrollSideBar.getTarget() > 0) {
scrollSideBar.setTarget(0);
@@ -206,52 +200,52 @@ public class GuiEnchantColour extends GuiScreen {
guiTopSidebar = scrollSideBar.getValue();
} else {
- guiTopSidebar = (height-ySizeSidebar)/2;
+ 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);
+ 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++) {
+ 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()) {
+ if (guiElementTextFields.get(yIndex)[i].getFocus()) {
int addOffset = 0;
- if(keyCode == Keyboard.KEY_UP) {
+ if (keyCode == Keyboard.KEY_UP) {
addOffset -= 1;
- } else if(keyCode == Keyboard.KEY_DOWN) {
+ } else if (keyCode == Keyboard.KEY_DOWN) {
addOffset += 1;
}
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
- if(yIndex+addOffset < 0) {
+ if (yIndex + addOffset < 0) {
addOffset = -yIndex;
- } else if(yIndex+addOffset > NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()) {
- addOffset = NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.size()-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,
+ NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.add(yIndex + addOffset,
getEnchantOpString(guiElementTextFields.get(yIndex), comparators.get(yIndex), modifiers.get(yIndex)));
- if(addOffset != 0) {
+ if (addOffset != 0) {
GuiElementTextField[] guiElementTextFieldArray = guiElementTextFields.remove(yIndex);
- guiElementTextFields.add(yIndex+addOffset, guiElementTextFieldArray);
+ guiElementTextFields.add(yIndex + addOffset, guiElementTextFieldArray);
}
return;
}
@@ -279,7 +273,7 @@ public class GuiEnchantColour extends GuiScreen {
int dWheel = Mouse.getEventDWheel();
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
- if(mouseX > guiLeft && mouseX < guiLeft + xSize) {
+ if (mouseX > guiLeft && mouseX < guiLeft + xSize) {
if (dWheel < 0) {
scroll.setTarget(scroll.getTarget() - 50);
scroll.resetTimer();
@@ -287,7 +281,7 @@ public class GuiEnchantColour extends GuiScreen {
scroll.setTarget(scroll.getTarget() + 50);
scroll.resetTimer();
}
- } else if(mouseX > guiLeft+xSize && mouseX < guiLeft + xSize+ 100) {
+ } else if (mouseX > guiLeft + xSize && mouseX < guiLeft + xSize + 100) {
if (dWheel < 0) {
scrollSideBar.setTarget(scrollSideBar.getTarget() - 50);
scrollSideBar.resetTimer();
@@ -302,20 +296,20 @@ public class GuiEnchantColour extends GuiScreen {
public static int getIntModifier(String modifier) {
try {
return Integer.parseInt(modifier);
- } catch(NumberFormatException e) {
+ } catch (NumberFormatException e) {
return 0;
}
}
private boolean validShareContents() {
try {
- String base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+ String base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
- if(base64.length() <= sharePrefix.length()) return false;
+ if (base64.length() <= sharePrefix.length()) return false;
try {
return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
- } catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
return false;
}
} catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
@@ -326,16 +320,16 @@ public class GuiEnchantColour extends GuiScreen {
@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) {
+ 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) {
+ 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)));
@@ -347,26 +341,26 @@ public class GuiEnchantColour extends GuiScreen {
}
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) {
+ 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) {
+ 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) {
+ if (mouseY < guiTop + 23 + 25 * yIndex + 10) {
selectedModifier = UNDERLINE_MODIFIER;
} else {
selectedModifier = STRIKETHROUGH_MODIFIER;
}
}
- if(selectedModifier != -1) {
+ if (selectedModifier != -1) {
int modifierMasked = (modifierI & selectedModifier);
int modifierMaskedInverted = selectedModifier - modifierMasked;
@@ -374,27 +368,30 @@ public class GuiEnchantColour extends GuiScreen {
int finalModifier = (modifierI & modifierInverted) | modifierMaskedInverted;
- modifiers.put(yIndex, ""+finalModifier);
+ 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) {
+ 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;
+ comparators.put(yIndex, "=");
+ break;
case "=":
- comparators.put(yIndex, "<"); break;
+ comparators.put(yIndex, "<");
+ break;
default:
- comparators.put(yIndex, ">"); break;
+ 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) {
+ } else if (mouseX > guiLeft + 160 && mouseX < guiLeft + 160 + 20) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours.remove(yIndex);
guiElementTextFields.remove(yIndex);
comparators.remove(yIndex);
@@ -402,79 +399,77 @@ public class GuiEnchantColour extends GuiScreen {
}
}
}
- if(mouseX >= guiLeft+57 && mouseX <= guiLeft+xSize-57) {
- if(mouseY >= guiTop+ySize-30 && mouseY <= guiTop+ySize-10) {
+ 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){
+ 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);
+ base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
} catch (HeadlessException | IOException | UnsupportedFlavorException e) {
return;
}
- if(base64.length() <= sharePrefix.length()) return;
+ if (base64.length() <= sharePrefix.length()) return;
String jsonString;
try {
jsonString = new String(Base64.getDecoder().decode(base64));
- if(!jsonString.startsWith(sharePrefix)) return;
+ if (!jsonString.startsWith(sharePrefix)) return;
jsonString = jsonString.substring(sharePrefix.length());
- } catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
return;
}
System.out.println(jsonString);
JsonArray presetArray;
- try{
+ try {
presetArray = new JsonParser().parse(jsonString).getAsJsonArray();
- } catch (IllegalStateException | JsonParseException e){
+ } 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()) {
+ if (matcher.matches()) {
presetList.add(presetArray.get(i).getAsString());
}
}
}
- if(presetList.size() != 0) {
+ if (presetList.size() != 0) {
NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = presetList;
}
-
- } else if(mouseY > guiTopSidebar+2+24 && mouseY < guiTopSidebar+20+24+2){
+ } 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)));
+ for (String s : result) {
+ jsonArray.add(new JsonPrimitive(s));
}
- String base64String = Base64.getEncoder().encodeToString((sharePrefix+jsonArray).getBytes(StandardCharsets.UTF_8));
+ 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){
+ } 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) {
+ if (colourOps.size() > index) {
return colourOps.get(index);
} else {
- switch(index) {
+ switch (index) {
case 0:
return "[a-zA-Z\\- ]+";
case 1:
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..07f514cc 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;
@@ -48,8 +46,8 @@ public class GuiInvButtonEditor extends GuiScreen {
private static final String sharePrefix = "NEUBUTTONS/";
- private int xSize = 176;
- private int ySize = 166;
+ private final int xSize = 176;
+ private final int ySize = 166;
private int guiLeft;
private int guiTop;
@@ -58,15 +56,16 @@ public class GuiInvButtonEditor extends GuiScreen {
private static final int ICON_TYPES = 3;
private int iconTypeIndex = 0;
- private int editorXSize = 150;
- private int editorYSize = 204;
+ private final int editorXSize = 150;
+ private final 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 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<>();
+
static {
prioritisedIcons.add("WORKBENCH");
prioritisedIcons.add("LEATHER_CHESTPLATE");
@@ -91,6 +90,7 @@ public class GuiInvButtonEditor extends GuiScreen {
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");
@@ -129,31 +129,30 @@ public class GuiInvButtonEditor extends GuiScreen {
private static void reloadExtraIcons() {
extraIcons = new HashMap<>();
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
+ 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());
+ for (Map.Entry<String, JsonElement> entry : json.entrySet()) {
+ if (entry.getValue().isJsonPrimitive()) {
+ extraIcons.put(entry.getKey(), "extra:" + entry.getValue().getAsString());
}
}
- } catch(Exception e) {
- }
+ } catch (Exception ignored) {}
}
private static void reloadPresets() {
presets = new LinkedHashMap<>();
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(
+ 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()) {
+ 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++) {
+ 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);
@@ -161,36 +160,35 @@ public class GuiInvButtonEditor extends GuiScreen {
presets.put(entry.getKey(), buttons);
}
}
- } catch(Exception e) {
- }
+ } 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;
+ 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 final LerpingInteger itemScroll = new LerpingInteger(0, 100);
private NEUConfig.InventoryButton editingButton = null;
- private static HashMap<String, ItemStack> skullMap = new HashMap<>();
+ private static final HashMap<String, ItemStack> skullMap = new HashMap<>();
public static void renderIcon(String icon, int x, int y) {
- if(extraIcons == null) {
+ if (extraIcons == null) {
reloadExtraIcons();
}
- if(icon.startsWith("extra:")) {
+ if (icon.startsWith("extra:")) {
String name = icon.substring("extra:".length());
- ResourceLocation resourceLocation = new ResourceLocation("notenoughupdates:invbuttons/extraicons/"+name+".png");
+ 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);
@@ -198,11 +196,11 @@ public class GuiInvButtonEditor extends GuiScreen {
ItemStack stack = getStack(icon);
float scale = 1;
- if(icon.startsWith("skull:")) {
+ if (icon.startsWith("skull:")) {
scale = 1.2f;
}
GlStateManager.pushMatrix();
- GlStateManager.translate(x+8, y+8, 0);
+ GlStateManager.translate(x + 8, y + 8, 0);
GlStateManager.scale(scale, scale, 1);
GlStateManager.translate(-8, -8, 0);
Utils.drawItemStack(stack, 0, 0);
@@ -211,11 +209,11 @@ public class GuiInvButtonEditor extends GuiScreen {
}
public static ItemStack getStack(String icon) {
- if(icon.startsWith("extra:")) {
+ if (icon.startsWith("extra:")) {
return null;
- } else if(icon.startsWith("skull:")) {
+ } else if (icon.startsWith("skull:")) {
String link = icon.substring("skull:".length());
- if(skullMap.containsKey(link)) return skullMap.get(link);
+ if (skullMap.containsKey(link)) return skullMap.get(link);
ItemStack render = new ItemStack(Items.skull, 1, 3);
NBTTagCompound nbt = new NBTTagCompound();
@@ -228,7 +226,7 @@ public class GuiInvButtonEditor extends GuiScreen {
skullOwner.setString("Id", uuid);
skullOwner.setString("Name", uuid);
- String display = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/"+link+"\"}}}";
+ String display = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + link + "\"}}}";
String displayB64 = Base64.getEncoder().encodeToString(display.getBytes());
textures_0.setString("Value", displayB64);
@@ -252,26 +250,26 @@ public class GuiInvButtonEditor extends GuiScreen {
super.drawDefaultBackground();
- guiLeft = width/2 - xSize/2;
- guiTop = height/2 - ySize/2;
+ 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);
+ 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) {
+ 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) {
+ if (button.anchorBottom) {
y += ySize;
}
- if(button.isActive()) {
+ if (button.isActive()) {
GlStateManager.color(1, 1, 1, 1f);
} else {
GlStateManager.color(1, 1, 1, 0.5f);
@@ -279,177 +277,178 @@ public class GuiInvButtonEditor extends GuiScreen {
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);
+ 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()) {
+ if (button.isActive()) {
+ if (button.icon != null && !button.icon.trim().isEmpty()) {
GlStateManager.enableDepth();
- renderIcon(button.icon, x+1, y+1);
+ renderIcon(button.icon, x + 1, y + 1);
}
} else {
- fontRendererObj.drawString("+", x+6, y+5, 0xffcccccc);
+ 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);
+ 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) {
+ 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);
+ 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++),
+ 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) {
+ if (editingButton != null) {
+ int x = guiLeft + editingButton.x;
+ int y = guiTop + editingButton.y;
+ if (editingButton.anchorRight) {
x += xSize;
}
- if(editingButton.anchorBottom) {
+ if (editingButton.anchorBottom) {
y += ySize;
}
GlStateManager.translate(0, 0, 300);
- editorLeft = x + 8 - editorXSize/2;
+ editorLeft = x + 8 - editorXSize / 2;
editorTop = y + 18 + 2;
boolean showArrow = true;
- if(editorTop+editorYSize+5 > height) {
- editorTop = height-editorYSize-5;
+ if (editorTop + editorYSize + 5 > height) {
+ editorTop = height - editorYSize - 5;
showArrow = false;
}
- if(editorLeft < 5) {
+ if (editorLeft < 5) {
editorLeft = 5;
showArrow = false;
}
- if(editorLeft+editorXSize+5 > width) {
- editorLeft = width-editorXSize-5;
+ 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);
+ 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);
+ 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);
+ fontRendererObj.drawString("Command", editorLeft + 7, editorTop + 7, 0xffa0a0a0, false);
- commandTextField.setSize(editorXSize-14, 16);
+ commandTextField.setSize(editorXSize - 14, 16);
commandTextField.setText(commandTextField.getText().replaceAll("^ +", ""));
- if(commandTextField.getText().startsWith("/")) {
+ if (commandTextField.getText().startsWith("/")) {
commandTextField.setPrependText("");
} else {
commandTextField.setPrependText("\u00a77/\u00a7r");
}
- commandTextField.render(editorLeft+7, editorTop+19);
+ commandTextField.render(editorLeft + 7, editorTop + 19);
- fontRendererObj.drawString("Background", editorLeft+7, editorTop+40, 0xffa0a0a0, false);
+ 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);
+ 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);
+ 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);
+ 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 uMin = 18 / 256f;
+ float uMax = 36 / 256f;
float vMin = 0;
- float vMax = 18/256f;
+ float vMax = 18 / 256f;
- for(int i=0; i<ICON_TYPES; i++) {
+ 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,
+ 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) {
+ if (i == 0) {
stack = new ItemStack(Items.diamond_sword);
- } else if(i == 1) {
+ } else if (i == 1) {
stack = getStack("skull:c9c8881e42915a9d29bb61a16fb26d059913204d265df5b439b3d792acd56");
- } else if(i == 2) {
+ } else if (i == 2) {
stack = new ItemStack(Items.lead);
}
- if(stack != null) Utils.drawItemStack(stack, editorLeft+8+20*i, editorTop+50+35);
+ if (stack != null) Utils.drawItemStack(stack, editorLeft + 8 + 20 * i, editorTop + 50 + 35);
}
- fontRendererObj.drawString("Icon Selector", editorLeft+7, editorTop+50+55, 0xffa0a0a0, false);
+ fontRendererObj.drawString("Icon Selector", editorLeft + 7, editorTop + 50 + 55, 0xffa0a0a0, false);
- iconTextField.render(editorLeft+7, editorTop+50+65);
+ 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);
+ GlScissorStack.push(0, editorTop + 136, width, editorTop + 196, scaledResolution);
- synchronized(searchedIcons) {
- if(iconTextField.getText().trim().isEmpty() && searchedIcons.isEmpty()) {
+ 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 max = (searchedIcons.size() - 1) / 6 * 20 - 40;
int scroll = itemScroll.getValue();
- if(scroll > max) scroll = max;
+ 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;
+ 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);
+ 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;
+ int startIndex = scroll / 20 * 6;
+ if (startIndex < 0) startIndex = 0;
+ if (endIndex > startIndex + 24) endIndex = startIndex + 24;
- for(int i=startIndex; i<endIndex; i++) {
+ 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);
+ 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);
+ 18 / 256f, 36 / 256f, 0 / 256f, 18 / 256f, GL11.GL_NEAREST);
- renderIcon(iconS, iconX+1, iconY+1);
+ renderIcon(iconS, iconX + 1, iconY + 1);
}
}
@@ -462,20 +461,20 @@ public class GuiInvButtonEditor extends GuiScreen {
@Override
public void handleMouseInput() throws IOException {
int scroll = Mouse.getEventDWheel();
- if(scroll != 0) {
+ if (scroll != 0) {
scroll = -scroll;
- if(scroll > 1) scroll = 8;
- if(scroll < -1) scroll = -8;
+ if (scroll > 1) scroll = 8;
+ if (scroll < -1) scroll = -8;
int delta = Math.abs(itemScroll.getTarget() - itemScroll.getValue());
- float acc = delta/20+1;
+ float acc = delta / 20 + 1;
scroll *= acc;
- int max = (searchedIcons.size()-1)/6*20-40;
+ int max = (searchedIcons.size() - 1) / 6 * 20 - 40;
int newTarget = itemScroll.getTarget() + scroll;
- if(newTarget > max) newTarget = max;
- if(newTarget < 0) newTarget = 0;
+ if (newTarget > max) newTarget = max;
+ if (newTarget < 0) newTarget = 0;
itemScroll.setTarget(newTarget);
itemScroll.resetTimer();
@@ -486,13 +485,13 @@ public class GuiInvButtonEditor extends GuiScreen {
private boolean validShareContents() {
try {
- String base64 = (String)Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
+ String base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
- if(base64.length() <= sharePrefix.length()) return false;
+ if (base64.length() <= sharePrefix.length()) return false;
try {
return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix);
- } catch (IllegalArgumentException e){
+ } catch (IllegalArgumentException e) {
return false;
}
} catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) {
@@ -504,64 +503,64 @@ public class GuiInvButtonEditor extends GuiScreen {
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 &&
+ 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()) {
+ 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()) {
+ 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) {
+ 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) {
+ 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) {
+ 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;
+ 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;
+ 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;
+ int startIndex = scroll / 20 * 6;
+ if (startIndex < 0) startIndex = 0;
+ if (endIndex > startIndex + 24) endIndex = startIndex + 24;
- for(int i=startIndex; i<endIndex; i++) {
+ 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);
+ 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) {
+ if (mouseX >= x && mouseX <= x + 18 &&
+ mouseY >= y && mouseY <= y + 18) {
editingButton.icon = iconS;
return;
}
@@ -572,19 +571,19 @@ public class GuiInvButtonEditor extends GuiScreen {
}
}
- for(NEUConfig.InventoryButton button : NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons) {
- int x = guiLeft+button.x;
- int y = guiTop+button.y;
- if(button.anchorRight) {
+ 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) {
+ if (button.anchorBottom) {
y += ySize;
}
- if(mouseX >= x && mouseY >= y &&
- mouseX <= x+18 && mouseY <= y+18) {
- if(editingButton == button) {
+ if (mouseX >= x && mouseY >= y &&
+ mouseX <= x + 18 && mouseY <= y + 18) {
+ if (editingButton == button) {
editingButton = null;
} else {
editingButton = button;
@@ -594,7 +593,7 @@ public class GuiInvButtonEditor extends GuiScreen {
}
}
- if(mouseX > guiLeft-2-88-22 && mouseX< guiLeft-2-22) {
+ if (mouseX > guiLeft - 2 - 88 - 22 && mouseX < guiLeft - 2 - 22) {
if (mouseY > guiTop + 2 && mouseY < guiTop + 22) {
String base64;
@@ -605,12 +604,12 @@ public class GuiInvButtonEditor extends GuiScreen {
return;
}
- if(base64.length() <= sharePrefix.length()) return;
+ if (base64.length() <= sharePrefix.length()) return;
String jsonString;
try {
jsonString = new String(Base64.getDecoder().decode(base64));
- if(!jsonString.startsWith(sharePrefix)) return;
+ if (!jsonString.startsWith(sharePrefix)) return;
jsonString = jsonString.substring(sharePrefix.length());
} catch (IllegalArgumentException e) {
return;
@@ -623,13 +622,11 @@ public class GuiInvButtonEditor extends GuiScreen {
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()) {
@@ -642,31 +639,29 @@ public class GuiInvButtonEditor extends GuiScreen {
NotEnoughUpdates.INSTANCE.config.hidden.inventoryButtons = buttons;
return;
- } catch(JsonParseException | ClassCastException | IllegalStateException e){
+ } 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)));
+ 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));
+ String base64String = Base64.getEncoder().encodeToString((sharePrefix + jsonArray).getBytes(StandardCharsets.UTF_8));
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null);
return;
}
}
- if(editingButton == null) {
+ 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) {
+ 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;
}
@@ -681,30 +676,30 @@ public class GuiInvButtonEditor extends GuiScreen {
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
- if(editingButton != null && commandTextField.getFocus()) {
+ if (editingButton != null && commandTextField.getFocus()) {
commandTextField.keyTyped(typedChar, keyCode);
editingButton.command = commandTextField.getText();
- } else if(editingButton != null && iconTextField.getFocus()) {
+ } else if (editingButton != null && iconTextField.getFocus()) {
String old = iconTextField.getText().trim();
iconTextField.keyTyped(typedChar, keyCode);
String newText = iconTextField.getText().trim();
- if(!old.equalsIgnoreCase(newText)) {
+ if (!old.equalsIgnoreCase(newText)) {
search();
}
}
}
- private ExecutorService searchES = Executors.newSingleThreadExecutor();
- private AtomicInteger searchId = new AtomicInteger(0);
+ 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) {
+ if (iconTypeIndex == 0) {
+ if (searchString.trim().isEmpty()) {
+ synchronized (searchedIcons) {
searchedIcons.clear();
List<String> unsorted = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet());
@@ -715,64 +710,64 @@ public class GuiInvButtonEditor extends GuiScreen {
}
searchES.submit(() -> {
- if(thisSearchId != searchId.get()) return;
+ if (thisSearchId != searchId.get()) return;
List<String> title = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("title:" + searchString.trim()));
- if(thisSearchId != searchId.get()) return;
+ if (thisSearchId != searchId.get()) return;
- if(!searchString.trim().contains(" ")) {
+ if (!searchString.trim().contains(" ")) {
StringBuilder sb = new StringBuilder();
- for(char c : searchString.toCharArray()) {
+ for (char c : searchString.toCharArray()) {
sb.append(c).append(" ");
}
title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:" + sb.toString().trim()));
}
- if(thisSearchId != searchId.get()) return;
+ 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;
+ if (thisSearchId != searchId.get()) return;
title.sort(prioritisingComparator);
desc.sort(prioritisingComparator);
- if(thisSearchId != searchId.get()) return;
+ if (thisSearchId != searchId.get()) return;
- synchronized(searchedIcons) {
+ synchronized (searchedIcons) {
searchedIcons.clear();
searchedIcons.addAll(title);
searchedIcons.addAll(desc);
}
});
- } else if(iconTypeIndex == 1) {
- if(searchString.trim().isEmpty()) {
+ } else if (iconTypeIndex == 1) {
+ if (searchString.trim().isEmpty()) {
searchedIcons.clear();
searchedIcons.addAll(skullIcons.values());
return;
}
- synchronized(searchedIcons) {
+ synchronized (searchedIcons) {
searchedIcons.clear();
- for(Map.Entry<String, String> entry : skullIcons.entrySet()) {
- if(NotEnoughUpdates.INSTANCE.manager.searchString(entry.getKey(), searchString)) {
+ 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()) {
+ } else if (iconTypeIndex == 2) {
+ if (searchString.trim().isEmpty()) {
searchedIcons.clear();
searchedIcons.addAll(extraIcons.values());
return;
}
- synchronized(searchedIcons) {
+ synchronized (searchedIcons) {
searchedIcons.clear();
- for(Map.Entry<String, String> entry : extraIcons.entrySet()) {
- if(NotEnoughUpdates.INSTANCE.manager.searchString(entry.getKey(), searchString)) {
+ 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..d0cb3f92 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,9 +22,7 @@ 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 {
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..a6928102 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java
@@ -2,25 +2,18 @@ package io.github.moulberry.notenoughupdates.miscgui;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUManager;
-import io.github.moulberry.notenoughupdates.util.TexLoc;
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.item.ItemStack;
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;
@@ -31,12 +24,12 @@ 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 final List<ItemStack[]> craftMatrices;
+ private final List<JsonObject> results;
private int currentIndex = 0;
- private String title;
- private NEUManager manager;
+ private final String title;
+ private final NEUManager manager;
public int guiLeft = 0;
public int guiTop = 0;
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..434d70c3 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java
@@ -18,7 +18,6 @@ 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;
@@ -36,18 +35,18 @@ public class InventoryStorageSelector {
}
public boolean isSlotSelected() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
isOverridingSlot = false;
return false;
}
- if(Minecraft.getMinecraft().currentScreen != null) {
+ if (Minecraft.getMinecraft().currentScreen != null) {
return false;
}
- if(Minecraft.getMinecraft().thePlayer == null) {
+ if (Minecraft.getMinecraft().thePlayer == null) {
isOverridingSlot = false;
return false;
}
- if(Minecraft.getMinecraft().thePlayer.inventory.currentItem != 0) {
+ if (Minecraft.getMinecraft().thePlayer.inventory.currentItem != 0) {
isOverridingSlot = false;
return false;
}
@@ -56,36 +55,40 @@ public class InventoryStorageSelector {
@SubscribeEvent
public void onMousePress(MouseEvent event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return;
}
- if(Minecraft.getMinecraft().currentScreen != null) {
+ if (Minecraft.getMinecraft().currentScreen != null) {
return;
}
- if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.arrowLeftKey)) {
+ 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)) {
+ 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)) {
+ 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()) {
+ 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) {
+ if (Mouse.getEventButton() == useKeycode || Mouse.getEventButton() == attackKeycode) {
+ if (Mouse.getEventButtonState() &&
+ Mouse.getEventButton() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey + 100) {
sendToPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
}
@@ -95,10 +98,10 @@ public class InventoryStorageSelector {
}
private void sendToPage(int displayId) {
- if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(displayId)) {
+ if (!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(displayId)) {
return;
}
- if(getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex) == null) {
+ 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);
@@ -108,75 +111,83 @@ public class InventoryStorageSelector {
@SubscribeEvent
public void onKeyPress(InputEvent.KeyInputEvent event) {
- if(Minecraft.getMinecraft().gameSettings.keyBindsHotbar[0].isKeyDown()) {
+ if (Minecraft.getMinecraft().gameSettings.keyBindsHotbar[0].isKeyDown()) {
isOverridingSlot = false;
}
- if(Minecraft.getMinecraft().currentScreen != null) {
+ if (Minecraft.getMinecraft().currentScreen != null) {
return;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return;
}
- if(KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotkey)) {
+ 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)) {
+ } 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)) {
+ 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)) {
+ 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()) {
+ 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) {
+ 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()){}
+ while (attack.isPressed()) {
+ }
}
- if(use.isPressed() || use.isKeyDown()) {
- if(attack.getKeyCode() != NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) {
+ 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()){}
+ while (use.isPressed()) {
+ }
}
}
}
public int onScroll(int direction, int resultantSlot) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return resultantSlot;
}
- if(Minecraft.getMinecraft().currentScreen != null) {
+ if (Minecraft.getMinecraft().currentScreen != null) {
return resultantSlot;
}
int keyCode = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey;
- if(isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) {
+ if (isOverridingSlot && KeybindHelper.isKeyDown(keyCode)) {
NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex -= direction;
- int max = StorageManager.getInstance().storageConfig.displayToStorageIdMap.size()-1;
+ 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;
+ 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;
}
@@ -184,15 +195,15 @@ public class InventoryStorageSelector {
KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackScrollKey) :
NotEnoughUpdates.INSTANCE.config.storageGUI.scrollToBackpack2 == 1;
- if(allowScroll && resultantSlot == 0 && direction == -1 && !isOverridingSlot) {
+ if (allowScroll && resultantSlot == 0 && direction == -1 && !isOverridingSlot) {
isOverridingSlot = true;
Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
return 0;
- } else if(resultantSlot == 1 && direction == -1 && isOverridingSlot) {
+ } else if (resultantSlot == 1 && direction == -1 && isOverridingSlot) {
isOverridingSlot = false;
Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
return 0;
- } else if(allowScroll && resultantSlot == 8 && direction == 1 && !isOverridingSlot) {
+ } else if (allowScroll && resultantSlot == 8 && direction == 1 && !isOverridingSlot) {
isOverridingSlot = true;
Minecraft.getMinecraft().getItemRenderer().resetEquippedProgress();
return 0;
@@ -201,7 +212,7 @@ public class InventoryStorageSelector {
}
private StorageManager.StoragePage getPage(int selectedIndex) {
- if(!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) {
+ if (!StorageManager.getInstance().storageConfig.displayToStorageIdMap.containsKey(selectedIndex)) {
return null;
}
int index = StorageManager.getInstance().storageConfig.displayToStorageIdMap.get(selectedIndex);
@@ -210,7 +221,7 @@ public class InventoryStorageSelector {
public ItemStack getNamedHeldItemOverride() {
StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- if(page != null && page.backpackDisplayStack != null) {
+ if (page != null && page.backpackDisplayStack != null) {
return page.backpackDisplayStack;
}
return new ItemStack(Item.getItemFromBlock(Blocks.chest));
@@ -222,9 +233,9 @@ public class InventoryStorageSelector {
public ItemStack getHeldItemOverride(int selectedIndex) {
StorageManager.StoragePage page = getPage(selectedIndex);
- if(page != null) {
+ if (page != null) {
ItemStack stack = page.backpackDisplayStack;
- if(stack == null || stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ if (stack == null || stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
return new ItemStack(Item.getItemFromBlock(Blocks.ender_chest));
}
return stack;
@@ -233,16 +244,18 @@ public class InventoryStorageSelector {
}
public void render(ScaledResolution scaledResolution, float partialTicks) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpack) {
return;
}
- if(Minecraft.getMinecraft().currentScreen != null) {
+ 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 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();
@@ -251,7 +264,7 @@ public class InventoryStorageSelector {
int offset = 91 + 10 + 12;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotbarSide == 1) {
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.backpackHotbarSide == 1) {
offset *= -1;
}
@@ -259,63 +272,63 @@ public class InventoryStorageSelector {
int left = centerX - offset - 12;
int top = scaledResolution.getScaledHeight() - 22;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview && isSlotSelected()) {
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview && isSlotSelected()) {
StorageManager.StoragePage page = getPage(NotEnoughUpdates.INSTANCE.config.storageGUI.selectedIndex);
- if(page != null && page.rows > 0) {
+ 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);
+ 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);
+ 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);
+ 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];
+ int[] isPaneCache = new int[rows * 9];
+ int[] ctmIndexCache = new int[rows * 9];
- for(int i=0; i<rows*9; i++) {
+ 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);
+ 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) {
+ if (paneType > 0) {
GlStateManager.disableAlpha();
- Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000);
+ 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;
+ int startCTMX = (ctmIndex % 12) * 19;
+ int startCTMY = (ctmIndex / 12) * 19;
ctmIndexCache[i] = ctmIndex;
- if(paneType != 17) {
- int rgb = StorageOverlay.getRGBFromPane(paneType-1);
+ 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);
+ 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();
@@ -326,61 +339,61 @@ public class InventoryStorageSelector {
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 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++) {
+ 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) {
+ if (type > 0) {
int ctmIndex = StorageOverlay.getCTMIndex(page, index, isPaneCache, ctmIndexCache);
- if(ctmIndex < 0) continue;
+ 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)) {
+ if ((i % 9 == 0 && index % 9 == 0) || (i % 9 == 8 && index % 9 == 8)) {
renderConnection = horizontal || vertical;
- } else if(index == leftIndex || index == rightIndex) {
+ } else if (index == leftIndex || index == rightIndex) {
renderConnection = horizontal;
} else {
renderConnection = vertical;
}
- if(renderConnection) {
+ if (renderConnection) {
Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- int rgb = StorageOverlay.getRGBFromPane(type-1);
+ 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.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.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) {
+ if (index == leftIndex) {
vertFlip = true;
- } else if(index == downIndex) {
+ } 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);
+ !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);
+ !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();
}
@@ -395,24 +408,24 @@ public class InventoryStorageSelector {
}
String pageTitle;
- if(page.customTitle != null && !page.customTitle.isEmpty()) {
+ if (page.customTitle != null && !page.customTitle.isEmpty()) {
pageTitle = page.customTitle;
} else {
pageTitle = getNamedHeldItemOverride().getDisplayName();
}
- Utils.drawItemStack(held, centerX-8, startY-8);
+ 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)) {
+ if (KeybindHelper.isKeyValid(keyCode) && !KeybindHelper.isKeyDown(keyCode)) {
String keyName = KeybindHelper.getKeyName(keyCode);
- Utils.drawStringCentered("["+keyName+"] Scroll Backpacks", fontRendererObj, centerX, startY-10, true, 0xff32CD32);
+ Utils.drawStringCentered("[" + keyName + "] Scroll Backpacks", fontRendererObj, centerX, startY - 10, true, 0xff32CD32);
}
GlStateManager.translate(0, 0, -200);
- } else if(page == null) {
+ } 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);
@@ -422,23 +435,23 @@ public class InventoryStorageSelector {
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()) {
+ 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);
+ 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)) {
+ 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;
+ if (displayIndex < 9) {
+ index = displayIndex + 1;
} else {
- index = displayIndex-8;
+ index = displayIndex - 8;
}
}
- Utils.drawItemStackWithText(held, left + 4, top + 3, ""+index);
+ Utils.drawItemStackWithText(held, left + 4, top + 3, "" + index);
GlStateManager.enableBlend();
}
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..83e0a4b0 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;
@@ -21,9 +24,9 @@ public class NEUOverlayPlacements extends GuiScreen {
private int clickedAnchorX;
private int clickedAnchorY;
private MBGuiElement clickedElement;
- private GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default");
+ private final GuiButton guiButton = new GuiButton(0, 5, 5, "Reset to Default");
- private boolean dropdownMenuShown = false;
+ private final boolean dropdownMenuShown = false;
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
@@ -38,7 +41,7 @@ public class NEUOverlayPlacements extends GuiScreen {
GlStateManager.enableAlpha();
this.drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16);*/
- if(mouseX < 300 && mouseY < 300 && clickedElement != null) {
+ if (mouseX < 300 && mouseY < 300 && clickedElement != null) {
guiButton.yPosition = height - 5 - guiButton.height;
} else {
guiButton.yPosition = 5;
@@ -50,62 +53,62 @@ public class NEUOverlayPlacements extends GuiScreen {
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);
+ 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()) {
+ 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());
+ 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) {
+ 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),
+ 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),
+ 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(),
+ 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(),
+ 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(),
+ 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),
+ 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);
+ 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);
@@ -115,28 +118,28 @@ public class NEUOverlayPlacements extends GuiScreen {
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
- if(mouseButton != 0 && mouseButton != 1) return;
+ if (mouseButton != 0 && mouseButton != 1) return;
MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
- int index=0;
- for(MBGuiElement element : mainGroup.getChildren()) {
+ 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) {
+ 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;
+ clickedAnchorX = (int) anchorPoint.offset.x;
+ clickedAnchorY = (int) anchorPoint.offset.y;
} else {
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ 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];
+ anchorPoint.anchorPoint = vals[(anchorPoint.anchorPoint.ordinal() + 1) % vals.length];
mainGroup.recalculate();
@@ -145,9 +148,9 @@ public class NEUOverlayPlacements extends GuiScreen {
mainGroup.recalculate();
- if(index == 0) {
+ if (index == 0) {
NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString();
- } else if(index == 1) {
+ } else if (index == 1) {
NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString();
}
}
@@ -158,7 +161,7 @@ public class NEUOverlayPlacements extends GuiScreen {
index++;
}
- if(guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
+ if (guiButton.mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) {
NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = "";
NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = "";
NotEnoughUpdates.INSTANCE.overlay.resetAnchors(false);
@@ -176,14 +179,14 @@ public class NEUOverlayPlacements extends GuiScreen {
@Override
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
- if(clickedElement != null) {
+ if (clickedElement != null) {
MBGuiGroupFloating mainGroup = NotEnoughUpdates.INSTANCE.overlay.guiGroup;
MBAnchorPoint anchorPoint = mainGroup.getChildrenMap().get(clickedElement);
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
int dX = mouseX - clickedX;
int dY = mouseY - clickedY;
- if(Math.abs(dX) > Math.abs(dY)) {
+ if (Math.abs(dX) > Math.abs(dY)) {
anchorPoint.offset.x = mouseX - clickedX + clickedAnchorX;
anchorPoint.offset.y = clickedAnchorY;
} else {
@@ -196,18 +199,20 @@ public class NEUOverlayPlacements extends GuiScreen {
}
int index = 0;
- for(MBGuiElement element : mainGroup.getChildren()) {
- if(element == clickedElement) {
- if(index == 0) {
+ for (MBGuiElement element : mainGroup.getChildren()) {
+ if (element == clickedElement) {
+ if (index == 0) {
NotEnoughUpdates.INSTANCE.config.hidden.overlaySearchBar = anchorPoint.toString();
- } else if(index == 1) {
+ } else if (index == 1) {
NotEnoughUpdates.INSTANCE.config.hidden.overlayQuickCommand = anchorPoint.toString();
}
break;
}
index++;
}
- try { MBDeserializer.serializeAndSave(mainGroup, "overlay"); } catch(Exception e) {}
+ try {
+ MBDeserializer.serializeAndSave(mainGroup, "overlay");
+ } catch (Exception ignored) {}
mainGroup.recalculate();
}
}
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..abef4db6 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,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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;
@@ -38,9 +37,8 @@ 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 {
@@ -50,44 +48,46 @@ public class StorageOverlay extends GuiElement {
private Framebuffer framebuffer = null;
- private Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
+ private final Set<Vector2f> enchantGlintRenderLocations = new HashSet<>();
- public static final ResourceLocation STORAGE_PREVIEW_TEXTURES[] = new ResourceLocation[4];
- private static final ResourceLocation STORAGE_TEXTURES[] = new ResourceLocation[4];
+ 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_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 < 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");
+ 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 GuiElementTextField searchBar = new GuiElementTextField("", 88, 10,
- GuiElementTextField.SCALE_TEXT | GuiElementTextField.DISABLE_BG);
- private GuiElementTextField renameStorageField = new GuiElementTextField("", 100, 13,
+ 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;
@@ -110,8 +110,8 @@ public class StorageOverlay extends GuiElement {
private int scrollVelocity = 0;
private long lastScroll = 0;
- private int[][] isPaneCaches = new int[40][];
- private int[][] ctmIndexCaches = new int[40][];
+ private final int[][] isPaneCaches = new int[40][];
+ private final int[][] ctmIndexCaches = new int[40][];
private int desiredHeightSwitch = -1;
private int desiredHeightMX = -1;
@@ -122,20 +122,20 @@ public class StorageOverlay extends GuiElement {
private int scrollGrabOffset = -1;
- private LerpingInteger scroll = new LerpingInteger(0, 200);
+ private final LerpingInteger scroll = new LerpingInteger(0, 200);
private int getMaximumScroll() {
- synchronized(StorageManager.getInstance().storageConfig.displayToStorageIdMapRender) {
+ 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;
+ 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;
+ int h = getPageCoords(coords).y + scroll.getValue() - getStorageViewSize() - 14;
- if(h > maxH) maxH = h;
+ if (h > maxH) maxH = h;
}
return maxH;
@@ -148,32 +148,32 @@ public class StorageOverlay extends GuiElement {
private void scrollToY(int y) {
int target = y;
- if(target < 0) target = 0;
+ if (target < 0) target = 0;
int maxY = getMaximumScroll();
- if(target > maxY) target = maxY;
+ if (target > maxY) target = maxY;
- float factor = (scroll.getValue()-target)/(float)(scroll.getValue()-y+1E-5);
+ 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.setTimeToReachTarget(Math.min(200, Math.max(20, (int) (200 * factor))));
scroll.resetTimer();
}
public void scrollToStorage(int displayId, boolean forceScroll) {
- if(displayId < 0) return;
+ if (displayId < 0) return;
- int y = getPageCoords(displayId).y-17;
- if(y < 3) {
+ 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) {
+ int y2 = getPageCoords(displayId + 3).y - 17 - storageViewSize;
+ if (y2 > 3) {
+ if (forceScroll) {
scrollToY(y + scroll.getValue());
} else {
- scrollToY(y2+scroll.getValue());
+ scrollToY(y2 + scroll.getValue());
}
}
}
@@ -189,7 +189,7 @@ public class StorageOverlay extends GuiElement {
@Override
public void render() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
GuiChest guiChest = (GuiChest) Minecraft.getMinecraft().currentScreen;
ContainerChest containerChest = (ContainerChest) guiChest.inventorySlots;
@@ -207,42 +207,42 @@ public class StorageOverlay extends GuiElement {
ResourceLocation storagePreviewTexture = STORAGE_PREVIEW_TEXTURES[displayStyle];
int textColour = 0x404040;
int searchTextColour = 0xe0e0e0;
- if(displayStyle == 2) {
+ if (displayStyle == 2) {
textColour = 0x000000;
searchTextColour = 0xa0a0a0;
- } else if(displayStyle == 3) {
+ } else if (displayStyle == 3) {
textColour = 0xFBCC6C;
- } else if(displayStyle == 0) {
+ } else if (displayStyle == 0) {
textColour = 0x909090;
searchTextColour = 0xa0a0a0;
}
long currentTime = System.currentTimeMillis();
- if(lastMillis > 0) {
+ if (lastMillis > 0) {
long deltaTime = currentTime - lastMillis;
millisAccumIndex += deltaTime;
- loadCircleIndex += millisAccumIndex / (1000/15);
- millisAccumIndex %= (1000/15);
+ loadCircleIndex += millisAccumIndex / (1000 / 15);
+ millisAccumIndex %= (1000 / 15);
millisAccumRotation += deltaTime;
- loadCircleRotation += millisAccumRotation / (1000/107);
- millisAccumRotation %= (1000/107);
+ loadCircleRotation += millisAccumRotation / (1000 / 107);
+ millisAccumRotation %= (1000 / 107);
millisAccumRoll += deltaTime;
- rollIndex += millisAccumRoll/100;
+ rollIndex += millisAccumRoll / 100;
millisAccumRoll %= 100;
}
lastMillis = currentTime;
loadCircleIndex %= LOAD_CIRCLE_SEQ.length;
- rollIndex %= NOT_RICKROLL_SEQ.length*2;
+ rollIndex %= NOT_RICKROLL_SEQ.length * 2;
loadCircleRotation %= 360;
- Color loadCircleColour = Color.getHSBColor(loadCircleRotation/360f, 0.3f, 0.9f);
+ Color loadCircleColour = Color.getHSBColor(loadCircleRotation / 360f, 0.3f, 0.9f);
ItemStack stackOnMouse = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
- if(stackOnMouse != null) {
+ if (stackOnMouse != null) {
String stackDisplay = Utils.cleanColour(stackOnMouse.getDisplayName());
- if(stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") ||
+ if (stackDisplay.startsWith("Backpack Slot ") || stackDisplay.startsWith("Empty Backpack Slot ") ||
stackDisplay.startsWith("Ender Chest Page ")) {
stackOnMouse = null;
}
@@ -254,18 +254,18 @@ public class StorageOverlay extends GuiElement {
int storageViewSize = getStorageViewSize();
int sizeX = 540;
- int sizeY = 100+storageViewSize;
+ int sizeY = 100 + storageViewSize;
int searchNobX = 18;
int itemHoverX = -1;
int itemHoverY = -1;
- guiLeft = width/2 - (sizeX-searchNobX)/2;
- guiTop = height/2 - sizeY/2;
+ guiLeft = width / 2 - (sizeX - searchNobX) / 2;
+ guiTop = height / 2 - sizeY / 2;
- if(displayStyle == 0) {
+ 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);
+ BackgroundBlur.renderBlurredBackground(7, width, height, guiLeft + 5, guiTop + storageViewSize, sizeX - searchNobX - 10, sizeY - storageViewSize - 4);
}
Utils.drawGradientRect(0, 0, width, height, 0xc0101010, 0xd0101010);
@@ -278,44 +278,44 @@ public class StorageOverlay extends GuiElement {
//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);
+ 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) {
+ if (scroll.getValue() > maxScroll) {
scroll.setValue(maxScroll);
}
- if(scroll.getValue() < 0) {
+ 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 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;
+ boolean mouseInsideStorages = mouseY > guiTop + 3 && mouseY < guiTop + 3 + storageViewSize;
//Storages
boolean doItemRender = true;
boolean doRenderFramebuffer = false;
int startY = getPageCoords(0).y;
- if(OpenGlHelper.isFramebufferEnabled()) {
+ 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;
+ 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();
+ 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);
+ if (framebuffer != null) {
+ GlScissorStack.push(0, guiTop + 3, width, guiTop + 3 + storageViewSize, scaledResolution);
GlStateManager.enableDepth();
GlStateManager.translate(0, startY, 107.0001f);
framebuffer.bindFramebufferTexture();
@@ -333,15 +333,15 @@ public class StorageOverlay extends GuiElement {
GlScissorStack.pop(scaledResolution);
}
- if(dirty || framebuffer == null) {
+ if (dirty || framebuffer == null) {
dirty = false;
- int fw = w*scaledResolution.getScaleFactor();
- int fh = h*scaledResolution.getScaleFactor();
+ int fw = w * scaledResolution.getScaleFactor();
+ int fh = h * scaledResolution.getScaleFactor();
- if(framebuffer == null) {
+ if (framebuffer == null) {
framebuffer = new Framebuffer(fw, fh, true);
- } else if(framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) {
+ } else if (framebuffer.framebufferWidth != fw || framebuffer.framebufferHeight != fh) {
framebuffer.createBindFramebuffer(fw, fh);
}
framebuffer.framebufferClear();
@@ -353,7 +353,7 @@ public class StorageOverlay extends GuiElement {
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GlStateManager.pushMatrix();
- GlStateManager.translate(-guiLeft, -guiTop-startY, 0);
+ GlStateManager.translate(-guiLeft, -guiTop - startY, 0);
doRenderFramebuffer = true;
} else {
@@ -361,9 +361,9 @@ public class StorageOverlay extends GuiElement {
}
}
- if(doItemRender) {
+ if (doItemRender) {
enchantGlintRenderLocations.clear();
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
+ for (Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
int displayId = entry.getKey();
int storageId = entry.getValue();
@@ -371,56 +371,56 @@ public class StorageOverlay extends GuiElement {
int storageX = coords.x;
int storageY = coords.y;
- if(!doRenderFramebuffer) {
- if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue;
+ 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) {
+ if (page != null && page.rows > 0) {
int rows = page.rows;
- isPaneCaches[storageId] = new int[page.rows*9];
- ctmIndexCaches[storageId] = new int[page.rows*9];
+ 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++) {
+ for (int k = 0; k < rows * 9; k++) {
ItemStack stack;
- if(storageId == currentPage) {
- stack = containerChest.getSlot(k+9).getStack();
+ 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);
+ int itemX = storageX + 1 + 18 * (k % 9);
+ int itemY = storageY + 1 + 18 * (k / 9);
//Render fancy glass
- if(stack != null) {
+ if (stack != null) {
int paneType = getPaneType(stack, k, isPaneCache);
- if(paneType > 0) {
+ if (paneType > 0) {
GlStateManager.disableAlpha();
- Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000);
+ 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;
+ int startCTMX = (ctmIndex % 12) * 19;
+ int startCTMY = (ctmIndex / 12) * 19;
ctmIndexCache[k] = ctmIndex;
- if(paneType != 17) {
- int rgb = getRGBFromPane(paneType-1);
+ 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);
+ 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];
@@ -533,15 +533,15 @@ public class StorageOverlay extends GuiElement {
//Render item
GlStateManager.translate(0, 0, 20);
- if(doRenderFramebuffer) {
+ 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) {
+
+ 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);
+ 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);
@@ -549,14 +549,14 @@ public class StorageOverlay extends GuiElement {
GL14.glBlendFuncSeparate(770, 771, 1, 0);
- if(stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) {
- enchantGlintRenderLocations.add(new Vector2f(itemX, itemY-startY));
+ if (stack != null && (stack.hasEffect() || stack.getItem() == Items.enchanted_book)) {
+ enchantGlintRenderLocations.add(new Vector2f(itemX, itemY - startY));
}
- } else if(storageId == currentPage) {
+ } 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);
+ 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);
@@ -571,7 +571,7 @@ public class StorageOverlay extends GuiElement {
}
}
- if(OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) {
+ if (OpenGlHelper.isFramebufferEnabled() && doRenderFramebuffer) {
GlStateManager.popMatrix();
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true);
@@ -582,8 +582,8 @@ public class StorageOverlay extends GuiElement {
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()) {
+ 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();
@@ -591,165 +591,165 @@ public class StorageOverlay extends GuiElement {
int storageX = coords.x;
int storageY = coords.y;
- if(coords.y-11 > 3+storageViewSize || coords.y+90 < 3) continue;
+ 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;
+
+ if (editingNameId == storageId) {
+ int len = fontRendererObj.getStringWidth(renameStorageField.getTextDisplay()) + 10;
renameStorageField.setSize(len, 12);
- renameStorageField.render(storageX, storageY-13);
+ renameStorageField.render(storageX, storageY - 13);
} else {
String pageTitle;
- if(page != null && page.customTitle != null && !page.customTitle.isEmpty()) {
+ if (page != null && page.customTitle != null && !page.customTitle.isEmpty()) {
pageTitle = Utils.chromaStringByColourCode(page.customTitle);
- } else if(entry.getValue() < 9) {
+ } else if (entry.getValue() < 9) {
pageTitle = "Ender Chest Page " + (entry.getValue() + 1);
} else {
- pageTitle = "Backpack Slot "+(storageId-8);
+ 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) {
+ 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);
+ fontRendererObj.drawString(pageTitle, storageX, storageY - 11, textColour);
}
- if(page == null) {
+ if (page == null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
GlStateManager.color(1, 1, 1, 1);
- int h = 18*3;
+ int h = 18 * 3;
- Utils.drawTexturedRect(storageX, storageY, 162, h, 0, 162 / 600f, 265 / 400f, (265+h) / 400f, GL11.GL_NEAREST);
+ 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) {
+ if (storageId < 9) {
Utils.drawStringCenteredScaledMaxWidth("Locked Page", fontRendererObj,
- storageX+81, storageY+h/2, true, 150, 0xd94c00);
+ storageX + 81, storageY + h / 2, true, 150, 0xd94c00);
} else {
Utils.drawStringCenteredScaledMaxWidth("Empty Backpack Slot", fontRendererObj,
- storageX+81, storageY+h/2, true, 150, 0xd94c00);
+ storageX + 81, storageY + h / 2, true, 150, 0xd94c00);
}
- } else if(page.rows <= 0) {
+ } else if (page.rows <= 0) {
Minecraft.getMinecraft().getTextureManager().bindTexture(storageTexture);
GlStateManager.color(1, 1, 1, 1);
- int h = 18*3;
+ 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);
+ storageX + 81, storageY + h / 2, true, 150, 0xffdf00);
} else {
int rows = page.rows;
int storageW = 162;
- int storageH = 18*rows;
+ 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;
+ 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++) {
+ 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);
+ 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) {
+ if (isPaneCache[k] == 17) {
int ctmIndex = getCTMIndex(page, k, isPaneCache, ctmIndexCache);
- int startCTMX = (ctmIndex%12)*19;
- int startCTMY = (ctmIndex/12)*19;
+ int startCTMX = (ctmIndex % 12) * 19;
+ int startCTMY = (ctmIndex / 12) * 19;
- int rgb = getRGBFromPane(isPaneCache[k]-1);
+ 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.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);
+ 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) {
+ } 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 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++) {
+ 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) {
+ if (type > 0) {
int ctmIndex = getCTMIndex(page, index, isPaneCache, ctmIndexCache);
- if(ctmIndex < 0) continue;
+ 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)) {
+ if ((k % 9 == 0 && index % 9 == 0) || (k % 9 == 8 && index % 9 == 8)) {
renderConnection = horizontal || vertical;
- } else if(index == leftIndex || index == rightIndex) {
+ } else if (index == leftIndex || index == rightIndex) {
renderConnection = horizontal;
} else {
renderConnection = vertical;
}
- if(renderConnection) {
+ if (renderConnection) {
shouldLimitBorder[k] = true;
hasConnection = true;
Minecraft.getMinecraft().getTextureManager().bindTexture(STORAGE_PANE_CTM_TEXTURE);
- int rgb = getRGBFromPane(type-1);
+ 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.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.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) {
+ if (index == leftIndex) {
vertFlip = true;
- } else if(index == downIndex) {
+ } 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);
+ !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);
+ !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();
@@ -757,12 +757,12 @@ public class StorageOverlay extends GuiElement {
}
}
- if(hasConnection) {
+ if (hasConnection) {
page.shouldDarkenIfNotSelected[k] = false;
GlStateManager.disableAlpha();
GlStateManager.translate(0, 0, 10);
- Gui.drawRect(itemX-1, itemY-1, itemX+17, itemY+17, 0x01000000);
+ Gui.drawRect(itemX - 1, itemY - 1, itemX + 17, itemY + 17, 0x01000000);
GlStateManager.translate(0, 0, -10);
GlStateManager.enableAlpha();
}
@@ -772,46 +772,46 @@ public class StorageOverlay extends GuiElement {
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);
+ 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++) {
+ 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);
+ 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())) {
+ 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);
+ 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) {
+ 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()) {
+ if (storageId != StorageManager.getInstance().getCurrentPageId()) {
hoveringOtherBackpack = true;
whiteOverlay = stackOnMouse == null;
- } else if(stack == null || allowHover) {
+ } else if (stack == null || allowHover) {
itemHoverX = itemX;
itemHoverY = itemY;
}
- if(stack != null && allowHover) {
+ 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) {
+ 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;
@@ -820,10 +820,10 @@ public class StorageOverlay extends GuiElement {
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) {
+ 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;
}
@@ -831,57 +831,57 @@ public class StorageOverlay extends GuiElement {
}
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;
+ 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
+ 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;
+ 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
+ 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
+ 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) {
+ if (allChroma) {
ResourceLocation loc;
- if(rollIndex < NOT_RICKROLL_SEQ.length) {
+ if (rollIndex < NOT_RICKROLL_SEQ.length) {
loc = NOT_RICKROLL_SEQ[rollIndex];
} else {
- loc = NOT_RICKROLL_SEQ[NOT_RICKROLL_SEQ.length*2-rollIndex-1];
+ loc = NOT_RICKROLL_SEQ[NOT_RICKROLL_SEQ.length * 2 - rollIndex - 1];
}
Minecraft.getMinecraft().getTextureManager().bindTexture(loc);
GlStateManager.color(1, 1, 1, 1);
@@ -889,63 +889,63 @@ public class StorageOverlay extends GuiElement {
}
} 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
+ 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 &&
+ } else if (currentTime - StorageManager.getInstance().storageOpenSwitchMillis < 1000 &&
StorageManager.getInstance().desiredStoragePage == storageId &&
StorageManager.getInstance().getCurrentPageId() != storageId) {
- Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x30000000);
+ 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.color(loadCircleColour.getRed() / 255f, loadCircleColour.getGreen() / 255f,
+ loadCircleColour.getBlue() / 255f, 1);
GlStateManager.pushMatrix();
- GlStateManager.translate(storageX+storageW/2, storageY+storageH/2, 0);
+ 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 (whiteOverlay) {
+ Gui.drawRect(storageX, storageY, storageX + storageW, storageY + storageH, 0x80ffffff);
} else {
- if(page.rows <= 0) {
- Gui.drawRect(storageX, storageY, storageX+storageW, storageY+storageH, 0x40000000);
+ 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);
+ 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) {
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ storageX + 81, storageY + storageH / 2 + 5, false, 150, 0xffdf00);
}
GlStateManager.enableDepth();
@@ -953,157 +953,159 @@ public class StorageOverlay extends GuiElement {
}
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);
+ 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);
+ fontRendererObj.drawString("Inventory", 180, storageViewSize + 6, textColour);
searchBar.setCustomTextColour(searchTextColour);
- searchBar.render(252, storageViewSize+5);
+ 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;
+ 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.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())) {
+ 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);
+ 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) {
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 && mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) {
itemHoverX = itemX;
itemHoverY = itemY;
- if(playerItems[i] != null) {
+ 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);
+ 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.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())) {
+ 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);
+ 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) {
+ 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);
+ 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);
+ 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) {
+ 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;
+ 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);
+ 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) {
+ 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;
+ 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++) {
+ 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;
+ int itemX = 10 + (i % 9) * 18;
+ int itemY = storageViewSize + 24 + (i / 9) * 18;
ItemStack stack;
- if(page != null && page.backpackDisplayStack != null) {
+ if (page != null && page.backpackDisplayStack != null) {
stack = page.backpackDisplayStack;
} else {
stack = StorageManager.LOCKED_ENDERCHEST_STACK;
}
- if(stack != null) {
+ if (stack != null) {
Utils.drawItemStack(stack, itemX, itemY);
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
+ 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;
+ 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;
+ 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) {
+ if (page != null && page.backpackDisplayStack != null) {
stack = page.backpackDisplayStack;
} else {
stack = StorageManager.getInstance().getMissingBackpackStack(i);
}
- if(stack != null) {
+ if (stack != null) {
Utils.drawItemStack(stack, itemX, itemY);
- if(mouseX >= guiLeft+itemX && mouseX < guiLeft+itemX+18 && mouseY >= guiTop+itemY && mouseY < guiTop+itemY+18) {
+ 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;
+ 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) {
+ if (!StorageManager.getInstance().onStorageMenu) {
List<String> tooltip = new ArrayList<>();
- for(String line : tooltipToDisplay) {
+ for (String line : tooltipToDisplay) {
tooltip.add(line.replace("Right-click to remove", "Click \"Edit\" to manage"));
}
tooltipToDisplay = tooltip;
@@ -1116,57 +1118,64 @@ public class StorageOverlay extends GuiElement {
//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;
+ 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;
+ float minU = (i * 16) / 256f;
+ float maxU = (i * 16 + 16) / 256f;
int vIndex = 0;
- switch(i) {
+ switch (i) {
case 2:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle; break;
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
+ break;
case 3:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview ? 1 : 0; break;
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview ? 1 : 0;
+ break;
case 4:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview ? 1 : 0; break;
+ vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview ? 1 : 0;
+ break;
case 5:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode ? 1 : 0; break;
+ 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;
+ 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;
+ 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);
+ 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) {
+ 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;
+ );
+ break;
case 1:
int tooltipStorageHeight = desiredHeightSwitch != -1 ? desiredHeightSwitch :
NotEnoughUpdates.INSTANCE.config.storageGUI.storageHeight;
tooltipToDisplay = createTooltip(
"Storage View Height",
- Math.round((tooltipStorageHeight-104)/52f),
+ Math.round((tooltipStorageHeight - 104) / 52f),
"Tiny",
"Small",
"Medium",
"Large",
"Huge"
);
- if(desiredHeightSwitch != -1) {
+ if (desiredHeightSwitch != -1) {
tooltipToDisplay.add("");
- tooltipToDisplay.add(EnumChatFormatting.YELLOW+"* Move mouse to apply changes *");
+ tooltipToDisplay.add(EnumChatFormatting.YELLOW + "* Move mouse to apply changes *");
}
break;
case 2:
@@ -1227,13 +1236,13 @@ public class StorageOverlay extends GuiElement {
}
}
- if(!StorageManager.getInstance().onStorageMenu) {
+ 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);
+ Utils.drawTexturedRect(171 - 36, 41 + storageViewSize, 36, 14, 24 / 600f, 60 / 600f, 251 / 400f, 265 / 400f, GL11.GL_NEAREST);
}
- if(itemHoverX >= 0 && itemHoverY >= 0) {
+ if (itemHoverX >= 0 && itemHoverY >= 0) {
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
Gui.drawRect(itemHoverX, itemHoverY, itemHoverX + 16, itemHoverY + 16, 0x80ffffff);
@@ -1244,46 +1253,46 @@ public class StorageOverlay extends GuiElement {
GlStateManager.popMatrix();
GlStateManager.translate(0, 0, 300);
allowTypingInSearchBar = false;
- if(stackOnMouse != null) {
+ if (stackOnMouse != null) {
GlStateManager.enableDepth();
- if(hoveringOtherBackpack) {
+ 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) {
+ } else if (slotPreview >= 0) {
StorageManager.StoragePage page = StorageManager.getInstance().getPage(slotPreview, false);
- if(page != null && page.rows > 0) {
+ 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);
+ 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, 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);
+ 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++) {
+ for (int i = 0; i < rows * 9; i++) {
ItemStack stack = page.items[i];
- if(stack != null) {
+ if (stack != null) {
GlStateManager.enableDepth();
- Utils.drawItemStack(stack, mouseX+8+18*(i%9), mouseY+8+18*(i/9));
+ 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);
+ 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 if (tooltipToDisplay != null) {
+ Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
} else {
allowTypingInSearchBar = true;
}
@@ -1291,97 +1300,126 @@ public class StorageOverlay extends GuiElement {
}
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;
+ 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) {
+ 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;
+ 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);
+ 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";
+ 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;
+ 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;
+ 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 (cache != null && cache[index] != 0) return cache[index];
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 2) {
- if(cache != null) cache[index] = -1;
+ 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))) {
+ 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;
+ 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;
+ if (cache != null) cache[index] = -1;
return -1;
}
@@ -1389,17 +1427,17 @@ public class StorageOverlay extends GuiElement {
String selPrefix = EnumChatFormatting.DARK_AQUA + " \u25b6 ";
String unselPrefix = EnumChatFormatting.GRAY.toString();
- for(int i=0; i<options.length; i++) {
- if(i == selectedOption) {
+ 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<String> list = Lists.newArrayList(options);
list.add(0, "");
- list.add(0, EnumChatFormatting.GREEN+title);
+ list.add(0, EnumChatFormatting.GREEN + title);
return list;
}
@@ -1414,88 +1452,88 @@ public class StorageOverlay extends GuiElement {
}
public IntPair getPageCoords(int displayId) {
- if(displayId < 0) displayId = 0;
+ if (displayId < 0) displayId = 0;
int y;
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode) {
- y = -scroll.getValue()+18+108*(displayId/3);
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode) {
+ y = -scroll.getValue() + 18 + 108 * (displayId / 3);
} else {
- y = -scroll.getValue()+17+104*(displayId/3);
+ y = -scroll.getValue() + 17 + 104 * (displayId / 3);
}
- for(int i=0; i<=displayId-3; i += 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;
+ 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)) {
+ 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) {
+ if (page == null || page.rows <= 0) {
maxRows = Math.max(maxRows, 3);
} else {
maxRows = Math.max(maxRows, page.rows);
}
}
- y -= (5-maxRows)*18;
+ y -= (5 - maxRows) * 18;
}
- return new IntPair(8+172*(displayId%3), y);
+ return new IntPair(8 + 172 * (displayId % 3), y);
}
@Override
public boolean mouseInput(int mouseX, int mouseY) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return false;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return false;
int dWheel = Mouse.getEventDWheel();
- if(!(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey != 0 &&
+ if (!(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey != 0 &&
KeybindHelper.isKeyDown(NotEnoughUpdates.INSTANCE.config.storageGUI.cancelScrollKey)) && dWheel != 0) {
- if(dWheel < 0) {
+ if (dWheel < 0) {
dWheel = -1;
- if(scrollVelocity > 0) scrollVelocity = 0;
+ if (scrollVelocity > 0) scrollVelocity = 0;
}
- if(dWheel > 0) {
+ if (dWheel > 0) {
dWheel = 1;
- if(scrollVelocity < 0) scrollVelocity = 0;
+ if (scrollVelocity < 0) scrollVelocity = 0;
}
long currentTime = System.currentTimeMillis();
- if(currentTime - lastScroll > 200) {
+ if (currentTime - lastScroll > 200) {
scrollVelocity = 0;
} else {
- scrollVelocity = (int)(scrollVelocity / 1.3f);
+ scrollVelocity = (int) (scrollVelocity / 1.3f);
}
lastScroll = currentTime;
- scrollVelocity += dWheel*10;
- scrollToY(scroll.getTarget()-scrollVelocity);
+ scrollVelocity += dWheel * 10;
+ scrollToY(scroll.getTarget() - scrollVelocity);
return true;
}
- if(Mouse.getEventButtonState()) {
+ if (Mouse.getEventButtonState()) {
editingNameId = -1;
}
- if(Mouse.getEventButton() == 0) {
- if(!Mouse.getEventButtonState()) {
+ 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());
+ } 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) {
+ if (scrollMouseY >= scrollBarY && scrollMouseY < scrollBarY + 12) {
scrollGrabOffset = scrollMouseY - scrollBarY;
}
}
}
- if(scrollGrabOffset >= 0 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
- int scrollMouseY = mouseY - (guiTop+8);
+ if (scrollGrabOffset >= 0 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
+ int scrollMouseY = mouseY - (guiTop + 8);
int scrollBarY = scrollMouseY - scrollGrabOffset;
- scrollToY(Math.round(scrollBarY*getMaximumScroll()/(float)getScrollBarHeight()));
+ scrollToY(Math.round(scrollBarY * getMaximumScroll() / (float) getScrollBarHeight()));
scroll.setTimeToReachTarget(10);
}
@@ -1506,31 +1544,31 @@ public class StorageOverlay extends GuiElement {
int storageViewSize = getStorageViewSize();
int sizeX = 540;
- int sizeY = 100+storageViewSize;
+ int sizeY = 100 + storageViewSize;
int searchNobX = 18;
- guiLeft = width/2 - (sizeX-searchNobX)/2;
- guiTop = height/2 - sizeY/2;
+ 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) {
+ 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());
+ 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) {
+ if (Mouse.getEventButton() == 1) {
searchBar.setText("");
StorageManager.getInstance().searchDisplay(searchBar.getText());
dirty = true;
@@ -1541,62 +1579,62 @@ public class StorageOverlay extends GuiElement {
}
}
- if(mouseX > guiLeft+181 && mouseX < guiLeft+181+162 &&
- mouseY > guiTop+storageViewSize+18 && mouseY < guiTop+storageViewSize+94) {
- if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
+ 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) {
+ if (mouseY > guiTop + 3 && mouseY < guiTop + storageViewSize + 3) {
int currentPage = StorageManager.getInstance().getCurrentPageId();
- for(Map.Entry<Integer, Integer> entry : StorageManager.getInstance().storageConfig.displayToStorageIdMapRender.entrySet()) {
+ 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;
+ 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) {
+ if (page != null) {
String pageTitle;
- if(page.customTitle != null && !page.customTitle.isEmpty()) {
+ if (page.customTitle != null && !page.customTitle.isEmpty()) {
pageTitle = page.customTitle;
- } else if(entry.getValue() < 9) {
+ } else if (entry.getValue() < 9) {
pageTitle = "Ender Chest Page " + (entry.getValue() + 1);
} else {
- pageTitle = "Backpack Slot "+(entry.getValue()-8);
+ 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()) {
+ 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)) {
+ if (!renameStorageField.getText().equalsIgnoreCase(pageTitle)) {
renameStorageField.setText(pageTitle);
}
}
- if(!renameStorageField.getFocus()) {
+ if (!renameStorageField.getFocus()) {
renameStorageField.setFocus(true);
} else {
- renameStorageField.mouseClicked(mouseX-guiLeft, mouseY-guiTop, Mouse.getEventButton());
+ renameStorageField.mouseClicked(mouseX - guiLeft, mouseY - guiTop, Mouse.getEventButton());
}
- } else if(Mouse.getEventButton() < 0 && Mouse.isButtonDown(0)) {
- renameStorageField.mouseClickMove(mouseX-guiLeft, mouseY-guiTop, 0, 0);
+ } 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) {
+ 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 &&
+ if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 &&
Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null &&
page != null) {
scrollToStorage(entry.getKey(), false);
@@ -1608,129 +1646,138 @@ public class StorageOverlay extends GuiElement {
}
}
- for(int i=0; i<10; i++) {
- int buttonX = 388+(i%5)*18;
- int buttonY = getStorageViewSize()+35+(i/5)*18;
+ 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;
+ float minU = (i * 16) / 256f;
+ float maxU = (i * 16 + 16) / 256f;
int vIndex = 0;
- switch(i) {
+ switch (i) {
case 2:
- vIndex = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle; break;
+ 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);
+ 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()) {
+ if (desiredHeightSwitch != -1 && Mouse.getEventButton() == -1 && !Mouse.getEventButtonState()) {
int delta = Math.abs(desiredHeightMX - mouseX) + Math.abs(desiredHeightMY - mouseY);
- if(delta > 3) {
+ 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);
+ 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 xIndex = xN / 18;
+ int yIndex = yN / 18;
- int buttonIndex = xIndex + 5*yIndex;
+ int buttonIndex = xIndex + 5 * yIndex;
- switch(buttonIndex) {
+ switch (buttonIndex) {
case 0:
- NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3 = false; break;
+ 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) {
+ 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;
+ size = sizeIndex * 54 + 104;
+ if (size < 104) size = 312;
+ if (size > 320) size = 104;
desiredHeightMX = mouseX;
desiredHeightMY = mouseY;
- desiredHeightSwitch = size; break;
+ desiredHeightSwitch = size;
+ break;
case 2:
int displayStyle = NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle;
- if(Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButton() == 0) {
displayStyle++;
} else {
displayStyle--;
}
- if(displayStyle < 0) displayStyle = STORAGE_TEXTURES.length-1;
- if(displayStyle >= STORAGE_TEXTURES.length) displayStyle = 0;
+ if (displayStyle < 0) displayStyle = STORAGE_TEXTURES.length - 1;
+ if (displayStyle >= STORAGE_TEXTURES.length) displayStyle = 0;
- NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle = displayStyle; break;
+ NotEnoughUpdates.INSTANCE.config.storageGUI.displayStyle = displayStyle;
+ break;
case 3:
NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview; break;
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.backpackPreview;
+ break;
case 4:
NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview; break;
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.enderchestPreview;
+ break;
case 5:
NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode; break;
+ !NotEnoughUpdates.INSTANCE.config.storageGUI.masonryMode;
+ break;
case 6:
int fancyPanes = NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes;
- if(Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButton() == 0) {
fancyPanes++;
} else {
fancyPanes--;
}
- if(fancyPanes < 0) fancyPanes = 2;
- if(fancyPanes >= 3) fancyPanes = 0;
+ if (fancyPanes < 0) fancyPanes = 2;
+ if (fancyPanes >= 3) fancyPanes = 0;
- NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes = fancyPanes; break;
+ NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes = fancyPanes;
+ break;
case 7:
NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus =
- !NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus; break;
+ !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) {
+ 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++) {
+ } 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 (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) {
+ 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;
+ 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 (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) {
+ if (mouseX >= guiLeft + itemX && mouseX < guiLeft + itemX + 18 &&
+ mouseY >= guiTop + itemY && mouseY < guiTop + itemY + 18) {
StorageManager.getInstance().sendToPage(storageId);
scrollToStorage(displayId, true);
return true;
@@ -1744,61 +1791,61 @@ public class StorageOverlay extends GuiElement {
}
public void overrideIsMouseOverSlot(Slot slot, int mouseX, int mouseY, CallbackInfoReturnable<Boolean> cir) {
- if(StorageManager.getInstance().shouldRenderStorageOverlayFast()) {
+ 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);
+ if (playerInv) {
+ if (slotId < 9) {
+ if (mouseY >= guiTop + storageViewSize + 76 && mouseY <= guiTop + storageViewSize + 92) {
+ int xN = mouseX - (guiLeft + 181);
- int xClicked = xN/18;
+ int xClicked = xN / 18;
- if(xClicked == slotId) {
+ if (xClicked == slotId) {
cir.setReturnValue(true);
return;
}
}
} else {
- int xN = mouseX-(guiLeft+181);
- int yN = mouseY-(guiTop+storageViewSize+18);
+ int xN = mouseX - (guiLeft + 181);
+ int yN = mouseY - (guiTop + storageViewSize + 18);
- int xClicked = xN/18;
- int yClicked = yN/18;
+ int xClicked = xN / 18;
+ int yClicked = yN / 18;
- if(xClicked >= 0 && xClicked <= 8 &&
+ if (xClicked >= 0 && xClicked <= 8 &&
yClicked >= 0 && yClicked <= 2) {
- if(xClicked + yClicked*9 + 9 == slotId) {
+ 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);
+ 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;
+ int xClicked = xN / 18;
- if(xClicked == slotId%9) {
+ 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);
+ } 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;
+ int xClicked = xN / 18;
+ int yClicked = yN / 18;
- if(xClicked == slotId%9 &&
- yClicked >= 0 && yClicked == slotId/9-3) {
+ if (xClicked == slotId % 9 &&
+ yClicked >= 0 && yClicked == slotId / 9 - 3) {
cir.setReturnValue(true);
return;
}
@@ -1806,19 +1853,19 @@ public class StorageOverlay extends GuiElement {
} else {
int currentPage = StorageManager.getInstance().getCurrentPageId();
int displayId = StorageManager.getInstance().getDisplayIdForStorageIdRender(currentPage);
- if(displayId >= 0) {
+ if (displayId >= 0) {
IntPair pageCoords = getPageCoords(displayId);
- int xN = mouseX-(guiLeft+pageCoords.x);
- int yN = mouseY-(guiTop+pageCoords.y);
+ int xN = mouseX - (guiLeft + pageCoords.x);
+ int yN = mouseY - (guiTop + pageCoords.y);
- int xClicked = xN/18;
- int yClicked = yN/18;
+ int xClicked = xN / 18;
+ int yClicked = yN / 18;
- if(xClicked >= 0 && xClicked <= 8 &&
+ if (xClicked >= 0 && xClicked <= 8 &&
yClicked >= 0 && yClicked <= 5) {
- if(xClicked + yClicked*9 + 9 == slotId) {
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.fancyPanes == 1 && slot.getHasStack() &&
+ 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;
@@ -1842,21 +1889,21 @@ public class StorageOverlay extends GuiElement {
@Override
public boolean keyboardInput() {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
clearSearch();
return false;
}
- if(Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindScreenshot.getKeyCode()) {
+ if (Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindScreenshot.getKeyCode()) {
return false;
}
- if(Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindFullscreen.getKeyCode()) {
+ if (Keyboard.getEventKey() == Minecraft.getMinecraft().gameSettings.keyBindFullscreen.getKeyCode()) {
return false;
}
- if(Keyboard.getEventKeyState()) {
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
+ 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;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return true;
GuiContainer container = (GuiContainer) Minecraft.getMinecraft().currentScreen;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -1865,8 +1912,8 @@ public class StorageOverlay extends GuiElement {
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 &&
+ 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());
@@ -1875,8 +1922,8 @@ public class StorageOverlay extends GuiElement {
}
}
- if(editingNameId >= 0) {
- if(Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
+ if (editingNameId >= 0) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
editingNameId = -1;
return true;
}
@@ -1885,28 +1932,26 @@ public class StorageOverlay extends GuiElement {
renameStorageField.setFocus(true);
searchBar.setFocus(false);
renameStorageField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(!prevText.equals(renameStorageField.getText())) {
+ if (!prevText.equals(renameStorageField.getText())) {
StorageManager.StoragePage page = StorageManager.getInstance().getPage(editingNameId, false);
- if(page != null) {
+ if (page != null) {
page.customTitle = renameStorageField.getText();
}
}
- } else if(searchBar.getFocus() || (allowTypingInSearchBar && NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus)) {
+ } 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())) {
+ if (!prevText.equals(searchBar.getText())) {
StorageManager.getInstance().searchDisplay(searchBar.getText());
dirty = true;
}
- if(NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus &&
+ if (NotEnoughUpdates.INSTANCE.config.storageGUI.searchBarAutofocus &&
searchBar.getText().isEmpty()) {
searchBar.setFocus(false);
}
- } else if(Keyboard.getEventKey() == Keyboard.KEY_E) {
- return false;
- }
+ } else return Keyboard.getEventKey() != Keyboard.KEY_E;
}
@@ -1914,13 +1959,14 @@ public class StorageOverlay extends GuiElement {
}
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;
+ 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) {
+ for (Vector2f loc : locations) {
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
GlStateManager.enableAlpha();
@@ -1941,8 +1987,8 @@ public class StorageOverlay extends GuiElement {
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.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();
@@ -1950,8 +1996,8 @@ public class StorageOverlay extends GuiElement {
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.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);
@@ -1967,8 +2013,8 @@ public class StorageOverlay extends GuiElement {
GlStateManager.bindTexture(0);
}
- public void fastRenderCheck(){
- if(!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
+ public void fastRenderCheck() {
+ if (!OpenGlHelper.isFramebufferEnabled() && NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
this.fastRender = true;
NEUEventListener.displayNotification(Lists.newArrayList(
"\u00a74Fast Render Warning",
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..d1df10c8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/TradeWindow.java
@@ -26,14 +26,14 @@ 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 ResourceLocation location = new ResourceLocation("notenoughupdates", "custom_trade.png");
private static final int xSize = 176;
private static final int ySize = 204;
@@ -53,20 +53,19 @@ public class TradeWindow {
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 (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return false;
+ if (!NotEnoughUpdates.INSTANCE.config.tradeMenu.enableCustomTrade) return false;
- if(hypixelTradeWindowActive(containerName)) {
+ if (hypixelTradeWindowActive(containerName)) {
return true;
}
- if(lastTradeMillis != -99) {
+ if (lastTradeMillis != -99) {
lastTradeMillis = -99;
ourTradeIndexes = new Integer[16];
theirTradeIndexes = new Integer[16];
@@ -78,13 +77,13 @@ public class TradeWindow {
}
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)) {
+ 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());
+ x + xOff / 2f, y + yOff / 2f, false, len,
+ new Color(20, 20, 20, 100 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB());
}
}
}
@@ -97,17 +96,17 @@ public class TradeWindow {
private static int getPrice(String internalname) {
int pricePer = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname);
- if(pricePer == -1) {
+ 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 (bazaarInfo != null && bazaarInfo.has("avg_buy")) {
+ pricePer = (int) bazaarInfo.get("avg_buy").getAsFloat();
}
}
- if(pricePer == -1) {
+ if (pricePer == -1) {
JsonObject info = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname);
- if(info != null && !NotEnoughUpdates.INSTANCE.manager.auctionManager.isVanillaItem(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());
+ int auctionPricePer = (int) (info.get("price").getAsFloat() / info.get("count").getAsFloat());
pricePer = auctionPricePer;
}
@@ -118,27 +117,30 @@ public class TradeWindow {
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")) {
+ 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++) {
+ for (int index = 0; index < clean.length(); index++) {
char c = clean.charAt(index);
- if("0123456789.".indexOf(c) >= 0) {
+ if ("0123456789.".indexOf(c) >= 0) {
sb.append(c);
} else {
- switch(c) {
+ switch (c) {
case 'K':
case 'k':
- mult = 1000; break;
+ mult = 1000;
+ break;
case 'M':
case 'm':
- mult = 1000000; break;
+ mult = 1000000;
+ break;
case 'B':
case 'b':
- mult = 1000000000; break;
+ mult = 1000000000;
+ break;
default:
break;
}
@@ -146,38 +148,38 @@ public class TradeWindow {
}
}
try {
- int coins = (int)(Float.parseFloat(sb.toString())*mult);
+ 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")) {
+ 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());
+ if (entry.getValue().isEmpty()) toRemove.add(entry.getKey());
}
topItems.keySet().removeAll(toRemove);
- Set<String> items = topItems.computeIfAbsent(existingPrice, k->new HashSet<>());
+ Set<String> items = topItems.computeIfAbsent(existingPrice, k -> new HashSet<>());
items.add("TRADE_COINS");
return coins;
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
} else {
int pricePer = getPrice(internalname);
- if(pricePer > 0) {
+ 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)) {
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
byte[] bytes = null;
@@ -187,22 +189,22 @@ public class TradeWindow {
break;
}
}
- if(bytes != null) {
+ 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) {
+ 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
+ if (id2 == 141) id2 = 391; //for some reason hypixel thinks carrots have id 141
Item mcItem = Item.getItemById(id2);
- if(mcItem == null) continue;
+ if (mcItem == null) continue;
ItemStack stack2 = new ItemStack(mcItem, count2, damage2);
stack2.setTagCompound(nbt);
@@ -210,26 +212,26 @@ public class TradeWindow {
priceInclBackpack += processTopItems(stack2, topItems, topItemsStack, topItemsCount);
}
}
- } catch(Exception e) { }
+ } 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)) {
+ 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());
+ if (entry.getValue().isEmpty()) toRemove.add(entry.getKey());
}
topItems.keySet().removeAll(toRemove);
- Set<String> items = topItems.computeIfAbsent(existingPrice, k->new HashSet<>());
+ 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);
+ int count = topItemsCount.computeIfAbsent(internalname, l -> 0);
+ topItemsCount.put(internalname, count + stack.stackSize);
return priceInclBackpack;
}
@@ -241,7 +243,7 @@ public class TradeWindow {
int price = 0;
NBTTagCompound tag = stack.getTagCompound();
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ if (tag != null && tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
byte[] bytes = null;
@@ -251,40 +253,40 @@ public class TradeWindow {
break;
}
}
- if(bytes != null) {
+ 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) {
+ 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) {
+ if (internalname2 != null) {
int pricePer2 = getPrice(internalname2);
- if(pricePer2 > 0) {
+ if (pricePer2 > 0) {
int count2 = items.getCompoundTagAt(k).getByte("Count");
price += pricePer2 * count2;
}
}
}
}
- } catch(Exception e) { }
+ } catch (Exception ignored) {}
}
}
return price;
}
public static void render(int mouseX, int mouseY) {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ 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;
+ guiLeft = (scaledResolution.getScaledWidth() - xSize) / 2;
+ guiTop = (scaledResolution.getScaledHeight() - ySize) / 2;
List<String> tooltipToDisplay = null;
ItemStack stackToRender = null;
@@ -293,38 +295,41 @@ public class TradeWindow {
//Set index mappings
//Our slots
TreeMap<Integer, List<Integer>> ourTradeMap = new TreeMap<>();
- for(int i=0; i<16; i++) {
+ for (int i = 0; i < 16; i++) {
ourTradeIndexes[i] = -1;
int x = i % 4;
int y = i / 4;
- int containerIndex = y*9+x;
+ int containerIndex = y * 9 + x;
ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
+ if (stack == null) continue;
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
- if(stack.getDisplayName().endsWith(" coins")) {
+ 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++) {
+ for (int index = 0; index < clean.length(); index++) {
char c = clean.charAt(index);
- if("0123456789.".indexOf(c) >= 0) {
+ if ("0123456789.".indexOf(c) >= 0) {
sb.append(c);
} else {
- switch(c) {
+ switch (c) {
case 'K':
case 'k':
- mult = 1000; break;
+ mult = 1000;
+ break;
case 'M':
case 'm':
- mult = 1000000; break;
+ mult = 1000000;
+ break;
case 'B':
case 'b':
- mult = 1000000000; break;
+ mult = 1000000000;
+ break;
default:
break;
}
@@ -332,12 +337,12 @@ public class TradeWindow {
}
}
try {
- int coins = (int)(Float.parseFloat(sb.toString())*mult);
+ int coins = (int) (Float.parseFloat(sb.toString()) * mult);
List<Integer> list = ourTradeMap.computeIfAbsent(coins, k -> new ArrayList<>());
list.add(containerIndex);
- } catch(Exception ignored) {
+ } catch (Exception ignored) {
List<Integer> list = ourTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
list.add(containerIndex);
}
@@ -347,7 +352,7 @@ public class TradeWindow {
}
} else {
int price = getPrice(internalname);
- if(price == -1) price = 0;
+ if (price == -1) price = 0;
price += getBackpackValue(stack);
@@ -359,60 +364,63 @@ public class TradeWindow {
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++) {
+ for (int i = 0; i < 16; i++) {
theirTradeIndexes[i] = -1;
- if(theirTradeChangesMillis[i] == null || currentTime - theirTradeChangesMillis[i] > CHANGE_EXCLAM_MILLIS) {
+ 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;
+ int containerIndex = y * 9 + x + 5;
ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
+ if (stack == null) continue;
NBTTagCompound tag = stack.getTagCompound();
String uuid = null;
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ 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);
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
}
} else {
- int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k->0);
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
}
- if(uuid != null) theirTradeCurrent.add(uuid);
+ if (uuid != null) theirTradeCurrent.add(uuid);
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname == null) {
- if(stack.getDisplayName().endsWith(" coins")) {
+ 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++) {
+ for (int index = 0; index < clean.length(); index++) {
char c = clean.charAt(index);
- if("0123456789.".indexOf(c) >= 0) {
+ if ("0123456789.".indexOf(c) >= 0) {
sb.append(c);
} else {
- switch(c) {
+ switch (c) {
case 'K':
case 'k':
- mult = 1000; break;
+ mult = 1000;
+ break;
case 'M':
case 'm':
- mult = 1000000; break;
+ mult = 1000000;
+ break;
case 'B':
case 'b':
- mult = 1000000000; break;
+ mult = 1000000000;
+ break;
default:
break;
}
@@ -420,12 +428,12 @@ public class TradeWindow {
}
}
try {
- int coins = (int)(Float.parseFloat(sb.toString())*mult);
+ int coins = (int) (Float.parseFloat(sb.toString()) * mult);
List<Integer> list = theirTradeMap.computeIfAbsent(coins, k -> new ArrayList<>());
list.add(containerIndex);
- } catch(Exception ignored) {
+ } catch (Exception ignored) {
List<Integer> list = theirTradeMap.computeIfAbsent(-1, k -> new ArrayList<>());
list.add(containerIndex);
}
@@ -436,14 +444,14 @@ public class TradeWindow {
} 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());
+ 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;
+ if (bazaarInfo != null && bazaarInfo.has("avg_buy")) {
+ price = (int) bazaarInfo.get("avg_buy").getAsFloat() * stack.stackSize;
}
}
@@ -454,58 +462,58 @@ public class TradeWindow {
}
}
int ourTradeIndex = 0;
- for(Map.Entry<Integer, List<Integer>> entry : ourTradeMap.descendingMap().entrySet()) {
- for(Integer index : entry.getValue()) {
+ 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++;
+ 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)) {
+ if (oldUUID != null && !theirTradeCurrent.contains(oldUUID)) {
theirTradeChangesMillis[j] = System.currentTimeMillis();
}
j++;
}
- for(int i=0; i<16; i++) {
+ 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 = 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;
+ if (stack == null) continue;
NBTTagCompound tag = stack.getTagCompound();
String uuid = null;
- if(tag != null && tag.hasKey("ExtraAttributes", 10)) {
+ 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);
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
}
} else {
- int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k->0);
+ int displayCount = displayCountMap.computeIfAbsent(stack.getDisplayName(), k -> 0);
uuid = stack.getDisplayName() + ":" + displayCount;
- displayCountMap.put(stack.getDisplayName(), displayCount+1);
+ displayCountMap.put(stack.getDisplayName(), displayCount + 1);
}
//System.out.println(uuid);
theirTradeOld[theirTradeIndex] = uuid;
@@ -517,42 +525,42 @@ public class TradeWindow {
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.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);
+ 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);
+ 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;
+ 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));
+ 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)) {
+ 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;
+ 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);
+ Utils.drawGradientRect(guiLeft + x, guiTop + y,
+ guiLeft + x + 16, guiTop + y + 16, col, col);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
@@ -562,27 +570,27 @@ public class TradeWindow {
index++;
}
- for(int i=0; i<16; i++) {
+ 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) {
+ if (containerIndex >= 0) {
stack = chest.inventorySlots.getInventory().get(containerIndex);
- Utils.drawItemStack(stack, guiLeft+10+x*18, guiTop+15+y*18);
+ 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;
+ 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);
+ 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();
@@ -591,10 +599,10 @@ public class TradeWindow {
}
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) {
+ 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);
}
@@ -602,62 +610,62 @@ public class TradeWindow {
}
ItemStack confirmStack = chest.inventorySlots.getInventory().get(39);
- if(confirmStack != null) {
+ 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) {
+ 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);
+ 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+"\\)");
+ 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!")) {
+ if (!confirmDisplay.equals(EnumChatFormatting.YELLOW + "Warning!") &&
+ !confirmDisplay.equals(EnumChatFormatting.YELLOW + "Deal!")) {
lastTradeMillis = -1;
}
- if(matcher.find()) {
+ 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,
+ } 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) {
+ } 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,
+ 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,
+ 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,
+ 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) {
+ if (theirConfirmStack != null) {
String confirmDisplay = theirConfirmStack.getDisplayName();
- if(mouseX > guiLeft+95 && mouseX < guiLeft+95+51) {
- if (mouseY > guiTop+91 && mouseY < guiTop+91+14) {
+ 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);
}
@@ -665,51 +673,51 @@ public class TradeWindow {
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);
+ 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,
+ 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,
+ } 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,
+ } 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++) {
+ 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) {
+ if (containerIndex >= 0) {
stack = chest.inventorySlots.getInventory().get(containerIndex);
- Utils.drawItemStack(stack, guiLeft+96+x*18, guiTop+15+y*18);
+ Utils.drawItemStack(stack, guiLeft + 96 + x * 18, guiTop + 15 + y * 18);
}
- if(currentTime % 400 > 200 && theirTradeChangesMillis[i] != null && theirTradeChangesMillis[i] > 0) {
+ 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);
+ 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;
+ 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);
+ 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();
@@ -717,18 +725,18 @@ public class TradeWindow {
}
}
- if(NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePrices) {
+ 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++) {
+ for (int i = 0; i < 16; i++) {
int x = i % 4;
int y = i / 4;
- int containerIndex = y*9+x;
+ int containerIndex = y * 9 + x;
ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
+ if (stack == null) continue;
ourPrice += processTopItems(stack, ourTopItems, ourTopItemsStack, ourTopItemsCount);
}
@@ -736,13 +744,13 @@ public class TradeWindow {
TreeMap<String, ItemStack> theirTopItemsStack = new TreeMap<>();
TreeMap<String, Integer> theirTopItemsCount = new TreeMap<>();
int theirPrice = 0;
- for(int i=0; i<16; i++) {
+ for (int i = 0; i < 16; i++) {
int x = i % 4;
int y = i / 4;
- int containerIndex = y*9+x+5;
+ int containerIndex = y * 9 + x + 5;
ItemStack stack = chest.inventorySlots.getInventory().get(containerIndex);
- if(stack == null) continue;
+ if (stack == null) continue;
theirPrice += processTopItems(stack, theirTopItems, theirTopItemsStack, theirTopItemsCount);
}
@@ -752,147 +760,146 @@ public class TradeWindow {
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());
+ 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()) {
+ 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 (stack == null) continue;
- if(NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
+ if (NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
String countS = "";
- if(ourTopItemsCount.containsKey(ourTopItemInternal)) {
+ 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";
+ if (count > 999999) {
+ countS = Math.floor(count / 10000f) / 100f + "m";
+ } else if (count > 999) {
+ countS = Math.floor(count / 10f) / 100f + "k";
} else {
- countS = ""+count;
+ countS = "" + count;
}
}
- Utils.drawItemStackWithText(stack, guiLeft-75-3, guiTop+49+18*ourTopIndex, countS);
+ 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);
+ 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);
+ 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;
+ 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());
+ 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()) {
+ 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 (stack == null) continue;
- if(NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
+ if (NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle) {
String countS = "";
- if(theirTopItemsCount.containsKey(theirTopItemInternal)) {
+ 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";
+ if (count > 999999) {
+ countS = Math.floor(count / 10000f) / 100f + "m";
+ } else if (count > 999) {
+ countS = Math.floor(count / 10f) / 100f + "k";
} else {
- countS = ""+count;
+ countS = "" + count;
}
}
- Utils.drawItemStackWithText(stack, guiLeft+xSize+25+3-16, guiTop+49+18*theirTopIndex, countS);
+ 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);
+ 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);
+ 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;
+ 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) {
+ 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");
+ 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) {
+ } 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");
+ 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) {
+ } 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");
+ tooltipToDisplay.add(EnumChatFormatting.GOLD + "Trade Prices Style");
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "Changes the style of the top item prices");
tooltipLen = 200;
}
}
- if(stackToRender != null) {
+ if (stackToRender != null) {
tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer,
Minecraft.getMinecraft().gameSettings.advancedItemTooltips);
}
- if(tooltipToDisplay != null) {
+ 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;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) return;
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledResolution.getScaledWidth();
@@ -901,24 +908,24 @@ public class TradeWindow {
int mouseX = Mouse.getEventX() * width / Minecraft.getMinecraft().displayWidth;
int mouseY = height - Mouse.getEventY() * height / Minecraft.getMinecraft().displayHeight - 1;
- GuiContainer chest = ((GuiContainer)Minecraft.getMinecraft().currentScreen);
+ 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) {
+ 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;
+ 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) {
+ 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 ||
+ if (!NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade ||
!SlotLocking.getInstance().isSlotLocked(slot)) {
Minecraft.getMinecraft().playerController.windowClick(
chest.inventorySlots.windowId,
@@ -931,15 +938,15 @@ public class TradeWindow {
index++;
}
- for(int i=0; i<16; i++) {
+ for (int i = 0; i < 16; i++) {
int x = i % 4;
int y = i / 4;
int containerIndex = ourTradeIndexes[i];
- if(containerIndex < 0) continue;
+ 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) {
+ 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);
@@ -948,8 +955,8 @@ public class TradeWindow {
}
}
- if(mouseX > guiLeft+10-1 && mouseX < guiLeft+10+18) {
- if(mouseY > guiTop+90-1 && mouseY < guiTop+90+18) {
+ 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);
@@ -958,15 +965,15 @@ public class TradeWindow {
}
ItemStack confirmStack = chest.inventorySlots.getInventory().get(39);
- if(confirmStack != null) {
+ 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) {
+ 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) {
+ } else if (lastTradeMillis < 0 || System.currentTimeMillis() - lastTradeMillis > 2000) {
Minecraft.getMinecraft().playerController.windowClick(
chest.inventorySlots.windowId,
39, 2, 3, Minecraft.getMinecraft().thePlayer);
@@ -978,16 +985,16 @@ public class TradeWindow {
}
}
- if(mouseX >= guiLeft+xSize+3 && mouseX <= guiLeft+xSize+3+17) {
- if(mouseY >= guiTop+ySize-19 && mouseY <= guiTop+ySize-19+17) {
+ 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) {
+ } 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) {
+ } else if (mouseY >= guiTop + ySize - 57 && mouseY <= guiTop + ySize - 57 + 17) {
NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle =
!NotEnoughUpdates.INSTANCE.config.tradeMenu.customTradePriceStyle;
return;
@@ -997,7 +1004,7 @@ public class TradeWindow {
}
public static boolean keyboardInput() {
- if(NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
+ if (NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking &&
NotEnoughUpdates.INSTANCE.config.slotLocking.lockSlotsInTrade &&
!Keyboard.isRepeatEvent() &&
KeybindHelper.isKeyPressed(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockKey)) {
@@ -1008,19 +1015,19 @@ public class TradeWindow {
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) {
+ 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;
+ 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) {
+ if (mouseX > guiLeft + x && mouseX < guiLeft + x + 16) {
+ if (mouseY > guiTop + y && mouseY < guiTop + y + 16) {
SlotLocking.getInstance().toggleLock(index);
return true;
}
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..f4d09b54 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,13 +1,7 @@
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 {
@@ -27,101 +21,101 @@ public class NeuTutorial extends TutorialBase {
// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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."));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// 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"));
+// buttons.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..48ee3bc7 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
@@ -31,14 +31,12 @@ public class TutorialBase extends GuiScreen {
protected static String title;
private int page = 0;
- private ResourceLocation screenshotBorder = new ResourceLocation("notenoughupdates:ss_border.jpg");
+ 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);
@@ -48,9 +46,9 @@ public class TutorialBase extends GuiScreen {
protected void keyTyped(char typedChar, int keyCode) throws IOException {
Keyboard.enableRepeatEvents(true);
super.keyTyped(typedChar, keyCode);
- if(keyCode == Keyboard.KEY_LEFT) {
+ if (keyCode == Keyboard.KEY_LEFT) {
page--;
- } else if(keyCode == Keyboard.KEY_RIGHT) {
+ } else if (keyCode == Keyboard.KEY_RIGHT) {
page++;
}
}
@@ -64,10 +62,10 @@ public class TutorialBase extends GuiScreen {
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;
+ 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);
@@ -75,12 +73,13 @@ public class TutorialBase extends GuiScreen {
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.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);
+ 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();
@@ -94,29 +93,27 @@ public class TutorialBase extends GuiScreen {
text.add(textArray.get(j).getAsString());
}
+ float x = guiLeft + 20f / scaleFactor + (sizeX - 40f / scaleFactor) * oldX;
+ float y = guiTop + 20f / scaleFactor + (sizeY - 40f / scaleFactor) * oldY;
- 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);
+ Utils.drawHoveringText(text, (int) x, (int) y + 12, 100000, 100000, 200, Minecraft.getMinecraft().fontRendererObj);
}
drawButtons();
}
- protected void drawButtons(){
+ protected void drawButtons() {
- for (int i = 0; i < buttons.size(); i++) {
- JsonObject button = buttons.get(i);
+ 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){
+ if (pages.get(i1).getAsInt() == page) {
drawButton = true;
break;
}
}
- if(!drawButton){
+ if (!drawButton) {
continue;
}
float x = button.get("x").getAsFloat();
@@ -125,9 +122,8 @@ public class TutorialBase extends GuiScreen {
// 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);
-
+ 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);
}
}
@@ -135,51 +131,46 @@ public class TutorialBase extends GuiScreen {
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
- int width= 88;
+ int width = 88;
int height = 20;
- for (int i = 0; i < buttons.size(); i++) {
- JsonObject button = buttons.get(i);
+ 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){
+ if (pages.get(i1).getAsInt() == page) {
drawButton = true;
break;
}
}
- if(!drawButton){
+ 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){
+ 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);
+ ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/" + command);
return;
}
}
}
-
-
-
-
- protected static List<JsonArray> texts = new ArrayList<JsonArray>();
+ 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){
+ 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]));
+ for (int j : pages) {
+ pagesArray.add(new JsonPrimitive(j));
}
- button.add("pages",pagesArray);
+ button.add("pages", pagesArray);
button.add("x", new JsonPrimitive(x));
button.add("y", new JsonPrimitive(y));
button.add("text", new JsonPrimitive(text));
@@ -187,33 +178,33 @@ public class TutorialBase extends GuiScreen {
return button;
}
- protected static JsonArray createNewTexts(JsonObject... texts){
+ protected static JsonArray createNewTexts(JsonObject... texts) {
JsonArray textArray = new JsonArray();
- for (int i = 0; i < texts.length; i++) {
- textArray.add(texts[i]);
+ for (JsonObject text : texts) {
+ textArray.add(text);
}
return textArray;
}
- protected static JsonObject createNewText(float x, float y, String... texts){
+ 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]));
+ 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){
+ 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)));
+ for (String text : texts) {
+ lines.add(new JsonPrimitive(text));
}
tooltip.add("lines", lines);
return tooltip;
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..ec2843eb 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;
@@ -13,28 +11,28 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(AbstractClientPlayer.class)
public class MixinAbstractClientPlayer {
- @Inject(method="hasSkin", at=@At("HEAD"), cancellable = 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) {
+ 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)
+ @Inject(method = "getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at = @At("HEAD"), cancellable = true)
public void getLocationSkin(CallbackInfoReturnable<ResourceLocation> cir) {
- AbstractClientPlayer $this = (AbstractClientPlayer)(Object)this;
+ AbstractClientPlayer $this = (AbstractClientPlayer) (Object) this;
NPCRetexturing.Skin skin = NPCRetexturing.getInstance().getSkin($this);
- if(skin != null) {
+ if (skin != null) {
cir.setReturnValue(skin.skinLocation);
}
}
- @Inject(method="getSkinType", at=@At("HEAD"), cancellable = true)
+ @Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true)
public void getSkinType(CallbackInfoReturnable<String> cir) {
- AbstractClientPlayer $this = (AbstractClientPlayer)(Object)this;
+ AbstractClientPlayer $this = (AbstractClientPlayer) (Object) this;
NPCRetexturing.Skin skin = NPCRetexturing.getInstance().getSkin($this);
- if(skin != null) {
+ 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..28a4a6fd 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinContainer.java
@@ -2,20 +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"))
+ @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..efb1824e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEffectRenderer.java
@@ -5,16 +5,14 @@ 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(
+ @Redirect(method = "renderParticles", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V")
)
@@ -22,7 +20,7 @@ public class MixinEffectRenderer {
GlStateManager.enableBlend();
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ 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/MixinEntityPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java
index 8757e369..3d930623 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java
@@ -11,13 +11,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin({EntityPlayer.class})
public abstract class MixinEntityPlayer {
- @Inject(method="isWearing", at=@At("HEAD"), cancellable = true)
+ @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;
+ 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")) {
+ 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..70db4b2c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java
@@ -15,16 +15,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(EntityPlayerSP.class)
public class MixinEntityPlayerSP {
- @Inject(method="dropOneItem", at=@At("HEAD"), cancellable = true)
+ @Inject(method = "dropOneItem", at = @At("HEAD"), cancellable = true)
public void dropOneItem(CallbackInfoReturnable<EntityItem> ci) {
- if(SBInfo.getInstance().isInDungeon) {
+ if (SBInfo.getInstance().isInDungeon) {
return;
}
int slot = Minecraft.getMinecraft().thePlayer.inventory.currentItem;
- if(SlotLocking.getInstance().isSlotIndexLocked(slot) || SlotLocking.getInstance().isSwapedSlotLocked()) {
+ if (SlotLocking.getInstance().isSlotIndexLocked(slot) || SlotLocking.getInstance().isSwapedSlotLocked()) {
ci.cancel();
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+
+ 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..5a2cac8a 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;
@@ -29,48 +25,52 @@ 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
+ protected abstract float getFOVModifier(float partialTicks, boolean useFOVSetting);
- @Shadow private Minecraft mc;
+ @Shadow
+ private Minecraft mc;
- @Shadow private float farPlaneDistance;
+ @Shadow
+ private float farPlaneDistance;
- @Shadow protected abstract void orientCamera(float partialTicks);
+ @Shadow
+ protected abstract void orientCamera(float partialTicks);
- @Inject(method="getFOVModifier", at=@At("RETURN"), cancellable = true)
+ @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",
+ @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",
+ @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()) {
+ if (!FancyPortals.overridePerspective()) {
Project.gluPerspective(f1, f2, f3, f4);
}
}
- @Inject(method="updateCameraAndRender", at=@At("RETURN"))
+ @Inject(method = "updateCameraAndRender", at = @At("RETURN"))
public void onUpdateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) {
- if(Minecraft.getMinecraft().getRenderViewEntity() == null) return;
+ if (Minecraft.getMinecraft().getRenderViewEntity() == null) return;
- if(FancyPortals.shouldRenderWorldOverlay()) {
+ if (FancyPortals.shouldRenderWorldOverlay()) {
GlStateManager.matrixMode(5889);
GlStateManager.loadIdentity();
Project.gluPerspective(getFOVModifier(partialTicks, true),
- (float)mc.displayWidth / (float)this.mc.displayHeight, 0.05F,
+ (float) mc.displayWidth / (float) this.mc.displayHeight, 0.05F,
farPlaneDistance * MathHelper.SQRT_2);
GlStateManager.matrixMode(5888);
GlStateManager.loadIdentity();
@@ -82,18 +82,18 @@ public abstract class MixinEntityRenderer {
}
}
- @Redirect(method="renderWorldPass", at=@At(
- value="INVOKE",
+ @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) {
+ 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;
+ 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);
@@ -104,56 +104,56 @@ public abstract class MixinEntityRenderer {
}
//orientCamera
- @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 0)
+ @ModifyVariable(method = "orientCamera", at = @At(value = "STORE"), ordinal = 0)
public double orientCamera_d0(double d0) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.x;
}
return d0;
}
- @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 1)
+ @ModifyVariable(method = "orientCamera", at = @At(value = "STORE"), ordinal = 1)
public double orientCamera_d1(double d1) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.y;
}
return d1;
}
- @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 2)
+ @ModifyVariable(method = "orientCamera", at = @At(value = "STORE"), ordinal = 2)
public double orientCamera_d2(double d2) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.z;
}
return d2;
}
//renderWorldPass
- @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 0)
+ @ModifyVariable(method = "renderWorldPass", at = @At(value = "STORE"), ordinal = 0)
public double renderWorldPass_d0(double d0) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.x;
}
return d0;
}
- @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 1)
+ @ModifyVariable(method = "renderWorldPass", at = @At(value = "STORE"), ordinal = 1)
public double renderWorldPass_d1(double d1) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.y;
}
return d1;
}
- @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 2)
+ @ModifyVariable(method = "renderWorldPass", at = @At(value = "STORE"), ordinal = 2)
public double renderWorldPass_d2(double d2) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ 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..fada73ed 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java
@@ -14,28 +14,30 @@ public class MixinGuiChest {
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))
+
+ @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))
+
+ @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))
+
+ @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")
+ 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) {}
+ } 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..2e79dea4 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;
@@ -41,20 +41,20 @@ 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!");
+ EnumChatFormatting.YELLOW + "Click to open NEU profile viewer!");
- @Inject(method="drawSlot", at=@At("RETURN"))
+ @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)
+ @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true)
public void drawSlot(Slot slot, CallbackInfo ci) {
- if(slot == null) return;
+ if (slot == null) return;
- GuiContainer $this = (GuiContainer)(Object)this;
+ GuiContainer $this = (GuiContainer) (Object) this;
- if(!hasProfileViewerStack && $this instanceof GuiChest && slot.getSlotIndex() > 9 && (slot.getSlotIndex() % 9 == 6 || slot.getSlotIndex() % 9 == 7) &&
+ 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;
@@ -62,13 +62,13 @@ public abstract class MixinGuiContainer extends GuiScreen {
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){
+ 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")){
+ 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()))) {
+ if (tagName.equals(displayname.substring(displayname.length() - tagName.length()))) {
ci.cancel();
this.zLevel = 100.0F;
@@ -89,23 +89,23 @@ public abstract class MixinGuiContainer extends GuiScreen {
}
} else if (slot.getSlotIndex() == 0)
hasProfileViewerStack = false;
- else if(!($this instanceof GuiChest))
+ else if (!($this instanceof GuiChest))
BetterContainers.profileViewerStackIndex = -1;
- if(slot.getStack() == null && NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
+ 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);
+ 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)) {
+ if (stack != null) {
+ if (EnchantingSolvers.onStackRender(stack, slot.inventory, slot.getSlotIndex(), slot.xDisplayPosition, slot.yDisplayPosition)) {
ci.cancel();
return;
}
@@ -113,24 +113,24 @@ public abstract class MixinGuiContainer extends GuiScreen {
RenderHelper.enableGUIStandardItemLighting();
- if(BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(slot.slotNumber, stack)) {
+ if (BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(slot.slotNumber, stack)) {
ci.cancel();
}
}
- @Redirect(method="drawScreen", at=@At(
+ @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) {
+ if (theSlot.slotNumber == BetterContainers.profileViewerStackIndex) {
this.renderToolTip(profileViewerStack, x, y);
} else {
this.renderToolTip(stack, x, y);
}
}
- @Inject(method="drawScreen",
- at=@At(
+ @Inject(method = "drawScreen",
+ at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V",
shift = At.Shift.AFTER
@@ -140,21 +140,21 @@ public abstract class MixinGuiContainer extends GuiScreen {
AuctionSortModeWarning.getInstance().onPostGuiRender();
}
- @Redirect(method="mouseReleased", at=@At(value = "INVOKE", target = "Ljava/util/Set;isEmpty()Z"))
+ @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)
+ @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"))
+ @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 &&
+ if (startColor == 0x80ffffff && endColor == 0x80ffffff &&
theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
int col = 0x80ff8080;
drawGradientRect(left, top, right, bottom, col, col);
@@ -166,52 +166,53 @@ public abstract class MixinGuiContainer extends GuiScreen {
@Shadow
private Slot theSlot;
- @Inject(method="drawScreen", at=@At("RETURN"))
+ @Inject(method = "drawScreen", at = @At("RETURN"))
public void drawScreen(CallbackInfo ci) {
- if(theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
+ if (theSlot != null && SlotLocking.getInstance().isSlotLocked(theSlot)) {
SlotLocking.getInstance().setRealSlot(theSlot);
theSlot = null;
- } else if(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))
+
+ @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = TARGET_GETSTACK))
public ItemStack drawScreen_getStack(Slot slot) {
- if(theSlot != null && theSlot == slot && theSlot.getStack() != null) {
+ if (theSlot != null && theSlot == slot && theSlot.getStack() != null) {
ItemStack newStack = EnchantingSolvers.overrideStack(theSlot.inventory, theSlot.getSlotIndex(), theSlot.getStack());
- if(newStack != null) {
+ if (newStack != null) {
return newStack;
}
}
return slot.getStack();
}
- @Redirect(method="drawSlot", at=@At(value="INVOKE", target=TARGET_GETSTACK))
+ @Redirect(method = "drawSlot", at = @At(value = "INVOKE", target = TARGET_GETSTACK))
public ItemStack drawSlot_getStack(Slot slot) {
- GuiContainer $this = (GuiContainer)(Object)this;
+ GuiContainer $this = (GuiContainer) (Object) this;
ItemStack stack = slot.getStack();
- if(stack != null) {
+ if (stack != null) {
ItemStack newStack = EnchantingSolvers.overrideStack(slot.inventory, slot.getSlotIndex(), stack);
- if(newStack != null) {
+ if (newStack != null) {
stack = newStack;
}
}
- if($this instanceof GuiChest) {
- Container container = ((GuiChest)$this).inventorySlots;
- if(container instanceof ContainerChest) {
- IInventory lower = ((ContainerChest)container).getLowerChestInventory();
+ 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) {
+ 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) {
+ 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;
}
@@ -226,27 +227,28 @@ public abstract class MixinGuiContainer extends GuiScreen {
}
private static final String TARGET_CANBEHOVERED = "Lnet/minecraft/inventory/Slot;canBeHovered()Z";
- @Redirect(method="drawScreen", at=@At(value="INVOKE", target=TARGET_CANBEHOVERED))
+
+ @Redirect(method = "drawScreen", at = @At(value = "INVOKE", target = TARGET_CANBEHOVERED))
public boolean drawScreen_canBeHovered(Slot slot) {
- if(NotEnoughUpdates.INSTANCE.config.improvedSBMenu.hideEmptyPanes &&
+ 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)){
+ @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)
+ @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;
+ GuiContainer $this = (GuiContainer) (Object) this;
- if(AuctionBINWarning.getInstance().onMouseClick(slotIn, slotId, clickedButton, clickType)) {
+ if (AuctionBINWarning.getInstance().onMouseClick(slotIn, slotId, clickedButton, clickType)) {
ci.cancel();
return;
}
@@ -255,7 +257,7 @@ public abstract class MixinGuiContainer extends GuiScreen {
SlotLocking.getInstance().onWindowClick(slotIn, slotId, clickedButton, clickType, (tuple) -> {
ci.cancel();
- if(tuple == null) {
+ if (tuple == null) {
ret.set(true);
} else {
int newSlotId = tuple.getLeft();
@@ -266,10 +268,10 @@ public abstract class MixinGuiContainer extends GuiScreen {
$this.mc.playerController.windowClick($this.inventorySlots.windowId, newSlotId, newClickedButton, newClickedType, $this.mc.thePlayer);
}
});
- if(ret.get()) return;
+ if (ret.get()) return;
- if(slotIn != null && slotIn.getStack() != null) {
- if(EnchantingSolvers.onStackClick(slotIn.getStack(), $this.inventorySlots.windowId,
+ if (slotIn != null && slotIn.getStack() != null) {
+ if (EnchantingSolvers.onStackClick(slotIn.getStack(), $this.inventorySlots.windowId,
slotId, clickedButton, clickType)) {
ci.cancel();
} else {
@@ -277,11 +279,11 @@ public abstract class MixinGuiContainer extends GuiScreen {
slotId, clickedButton, clickType);
}
}
- if(slotIn != null && BetterContainers.isOverriding() && (BetterContainers.isBlankStack(slotIn.slotNumber, slotIn.getStack()) ||
+ 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())) {
+ if (BetterContainers.isBlankStack(slotIn.slotNumber, slotIn.getStack())) {
$this.mc.playerController.windowClick($this.inventorySlots.windowId, slotId, 2, clickType, $this.mc.thePlayer);
ci.cancel();
} else {
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..3842a3c4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiIngame.java
@@ -22,31 +22,32 @@ public class MixinGuiIngame {
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))
+
+ @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) {
+ 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"))
+ @Inject(method = "renderTooltip", at = @At("HEAD"))
protected void renderTooltip(ScaledResolution sr, float partialTicks, CallbackInfo ci) {
- if(Minecraft.getMinecraft().getRenderViewEntity() instanceof EntityPlayer) {
+ 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"))
+ @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) {
+ 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;"))
+ @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 &&
+ if (!NotEnoughUpdates.INSTANCE.config.storageGUI.showInvBackpackPreview &&
InventoryStorageSelector.getInstance().isSlotSelected()) {
return InventoryStorageSelector.getInstance().getNamedHeldItemOverride();
}
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..4f481d4f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiInventory.java
@@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(GuiInventory.class)
public class MixinGuiInventory {
- @Inject(method="drawGuiContainerForegroundLayer", at=@At("HEAD"), cancellable = true)
+ @Inject(method = "drawGuiContainerForegroundLayer", at = @At("HEAD"), cancellable = true)
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY, CallbackInfo ci) {
- if(NotEnoughUpdates.INSTANCE.config.inventoryButtons.hideCrafting ||
+ 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..6dcad539 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;
@@ -11,7 +10,7 @@ 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"))
+ @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..0885502d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryEffectRenderer.java
@@ -4,16 +4,14 @@ 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"))
+ @ModifyVariable(method = "updateActivePotionEffects", at = @At(value = "STORE"))
public boolean hasVisibleEffect_updateActivePotionEffects(boolean hasVisibleEffect) {
- if(NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect &&
+ if (NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect &&
NotEnoughUpdates.INSTANCE.isOnSkyblock()) {
return false;
} else {
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..a9cb71da 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinInventoryPlayer.java
@@ -11,18 +11,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(InventoryPlayer.class)
public class MixinInventoryPlayer {
- @Inject(method="changeCurrentItem", at=@At("RETURN"))
+ @Inject(method = "changeCurrentItem", at = @At("RETURN"))
public void changeCurrentItemReturn(int direction, CallbackInfo ci) {
- InventoryPlayer $this = (InventoryPlayer)(Object)this;
+ InventoryPlayer $this = (InventoryPlayer) (Object) this;
$this.currentItem = InventoryStorageSelector.getInstance().onScroll(direction, $this.currentItem);
-
}
- @Inject(method="changeCurrentItem", at=@At("HEAD"))
+ @Inject(method = "changeCurrentItem", at = @At("HEAD"))
public void changeCurrentItemHead(int direction, CallbackInfo ci) {
- InventoryPlayer $this = (InventoryPlayer)(Object)this;
+ 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..94277c54 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemCameraTransforms.java
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ItemCameraTransforms.class)
public class MixinItemCameraTransforms {
- @Inject(method="applyTransform", at=@At("HEAD"))
+ @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..8ea0642e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java
@@ -1,29 +1,22 @@
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(
+ @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()) {
+ 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..6ba253af 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java
@@ -4,22 +4,18 @@ 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)
+ @Inject(method = "hasEffect", at = @At("HEAD"), cancellable = true)
public void hasEffect(CallbackInfoReturnable<Boolean> cir) {
- if(Utils.getHasEffectOverride()) {
+ if (Utils.getHasEffectOverride()) {
cir.setReturnValue(false);
return;
}
@@ -28,29 +24,28 @@ public class MixinItemStack {
@Shadow
private NBTTagCompound stackTagCompound;
- @Inject(method="getDisplayName",at=@At("HEAD"), cancellable=true)
+ @Inject(method = "getDisplayName", at = @At("HEAD"), cancellable = true)
public void getDisplayName(CallbackInfoReturnable<String> returnable) {
try {
- if(stackTagCompound == null || !stackTagCompound.hasKey("ExtraAttributes", 10)) {
+ if (stackTagCompound == null || !stackTagCompound.hasKey("ExtraAttributes", 10)) {
return;
}
- ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem((ItemStack)(Object)this);
+ ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem((ItemStack) (Object) this);
- if(data != null && data.customName != null) {
+ if (data != null && data.customName != null) {
String customName = data.customName;
- if(customName != null && !customName.equals("")) {
+ if (customName != null && !customName.equals("")) {
customName = Utils.chromaStringByColourCode(customName);
- if(data.customNamePrefix != null) {
+ if (data.customNamePrefix != null) {
customName = data.customNamePrefix + customName;
}
returnable.setReturnValue(customName);
}
}
- } catch(Exception e) { }
+ } 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..0a56a9ce 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerArmorBase.java
@@ -18,17 +18,17 @@ public abstract class MixinLayerArmorBase<T extends ModelBase> {
private static String customEnchGlint = null;
- @Redirect(method="renderLayer",
- at=@At(
+ @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) {
+ if (data != null) {
customEnchGlint = data.customGlintColour;
- if(data.overrideEnchantGlint) {
+ if (data.overrideEnchantGlint) {
return data.enchantGlintValue;
}
} else {
@@ -38,26 +38,25 @@ public abstract class MixinLayerArmorBase<T extends ModelBase> {
return stack.hasEffect();
}
- @Inject(method="renderGlint", at=@At("HEAD"), cancellable = true)
+ @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);
- })) {
+ 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(
+ @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) {
+ if (data != null && data.customLeatherColour != null) {
return ChromaColour.specialToChromaRGB(data.customLeatherColour);
}
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..77e49e7b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLayerCustomHead.java
@@ -20,21 +20,21 @@ public class MixinLayerCustomHead {
private static String customGlintColour = null;
- @Inject(method="doRenderLayer", at=@At("HEAD"))
+ @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) {
+ if (data != null && data.overrideEnchantGlint && data.enchantGlintValue) {
customGlintColour = data.customGlintColour;
} else {
customGlintColour = null;
}
}
- @Redirect(method="doRenderLayer",
- at=@At(
+ @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"
)
@@ -47,7 +47,7 @@ public class MixinLayerCustomHead {
p_180543_6_, p_180543_7_, p_180543_8_);
GL11.glPopMatrix();
- if(customGlintColour != null) {
+ if (customGlintColour != null) {
ItemCustomizeManager.renderEffectHook(customGlintColour, (color) -> {
float red = ((color >> 16) & 0xFF) / 255f;
float green = ((color >> 8) & 0xFF) / 255f;
@@ -56,7 +56,7 @@ public class MixinLayerCustomHead {
GlStateManager.color(red, green, blue, alpha);
- GlStateManager.scale(1/8f, 1/8f, 1/8f);
+ GlStateManager.scale(1 / 8f, 1 / 8f, 1 / 8f);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
ItemCustomizeManager.disableTextureBinding = true;
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..fff9f29d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java
@@ -2,19 +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)
+ @Inject(method = "setLoadingProgress", at = @At(value = "HEAD"), cancellable = true)
public void setLoadingProgress(int progress, CallbackInfo ci) {
- if(progress < 0 && !FancyPortals.shouldRenderLoadingScreen()) {
+ 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..4b667218 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java
@@ -1,46 +1,41 @@
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 were'nt being loaded before
-/* @Shadow public WorldClient theWorld;
+ //Commented as they weren't 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() {
- }*/
+ @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){
+ 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..8e14c583 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMouseHelper.java
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MouseHelper.class)
public class MixinMouseHelper {
- @Inject(method = { "ungrabMouseCursor" }, at = { @At("HEAD") }, cancellable = true)
+ @Inject(method = {"ungrabMouseCursor"}, at = {@At("HEAD")}, cancellable = true)
public void ungrabMouseCursor(final CallbackInfo ci) {
if (System.currentTimeMillis() - NEUEventListener.lastGuiClosed < 150L) {
ci.cancel();
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..c67d3a07 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;
@@ -21,15 +19,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
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))
+
+ @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) {
+ if (CustomItemEffects.INSTANCE.aoteTeleportationCurr != null) {
CustomItemEffects.INSTANCE.aoteTeleportationMillis += Math.max(0, Math.min(300, CustomItemEffects.INSTANCE.tpTime));
}
player.setPositionAndRotation(x, y, z, yaw, pitch);
}
- @Redirect(method="handleParticles", at=@At(
+ @Redirect(method = "handleParticles", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/multiplayer/WorldClient;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;ZDDDDDD[I)V"
))
@@ -37,38 +36,38 @@ public class MixinNetHandlerPlayClient {
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) {
+ if (!override) {
world.spawnParticle(particleTypes, isLongDistance, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, params);
}
}
- @Inject(method="handleSpawnMob", at=@At("RETURN"))
+ @Inject(method = "handleSpawnMob", at = @At("RETURN"))
public void handleSpawnMob(S0FPacketSpawnMob packetIn, CallbackInfo ci) {
//CollectionLogManager.getInstance().onEntityMetadataUpdated(packetIn.getEntityID());
}
- @Inject(method="handleSetSlot", at=@At("RETURN"))
+ @Inject(method = "handleSetSlot", at = @At("RETURN"))
public void handleSetSlot(S2FPacketSetSlot packetIn, CallbackInfo ci) {
EnchantingSolvers.processInventoryContents(false);
StorageManager.getInstance().setSlotPacket(packetIn);
}
- @Inject(method="handleOpenWindow", at=@At("RETURN"))
+ @Inject(method = "handleOpenWindow", at = @At("RETURN"))
public void handleOpenWindow(S2DPacketOpenWindow packetIn, CallbackInfo ci) {
StorageManager.getInstance().openWindowPacket(packetIn);
}
- @Inject(method="handleCloseWindow", at=@At("RETURN"))
+ @Inject(method = "handleCloseWindow", at = @At("RETURN"))
public void handleCloseWindow(S2EPacketCloseWindow packetIn, CallbackInfo ci) {
StorageManager.getInstance().closeWindowPacket(packetIn);
}
- @Inject(method="handleWindowItems", at=@At("RETURN"))
+ @Inject(method = "handleWindowItems", at = @At("RETURN"))
public void handleOpenWindow(S30PacketWindowItems packetIn, CallbackInfo ci) {
StorageManager.getInstance().setItemsPacket(packetIn);
}
- @Inject(method="handleRespawn", at=@At(
+ @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))
@@ -76,25 +75,23 @@ public class MixinNetHandlerPlayClient {
FancyPortals.onRespawnPacket(packetIn);
}
- @Inject(method="handleBlockChange", at=@At("HEAD"))
+ @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"))
+ @Inject(method = "addToSendQueue", at = @At("HEAD"))
public void addToSendQueue(Packet packet, CallbackInfo ci) {
- if(packet instanceof C0EPacketClickWindow) {
- StorageManager.getInstance().clientSendWindowClick((C0EPacketClickWindow)packet);
+ if (packet instanceof C0EPacketClickWindow) {
+ StorageManager.getInstance().clientSendWindowClick((C0EPacketClickWindow) packet);
}
}
- @Inject(method="handlePlayerListHeaderFooter", at=@At("HEAD"))
+ @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..4e260a9c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java
@@ -1,12 +1,7 @@
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.miscfeatures.ItemCooldowns;
-import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff;
-import net.minecraft.client.Minecraft;
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;
@@ -17,7 +12,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerControllerMP.class)
public class MixinPlayerControllerMP {
- @Inject(method="clickBlock", at=@At("HEAD"), cancellable = true)
+ @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)) {
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..25cc13cc 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;
@@ -16,10 +16,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Render.class)
public class MixinRender {
- @Inject(method="bindEntityTexture", at=@At("HEAD"), cancellable = true)
+ @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"),
+ 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);
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..9b43e675 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java
@@ -18,10 +18,8 @@ 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.*;
@@ -33,16 +31,17 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> {
super(renderManager);
}
- @Inject(method = "doRender(Lnet/minecraft/entity/projectile/EntityFishHook;DDDFF)V", at=@At(value = "HEAD"), cancellable = true)
+ @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 &&
+ 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;
+ 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 &&
@@ -51,7 +50,7 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> {
ci.cancel();
GlStateManager.pushMatrix();
- GlStateManager.translate((float)x, (float)y, (float)z);
+ 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);
@@ -76,37 +75,37 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> {
double playerVecY;
double playerVecZ;
double startY;
- if(this.renderManager.options.thirdPersonView == 0 && entity.angler == Minecraft.getMinecraft().thePlayer) {
+ 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);
+ 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.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;
+ 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;
+ 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;
+ 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));
+ 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();
@@ -122,13 +121,13 @@ public abstract class MixinRenderFish extends Render<EntityFishHook> {
int colourI = SpecialColour.specialToChromaRGB(specialColour);
for (int l = 0; l <= 16; ++l) {
- if(SpecialColour.getSpeed(specialColour) > 0) { //has chroma
+ 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)
+ 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();
}
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..c4eaee15 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;
@@ -15,92 +15,92 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(RenderGlobal.class)
public class MixinRenderGlobal {
- @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 4)
+ @ModifyVariable(method = "setupTerrain", at = @At(value = "STORE"), ordinal = 4)
public double setupTerrain_d0(double d3) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.x;
}
return d3;
}
- @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 5)
+ @ModifyVariable(method = "setupTerrain", at = @At(value = "STORE"), ordinal = 5)
public double setupTerrain_d1(double d4) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.y;
}
return d4;
}
- @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 6)
+ @ModifyVariable(method = "setupTerrain", at = @At(value = "STORE"), ordinal = 6)
public double setupTerrain_d2(double d5) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.z;
}
return d5;
}
//renderEntities
- @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 3)
+ @ModifyVariable(method = "renderEntities", at = @At(value = "STORE"), ordinal = 3)
public double renderEntities_d0(double d3) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.x;
}
return d3;
}
- @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 4)
+ @ModifyVariable(method = "renderEntities", at = @At(value = "STORE"), ordinal = 4)
public double renderEntities_d1(double d4) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.y;
}
return d4;
}
- @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 5)
+ @ModifyVariable(method = "renderEntities", at = @At(value = "STORE"), ordinal = 5)
public double renderEntities_d2(double d5) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.z;
}
return d5;
}
- @Inject(method="renderBlockLayer", at=@At("RETURN"))
+ @Inject(method = "renderBlockLayer", at = @At("RETURN"))
public void renderBlockLayer(EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass,
- Entity entityIn, CallbackInfoReturnable<Integer> cir) {
- if(blockLayerIn == EnumWorldBlockLayer.CUTOUT) {
+ Entity entityIn, CallbackInfoReturnable<Integer> cir) {
+ if (blockLayerIn == EnumWorldBlockLayer.CUTOUT) {
CapeManager.getInstance().postRenderBlocks();
}
}
//drawBlockDamageTexture
- @ModifyVariable(method="drawBlockDamageTexture", at=@At(value="STORE"), ordinal = 0)
+ @ModifyVariable(method = "drawBlockDamageTexture", at = @At(value = "STORE"), ordinal = 0)
public double drawBlockDamageTexture_d0(double d0) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.x;
}
return d0;
}
- @ModifyVariable(method="drawBlockDamageTexture", at=@At(value="STORE"), ordinal = 1)
+ @ModifyVariable(method = "drawBlockDamageTexture", at = @At(value = "STORE"), ordinal = 1)
public double drawBlockDamageTexture_d1(double d1) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ if (currentPosition != null) {
return currentPosition.y;
}
return d1;
}
- @ModifyVariable(method="drawBlockDamageTexture", at=@At(value="STORE"), ordinal = 2)
+ @ModifyVariable(method = "drawBlockDamageTexture", at = @At(value = "STORE"), ordinal = 2)
public double drawBlockDamageTexture_d2(double d2) {
Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition();
- if(currentPosition != null) {
+ 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..765437c8 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;
@@ -31,7 +31,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
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) {
+ 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();
@@ -46,17 +46,17 @@ public abstract class MixinRenderItem {
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"
- )
+ @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) {
+ if (data != null) {
customEnchGlint = data.customGlintColour;
- if(data.overrideEnchantGlint) {
+ if (data.overrideEnchantGlint) {
return data.enchantGlintValue;
}
} else {
@@ -66,8 +66,8 @@ public abstract class MixinRenderItem {
return stack.hasEffect();
}
- @Redirect(method="renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V",
- at=@At(
+ @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"
)
@@ -78,8 +78,8 @@ public abstract class MixinRenderItem {
GL11.glPopMatrix();
ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null) {
- if(data.overrideEnchantGlint && data.enchantGlintValue) {
+ 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;
@@ -88,7 +88,7 @@ public abstract class MixinRenderItem {
GlStateManager.color(red, green, blue, alpha);
- GlStateManager.scale(1/8f, 1/8f, 1/8f);
+ GlStateManager.scale(1 / 8f, 1 / 8f, 1 / 8f);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
ItemCustomizeManager.disableTextureBinding = true;
@@ -101,16 +101,16 @@ public abstract class MixinRenderItem {
}
}
- @Redirect(method="renderQuads",
- at=@At(
+ @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) {
+ if (renderPass == 0) {
ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem(stack);
- if(data != null && data.customLeatherColour != null) {
+ if (data != null && data.customLeatherColour != null) {
return ChromaColour.specialToChromaRGB(data.customLeatherColour);
}
}
@@ -118,11 +118,9 @@ public abstract class MixinRenderItem {
return item.getColorFromItemStack(stack, renderPass);
}
- @Inject(method="renderEffect", at=@At("HEAD"), cancellable = true)
+ @Inject(method = "renderEffect", at = @At("HEAD"), cancellable = true)
public void renderEffect(IBakedModel model, CallbackInfo ci) {
- if(ItemCustomizeManager.renderEffectHook(customEnchGlint, (color) -> {
- renderModel(model, color);
- })) {
+ if (ItemCustomizeManager.renderEffectHook(customEnchGlint, (color) -> renderModel(model, color))) {
ci.cancel();
}
}
@@ -175,88 +173,88 @@ public abstract class MixinRenderItem {
}
}*/
- @Inject(method="renderItemIntoGUI", at=@At("HEAD"))
+ @Inject(method = "renderItemIntoGUI", at = @At("HEAD"))
public void renderItemHead(ItemStack stack, int x, int y, CallbackInfo ci) {
- if(NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
+ if (NotEnoughUpdates.INSTANCE.overlay.searchMode && NEUEventListener.drawingGuiScreen) {
boolean matches = false;
GuiTextField textField = NotEnoughUpdates.INSTANCE.overlay.getTextField();
- if(textField.getText().trim().isEmpty()) {
+ if (textField.getText().trim().isEmpty()) {
matches = true;
- } else if(stack != null) {
- for(String search : textField.getText().split("\\|")) {
+ } else if (stack != null) {
+ for (String search : textField.getText().split("\\|")) {
matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
}
}
- if(matches) {
+ 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);
+ Gui.drawRect(x, y, x + 16, y + 16, NEUOverlay.overlayColourLight);
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
}
}
}
- @Inject(method="renderItemIntoGUI", at=@At("RETURN"))
+ @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) {
+ 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()) {
+ if (textField.getText().trim().isEmpty()) {
matches = true;
- } else if(stack != null) {
- for(String search : textField.getText().split("\\|")) {
+ } else if (stack != null) {
+ for (String search : textField.getText().split("\\|")) {
matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
}
}
- if(!matches) {
+ if (!matches) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, 110 + Minecraft.getMinecraft().getRenderItem().zLevel);
- Gui.drawRect(x, y, x+16, y+16, NEUOverlay.overlayColourDark);
+ Gui.drawRect(x, y, x + 16, y + 16, NEUOverlay.overlayColourDark);
GlStateManager.popMatrix();
}
}
}
- @Inject(method="renderItemOverlayIntoGUI", at=@At("RETURN"))
+ @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) {
+ 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()) {
+ if (textField.getText().trim().isEmpty()) {
matches = true;
} else {
- for(String search : textField.getText().split("\\|")) {
+ for (String search : textField.getText().split("\\|")) {
matches |= NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, search.trim());
}
}
- if(!matches) {
+ 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);
+ Gui.drawRect(xPosition, yPosition, xPosition + 16, yPosition + 16, NEUOverlay.overlayColourDark);
GlStateManager.enableDepth();
GlStateManager.popMatrix();
}
}
}
- if(stack == null) return;
+ if (stack == null) return;
float damageOverride = ItemCooldowns.getDurabilityOverride(stack);
- if(damageOverride >= 0) {
+ if (damageOverride >= 0) {
float barX = 13.0f - damageOverride * 13.0f;
- int col = (int)Math.round(255.0D - damageOverride * 255.0D);
+ int col = (int) Math.round(255.0D - damageOverride * 255.0D);
GlStateManager.disableLighting();
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
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..1e79c9ec 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;
@@ -12,9 +12,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({RenderList.class})
public abstract class MixinRenderList {
- @Inject(method="renderChunkLayer", at=@At("HEAD"))
+ @Inject(method = "renderChunkLayer", at = @At("HEAD"))
public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) {
- if(DungeonBlocks.textureExists()) {
+ if (DungeonBlocks.textureExists()) {
DungeonBlocks.bindTextureIfExists();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
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..ea9f808a 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;
@@ -19,20 +16,20 @@ 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 =
+ @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) {
+ if (entity instanceof EntityArmorStand) {
return DamageCommas.replaceName(entity);
} else {
return entity.getDisplayName();
}
}
- @Inject(method="getColorMultiplier", at=@At("HEAD"), cancellable = true)
+ @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) {
+ 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..1bbf3a88 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTextureManager.java
@@ -11,9 +11,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TextureManager.class)
public class MixinTextureManager {
- @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true)
+ @Inject(method = "bindTexture", at = @At("HEAD"), cancellable = true)
public void bindTexture(ResourceLocation location, CallbackInfo ci) {
- if(ItemCustomizeManager.disableTextureBinding) {
+ 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..57742352 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySkullRenderer.java
@@ -8,15 +8,14 @@ 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)
+ @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)) {
+ 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..324a7043 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;
@@ -14,16 +14,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({TileEntitySpecialRenderer.class})
public abstract class MixinTileEntitySpecialRenderer {
- @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true)
+ @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") ||
+ 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,
+ 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);
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..2a958678 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java
@@ -12,9 +12,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin({VboRenderList.class})
public abstract class MixinVboRenderList {
- @Inject(method="renderChunkLayer", at=@At("HEAD"))
+ @Inject(method = "renderChunkLayer", at = @At("HEAD"))
public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) {
- if(DungeonBlocks.textureExists()) {
+ if (DungeonBlocks.textureExists()) {
DungeonBlocks.bindTextureIfExists();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
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..2985ef3a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java
@@ -3,7 +3,6 @@ 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.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,25 +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)
+ @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 &&
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.disableHyperionParticles &&
System.currentTimeMillis() - CustomItemEffects.INSTANCE.lastUsedHyperion < 500) {
- if(particleID == 1) {
+ if (particleID == 1) {
ci.cancel();
}
}
}
- @Inject(method="getBiomeGenForCoords", at=@At("HEAD"), cancellable = true)
+ @Inject(method = "getBiomeGenForCoords", at = @At("HEAD"), cancellable = true)
public void getBiomeGenForCoords(BlockPos pos, CallbackInfoReturnable<BiomeGenBase> cir) {
int retexture = DwarvenMinesTextures.retexture(pos);
- if(retexture == 1) {
+ if (retexture == 1) {
cir.setReturnValue(BiomeGenBase.extremeHillsPlus);
- } else if(retexture == 2) {
+ } else if (retexture == 2) {
cir.setReturnValue(BiomeGenBase.extremeHillsEdge);
- } else if(retexture == 3) {
+ } else if (retexture == 3) {
cir.setReturnValue(BiomeGenBase.coldBeach);
}
}
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..459ebe7f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java
@@ -12,12 +12,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(WorldClient.class)
public class MixinWorldClient {
- @Inject(method="addEntityToWorld", at=@At("HEAD"))
+ @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"))
+ @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..1d7d6876 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -29,23 +29,21 @@ 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;
+ 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)
- ));
+ }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)));
}
@Override
public void executeRunnable(int runnableId) {
String activeConfigCategory = null;
- if(Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) {
+ if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) {
GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen;
- if(wrapper.element instanceof NEUConfigEditor) {
- activeConfigCategory = ((NEUConfigEditor)wrapper.element).getSelectedCategoryName();
+ if (wrapper.element instanceof NEUConfigEditor) {
+ activeConfigCategory = ((NEUConfigEditor) wrapper.element).getSelectedCategoryName();
}
}
@@ -60,9 +58,7 @@ public class NEUConfig extends Config {
Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(
NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition,
NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> {
- }, () -> {
- }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)
- ));
+ }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor)));
return;
case 3:
editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition);
@@ -125,7 +121,6 @@ public class NEUConfig extends Config {
)
public InventoryButtons inventoryButtons = new InventoryButtons();
-
@Expose
@Category(
name = "Slot Locking",
@@ -175,7 +170,6 @@ public class NEUConfig extends Config {
)
public Dungeons dungeons = new Dungeons();
-
@Expose
@Category(
name = "Enchanting GUI/Solvers",
@@ -190,7 +184,6 @@ public class NEUConfig extends Config {
)
public Mining mining = new Mining();
-
@Expose
@Category(
name = "Fishing",
@@ -233,7 +226,6 @@ public class NEUConfig extends Config {
)
public PetOverlay petOverlay = new PetOverlay();
-
@Expose
@Category(
name = "AH Tweaks",
@@ -266,35 +258,56 @@ public class NEUConfig extends Config {
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;
+ @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;
+ @Expose
+ public boolean disableBrokenCapes = false;
}
- public static ArrayList<String> createDefaultEnchantColours(){
+ public static ArrayList<String> createDefaultEnchantColours() {
return Lists.newArrayList(
"[a-zA-Z\\- ]+:\u003e:9:6:0",
"[a-zA-Z\\- ]+:\u003e:6:c:0",
@@ -320,26 +333,36 @@ public class NEUConfig extends Config {
}
public HiddenProfileSpecific getProfileSpecific() {
- if(SBInfo.getInstance().currentProfile == null) {
+ if (SBInfo.getInstance().currentProfile == null) {
return null;
}
- return hidden.profileSpecific.computeIfAbsent(SBInfo.getInstance().currentProfile, k-> new HiddenProfileSpecific());
+ 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 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 int commissionMilestone = 0;
- @Expose public HashMap<String, Boolean> automatonParts = new HashMap<String, Boolean>(){{
+ @Expose
+ public HashMap<String, Boolean> automatonParts = new HashMap<String, Boolean>() {{
put("Electron Transmitter", false);
put("FTX 3070", false);
put("Robotron Reflector", false);
@@ -348,25 +371,27 @@ public class NEUConfig extends Config {
put("Synthetic Heart", false);
}};
- @Expose public HashMap<String, Boolean> divanMinesParts = new HashMap<String, Boolean>(){{
+ @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>(){{
+ @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() {
+ public HiddenLocationSpecific getLocationSpecific() {
String location = SBInfo.getInstance().getLocation();
- if(location == null || location.isEmpty()) {
+ if (location == null || location.isEmpty()) {
return null;
}
@@ -374,32 +399,33 @@ public class NEUConfig extends Config {
}
public HiddenLocationSpecific getLocationSpecific(String location) {
- return hidden.locationSpecific.computeIfAbsent(location, k-> new HiddenLocationSpecific());
+ return hidden.locationSpecific.computeIfAbsent(location, k -> new HiddenLocationSpecific());
}
public static class HiddenLocationSpecific {
- @Expose public Map<String, Integer> commissionMaxes = new HashMap<>();
- }
+ @Expose
+ public Map<String, Integer> commissionMaxes = new HashMap<>();
+ }
- public static List<InventoryButton> createDefaultInventoryButtons() {
+ 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, ""));
+ 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, ""));
+ 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, ""));
+ 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, ""));
@@ -411,48 +437,56 @@ public class NEUConfig extends Config {
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, ""));
+ 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, ""));
+ 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, ""));
+ 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, ""));
+ 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, ""));
+ 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, ""));
+ 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 int x;
+ @Expose
+ public int y;
+ @Expose
+ public boolean playerInvOnly;
- @Expose public boolean anchorRight;
- @Expose public boolean anchorBottom;
+ @Expose
+ public boolean anchorRight;
+ @Expose
+ public boolean anchorBottom;
- @Expose public int backgroundIndex;
- @Expose public String command;
- @Expose public String icon;
+ @Expose
+ public int backgroundIndex;
+ @Expose
+ public String command;
+ @Expose
+ public String icon;
public boolean isActive() {
return command.trim().length() > 0;
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..f4702761 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java
@@ -24,25 +24,26 @@ 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.*;
+
+import static io.github.moulberry.notenoughupdates.util.GuiTextures.*;
public class NEUConfigEditor extends GuiElement {
public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config);
- private static final ResourceLocation[] socialsIco = new ResourceLocation[] {
+ private static final ResourceLocation[] socialsIco = new ResourceLocation[]{
DISCORD,
GITHUB,
TWITTER,
YOUTUBE,
PATREON
};
- private static final String[] socialsLink = new String[] {
+ private static final String[] socialsLink = new String[]{
"https://discord.gg/moulberry",
"https://github.com/Moulberry/NotEnoughUpdates",
"https://twitter.com/moulberry/",
@@ -59,16 +60,16 @@ public class NEUConfigEditor extends GuiElement {
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 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 LerpingInteger minimumSearchSize = new LerpingInteger(0, 150);
- private GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0);
+ private final LerpingInteger minimumSearchSize = new LerpingInteger(0, 150);
+ private final GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0);
public NEUConfigEditor(Config config) {
this(config, null);
@@ -78,36 +79,36 @@ public class NEUConfigEditor extends GuiElement {
this.openedMillis = System.currentTimeMillis();
this.processedConfig = ConfigProcessor.create(config);
- for(ConfigProcessor.ProcessedCategory category : processedConfig.values()) {
- for(ConfigProcessor.ProcessedOption option : category.options.values()) {
+ 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);
+ 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)) {
+ 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())) {
+ 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())) {
+ if (selectedCategory == null) {
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) {
+ if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) {
selectedCategory = category.getKey();
break;
}
@@ -120,26 +121,26 @@ public class NEUConfigEditor extends GuiElement {
private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() {
LinkedHashMap<String, ConfigProcessor.ProcessedCategory> newMap = new LinkedHashMap<>(processedConfig);
- if(searchedCategories != null) newMap.values().retainAll(searchedCategories);
+ 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) {
+ if (searchedOptions != null) {
Set<ConfigProcessor.ProcessedOption> retain = new HashSet<>();
retain.addAll(searchedOptions);
- if(searchedAccordions != null) {
+ 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 != null && !visibleAccordions.isEmpty()) {
+ for (ConfigProcessor.ProcessedOption option : newMap.values()) {
+ if (option.editor instanceof GuiOptionEditorAccordion) {
+ int accordionId = ((GuiOptionEditorAccordion) option.editor).getAccordionId();
- if(visibleAccordions.contains(accordionId)) {
+ if (visibleAccordions.contains(accordionId)) {
retain.add(option);
}
}
@@ -172,12 +173,12 @@ public class NEUConfigEditor extends GuiElement {
searchedOptions = null;
searchedAccordions = null;
- if(!search.isEmpty()) {
+ if (!search.isEmpty()) {
searchedCategories = new HashSet<>();
searchedAccordions = new HashMap<>();
- for(String word : search.split(" ")) {
- if(word.trim().isEmpty()) continue;
+ for (String word : search.split(" ")) {
+ if (word.trim().isEmpty()) continue;
Set<ConfigProcessor.ProcessedOption> options = new HashSet<>();
@@ -186,8 +187,8 @@ public class NEUConfigEditor extends GuiElement {
map.values().forEach(options::addAll);
- if(!options.isEmpty()) {
- if(searchedOptions == null) {
+ if (!options.isEmpty()) {
+ if (searchedOptions == null) {
searchedOptions = new HashSet<>(options);
} else {
searchedOptions.retainAll(options);
@@ -195,15 +196,15 @@ public class NEUConfigEditor extends GuiElement {
}
}
- if(searchedOptions == null) {
- searchedOptions = new HashSet<>();
+ if (searchedOptions == null) {
+ searchedOptions = new HashSet<>();
} else {
- for(ConfigProcessor.ProcessedOption option : searchedOptions) {
+ for (ConfigProcessor.ProcessedOption option : searchedOptions) {
ConfigProcessor.ProcessedCategory cat = categoryForOption.get(option);
- if(cat == null) continue;
+ if (cat == null) continue;
searchedCategories.add(cat);
- searchedAccordions.computeIfAbsent(cat, k->new HashSet<>()).add(option.accordionId);
+ searchedAccordions.computeIfAbsent(cat, k -> new HashSet<>()).add(option.accordionId);
}
}
}
@@ -224,232 +225,232 @@ public class NEUConfigEditor extends GuiElement {
int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- float opacityFactor = LerpUtils.sigmoidZeroOne(delta/500f);
+ float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f);
RenderUtils.drawGradientRect(0, 0, 0, width, height,
- (int)(0x80*opacityFactor) << 24 | 0x101010,
- (int)(0x90*opacityFactor) << 24 | 0x101010);
+ (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 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 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);
+ if (delta < 150) {
+ openingXSize = (int) (delta * xSize / 150);
openingYSize = 5;
- } else if(delta < 300) {
- openingYSize = 5 + (int)(delta-150)*(ySize-5)/150;
+ } else if (delta < 300) {
+ openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150;
}
RenderUtils.drawFloatingRectDark(
- (scaledResolution.getScaledWidth() - openingXSize)/2,
- (scaledResolution.getScaledHeight() - openingYSize)/2,
+ (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);
+ 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);
+ 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);
+ 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()) {
+ for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : currentConfigEditing.entrySet()) {
String selectedCategory = getSelectedCategory();
- if(selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) {
+ if (selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) {
setSelectedCategory(entry.getKey());
}
String catName = entry.getValue().name;
- if(entry.getKey().equals(getSelectedCategory())) {
+ 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);
+ 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()));
+ 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) {
+ 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) {
+ 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.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())));
+ 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);
+ 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);
+ fr, x + 75, y + 44, false, 120, 0xa368ef);
- RenderUtils.drawFloatingRectDark(x+149, y+29, xSize-154, ySize-34, false);
+ 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;
+ 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);
+ 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) {
+ if (shouldShow && minimumSearchSize.getTarget() < 30) {
minimumSearchSize.setTarget(30);
minimumSearchSize.resetTimer();
- } else if(!shouldShow && minimumSearchSize.getTarget() > 0) {
+ } 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;
+ 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);
+ searchField.render(innerRight - 25 - len, innerTop - (20 + innerPadding) / 2 - 9);
rightStuffLen += 5 + len;
}
- if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
+ 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);
+ 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
+ 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);
+ GlScissorStack.push(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, scaledResolution);
float barSize = 1;
int optionY = -optionsScroll.getValue();
- if(getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
+ if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
- int optionWidthDefault = innerRight-innerLeft-20;
+ int optionWidthDefault = innerRight - innerLeft - 20;
GlStateManager.enableDepth();
HashMap<Integer, Integer> activeAccordions = new HashMap<>();
- for(ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
- if(editor == null) {
+ if (editor == null) {
continue;
}
- if(editor instanceof GuiOptionEditorAccordion) {
+ if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
+ if (accordion.getToggled()) {
int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ 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);
+ 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()));
+ 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())) {
+ if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) {
int optionYOverlay = -optionsScroll.getValue();
ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory());
- int optionWidthDefault = innerRight-innerLeft-20;
+ 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()) {
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
- if(editor == null) {
+ if (editor == null) {
continue;
}
- if(editor instanceof GuiOptionEditorAccordion) {
+ if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
+ if (accordion.getToggled()) {
int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ 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);
+ 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;
}
@@ -458,37 +459,37 @@ public class NEUConfigEditor extends GuiElement {
}
GL11.glEnable(GL11.GL_SCISSOR_TEST);
- float barStart = optionsScroll.getValue() / (float)(optionY + optionsScroll.getValue());
- float barEnd = barStart+barSize;
- if(barEnd > 1) {
+ 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) {
+ 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.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())));
+ 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);
+ 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++) {
+ 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);
+ 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]);
+ 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) {
+ if (tooltipToDisplay != null) {
TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, fr);
}
@@ -500,128 +501,128 @@ public class NEUConfigEditor extends GuiElement {
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 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 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;
+ 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 (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;
+ 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) {
+ 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();
+ if (!searchField.getText().equals(old)) search();
}
}
}
int dWheel = Mouse.getEventDWheel();
- if(mouseY > innerTop && mouseY < innerBottom && dWheel != 0) {
- if(dWheel < 0) {
+ if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) {
+ if (dWheel < 0) {
dWheel = -1;
}
- if(dWheel > 0) {
+ if (dWheel > 0) {
dWheel = 1;
}
- if(mouseX < innerLeft) {
- int newTarget = categoryScroll.getTarget() - dWheel*30;
- if(newTarget < 0) {
+ 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) {
+ 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));
+ 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) {
+ 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) {
+ 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())) {
+ 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)) {
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
}
GuiOptionEditor editor = option.editor;
- if(editor == null) {
+ if (editor == null) {
continue;
}
- if(editor instanceof GuiOptionEditorAccordion) {
+ if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
+ if (accordion.getToggled()) {
int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ 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));
+ 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) {
+ 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.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) {
+ } 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) {
+ 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) {
+ if (mouseX >= x + 5 && mouseX <= x + 145 &&
+ mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7) {
setSelectedCategory(entry.getKey());
return true;
}
@@ -629,86 +630,87 @@ public class NEUConfigEditor extends GuiElement {
}
}
- for(int socialIndex=0; socialIndex<socialsLink.length; socialIndex++) {
- int socialLeft = x+xSize-23-18*socialIndex;
+ 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) {
+ if (mouseX >= socialLeft && mouseX <= socialLeft + 16 &&
+ mouseY >= y + 6 && mouseY <= y + 23) {
try {
Desktop.getDesktop().browse(new URI(socialsLink[socialIndex]));
- } catch(Exception ignored) {}
+ } 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()) {
+ 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)) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
GuiOptionEditor editor = option.editor;
- if(editor == null) {
+ if (editor == null) {
continue;
}
- if(editor instanceof GuiOptionEditorAccordion) {
+ if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
+ if (accordion.getToggled()) {
int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ 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)) {
+ 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 &&
+ 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;
+ 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()) {
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
int optionWidth = optionWidthDefault;
- if(option.accordionId >= 0) {
- if(!activeAccordions.containsKey(option.accordionId)) {
- continue;
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
+ continue;
+ }
+ int accordionDepth = activeAccordions.get(option.accordionId);
+ optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1);
}
- int accordionDepth = activeAccordions.get(option.accordionId);
- optionWidth = optionWidthDefault - (2*innerPadding)*(accordionDepth+1);
- }
GuiOptionEditor editor = option.editor;
- if(editor == null) {
+ 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;
+ 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);
}
- activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
- }
- if(editor.mouseInput((innerLeft+innerRight-optionWidth)/2-5, innerTop+5+optionY, optionWidth, mouseX, mouseY)) {
+ if (editor.mouseInput((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth, mouseX, mouseY)) {
return true;
}
optionY += editor.getHeight() + 5;
@@ -723,47 +725,47 @@ public class NEUConfigEditor extends GuiElement {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int width = scaledResolution.getScaledWidth();
- int xSize = Math.min(width-100/scaledResolution.getScaleFactor(), 500);
+ 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;
+ int innerPadding = 20 / adjScaleFactor;
+ int innerWidth = xSize - 154 - innerPadding * 2;
- if(Keyboard.getEventKeyState()) {
+ 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));
+ searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(searchField.getText(), innerWidth / 2 - 20));
- if(!searchField.getText().equals(old)) search();
+ if (!searchField.getText().equals(old)) search();
}
- if(getSelectedCategory() != null && getCurrentConfigEditing() != null && getCurrentConfigEditing().containsKey(getSelectedCategory())) {
+ 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)) {
+ for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) {
+ if (option.accordionId >= 0) {
+ if (!activeAccordions.containsKey(option.accordionId)) {
continue;
}
}
GuiOptionEditor editor = option.editor;
- if(editor == null) {
+ if (editor == null) {
continue;
}
- if(editor instanceof GuiOptionEditorAccordion) {
+ if (editor instanceof GuiOptionEditorAccordion) {
GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor;
- if(accordion.getToggled()) {
+ if (accordion.getToggled()) {
int accordionDepth = 0;
- if(option.accordionId >= 0) {
- accordionDepth = activeAccordions.get(option.accordionId)+1;
+ if (option.accordionId >= 0) {
+ accordionDepth = activeAccordions.get(option.accordionId) + 1;
}
activeAccordions.put(accordion.getAccordionId(), accordionDepth);
}
}
- if(editor.keyboardInput()) {
+ if (editor.keyboardInput()) {
return true;
}
}
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..9ba71505 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,7 +2,6 @@ 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(
@@ -66,7 +65,6 @@ public class Dungeons {
@ConfigAccordionId(id = 1)
public int profitDisplayLoc = 0;
-
@ConfigOption(
name = "Dungeon Win Overlay",
desc = ""
@@ -195,5 +193,4 @@ public class Dungeons {
@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..f13ab162 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
@@ -53,7 +53,6 @@ public class Enchanting {
@ConfigAccordionId(id = 1)
public int enchantOrdering = 0;
-
@ConfigOption(
name = "Enchanting Solvers",
desc = ""
@@ -61,7 +60,6 @@ public class Enchanting {
@ConfigEditorAccordion(id = 0)
public boolean enchantingSolversAccordion = false;
-
@Expose
@ConfigOption(
name = "Enable Solvers",
@@ -79,7 +77,7 @@ public class Enchanting {
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
public boolean preventMisclicks = true;*/
-
+
@Expose
@ConfigOption(
name = "Hide Tooltips",
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..6b4124ea 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
@@ -269,15 +269,13 @@ public class ItemOverlays {
@Expose
@ConfigOption(
name = "Fast update",
- desc = "Updates the bonemerang overlay faster.\n"+
+ 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 = ""
@@ -303,7 +301,6 @@ public class ItemOverlays {
@ConfigAccordionId(id = 5)
public boolean alwaysShowCrystal = false;
-
@Expose
@ConfigOption(
name = "Enable Prismapump Overlay",
@@ -312,7 +309,6 @@ public class ItemOverlays {
@ConfigEditorBoolean
public boolean enablePrismapumpOverlay = true;
-
@Expose
@ConfigOption(
name = "Pickaxe Ability Cooldown",
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..2c05d553 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
@@ -169,7 +169,6 @@ public class Mining {
@ConfigAccordionId(id = 2)
public int forgeDisplayEnabledLocations = 0;
-
@ConfigOption(
name = "Metal Detector Solver",
desc = ""
@@ -279,7 +278,6 @@ public class Mining {
@ConfigAccordionId(id = 4)
public int crystalHollowOverlayStyle = 0;
-
@Expose
@ConfigOption(
name = "Show Icons",
@@ -289,7 +287,6 @@ public class Mining {
@ConfigAccordionId(id = 4)
public boolean crystalHollowIcons = true;
-
@Expose
@ConfigOption(
name = "Hide Done",
@@ -485,7 +482,6 @@ public class Mining {
@ConfigEditorBoolean
public boolean titaniumAlertMustBeVisible = false;
-
@Expose
@ConfigOption(
name = "Dwarven Mines Textures",
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..fddf84e3 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
@@ -20,8 +20,6 @@ public class Misc {
@ConfigEditorBoolean
public boolean hidePotionEffect = true;
-
-
@Expose
@ConfigOption(
name = "Streamer Mode",
@@ -38,7 +36,6 @@ public class Misc {
@ConfigEditorBoolean
public boolean guiButtonClicks = true;
-
@Expose
@ConfigOption(
name = "Replace Chat Social Options",
@@ -47,8 +44,6 @@ public class Misc {
@ConfigEditorBoolean
public boolean replaceSocialOptions = true;
-
-
@Expose
@ConfigOption(
name = "Damage Indicator Style",
@@ -87,6 +82,4 @@ public class Misc {
@ConfigEditorBoolean
public boolean disableSkullRetexturing = 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..0035581c 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
@@ -58,20 +58,19 @@ public class MiscOverlays {
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)
+ @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)
+ @ConfigAccordionId(id = 1)
@ConfigEditorDropdown(
values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
)
@@ -83,7 +82,7 @@ public class MiscOverlays {
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)
+ @ConfigAccordionId(id = 1)
@ConfigEditorDropdown(
values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
)
@@ -95,7 +94,7 @@ public class MiscOverlays {
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)
+ @ConfigAccordionId(id = 1)
@ConfigEditorDropdown(
values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
)
@@ -107,7 +106,7 @@ public class MiscOverlays {
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)
+ @ConfigAccordionId(id = 1)
@ConfigEditorDropdown(
values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
)
@@ -119,7 +118,7 @@ public class MiscOverlays {
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)
+ @ConfigAccordionId(id = 1)
@ConfigEditorDropdown(
values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
)
@@ -131,7 +130,7 @@ public class MiscOverlays {
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)
+ @ConfigAccordionId(id = 1)
@ConfigEditorDropdown(
values = {"Only when ready", "When very Soon", "When soon", "When Kinda Soon", "Always"}
)
@@ -206,7 +205,6 @@ public class MiscOverlays {
@ConfigAccordionId(id = 2)
public int kindaSoonColour = 1;
-
@Expose
@ConfigOption(
name = "Default Colour",
@@ -220,7 +218,6 @@ public class MiscOverlays {
@ConfigAccordionId(id = 2)
public int defaultColour = 15;
-
@Expose
@ConfigOption(
name = "Todo Position",
@@ -233,7 +230,6 @@ public class MiscOverlays {
@ConfigAccordionId(id = 0)
public Position todoPosition = new Position(100, 0);
-
@Expose
@ConfigOption(
name = "Todo Style",
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..107931db 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
@@ -16,7 +16,7 @@ public class Notifications {
@Expose
@ConfigOption(
name = "RAM Warning",
- desc = "Warning when game starts with lots of RAM allocated\n"+
+ 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
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..a5b5c2fa 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
@@ -115,7 +115,6 @@ public class StorageGUI {
@ConfigAccordionId(id = 1)
public int cancelScrollKey = 0;
-
@ConfigOption(
name = "Inventory Backpacks",
desc = ""
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..6f5865ed 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
@@ -12,8 +12,6 @@ public class Toolbar {
@ConfigEditorButton(runnableId = 6, buttonText = "Edit")
public boolean positionButton = true;
-
-
@ConfigOption(
name = "Search Bar",
desc = ""
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..e88f694b 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
@@ -77,8 +77,6 @@ public class TooltipTweaks {
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
public int disablePriceKeyKeybind = Keyboard.KEY_NONE;
-
-
@Expose
@ConfigOption(
name = "Show reforge stats",
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..e6a060f1 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
@@ -13,7 +13,6 @@ public class TradeMenu {
@ConfigEditorBoolean
public boolean enableCustomTrade = true;
-
@Expose
@ConfigOption(
name = "Price Information",
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..d8ddcbc9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java
@@ -36,11 +36,11 @@ public class AuctionSearchOverlay {
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 final 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 final Splitter SPACE_SPLITTER = Splitter.on(" ").omitEmptyStrings().trimResults();
private static boolean tabCompleted = false;
private static int tabCompletionIndex = -1;
@@ -58,40 +58,38 @@ public class AuctionSearchOverlay {
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;
+ 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;
+ 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 (!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 = "";
+ 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;
+ if (lastContainer == null) return false;
+ if (!lastContainer.equals("Auctions Browser") && !lastContainer.startsWith("Auctions: ")) return false;
- TileEntitySign tes = ((GuiEditSign)Minecraft.getMinecraft().currentScreen).tileSign;
+ 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;
+ 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() {
@@ -105,42 +103,42 @@ public class AuctionSearchOverlay {
int h = NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches ? 219 : 145;
- int topY = height/4;
- if(scaledResolution.getScaleFactor() >= 4) {
- topY = height/2 - h/2 + 5;
+ 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);
+ 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);
+ 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) {
+ 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);
+ 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);
+ 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);
+ 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);
+ textField.render(width / 2 - 100 + 1, topY + 1);
- if(textField.getText().trim().isEmpty()) autocompletedItems.clear();
+ 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);
@@ -148,7 +146,7 @@ public class AuctionSearchOverlay {
List<String> tooltipToDisplay = null;
int num = 0;
- synchronized(autocompletedItems) {
+ synchronized (autocompletedItems) {
String[] autoCompletedItemsArray = autocompletedItems.toArray(new String[0]);
for (int i = 0; i < autocompletedItems.size(); i++) {
String str = autoCompletedItemsArray[i];
@@ -176,28 +174,28 @@ public class AuctionSearchOverlay {
width / 2 - 74, topY + 35 + num * 22 + 1, 0xdddddd, true);
GlStateManager.enableDepth();
- Utils.drawItemStack(stack, width/2-94+2, topY+32+num*22+1);
+ 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) {
+ 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 (++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);
+ 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;
+ 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);
+ Minecraft.getMinecraft().fontRendererObj.drawString(s, width / 2 - 95 + 1, topY + 45 + AUTOCOMPLETE_HEIGHT + i * 10 + 2, 0xdddddd, true);
}
- if(tooltipToDisplay != null) {
+ if (tooltipToDisplay != null) {
Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
}
}
@@ -205,22 +203,21 @@ public class AuctionSearchOverlay {
}
public static void close() {
- if(NotEnoughUpdates.INSTANCE.config.ahTweaks.keepPreviousSearch) {
+ if (NotEnoughUpdates.INSTANCE.config.ahTweaks.keepPreviousSearch) {
search();
} else {
- synchronized(autocompletedItems) {
+ synchronized (autocompletedItems) {
autocompletedItems.clear();
}
}
-
- TileEntitySign tes = ((GuiEditSign)Minecraft.getMinecraft().currentScreen).tileSign;
+ TileEntitySign tes = ((GuiEditSign) Minecraft.getMinecraft().currentScreen).tileSign;
String search = searchString.trim();
- if(searchStringExtra != null && !searchStringExtra.isEmpty()) {
+ if (searchStringExtra != null && !searchStringExtra.isEmpty()) {
search += " " + searchStringExtra.trim();
}
- if(search.length() <= 15) {
+ 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);
@@ -229,13 +226,13 @@ public class AuctionSearchOverlay {
StringBuilder line1 = new StringBuilder();
int currentLine = 0;
- for(String word : words) {
- if(currentLine == 0) {
- if(line0.length() + word.length() > 15) {
+ for (String word : words) {
+ if (currentLine == 0) {
+ if (line0.length() + word.length() > 15) {
currentLine++;
} else {
line0.append(word);
- if(line0.length() >= 15) {
+ if (line0.length() >= 15) {
currentLine++;
continue;
} else {
@@ -243,33 +240,33 @@ public class AuctionSearchOverlay {
}
}
}
- if(currentLine == 1) {
- if(line1.length() + word.length() > 15) {
+ 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) {
+ if (line1.length() >= 15) {
break;
} else {
line1.append(" ");
}
}
}
- if(line1.length() >= 15) break;
+ 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()) {
+ 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);
+ while (previousAuctionSearches.size() > 5) {
+ previousAuctionSearches.remove(previousAuctionSearches.size() - 1);
}
}
@@ -280,8 +277,8 @@ public class AuctionSearchOverlay {
}
}
- private static ExecutorService searchES = Executors.newSingleThreadExecutor();
- private static AtomicInteger searchId = new AtomicInteger(0);
+ private static final ExecutorService searchES = Executors.newSingleThreadExecutor();
+ private static final AtomicInteger searchId = new AtomicInteger(0);
private static String getItemIdAtIndex(int i) {
if (!autocompletedItems.isEmpty()) {
@@ -313,25 +310,25 @@ public class AuctionSearchOverlay {
if (thisSearchId != searchId.get()) return;
- if(!searchString.trim().contains(" ")) {
+ if (!searchString.trim().contains(" ")) {
StringBuilder sb = new StringBuilder();
- for(char c : searchString.toCharArray()) {
+ for (char c : searchString.toCharArray()) {
sb.append(c).append(" ");
}
- title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:"+sb.toString().trim()));
+ title.addAll(NotEnoughUpdates.INSTANCE.manager.search("title:" + sb.toString().trim()));
}
- if(thisSearchId != searchId.get()) return;
+ if (thisSearchId != searchId.get()) return;
- List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:"+searchString.trim()));
+ List<String> desc = new ArrayList<>(NotEnoughUpdates.INSTANCE.manager.search("desc:" + searchString.trim()));
desc.removeAll(title);
- if(thisSearchId != searchId.get()) return;
+ if (thisSearchId != searchId.get()) return;
Set<String> auctionableItems = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBinKeySet();
auctionableItems.addAll(NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfoKeySet());
- if(!auctionableItems.isEmpty()) {
+ if (!auctionableItems.isEmpty()) {
title.retainAll(auctionableItems);
desc.retainAll(auctionableItems);
@@ -344,9 +341,9 @@ public class AuctionSearchOverlay {
desc.removeAll(bazaarItems);
}
- if(thisSearchId != searchId.get()) return;
+ if (thisSearchId != searchId.get()) return;
- synchronized(autocompletedItems) {
+ synchronized (autocompletedItems) {
autocompletedItems.clear();
autocompletedItems.addAll(title);
autocompletedItems.addAll(desc);
@@ -355,16 +352,16 @@ public class AuctionSearchOverlay {
}
public static void keyEvent() {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
searchStringExtra = "";
close();
- if(NotEnoughUpdates.INSTANCE.config.ahTweaks.escFullClose) {
+ 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) {
+ } else if (Keyboard.getEventKey() == Keyboard.KEY_RETURN) {
searchStringExtra = "";
close();
- } else if(Keyboard.getEventKey() == Keyboard.KEY_TAB) {
+ } else if (Keyboard.getEventKey() == Keyboard.KEY_TAB) {
//autocomplete to first item in the list
tabCompleted = true;
String id = getItemIdAtIndex(0);
@@ -376,7 +373,7 @@ public class AuctionSearchOverlay {
tabCompletionIndex = 0;
searchString = id;
}
- } else if(Keyboard.getEventKeyState()) {
+ } else if (Keyboard.getEventKeyState()) {
if (tabCompleted) {
String id;
switch (Keyboard.getEventKey()) {
@@ -435,21 +432,21 @@ public class AuctionSearchOverlay {
int h = NotEnoughUpdates.INSTANCE.config.ahTweaks.showPastSearches ? 219 : 145;
- int topY = height/4;
- if(scaledResolution.getScaleFactor() >= 4) {
- topY = height/2 - h/2 + 5;
+ 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) {
+ 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) {
+ for (int i = 1; i <= 5; i++) {
+ if (mouseX < width / 2 + 108 + 10 * i) {
starClicked = i;
break;
}
}
- if(selectedStars == starClicked) {
+ if (selectedStars == starClicked) {
selectedStars = 0;
} else {
selectedStars = starClicked;
@@ -457,37 +454,37 @@ public class AuctionSearchOverlay {
return;
}
- if(Mouse.getEventButtonState() && mouseX >= width/2+106 && mouseX <= width/2+116 &&
- mouseY >= topY+42 && mouseY <= topY+50) {
+ 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.getEventButtonState() && Mouse.getEventButton() == -1 && searchFieldClicked) {
+ textField.mouseClickMove(mouseX - 2, topY + 10, 0, 0);
}
- if(Mouse.getEventButton() != -1) {
+ 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) {
+ 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());
+ textField.mouseClicked(mouseX - 2, mouseY, Mouse.getEventButton());
- if(Mouse.getEventButton() == 1) {
+ if (Mouse.getEventButton() == 1) {
searchString = "";
- synchronized(autocompletedItems) {
+ synchronized (autocompletedItems) {
autocompletedItems.clear();
}
}
- } else if(mouseX < width/2+75) {
+ } else if (mouseX < width / 2 + 75) {
searchStringExtra = "";
close();
- } else if(mouseX < width/2+100) {
+ } else if (mouseX < width / 2 + 100) {
searchStringExtra = "";
close();
Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId));
@@ -495,30 +492,30 @@ public class AuctionSearchOverlay {
NotEnoughUpdates.INSTANCE.config, "AH Search GUI"));
}
}
- } else if(Mouse.getEventButton() == 0) {
+ } else if (Mouse.getEventButton() == 0) {
int num = 0;
- synchronized(autocompletedItems) {
- for(String str : autocompletedItems) {
+ synchronized (autocompletedItems) {
+ for (String str : autocompletedItems) {
JsonObject obj = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(str);
- if(obj != null) {
+ 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) {
+ 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(";")) {
+ 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] = "";
+ 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++) {
+ if (essenceCosts != null && essenceCosts.has(str) && selectedStars > 0) {
+ for (int i = 0; i < selectedStars; i++) {
searchStringExtra += "\u272A";
}
- if(selectedStars < 5 && !atLeast) {
+ if (selectedStars < 5 && !atLeast) {
searchStringExtra += " ";
searchStringExtra += stack.getItem().getItemStackDisplayName(stack).substring(0, 1);
}
@@ -528,17 +525,17 @@ public class AuctionSearchOverlay {
return;
}
- if(++num >= 5) break;
+ 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;
+ 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) {
+ 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();
@@ -549,7 +546,6 @@ public class AuctionSearchOverlay {
}
}
-
}
}
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..6b7d498c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BonemerangOverlay.java
@@ -17,8 +17,6 @@ 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);
@@ -31,54 +29,53 @@ public class BonemerangOverlay extends TextOverlay {
@Override
public void updateFrequent() {
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate){
+ if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate) {
updateOverlay();
}
}
@Override
public void update() {
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate){
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangFastUpdate) {
updateOverlay();
}
}
- private void updateOverlay(){
- if(!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay && NotEnoughUpdates.INSTANCE.config.itemOverlays.highlightTargeted){
+ 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;
+ 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")) {
+ 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);
+ 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);
+ 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++) {
+ 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) &&
+ if (!Minecraft.getMinecraft().theWorld.isAirBlock(blockPos) &&
Minecraft.getMinecraft().theWorld.getBlockState(blockPos).getBlock().isFullCube()) {
map.put(0, EnumChatFormatting.RED + "Bonemerang will break!");
break;
@@ -95,7 +92,7 @@ public class BonemerangOverlay extends TextOverlay {
position.translate(step.x, step.y, step.z);
}
- if(NotEnoughUpdates.INSTANCE.config.itemOverlays.enableBonemerangOverlay) {
+ 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)) {
@@ -106,6 +103,6 @@ public class BonemerangOverlay extends TextOverlay {
}
- if(overlayStrings.isEmpty()) overlayStrings = null;
+ if (overlayStrings.isEmpty()) overlayStrings = null;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java
index eb4749db..532f3324 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/CraftingOverlay.java
@@ -22,7 +22,6 @@ public class CraftingOverlay {
public static boolean shouldRender = false;
private static String text = null;
-
public static void render() {
if (shouldRender) {
ContainerChest container = (ContainerChest) Minecraft.getMinecraft().thePlayer.openContainer;
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..e8ad503e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FarmingOverlay.java
@@ -9,7 +9,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;
@@ -25,14 +24,14 @@ public class FarmingOverlay extends TextOverlay {
private int counter = -1;
private float cropsPerSecondLast = 0;
private float cropsPerSecond = 0;
- private LinkedList<Integer> counterQueue = new LinkedList<>();
+ 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 LinkedList<Float> xpGainQueue = new LinkedList<>();
+ private final LinkedList<Float> xpGainQueue = new LinkedList<>();
private float xpGainHourLast = -1;
private float xpGainHour = -1;
@@ -46,8 +45,8 @@ public class FarmingOverlay extends TextOverlay {
private float interp(float now, float last) {
float interp = now;
- if(last >= 0 && last != now) {
- float factor = (System.currentTimeMillis()-lastUpdate)/1000f;
+ if (last >= 0 && last != now) {
+ float factor = (System.currentTimeMillis() - lastUpdate) / 1000f;
factor = LerpUtils.clampZeroOne(factor);
interp = last + (now - last) * factor;
}
@@ -56,7 +55,7 @@ public class FarmingOverlay extends TextOverlay {
@Override
public void update() {
- if(!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) {
+ if (!NotEnoughUpdates.INSTANCE.config.skillOverlays.farmingOverlay) {
counter = -1;
overlayStrings = null;
return;
@@ -67,26 +66,26 @@ public class FarmingOverlay extends TextOverlay {
xpGainHourLast = xpGainHour;
counter = -1;
- if(Minecraft.getMinecraft().thePlayer == null) return;
+ if (Minecraft.getMinecraft().thePlayer == null) return;
ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(stack != null && stack.hasTagCompound()) {
+ if (stack != null && stack.hasTagCompound()) {
NBTTagCompound tag = stack.getTagCompound();
- if(tag.hasKey("ExtraAttributes", 10)) {
+ if (tag.hasKey("ExtraAttributes", 10)) {
NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes");
- if(ea.hasKey("mined_crops", 99)) {
+ if (ea.hasKey("mined_crops", 99)) {
counter = ea.getInteger("mined_crops");
counterQueue.add(0, counter);
- } else if(ea.hasKey("farmed_cultivating", 99)) {
+ } 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")) {
+ if (internalname != null && internalname.startsWith("THEORETICAL_HOE_WARTS")) {
skillType = "Alchemy";
} else {
skillType = "Farming";
@@ -94,41 +93,41 @@ public class FarmingOverlay extends TextOverlay {
skillInfoLast = skillInfo;
skillInfo = XPInformation.getInstance().getSkillInfo(skillType);
- if(skillInfo != null) {
+ if (skillInfo != null) {
float totalXp = skillInfo.totalXp;
- if(lastTotalXp > 0) {
+ if (lastTotalXp > 0) {
float delta = totalXp - lastTotalXp;
- if(delta > 0 && delta < 1000) {
+ if (delta > 0 && delta < 1000) {
xpGainTimer = 3;
xpGainQueue.add(0, delta);
- while(xpGainQueue.size() > 30) {
+ while (xpGainQueue.size() > 30) {
xpGainQueue.removeLast();
}
float totalGain = 0;
- for(float f : xpGainQueue) totalGain += f;
+ for (float f : xpGainQueue) totalGain += f;
xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
isFarming = true;
- } else if(xpGainTimer > 0) {
+ } else if (xpGainTimer > 0) {
xpGainTimer--;
xpGainQueue.add(0, 0f);
- while(xpGainQueue.size() > 30) {
+ while (xpGainQueue.size() > 30) {
xpGainQueue.removeLast();
}
float totalGain = 0;
- for(float f : xpGainQueue) totalGain += f;
+ for (float f : xpGainQueue) totalGain += f;
xpGainHour = totalGain * (60 * 60) / xpGainQueue.size();
isFarming = true;
- } else if(delta <= 0) {
+ } else if (delta <= 0) {
isFarming = false;
}
}
@@ -136,11 +135,11 @@ public class FarmingOverlay extends TextOverlay {
lastTotalXp = totalXp;
}
- while(counterQueue.size() >= 4) {
+ while (counterQueue.size() >= 4) {
counterQueue.removeLast();
}
- if(counterQueue.isEmpty()) {
+ if (counterQueue.isEmpty()) {
cropsPerSecond = -1;
cropsPerSecondLast = 0;
} else {
@@ -148,10 +147,10 @@ public class FarmingOverlay extends TextOverlay {
int last = counterQueue.getLast();
int first = counterQueue.getFirst();
- cropsPerSecond = (first - last)/3f;
+ cropsPerSecond = (first - last) / 3f;
}
- if(counter != -1) {
+ if (counter != -1) {
overlayStrings = new ArrayList<>();
} else {
overlayStrings = null;
@@ -163,7 +162,7 @@ public class FarmingOverlay extends TextOverlay {
public void updateFrequent() {
super.updateFrequent();
- if(counter < 0) {
+ if (counter < 0) {
overlayStrings = null;
} else {
HashMap<Integer, String> lineMap = new HashMap<>();
@@ -172,34 +171,34 @@ public class FarmingOverlay extends TextOverlay {
NumberFormat format = NumberFormat.getIntegerInstance();
- if(counter >= 0) {
- int counterInterp = (int)interp(counter, counterLast);
+ if (counter >= 0) {
+ int counterInterp = (int) interp(counter, counterLast);
- lineMap.put(0, EnumChatFormatting.AQUA+"Counter: "+EnumChatFormatting.YELLOW+format.format(counterInterp));
+ 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");
+ 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));
+ 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");
+ 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)"));
+ lineMap.put(5, EnumChatFormatting.AQUA + "XP/h: " + EnumChatFormatting.YELLOW +
+ format.format(xpInterp) + (isFarming ? "" : EnumChatFormatting.RED + " (PAUSED)"));
}
- if(skillInfo != null) {
+ if (skillInfo != null) {
StringBuilder levelStr = new StringBuilder(EnumChatFormatting.AQUA + skillType.substring(0, 4) + ": ");
levelStr.append(EnumChatFormatting.YELLOW)
@@ -208,13 +207,13 @@ public class FarmingOverlay extends TextOverlay {
.append(" [");
float progress = skillInfo.currentXp / skillInfo.currentXpMax;
- if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.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) {
+ for (int i = 0; i < lines; i++) {
+ if (i / lines < progress) {
levelStr.append(EnumChatFormatting.YELLOW);
} else {
levelStr.append(EnumChatFormatting.DARK_GRAY);
@@ -225,30 +224,30 @@ public class FarmingOverlay extends TextOverlay {
levelStr.append(EnumChatFormatting.GRAY)
.append("] ")
.append(EnumChatFormatting.YELLOW)
- .append((int)(progress*100))
+ .append((int) (progress * 100))
.append("%");
- int current = (int)skillInfo.currentXp;
- if(skillInfoLast != null && skillInfo.currentXpMax == skillInfoLast.currentXpMax) {
- current = (int)interp(current, skillInfoLast.currentXp);
+ 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));
+ 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!");
+ 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");
+ 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));
+ lineMap.put(7, EnumChatFormatting.AQUA + "ETA: " + EnumChatFormatting.YELLOW + Utils.prettyTime((long) (remaining) * 1000 * 60 * 60 / (long) xpInterp));
}
}
@@ -256,20 +255,19 @@ public class FarmingOverlay extends TextOverlay {
float yaw = Minecraft.getMinecraft().thePlayer.rotationYawHead;
yaw %= 360;
- if(yaw < 0) yaw += 360;
- if(yaw > 180) 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");
+ 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) {
+ 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;
+ if (overlayStrings != null && overlayStrings.isEmpty()) overlayStrings = null;
}
}
-
}
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..897fbc5e 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,7 +17,6 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import java.awt.*;
-import java.util.Random;
public class FuelBar {
@@ -31,33 +29,34 @@ public class FuelBar {
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 (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;
+ if (Minecraft.getMinecraft().thePlayer == null) return;
+ if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return;
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- if(held != null) {
+ if (held != null) {
String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
- if(internalname != null && (internalname.contains("_DRILL_") || internalname.equals("DIVAN_DRILL"))) {
+ if (internalname != null && (internalname.contains("_DRILL_") || internalname.equals("DIVAN_DRILL"))) {
String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound());
- for(String line : lore) {
+ for (String line : lore) {
try {
- if(line.startsWith("\u00A77Fuel: ")) {
+ if (line.startsWith("\u00A77Fuel: ")) {
String[] split = Utils.cleanColour(line).split("/");
- if(split.length == 2) {
+ if (split.length == 2) {
String fuelS = split[0].split(" ")[1];
- int fuel = Integer.parseInt(fuelS.replace(",","").trim());
+ int fuel = Integer.parseInt(fuelS.replace(",", "").trim());
String maxFuelS = split[1].trim();
int mult = 1;
- if(maxFuelS.endsWith("k")) {
+ if (maxFuelS.endsWith("k")) {
mult = 1000;
}
- int maxFuel = Integer.parseInt(maxFuelS.replace("k", "").trim())*mult;
- fuelAmount = fuel/(float)maxFuel;
- if(fuelAmount > 1) {
+ int maxFuel = Integer.parseInt(maxFuelS.replace("k", "").trim()) * mult;
+ fuelAmount = fuel / (float) maxFuel;
+ if (fuelAmount > 1) {
fuelAmount = 1;
}
fuelString = line;
@@ -65,7 +64,7 @@ public class FuelBar {
break;
}
}
- } catch(Exception ignored) {}
+ } catch (Exception ignored) {}
}
}
}
@@ -73,65 +72,65 @@ public class FuelBar {
@SubscribeEvent
public void onRenderScreen(RenderGameOverlayEvent.Post event) {
- if(fuelAmount < 0) return;
- if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return;
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ 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);
+ 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));
+ 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)) {
+ 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);
+ 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);
+ 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));
+ int startTexX = left ? 0 : (170 + 11 - (int) Math.ceil(rCapSize));
- if(completion < 1) {
+ if (completion < 1) {
Utils.drawTexturedRect(x, y, size, 5,
- startTexX/181f, 1, 0/10f, 5/10f, GL11.GL_NEAREST);
+ 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);
+ 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;
+ int startTexX = 10 + id * 10;
- if(completion < 1) {
+ if (completion < 1) {
Utils.drawTexturedRect(x, y, 10, 5,
- startTexX/181f, (startTexX+10)/181f, 0/10f, 5/10f, GL11.GL_NEAREST);
+ 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);
+ if (completion > 0) {
+ Utils.drawTexturedRect(x, y, 10 * completion, 5,
+ startTexX / 181f, (startTexX + 10 * completion) / 181f, 5 / 10f, 10 / 10f, GL11.GL_NEAREST);
}
}
@@ -141,26 +140,26 @@ public class FuelBar {
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 0);
- xSize = xSize/1.5f;
+ 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);
+ 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 offsetCompleteX = xSize * completed;
+ for (int xOffset = 0; xOffset < xSize; xOffset += 10) {
float notchCompl = 1;
- if(xOffset > offsetCompleteX) {
+ if (xOffset > offsetCompleteX) {
notchCompl = 0;
- } else if(xOffset+10 > offsetCompleteX) {
- notchCompl = (offsetCompleteX-xOffset)/10f;
+ } else if (xOffset + 10 > offsetCompleteX) {
+ notchCompl = (offsetCompleteX - xOffset) / 10f;
}
- if(xOffset == 0) {
+ if (xOffset == 0) {
renderBarCap(0, 0, true, 0, notchCompl);
- } else if(xOffset + 11 > xSize) {
- renderBarCap(xOffset, 0, false, xSize-xOffset, notchCompl);
+ } else if (xOffset + 11 > xSize) {
+ renderBarCap(xOffset, 0, false, xSize - xOffset, notchCompl);
} else {
- renderBarNotch(xOffset, 0, xOffset/10, notchCompl);
+ renderBarNotch(xOffset, 0, xOffset / 10, notchCompl);
}
}
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..57a97161 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java
@@ -44,15 +44,15 @@ public class MiningOverlay extends TextOverlay {
@Override
public void updateFrequent() {
- if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) {
+ 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) {
+ if (containerName.equals("Commissions") && lower.getSizeInventory() >= 27) {
UpdateCommissions(lower);
- } else if(containerName.equals("Forge") && lower.getSizeInventory() >= 36) {
+ } else if (containerName.equals("Forge") && lower.getSizeInventory() >= 36) {
updateForge(lower);
}
}
@@ -70,8 +70,7 @@ public class MiningOverlay extends TextOverlay {
if (stack != null) {
String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound());
- for (int i1 = 0; i1 < lore.length; i1++) {
- String line = lore[i1];
+ for (String line : lore) {
Matcher matcher = timeRemainingForge.matcher(line);
if (stack.getDisplayName().matches("\\xA7cSlot #([1-5])")) {
ForgeItem newForgeItem = new ForgeItem(i, 1, false);
@@ -103,8 +102,7 @@ public class MiningOverlay extends TextOverlay {
if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) {
duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000;
}
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) {}
if (duration > 0) {
ForgeItem newForgeItem = new ForgeItem(Utils.cleanColour(stack.getDisplayName()), System.currentTimeMillis() + duration, i, false);
replaceForgeOrAdd(newForgeItem, hidden.forgeItems, true);
@@ -123,20 +121,18 @@ public class MiningOverlay extends TextOverlay {
private void UpdateCommissions(IInventory lower) {
// Get the location (type) of the currently shown commissions
ItemStack commTypeStack = lower.getStackInSlot(27);
- if (commTypeStack == null || !commTypeStack.hasTagCompound())
- {
+ if (commTypeStack == null || !commTypeStack.hasTagCompound()) {
return;
}
String name = Utils.cleanColour(commTypeStack.getDisplayName()).trim();
- if (!name.equals("Switch Type"))
- {
+ if (!name.equals("Switch Type")) {
return;
}
String commLocation = null;
String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(commTypeStack.getTagCompound());
- for(String line : lore) {
+ for (String line : lore) {
if (line == null) {
continue;
}
@@ -155,36 +151,36 @@ public class MiningOverlay extends TextOverlay {
}
// Now get the commission info
- for(int i=9; i<18; i++) {
+ for (int i = 9; i < 18; i++) {
ItemStack stack = lower.getStackInSlot(i);
- if(stack != null && stack.hasTagCompound()) {
+ 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) {
+ for (String line : lore) {
+ if (commName != null) {
String clean = Utils.cleanColour(line).trim();
- if(clean.isEmpty()) {
+ if (clean.isEmpty()) {
break;
} else {
Matcher matcher = NUMBER_PATTERN.matcher(clean);
- if(matcher.find()) {
+ if (matcher.find()) {
try {
numberValue = Integer.parseInt(matcher.group("number").replace(",", ""));
- } catch(NumberFormatException ignored) {}
+ } catch (NumberFormatException ignored) {}
}
}
}
- if(line.startsWith("\u00a77\u00a79")) {
+ if (line.startsWith("\u00a77\u00a79")) {
String textAfter = line.substring(4);
- if(!textAfter.contains("\u00a7") && !textAfter.equals("Rewards") && !textAfter.equals("Progress")) {
+ 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) {
+ if (commName != null && numberValue > 0) {
locationSpecific.commissionMaxes.put(commName, numberValue);
}
}
@@ -193,6 +189,7 @@ public class MiningOverlay extends TextOverlay {
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;
@@ -264,9 +261,10 @@ 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")) {
+ 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();
@@ -307,10 +305,10 @@ public class MiningOverlay extends TextOverlay {
} else {
if (name.contains("LOCKED")) {
- ForgeItem item = new ForgeItem(forgeInt, 1,true);
+ ForgeItem item = new ForgeItem(forgeInt, 1, true);
replaceForgeOrAdd(item, hidden.forgeItems, true);
} else if (name.contains("EMPTY")) {
- ForgeItem item = new ForgeItem(forgeInt, 0,true);
+ 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 {
@@ -340,8 +338,7 @@ public class MiningOverlay extends TextOverlay {
if (matcher.group("seconds") != null && !matcher.group("seconds").equals("")) {
duration = duration + (long) Integer.parseInt(matcher.group("seconds")) * 1000;
}
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) {}
if (duration > 0) {
duration = duration + 4000;
ForgeItem item = new ForgeItem(Utils.cleanColour(itemName), System.currentTimeMillis() + duration, forgeInt, true);
@@ -360,8 +357,7 @@ public class MiningOverlay extends TextOverlay {
float progress = Float.parseFloat(split[1].replace("%", "")) / 100;
progress = LerpUtils.clampZeroOne(progress);
commissionProgress.put(split[0], progress);
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) {}
} else {
commissionProgress.put(split[0], 1.0f);
}
@@ -424,8 +420,6 @@ public class MiningOverlay extends TextOverlay {
pickaxeCooldown = DARK_AQUA + "Pickaxe CD: \u00a7a" + (ItemCooldowns.pickaxeUseCooldownMillisRemaining / 1000) + "s";
}
-
-
for (int index : NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2) {
switch (index) {
case 0:
@@ -449,35 +443,35 @@ public class MiningOverlay extends TextOverlay {
}
} else {
overlayStrings = new ArrayList<>();
- if(hidden == null){
+ 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){
+ if (NotEnoughUpdates.INSTANCE.config.mining.dwarvenText2.get(i) == 3) {
forgeDisplay = true;
}
}
- if(forgeDisplay){
- if(NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 1 && !SBInfo.getInstance().isInDungeon){
+ 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){
+ } else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplayEnabledLocations == 2) {
overlayStrings.addAll(getForgeStrings(hidden.forgeItems));
}
}
}
- if(overlayStrings.isEmpty()) overlayStrings = null;
+ if (overlayStrings.isEmpty()) overlayStrings = null;
}
- private static List<String> getForgeStrings(List<ForgeItem> forgeItems){
+ 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);
+ 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) {
@@ -491,7 +485,7 @@ public class MiningOverlay extends TextOverlay {
continue forgeIDLabel;
}
} else if (NotEnoughUpdates.INSTANCE.config.mining.forgeDisplay == 2) {
- if (item.status == 2 || item.status ==0) {
+ if (item.status == 2 || item.status == 0) {
forgeString.add(item.getFormattedString(currentTimeMillis));
continue forgeIDLabel;
@@ -507,7 +501,7 @@ public class MiningOverlay extends TextOverlay {
return forgeString;
}
- private static void replaceForgeOrAdd(ForgeItem item, List<ForgeItem> forgeItems, boolean overwrite){
+ 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) {
@@ -515,10 +509,10 @@ public class MiningOverlay extends TextOverlay {
return;
} else {
ForgeItem currentItem = forgeItems.get(i);
- if (!(currentItem.status == 2 && item.status ==2)) {
+ if (!(currentItem.status == 2 && item.status == 2)) {
forgeItems.set(i, item);
return;
- } else if(currentItem.fromScoreBoard){
+ } else if (currentItem.fromScoreBoard) {
forgeItems.set(i, item);
return;
}
@@ -530,8 +524,8 @@ public class MiningOverlay extends TextOverlay {
return;
}
- public static class ForgeItem{
- public ForgeItem(String itemName, long finishTime, int forgeID, boolean fromScoreBoard){
+ public static class ForgeItem {
+ public ForgeItem(String itemName, long finishTime, int forgeID, boolean fromScoreBoard) {
this.itemName = itemName;
this.finishTime = finishTime;
this.status = 2;
@@ -539,52 +533,54 @@ public class MiningOverlay extends TextOverlay {
this.fromScoreBoard = fromScoreBoard;
}
- public ForgeItem(int forgeID, int status, boolean 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";
+ @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+": ";
+ 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);
+ 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";
+ 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 - (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";
+ 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";
+ return returnText + EnumChatFormatting.DARK_GREEN + "Done";
}
}
}
@@ -593,16 +589,16 @@ public class MiningOverlay extends TextOverlay {
@SideOnly(Side.CLIENT)
static class PlayerComparator implements Comparator<NetworkPlayerInfo> {
- private PlayerComparator() { }
+ 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();
+ 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();
}
}
@@ -680,14 +676,14 @@ public class MiningOverlay extends TextOverlay {
break;
}
if (icon == null) {
- if(beforeColon.startsWith("Forge")){
+ 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")){
+ } 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")){
+ } 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")) {
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..a9349865 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java
@@ -37,13 +37,13 @@ public class OverlayManager {
"\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));
+ 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) {
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
return TextOverlayStyle.values()[style];
}
return TextOverlayStyle.BACKGROUND;
@@ -55,13 +55,13 @@ public class OverlayManager {
"\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));
+ 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) {
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
return TextOverlayStyle.values()[style];
}
return TextOverlayStyle.BACKGROUND;
@@ -76,13 +76,13 @@ public class OverlayManager {
"\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));
+ 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) {
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
return TextOverlayStyle.values()[style];
}
return TextOverlayStyle.BACKGROUND;
@@ -98,13 +98,13 @@ public class OverlayManager {
"\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));
+ 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) {
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
return TextOverlayStyle.values()[style];
}
return TextOverlayStyle.BACKGROUND;
@@ -116,7 +116,7 @@ public class OverlayManager {
);
bonemerangOverlay = new BonemerangOverlay(NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangPosition, () -> bonemerangDummy, () -> {
int style = NotEnoughUpdates.INSTANCE.config.itemOverlays.bonemerangOverlayStyle;
- if(style >= 0 && style < TextOverlayStyle.values().length) {
+ if (style >= 0 && style < TextOverlayStyle.values().length) {
return TextOverlayStyle.values()[style];
}
return TextOverlayStyle.BACKGROUND;
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..5cd4df00 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/RancherBootOverlay.java
@@ -19,28 +19,24 @@ 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 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 (true) return false;
//if(!NotEnoughUpdates.INSTANCE.config.auctionHouseSearch.enableSearchOverlay) return false;
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) return false;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiEditSign)) return false;
- TileEntitySign tes = ((GuiEditSign)Minecraft.getMinecraft().currentScreen).tileSign;
+ 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;
+ 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() {
@@ -52,24 +48,24 @@ public class RancherBootOverlay {
Utils.drawGradientRect(0, 0, width, height, -1072689136, -804253680);
- int topY = height/4;
+ 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);
+ Gui.drawRect(width / 2 + 52, topY, width / 2 + 100, topY + 20, 0xffffffff);
- textField.render(width/2+52, topY);
+ textField.render(width / 2 + 52, topY);
- slider.x = width/2-100;
+ slider.x = width / 2 - 100;
slider.y = topY;
slider.render();
int numIcons = 3;
- int iconsLeft = width/2 - (numIcons*25 - 5)/2 ;
+ 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);
+ 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);
}
@@ -81,20 +77,20 @@ public class RancherBootOverlay {
}
public static void keyEvent() {
- if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
+ if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
Minecraft.getMinecraft().displayGuiScreen(null);
} else {
slider.keyboardInput();
- if(Keyboard.getEventKeyState()) {
+ if (Keyboard.getEventKeyState()) {
textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
- if(textField.getText().length() > 5) textField.setText(textField.getText().substring(0, 5));
+ 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) {
+ } catch (NumberFormatException ignored) {
textField.setCustomBorderColour(0xffff0000);
}
}
@@ -111,7 +107,7 @@ public class RancherBootOverlay {
public static void setValue(int value) {
setCurrentSpeed(value);
- textField.setText(""+getCurrentSpeed());
+ textField.setText("" + getCurrentSpeed());
}
public static void mouseEvent() {
@@ -121,35 +117,35 @@ public class RancherBootOverlay {
int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
- int topY = height/4;
+ 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.getEventButtonState() && Mouse.getEventButton() == -1 && textFieldClicked) {
+ textField.mouseClickMove(mouseX - 2, topY + 10, 0, 0);
}
- if(Mouse.getEventButton() != -1) {
+ if (Mouse.getEventButton() != -1) {
textFieldClicked = false;
}
- if(mouseX > width/2+52 && mouseX < width/2+100 && mouseY > topY && mouseY < topY+20) {
- if(Mouse.getEventButtonState()) {
+ 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()) {
+ if (Mouse.getEventButtonState()) {
int numIcons = 3;
- int iconsLeft = width/2 - (numIcons*25 - 5)/2 ;
+ 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) {
+ 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());
+ textField.setText("" + getCurrentSpeed());
}
return;
}
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..6756d6c0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
@@ -11,18 +11,17 @@ 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;
+ private final Position position;
protected Supplier<TextOverlayStyle> styleSupplier;
public int overlayWidth = -1;
public int overlayHeight = -1;
public List<String> overlayStrings = null;
- private Supplier<List<String>> dummyStrings;
+ private final Supplier<List<String>> dummyStrings;
public boolean shouldUpdateFrequent = false;
@@ -32,7 +31,7 @@ public abstract class TextOverlay {
public TextOverlay(Position position, Supplier<List<String>> dummyStrings, Supplier<TextOverlayStyle> styleSupplier) {
this.position = position;
this.styleSupplier = styleSupplier;
- if(dummyStrings == null) {
+ if (dummyStrings == null) {
this.dummyStrings = () -> null;
} else {
this.dummyStrings = dummyStrings;
@@ -42,7 +41,7 @@ public abstract class TextOverlay {
public Vector2f getDummySize() {
List<String> dummyStrings = this.dummyStrings.get();
- if(dummyStrings != null) {
+ if (dummyStrings != null) {
return getSize(dummyStrings);
}
return new Vector2f(100, 50);
@@ -53,6 +52,7 @@ public abstract class TextOverlay {
}
public void updateFrequent() {}
+
public abstract void update();
public void renderDummy() {
@@ -61,7 +61,7 @@ public abstract class TextOverlay {
}
public void render() {
- if(shouldUpdateFrequent) {
+ if (shouldUpdateFrequent) {
updateFrequent();
shouldUpdateFrequent = false;
}
@@ -71,14 +71,14 @@ public abstract class TextOverlay {
protected Vector2f getSize(List<String> strings) {
int overlayHeight = 0;
int overlayWidth = 0;
- for(String s : strings) {
- if(s == null) {
+ for (String s : strings) {
+ if (s == null) {
overlayHeight += 3;
continue;
}
- for(String s2 : s.split("\n")) {
+ for (String s2 : s.split("\n")) {
int sWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(s2);
- if(sWidth > overlayWidth) {
+ if (sWidth > overlayWidth) {
overlayWidth = sWidth;
}
overlayHeight += 10;
@@ -88,11 +88,11 @@ public abstract class TextOverlay {
int paddingX = 0;
int paddingY = 0;
- if(styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
+ if (styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
paddingX = PADDING_X;
paddingY = PADDING_Y;
}
- return new Vector2f(overlayWidth+paddingX*2, overlayHeight+paddingY*2);
+ return new Vector2f(overlayWidth + paddingX * 2, overlayHeight + paddingY * 2);
}
protected Vector2f getTextOffset() {
@@ -111,19 +111,19 @@ public abstract class TextOverlay {
protected void renderLine(String line, Vector2f position, boolean dummy) {}
private void render(List<String> strings, boolean dummy) {
- if(strings == null) return;
+ if (strings == null) return;
Vector2f size = getSize(strings);
- overlayHeight = (int)size.y;
- overlayWidth = (int)size.x;
+ overlayHeight = (int) size.y;
+ overlayWidth = (int) size.x;
Vector2f position = getPosition(overlayWidth, overlayHeight);
- int x = (int)position.x;
- int y = (int)position.y;
+ 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);
+ 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);
@@ -131,7 +131,7 @@ public abstract class TextOverlay {
int paddingX = 0;
int paddingY = 0;
- if(styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
+ if (styleSupplier.get() == TextOverlayStyle.BACKGROUND) {
paddingX = PADDING_X;
paddingY = PADDING_Y;
}
@@ -141,25 +141,25 @@ public abstract class TextOverlay {
paddingY += (int) textOffset.y;
int yOff = 0;
- for(String s : strings) {
- if(s == null) {
+ 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);
+ 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;
+ int xPad = (int) pos.x;
+ int yPad = (int) pos.y;
- if(style == TextOverlayStyle.FULL_SHADOW) {
+ 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)) {
+ 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);
+ xPad + xO / 2f, yPad + yO / 2f,
+ new Color(0, 0, 0, 200 / Math.max(Math.abs(xO), Math.abs(yO))).getRGB(), false);
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
index 65c7d3f6..ee29fb83 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
@@ -21,12 +21,14 @@ 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 {
@@ -41,48 +43,46 @@ public class TimersOverlay extends TextOverlay {
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;
+ private final 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 (hidden == null) return;
- if(event.type == 0) {
+ if (event.type == 0) {
long currentTime = System.currentTimeMillis();
Matcher cakeMatcher = CAKE_PATTERN.matcher(event.message.getFormattedText());
- if(cakeMatcher.matches()) {
+ if (cakeMatcher.matches()) {
hidden.firstCakeAte = currentTime;
return;
}
Matcher puzzlerMatcher = PUZZLER_PATTERN.matcher(event.message.getFormattedText());
- if(puzzlerMatcher.matches()) {
+ if (puzzlerMatcher.matches()) {
hidden.puzzlerCompleted = currentTime;
return;
}
Matcher fetchurMatcher = FETCHUR_PATTERN.matcher(event.message.getFormattedText());
- if(fetchurMatcher.matches()) {
+ if (fetchurMatcher.matches()) {
hidden.fetchurCompleted = currentTime;
return;
}
Matcher fetchur2Matcher = FETCHUR2_PATTERN.matcher(event.message.getFormattedText());
- if(fetchur2Matcher.matches()) {
+ if (fetchur2Matcher.matches()) {
hidden.fetchurCompleted = currentTime;
return;
}
-
}
}
@Override
protected Vector2f getSize(List<String> strings) {
- if(NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons)
+ if (NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons)
return super.getSize(strings).translate(12, 0);
return super.getSize(strings);
}
@@ -96,7 +96,7 @@ public class TimersOverlay extends TextOverlay {
@Override
protected void renderLine(String line, Vector2f position, boolean dummy) {
- if(!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons) {
+ if (!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoIcons) {
return;
}
GlStateManager.enableDepth();
@@ -105,13 +105,19 @@ public class TimersOverlay extends TextOverlay {
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;
+ 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[] {
+ 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),
@@ -131,21 +137,27 @@ public class TimersOverlay extends TextOverlay {
ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan"));
- long fetchurIndex = ((currentTimeEST.getDayOfMonth()+1) % 13)-1;
+ 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;
+ if (fetchurIndex < 0) fetchurIndex += 13;
- icon = FETCHUR_ICONS[(int)fetchurIndex];
+ 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 "Commissions":
+ icon = COMMISSIONS_ICON;
+ break;
+ case "Experiments":
+ icon = EXPERIMENTS_ICON;
+ break;
+ case "Cookie Buff":
+ icon = COOKIE_ICON;
+ break;
}
- if(icon != null) {
+ if (icon != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(position.x, position.y, 0);
GlStateManager.scale(0.5f, 0.5f, 1f);
@@ -161,7 +173,6 @@ public class TimersOverlay extends TextOverlay {
@Override
public void update() {
-
long currentTime = System.currentTimeMillis();
NEUConfig.HiddenProfileSpecific hidden = NotEnoughUpdates.INSTANCE.config.getProfileSpecific();
@@ -200,20 +211,20 @@ public class TimersOverlay extends TextOverlay {
}
}
ItemStack stackSuperPairs = lower.getStackInSlot(22);
- if(stackSuperPairs != null && stackSuperPairs.getItem() == Items.skull && stackSuperPairs.getTagCompound() != null){
+ 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 text = lore[lore.length - 1];
String cleanText = Utils.cleanColour(text);
- if(cleanText.equals("Experiments on cooldown!")){
+ if (cleanText.equals("Experiments on cooldown!")) {
hidden.experimentsCompleted = currentTime;
return;
}
}
hidden.experimentsCompleted = 0;
return;
- } else if(containerName.equals("Superpairs Rewards") && lower.getSizeInventory() >= 27){
+ } else if (containerName.equals("Superpairs Rewards") && lower.getSizeInventory() >= 27) {
ItemStack stack = lower.getStackInSlot(13);
- if(stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")){
+ if (stack != null && Utils.cleanColour(stack.getDisplayName()).equals("Superpairs")) {
hidden.experimentsCompleted = currentTime;
}
}
@@ -246,8 +257,7 @@ public class TimersOverlay extends TextOverlay {
if (godpotRemaingTimeUnformatted.length >= 1) {
godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 1000;
}
- } catch (Exception ignored) {
- }
+ } catch (Exception ignored) {}
hidden.godPotionDuration = godPotDuration;
@@ -310,7 +320,6 @@ public class TimersOverlay extends TextOverlay {
hidden.godPotionDuration = 0;
}
-
if (!NotEnoughUpdates.INSTANCE.config.miscOverlays.todoOverlay2) {
overlayStrings = null;
return;
@@ -352,11 +361,10 @@ public class TimersOverlay extends TextOverlay {
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 (!(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() &&
@@ -371,90 +379,89 @@ public class TimersOverlay extends TextOverlay {
} 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;
+ 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));
+ 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 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));
+ 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));
+ 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));
+ 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)) {
+ for (int index : NotEnoughUpdates.INSTANCE.config.miscOverlays.todoText2) {
+ if (map.containsKey(index)) {
overlayStrings.add(map.get(index));
}
}
- if(overlayStrings.isEmpty()) overlayStrings = null;
+ if (overlayStrings.isEmpty()) overlayStrings = null;
}
-
private enum TimeEnums {
- DAY (86400000),
+ DAY(86400000),
HALFDAY(43200000),
HOUR(3600000),
HALFANHOUR(1800000);
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..1eb8f1c0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -118,54 +118,54 @@ public class GuiProfileViewer extends GuiScreen {
public GuiProfileViewer(ProfileViewer.Profile profile) {
this.profile = profile;
String name = "";
- if(profile != null && profile.getHypixelProfile() != null) {
+ 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) {
+ if (currentPage == ProfileViewerPage.LOADING) {
currentPage = ProfileViewerPage.BASIC;
}
}
- private GuiElementTextField playerNameTextField;
+ private final GuiElementTextField playerNameTextField;
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
currentTime = System.currentTimeMillis();
- if(startTime == 0) startTime = currentTime;
+ if (startTime == 0) startTime = currentTime;
ProfileViewerPage page = currentPage;
- if(profile == null) {
+ if (profile == null) {
page = ProfileViewerPage.INVALID_NAME;
- } else if(profile.getPlayerInformation(null) == null) {
+ } else if (profile.getPlayerInformation(null) == null) {
page = ProfileViewerPage.LOADING;
- } else if(profile.getLatestProfile() == null) {
+ } else if (profile.getLatestProfile() == null) {
page = ProfileViewerPage.NO_SKYBLOCK;
}
- if(profileId == null && profile != null && profile.getLatestProfile() != null) {
+ if (profileId == null && profile != null && profile.getLatestProfile() != null) {
profileId = profile.getLatestProfile();
}
{
//this is just to cache the guild info
- if(profile != null) {
+ 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;
+ 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);
+ renderBlurredBackground(width, height, guiLeft + 2, guiTop + 2, sizeX - 4, sizeY - 4);
GlStateManager.enableDepth();
GlStateManager.translate(0, 0, 5);
@@ -187,58 +187,55 @@ public class GuiProfileViewer extends GuiScreen {
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);
+ if (!(page == ProfileViewerPage.LOADING)) {
+ playerNameTextField.render(guiLeft + sizeX - 100, guiTop + sizeY + 5);
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- if(profile != null) {
+ 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);
+ 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")) {
+ 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);
+ 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);
+ 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());
+ 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;
+ 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);
+ 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++) {
+ 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());
+ 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")) {
+ 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);
+ Utils.drawTexturedRect(guiLeft - 16 - 5, guiTop + sizeY + 2 + 23 + dropdownOptionSize * yIndex, 16, 16, GL11.GL_NEAREST);
}
}
@@ -267,10 +264,10 @@ public class GuiProfileViewer extends GuiScreen {
drawPetsPage(mouseX, mouseY, partialTicks);
break;
case LOADING:
- String str = EnumChatFormatting.YELLOW+"Loading player profiles.";
+ String str = EnumChatFormatting.YELLOW + "Loading player profiles.";
long currentTimeMod = System.currentTimeMillis() % 1000;
- if(currentTimeMod > 333) {
- if(currentTimeMod < 666) {
+ if (currentTimeMod > 333) {
+ if (currentTimeMod < 666) {
str += ".";
} else {
str += "..";
@@ -278,49 +275,49 @@ public class GuiProfileViewer extends GuiScreen {
}
Utils.drawStringCentered(str, Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+101, true, 0);
+ 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){
+ 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){
+ 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() {
@@ -337,23 +334,23 @@ public class GuiProfileViewer extends GuiScreen {
}
}
}
-
+
break;
case INVALID_NAME:
- Utils.drawStringCentered(EnumChatFormatting.RED+"Invalid name or API is down!", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+sizeX/2f, guiTop+101, true, 0);
+ 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);
+ Utils.drawStringCentered(EnumChatFormatting.RED + "No skyblock data found!", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + sizeX / 2f, guiTop + 101, true, 0);
break;
}
lastTime = currentTime;
- if(tooltipToDisplay != null) {
+ if (tooltipToDisplay != null) {
List<String> grayTooltip = new ArrayList<>(tooltipToDisplay.size());
- for(String line : tooltipToDisplay) {
+ for (String line : tooltipToDisplay) {
grayTooltip.add(EnumChatFormatting.GRAY + line);
}
Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj);
@@ -363,15 +360,15 @@ public class GuiProfileViewer extends GuiScreen {
private void renderTabs(boolean renderPressed) {
int ignoredTabs = 0;
- for(int i=0; i<ProfileViewerPage.values().length; i++) {
+ for (int i = 0; i < ProfileViewerPage.values().length; i++) {
ProfileViewerPage page = ProfileViewerPage.values()[i];
- if(page.stack == null) {
+ if (page.stack == null) {
ignoredTabs++;
continue;
}
boolean pressed = page == currentPage;
- if(pressed == renderPressed) {
- renderTab(page.stack, i-ignoredTabs, pressed);
+ if (pressed == renderPressed) {
+ renderTab(page.stack, i - ignoredTabs, pressed);
}
}
}
@@ -383,25 +380,25 @@ public class GuiProfileViewer extends GuiScreen {
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
- int x = guiLeft+xIndex*28;
- int y = guiTop-28;
+ 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;
+ 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;
+ if (xIndex != 0) {
+ uMin = 28 / 256f;
+ uMax = 56 / 256f;
}
- renderBlurredBackground(width, height, x+2, y+2, 28-4, 28-4);
+ renderBlurredBackground(width, height, x + 2, y + 2, 28 - 4, 28 - 4);
} else {
- renderBlurredBackground(width, height, x+2, y+4, 28-4, 28-4);
+ renderBlurredBackground(width, height, x + 2, y + 4, 28 - 4, 28 - 4);
}
GlStateManager.disableLighting();
@@ -411,29 +408,29 @@ public class GuiProfileViewer extends GuiScreen {
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);
+ Utils.drawTexturedRect(x, y, 28, pressed ? 32 : 31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
GlStateManager.enableDepth();
- Utils.drawItemStack(stack, x+6, y+9);
+ 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) {
+ if (currentPage != ProfileViewerPage.LOADING && currentPage != ProfileViewerPage.INVALID_NAME) {
int ignoredTabs = 0;
- for(int i=0; i<ProfileViewerPage.values().length; i++) {
+ for (int i = 0; i < ProfileViewerPage.values().length; i++) {
ProfileViewerPage page = ProfileViewerPage.values()[i];
- if(page.stack == null) {
+ if (page.stack == null) {
ignoredTabs++;
continue;
}
int i2 = i - ignoredTabs;
- int x = guiLeft+i2*28;
- int y = guiTop-28;
+ 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();
+ if (mouseX > x && mouseX < x + 28) {
+ if (mouseY > y && mouseY < y + 32) {
+ if (currentPage != page) Utils.playPressSound();
currentPage = page;
inventoryTextField.otherComponentClick();
playerNameTextField.otherComponentClick();
@@ -448,8 +445,8 @@ public class GuiProfileViewer extends GuiScreen {
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) {
+ 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;
@@ -457,16 +454,16 @@ public class GuiProfileViewer extends GuiScreen {
}
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;
+ 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) {
+ if (mouseX > guiLeft + x && mouseX < guiLeft + x + 20) {
+ if (mouseY > guiTop + y && mouseY < guiTop + y + 20) {
selectedPet = i;
return;
}
@@ -474,18 +471,18 @@ public class GuiProfileViewer extends GuiScreen {
}
break;
}
- if(mouseX > guiLeft+sizeX-100 && mouseX < guiLeft+sizeX) {
- if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) {
+ 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{
+ 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));
+ desk.browse(new URI("https://sky.shiiyu.moe/stats/" + profile.getHypixelProfile().get("displayname").getAsString() + "/" + profileId));
Utils.playPressSound();
return;
} catch (UnsupportedOperationException | IOException | URISyntaxException ignored) {
@@ -496,41 +493,41 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- if(mouseX > guiLeft && mouseX < guiLeft+100 && profile != null && !profile.getProfileIds().isEmpty()) {
+ 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) {
+ 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)) {
+ for (int index = 0; index < profile.getProfileIds().size(); index++) {
+ if (profile.getProfileIds().get(index).equals(profileId)) {
profileNum = index;
break;
}
}
- if(mouseButton == 0) {
+ if (mouseButton == 0) {
profileNum++;
} else {
profileNum--;
}
- if(profileNum >= profile.getProfileIds().size()) profileNum = 0;
- if(profileNum < 0) profileNum = profile.getProfileIds().size()-1;
+ 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)) {
+ 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()) {
+ } 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)) {
+ if (profileId != null && !profileId.equals(newProfileId)) {
resetCache();
}
profileId = newProfileId;
@@ -560,11 +557,11 @@ public class GuiProfileViewer extends GuiScreen {
keyTypedDung(typedChar, keyCode);
break;
}
- if(playerNameTextField.getFocus() && !(currentPage == ProfileViewerPage.LOADING)) {
- if(keyCode == Keyboard.KEY_RETURN) {
+ 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();
+ if (profile != null) profile.resetCache();
Minecraft.getMinecraft().displayGuiScreen(new GuiProfileViewer(profile));
});
}
@@ -589,38 +586,38 @@ public class GuiProfileViewer extends GuiScreen {
}
protected void mouseClickedDung(int mouseX, int mouseY, int mouseButton) {
- if(mouseX >= guiLeft+50 && mouseX <= guiLeft+70 &&
- mouseY >= guiTop+54 && mouseY <= guiTop+64) {
+ 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) {
+ if (mouseX >= guiLeft + 23 + 110 - 17 - cW && mouseX <= guiLeft + 23 + 110 - 17 &&
+ mouseY >= guiTop + 55 && mouseY <= guiTop + 65) {
calculateFloorLevelXP();
}
- int y = guiTop+142;
+ int y = guiTop + 142;
- if(mouseY >= y-2 && mouseY <= y+9) {
- for(int i=1; i<=7; i++) {
- int w = fontRendererObj.getStringWidth(""+i);
+ 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;
+ int x = guiLeft + 23 + 110 * i / 8 - w / 2;
- if(mouseX >= x-2 && mouseX <= x+7) {
+ if (mouseX >= x - 2 && mouseX <= x + 7) {
floorTime = i;
return;
}
}
}
- if(mouseX >= guiLeft-29 && mouseX <= guiLeft){
- if(mouseY >= guiTop && mouseY<= guiTop+28){
+ if (mouseX >= guiLeft - 29 && mouseX <= guiLeft) {
+ if (mouseY >= guiTop && mouseY <= guiTop + 28) {
onMasterMode = false;
return;
- } else if(mouseY+28 >= guiTop && mouseY<= guiTop+28*2){
+ } else if (mouseY + 28 >= guiTop && mouseY <= guiTop + 28 * 2) {
onMasterMode = true;
return;
}
@@ -632,31 +629,39 @@ public class GuiProfileViewer extends GuiScreen {
}
protected void keyTypedInvs(char typedChar, int keyCode) throws IOException {
- switch(keyCode) {
+ switch (keyCode) {
case Keyboard.KEY_1:
case Keyboard.KEY_NUMPAD1:
- selectedInventory = "inv_contents"; break;
+ selectedInventory = "inv_contents";
+ break;
case Keyboard.KEY_2:
case Keyboard.KEY_NUMPAD2:
- selectedInventory = "ender_chest_contents"; break;
+ selectedInventory = "ender_chest_contents";
+ break;
case Keyboard.KEY_3:
case Keyboard.KEY_NUMPAD3:
- selectedInventory = "backpack_contents"; break;
+ selectedInventory = "backpack_contents";
+ break;
case Keyboard.KEY_4:
case Keyboard.KEY_NUMPAD4:
- selectedInventory = "personal_vault_contents"; break;
+ selectedInventory = "personal_vault_contents";
+ break;
case Keyboard.KEY_5:
case Keyboard.KEY_NUMPAD5:
- selectedInventory = "talisman_bag"; break;
+ selectedInventory = "talisman_bag";
+ break;
case Keyboard.KEY_6:
case Keyboard.KEY_NUMPAD6:
- selectedInventory = "wardrobe_contents"; break;
+ selectedInventory = "wardrobe_contents";
+ break;
case Keyboard.KEY_7:
case Keyboard.KEY_NUMPAD7:
- selectedInventory = "fishing_bag"; break;
+ selectedInventory = "fishing_bag";
+ break;
case Keyboard.KEY_8:
case Keyboard.KEY_NUMPAD8:
- selectedInventory = "potion_bag"; break;
+ selectedInventory = "potion_bag";
+ break;
}
Utils.playPressSound();
@@ -665,7 +670,7 @@ public class GuiProfileViewer extends GuiScreen {
protected void keyTypedCols(char typedChar, int keyCode) throws IOException {
ItemStack stack = null;
Iterator<ItemStack> items = ProfileViewer.getCollectionCatToCollectionMap().keySet().iterator();
- switch(keyCode) {
+ switch (keyCode) {
case Keyboard.KEY_5:
case Keyboard.KEY_NUMPAD5:
stack = items.next();
@@ -682,21 +687,21 @@ public class GuiProfileViewer extends GuiScreen {
case Keyboard.KEY_NUMPAD1:
stack = items.next();
}
- if(stack != null) {
+ 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) {
+ 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) {
+ } else if (mouseX > guiLeft + 100 + 15 && mouseX < guiLeft + 100 + 20 + 12) {
+ if (sortedPets != null && petsPage < Math.ceil(sortedPets.size() / 20f) - 1) {
petsPage++;
}
return;
@@ -705,18 +710,18 @@ public class GuiProfileViewer extends GuiScreen {
}
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();
+ 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;
}
@@ -726,24 +731,24 @@ public class GuiProfileViewer extends GuiScreen {
}
JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
- if(inventoryInfo == null) return;
+ if (inventoryInfo == null) return;
ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
- if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1;
- if(currentInventoryIndex < 0) currentInventoryIndex = 0;
+ if (currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length - 1;
+ if (currentInventoryIndex < 0) currentInventoryIndex = 0;
ItemStack[][] inventory = inventories[currentInventoryIndex];
- if(inventory == null) return;
+ if (inventory == null) return;
int inventoryRows = inventory.length;
- int invSizeY = inventoryRows*18+17+7;
+ int invSizeY = inventoryRows * 18 + 17 + 7;
- int y = guiTop+101-invSizeY/2;
- int staticSelectorHeight = guiTop+177;
+ 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) {
+ if (mouseY > staticSelectorHeight && mouseY < staticSelectorHeight + 16) {
+ if (mouseX > guiLeft + 320 - 12 && mouseX < guiLeft + 320 + 12) {
+ if (mouseX < guiLeft + 320) {
currentInventoryIndex--;
} else {
currentInventoryIndex++;
@@ -757,11 +762,11 @@ public class GuiProfileViewer extends GuiScreen {
private void mouseReleasedCols(int mouseX, int mouseY, int mouseButton) {
int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
- int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
+ 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) {
+ 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;
@@ -774,13 +779,13 @@ public class GuiProfileViewer extends GuiScreen {
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 final HashMap<String, ProfileViewer.Level> levelObjCatas = new HashMap<>();
+ private final HashMap<String, HashMap<String, ProfileViewer.Level>> levelObjClasseses = new HashMap<>();
- private GuiElementTextField dungeonLevelTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+ 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),
+ 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 = {
@@ -798,9 +803,9 @@ public class GuiProfileViewer extends GuiScreen {
private void calculateFloorLevelXP() {
JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
+ if (leveling == null) return;
ProfileViewer.Level levelObjCata = levelObjCatas.get(profileId);
- if(levelObjCata == null) return;
+ if (levelObjCata == null) return;
try {
dungeonLevelTextField.setCustomBorderColour(0xffffffff);
@@ -810,26 +815,27 @@ public class GuiProfileViewer extends GuiScreen {
float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel);
- for(int level=0; level<Math.min(floorLevelTo, levelingArray.size()); level++) {
- if(level < Math.floor(levelObjCata.level)) {
+ 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) {
+ if (remaining < 0) {
remaining = 0;
}
floorLevelToXP = (int) remaining;
- } catch(Exception e) {
+ } 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));
+ 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));
}
@@ -838,26 +844,25 @@ public class GuiProfileViewer extends GuiScreen {
Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
JsonObject hypixelInfo = profile.getHypixelProfile();
- if(hypixelInfo == null) return;
+ if (hypixelInfo == null) return;
JsonObject profileInfo = profile.getProfileInformation(profileId);
- if(profileInfo == null) return;
+ if (profileInfo == null) return;
JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
+ if (leveling == null) return;
int sectionWidth = 110;
- String dungeonString = onMasterMode?"master_catacombs":"catacombs";
+ 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);
-
+ 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) {
+ if (levelObjCata == null) {
float cataXp = Utils.getElementAsFloat(Utils.getElement(profileInfo,
"dungeons.dungeon_types.catacombs.experience"), 0);
levelObjCata = ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
@@ -865,37 +870,37 @@ public class GuiProfileViewer extends GuiScreen {
levelObjCatas.put(profileId, levelObjCata);
}
- String skillName = EnumChatFormatting.RED+"Catacombs";
+ String skillName = EnumChatFormatting.RED + "Catacombs";
float level = levelObjCata.level;
- int levelFloored = (int)Math.floor(level);
+ int levelFloored = (int) Math.floor(level);
- if(floorLevelTo == -1 && levelFloored >= 0) {
- dungeonLevelTextField.setText(""+(levelFloored+1));
+ if (floorLevelTo == -1 && levelFloored >= 0) {
+ dungeonLevelTextField.setText("" + (levelFloored + 1));
calculateFloorLevelXP();
}
- int x = guiLeft+23;
- int y = guiTop+25;
+ 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);
+ 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) {
+ 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)) {
+ 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);
+ 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);
@@ -905,47 +910,47 @@ public class GuiProfileViewer extends GuiScreen {
"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("# 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))));
+ 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))));
+ 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))));
+ if (timeF7 > 1000) {
+ tooltipToDisplay.add(String.format("Expected Time (F7) : %s", Utils.prettyTime(runsF7 * (long) (timeF7 * 1.2))));
hasTime = true;
}
- if(hasTime) {
+ 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_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("");
+ 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("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]");
+ tooltipToDisplay.add("[Hold " + EnumChatFormatting.YELLOW + "CTRL" + EnumChatFormatting.GRAY + " to see details]");
}
}
dungeonLevelTextField.setSize(20, 10);
- dungeonLevelTextField.render(x+22, y+29);
+ dungeonLevelTextField.render(x + 22, y + 29);
int calcLen = fontRendererObj.getStringWidth("Calculate");
- Utils.renderShadowedString(EnumChatFormatting.WHITE+"Calculate", x+sectionWidth-17-calcLen/2f,
- y+30, 100);
+ Utils.renderShadowedString(EnumChatFormatting.WHITE + "Calculate", x + sectionWidth - 17 - calcLen / 2f,
+ y + 30, 100);
//Random stats
@@ -954,114 +959,114 @@ public class GuiProfileViewer extends GuiScreen {
float totalRuns = 0;
float totalRunsF = 0;
float totalRunsF5 = 0;
- for(int i=1; i<=7; i++) {
+ for (int i = 1; i <= 7; i++) {
float runs = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.tier_completions."+i), 0);
+ "dungeons.dungeon_types.catacombs.tier_completions." + i), 0);
totalRunsF += runs;
- if(i >= 5) {
+ if (i >= 5) {
totalRunsF5 += runs;
}
}
float totalRunsM = 0;
float totalRunsM5 = 0;
- for(int i=1; i<=7; i++) {
+ for (int i = 1; i <= 7; i++) {
float runs = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.master_catacombs.tier_completions."+i), 0);
+ "dungeons.dungeon_types.master_catacombs.tier_completions." + i), 0);
totalRunsM += runs;
- if(i >= 5) {
+ if (i >= 5) {
totalRunsM5 += runs;
}
}
- totalRuns=totalRunsF+totalRunsM;
+ totalRuns = totalRunsF + totalRunsM;
float mobKills = 0;
float mobKillsF = 0;
float mobKillsF5 = 0;
- for(int i=1; i<=7; i++) {
+ for (int i = 1; i <= 7; i++) {
float kills = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.catacombs.mobs_killed."+i), 0);
+ "dungeons.dungeon_types.catacombs.mobs_killed." + i), 0);
mobKillsF += kills;
- if(i >= 5) {
+ if (i >= 5) {
mobKillsF5 += kills;
}
}
float mobKillsM = 0;
float mobKillsM5 = 0;
- for(int i=1; i<=7; i++) {
+ for (int i = 1; i <= 7; i++) {
float kills = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types.master_catacombs.mobs_killed."+i), 0);
+ "dungeons.dungeon_types.master_catacombs.mobs_killed." + i), 0);
mobKillsM += kills;
- if(i >= 5) {
+ if (i >= 5) {
mobKillsM5 += kills;
}
}
- mobKills = mobKillsF+mobKillsM;
+ mobKills = mobKillsF + mobKillsM;
- int miscTopY = y+55;
+ 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);
+ 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;
+ int y3 = y + 117;
- for(int i=1; i<=7; i++) {
- int w = fontRendererObj.getStringWidth(""+i);
+ for (int i = 1; i <= 7; i++) {
+ int w = fontRendererObj.getStringWidth("" + i);
- int bx = x+sectionWidth*i/8-w/2;
+ 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;
+ 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,
+ 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);
+ 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);
+ "dungeons.dungeon_types." + dungeonString + ".fastest_time." + floorTime), 0);
float timeS = Utils.getElementAsFloat(Utils.getElement(profileInfo,
- "dungeons.dungeon_types."+dungeonString+".fastest_time_s."+floorTime), 0);
+ "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);
+ "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;
+ 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++) {
+ 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);
+ "dungeons.dungeon_types." + dungeonString + ".tier_completions." + i), 0);
- if(BOSS_HEADS[i-1] == null) {
- String textureLink = bossFloorHeads[i-1];
+ 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()));
@@ -1085,59 +1090,58 @@ public class GuiProfileViewer extends GuiScreen {
nbt.setTag("SkullOwner", skullOwner);
stack.setTagCompound(nbt);
- BOSS_HEADS[i-1] = stack;
+ BOSS_HEADS[i - 1] = stack;
}
GlStateManager.pushMatrix();
- GlStateManager.translate(x-4, y+10+20*(i-1), 0);
+ 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);
+ 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);
+ 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;
+ 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);
+ 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()) {
+ if (activeClassElement instanceof JsonPrimitive && ((JsonPrimitive) activeClassElement).isString()) {
activeClass = activeClassElement.getAsString();
}
- for(int i=0; i<dungSkillsName.length; i++) {
+ 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)) {
+ 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);
+ "dungeons.player_classes." + skillName.toLowerCase() + ".experience"), 0);
ProfileViewer.Level levelObj = ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(),
- cataXp, 50, false);
+ cataXp, 50, false);
levelObjClasses.put(skillName, levelObj);
}
String colour = EnumChatFormatting.WHITE.toString();
- if(skillName.toLowerCase().equals(activeClass)) {
+ 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);
+ renderXpBar(colour + skillName, dungSkillsStack[i], x, y + 20 + 29 * i, sectionWidth, levelObj, mouseX, mouseY);
}
}
@@ -1148,17 +1152,16 @@ public class GuiProfileViewer extends GuiScreen {
//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();
+ private void drawSideButtons() {
+ // GlStateManager.pushMatrix();
GlStateManager.enableDepth();
GlStateManager.translate(0, 0, 5);
- if(onMasterMode){
+ if (onMasterMode) {
drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), true);
} else {
drawSideButton(0, dungeonsModeIcons.get("catacombs"), true);
@@ -1166,7 +1169,7 @@ public class GuiProfileViewer extends GuiScreen {
GlStateManager.translate(0, 0, -3);
GlStateManager.translate(0, 0, -2);
- if(!onMasterMode){
+ if (!onMasterMode) {
drawSideButton(1, dungeonsModeIcons.get("master_catacombs"), false);
} else {
drawSideButton(0, dungeonsModeIcons.get("catacombs"), false);
@@ -1175,36 +1178,32 @@ public class GuiProfileViewer extends GuiScreen {
//GlStateManager.popMatrix();
}
-
-
-
- private void drawSideButton(int yIndex, ItemStack itemStack, boolean pressed){
+ 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;
+ 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;
+ 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;
+ if (yIndex != 0) {
+ vMin = 228 / 256f;
vMax = 1f;
}
- renderBlurredBackground(width, height, x+2, y+2, 30, 28-4);
+ renderBlurredBackground(width, height, x + 2, y + 2, 30, 28 - 4);
} else {
- renderBlurredBackground(width, height, x+2, y+2, 28-2, 28-4);
+ renderBlurredBackground(width, height, x + 2, y + 2, 28 - 2, 28 - 4);
}
GlStateManager.disableLighting();
@@ -1215,36 +1214,33 @@ public class GuiProfileViewer extends GuiScreen {
Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements);
- Utils.drawTexturedRect(x, y, pressed?32:28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x, y, pressed ? 32 : 28, 28, uMin, uMax, vMin, vMax, GL11.GL_NEAREST);
GlStateManager.enableDepth();
- Utils.drawItemStack(itemStack, x+8, y+7);
-
-
-
+ 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);
+ int levelFloored = (int) Math.floor(level);
- Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, xSize-20);
+ Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, xSize - 20);
- if(levelObj.maxed) {
- renderGoldBar(x, y+6, xSize);
+ if (levelObj.maxed) {
+ renderGoldBar(x, y + 6, xSize);
} else {
- renderBar(x, y+6, xSize, level%1);
+ renderBar(x, y + 6, xSize, level % 1);
}
- if(mouseX > x && mouseX < x+120) {
- if(mouseY > y-4 && mouseY < y+13) {
+ if (mouseX > x && mouseX < x + 120) {
+ if (mouseY > y - 4 && mouseY < y + 13) {
String levelStr;
- if(levelObj.maxed) {
- levelStr = EnumChatFormatting.GOLD+"MAXED!";
+ if (levelObj.maxed) {
+ levelStr = EnumChatFormatting.GOLD + "MAXED!";
} else {
- int maxXp = (int)levelObj.maxXpForLevel;
- levelStr = EnumChatFormatting.DARK_PURPLE.toString() + shortNumberFormat(Math.round((level%1)*maxXp),
+ int maxXp = (int) levelObj.maxXpForLevel;
+ levelStr = EnumChatFormatting.DARK_PURPLE + shortNumberFormat(Math.round((level % 1) * maxXp),
0) + "/" + shortNumberFormat(maxXp, 0);
}
@@ -1252,11 +1248,11 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- GL11.glTranslatef((x), (y-6f), 0);
+ 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);
+ GL11.glScalef(1 / 0.7f, 1 / 0.7f, 1);
+ GL11.glTranslatef(-(x), -(y - 6f), 0);
}
public static class PetLevel {
@@ -1268,14 +1264,14 @@ public class GuiProfileViewer extends GuiScreen {
public float totalXp;
}
- private static JsonObject getPetInfo(String pet_name, String rarity){
+ 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)){
+ 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")){
+ if (pet.has("type") && pet.has("pet_levels")) {
int type = pet.get("type").getAsInt();
switch (type) {
case 1:
@@ -1293,13 +1289,13 @@ public class GuiProfileViewer extends GuiScreen {
} else {
petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
}
- if(pet.has("max_level")){
+ 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")){
+ 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));
@@ -1312,7 +1308,6 @@ public class GuiProfileViewer extends GuiScreen {
petInfo.add("pet_levels", Constants.PETS.getAsJsonArray("pet_levels"));
}
-
return petInfo;
}
@@ -1330,12 +1325,12 @@ public class GuiProfileViewer extends GuiScreen {
boolean addLevel = true;
- for(int i=offset; i<offset+maxPetLevel-1; i++) {
- if(addLevel) {
+ 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));
+ if (xpTotal > exp) {
+ currentLevelProgress = (exp - (xpTotal - currentLevelRequirement));
addLevel = false;
} else {
level += 1;
@@ -1347,23 +1342,24 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- level += currentLevelProgress/currentLevelRequirement;
- if(level <= 0) {
+ level += currentLevelProgress / currentLevelRequirement;
+ if (level <= 0) {
level = 1;
- } else if(level > maxPetLevel) {
+ } else if (level > maxPetLevel) {
level = maxPetLevel;
}
PetLevel levelObj = new PetLevel();
levelObj.level = level;
levelObj.currentLevelRequirement = currentLevelRequirement;
levelObj.maxXP = xpTotal;
- levelObj.levelPercentage = currentLevelProgress/currentLevelRequirement;
+ 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);
@@ -1381,7 +1377,9 @@ public class GuiProfileViewer extends GuiScreen {
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);
@@ -1398,6 +1396,7 @@ public class GuiProfileViewer extends GuiScreen {
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");
@@ -1406,68 +1405,69 @@ public class GuiProfileViewer extends GuiScreen {
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;
+ if (petsInfo == null) return;
JsonObject petsJson = Constants.PETS;
- if(petsJson == null) return;
+ if (petsJson == null) return;
String location = null;
JsonObject status = profile.getPlayerStatus();
- if(status != null && status.has("mode")) {
+ if (status != null && status.has("mode")) {
location = status.get("mode").getAsString();
}
- backgroundRotation += (currentTime - lastTime)/400f;
+ backgroundRotation += (currentTime - lastTime) / 400f;
backgroundRotation %= 360;
String panoramaIdentifier = "day";
- if(SBInfo.getInstance().currentTimeDate != null) {
- if(SBInfo.getInstance().currentTimeDate.getHours() <= 6 ||
+ 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) {
+ if (sortedPets == null) {
sortedPets = new ArrayList<>();
sortedPetsStack = new ArrayList<>();
- for(int i=0; i<pets.size(); i++) {
+ 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;
+ 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;
+ if (tierNum2 == null) return -1;
int tierNum2I = Integer.parseInt(tierNum2);
float exp2 = pet2.get("exp").getAsFloat();
- if(tierNum1I != tierNum2I) {
+ if (tierNum1I != tierNum2I) {
return tierNum2I - tierNum1I;
} else {
- return (int)(exp2 - exp1);
+ return (int) (exp2 - exp1);
}
});
- for(JsonObject pet : sortedPets) {
+ 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);
+ 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 (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);
+ 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);
@@ -1479,71 +1479,72 @@ public class GuiProfileViewer extends GuiScreen {
pet.addProperty("currentLevelRequirement", currentLevelRequirement);
pet.addProperty("maxXP", maxXP);
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname+";"+tierNum);
- if(petItem == null) continue;
+ 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));
+ HashMap<String, String> replacements = NotEnoughUpdates.INSTANCE.manager.getLoreReplacements(petname, tier, (int) Math.floor(level));
- if(heldItem != null) {
+ 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()) {
+ 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) {}
+ 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()) {
+ 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) {}
+ 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 tag = stack.getTagCompound() == null ? new NBTTagCompound() : stack.getTagCompound();
+ if (tag.hasKey("display", 10)) {
NBTTagCompound display = tag.getCompoundTag("display");
- if(display.hasKey("Lore", 9)) {
+ 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++) {
+ for (int j = 0; j < lore.tagCount(); j++) {
String line = lore.getStringTagAt(j);
- if(line.trim().isEmpty()) {
+ if (line.trim().isEmpty()) {
blankLocations.put(blankLocations.size(), j);
}
- for(Map.Entry<String, String> replacement : replacements.entrySet()) {
- line = line.replace("{"+replacement.getKey()+"}", replacement.getValue());
+ 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){
+ Integer secondLastBlank = blankLocations.get(blankLocations.size() - 2);
+ if (skin != null) {
JsonObject petSkin = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PET_SKIN_" + skin);
- if(petSkin != null){
+ 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){
+ if (name != null) {
name = Utils.cleanColour(name);
- newLore.set(0, new NBTTagString(newLore.get(0).toString().replace("\"" , "") + ", " + 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++){
+ 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\"")){
+ if (cleaned.equals("\"Right-click to add this pet to\"")) {
newLore.removeTag(i + 1);
newLore.removeTag(i);
secondLastBlank = i - 1;
@@ -1553,7 +1554,7 @@ public class GuiProfileViewer extends GuiScreen {
NBTTagList temp = new NBTTagList();
for (int i = 0; i < newLore.tagCount(); i++) {
temp.appendTag(newLore.get(i));
- if(secondLastBlank != null && i == secondLastBlank) {
+ if (secondLastBlank != null && i == secondLastBlank) {
if (heldItem != null) {
temp.appendTag(new NBTTagString(EnumChatFormatting.GOLD + "Held Item: " + heldItemJson.get("displayname").getAsString()));
int blanks = 0;
@@ -1580,10 +1581,10 @@ public class GuiProfileViewer extends GuiScreen {
newLore = temp;
display.setTag("Lore", newLore);
}
- if(display.hasKey("Name", 8)) {
+ 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());
+ for (Map.Entry<String, String> replacement : replacements.entrySet()) {
+ displayName = displayName.replace("{" + replacement.getKey() + "}", replacement.getValue());
}
display.setTag("Name", new NBTTagString(displayName));
}
@@ -1595,21 +1596,21 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- Panorama.drawPanorama(-backgroundRotation, guiLeft+212, guiTop+44, 81, 108, -0.37f, 0.6f,
- getPanoramasForLocation(location==null?"dynamic":location, panoramaIdentifier));
+ 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);
+ 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()) {
+ if (selectedPet == -1 && activePetElement != null && activePetElement.isJsonObject()) {
JsonObject active = activePetElement.getAsJsonObject();
- for(int i=0; i<sortedPets.size(); i++) {
- if(sortedPets.get(i) == active) {
+ for (int i = 0; i < sortedPets.size(); i++) {
+ if (sortedPets.get(i) == active) {
selectedPet = i;
break;
}
@@ -1618,81 +1619,77 @@ public class GuiProfileViewer extends GuiScreen {
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) {
+ 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) {
+ } 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 > 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);
+ 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++) {
+ 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) {
+ 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;
+ 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);
+ 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.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);
+ 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) {
+ 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) {
+ 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 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;
+ 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());
+ 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);
+ Minecraft.getMinecraft().fontRendererObj.drawString(display, -halfDisplayLen - 28, 0, 0, true);
GlStateManager.enableDepth();
GlStateManager.translate(-55, 0, 0);
@@ -1706,70 +1703,70 @@ public class GuiProfileViewer extends GuiScreen {
float maxXP = pet.get("maxXP").getAsFloat();
String[] split = display.split("] ");
- String colouredName = split[split.length-1];
+ String colouredName = split[split.length - 1];
- Utils.renderAlignedString(colouredName, EnumChatFormatting.WHITE+"Level "+(int)Math.floor(level), guiLeft+319, guiTop+28, 98);
+ 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);
+ 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 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 + "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);
+ 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 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 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 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);
+ 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;
+ if (resourceCollectionInfo == null) return;
int collectionCatSize = ProfileViewer.getCollectionCatToCollectionMap().size();
- int collectionCatYSize = (int)(162f/(collectionCatSize-1+0.0000001f));
+ int collectionCatYSize = (int) (162f / (collectionCatSize - 1 + 0.0000001f));
{
int yIndex = 0;
- for(ItemStack stack : ProfileViewer.getCollectionCatToCollectionMap().keySet()) {
- if(selectedCollectionCategory == null) selectedCollectionCategory = stack;
+ 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));
+ 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));
+ 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);
+ guiLeft + 134, guiTop + 14, true, 4210752);
JsonObject minionTiers = collectionInfo.get("minion_tiers").getAsJsonObject();
JsonObject collectionTiers = collectionInfo.get("collection_tiers").getAsJsonObject();
@@ -1778,21 +1775,21 @@ public class GuiProfileViewer extends GuiScreen {
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++) {
+ if (collections != null) {
+ for (int i = 0; i < collections.size(); i++) {
String collection = collections.get(i);
- if(collection != null) {
+ if (collection != null) {
ItemStack collectionItem = ProfileViewer.getCollectionToCollectionDisplayMap().get(collection);
- if(collectionItem != null) {
- int xIndex = i%COLLS_XCOUNT;
- int yIndex = i/COLLS_XCOUNT;
+ 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;
+ 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) {
+ int tier = (int) Utils.getElementAsFloat(collectionTiers.get(collection), 0);
+ if (tier > 20 || tier < 0) {
tierString = String.valueOf(tier);
} else {
tierString = romans[tier];
@@ -1802,43 +1799,43 @@ public class GuiProfileViewer extends GuiScreen {
Color color = new Color(128, 128, 128, 255);
int tierStringColour = color.getRGB();
float completedness = 0;
- if(maxAmount > 0) {
- completedness = amount/maxAmount;
+ if (maxAmount > 0) {
+ completedness = amount / maxAmount;
}
completedness = Math.min(1, completedness);
- if(maxAmounts.has(collection) && completedness >= 1) {
+ 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);
+ 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);
+ 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) {
+ 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);
+ (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) {
+ if (tier >= 0) {
Utils.drawStringCentered(tierString, fontRendererObj,
- guiLeft+x+10, guiTop+y-4, true,
+ guiLeft + x + 10, guiTop + y - 4, true,
tierStringColour);
}
- Utils.drawStringCentered(shortNumberFormat(amount, 0)+"", fontRendererObj,
- guiLeft+x+10, guiTop+y+26, true,
+ Utils.drawStringCentered(shortNumberFormat(amount, 0) + "", fontRendererObj,
+ guiLeft + x + 10, guiTop + y + 26, true,
color.getRGB());
}
}
@@ -1846,14 +1843,13 @@ public class GuiProfileViewer extends GuiScreen {
}
Utils.drawStringCentered(selectedCollectionCategory.getDisplayName() + " Minions", Minecraft.getMinecraft().fontRendererObj,
- guiLeft+326, guiTop+14, true, 4210752);
-
+ guiLeft + 326, guiTop + 14, true, 4210752);
List<String> minions = ProfileViewer.getCollectionCatToMinionMap().get(selectedCollectionCategory);
- if(minions != null) {
- for(int i=0; i<minions.size(); i++) {
+ if (minions != null) {
+ for (int i = 0; i < minions.size(); i++) {
String minion = minions.get(i);
- if(minion != null) {
+ if (minion != null) {
JsonObject misc = Constants.MISC;
float MAX_MINION_TIER = Utils.getElementAsFloat(Utils.getElement(misc, "minions." + minion + "_GENERATOR"), 11);
@@ -1865,52 +1861,52 @@ public class GuiProfileViewer extends GuiScreen {
minionJson = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(minion + "_GENERATOR_" + tier);
}
- if(minionJson != null) {
- int xIndex = i%COLLS_XCOUNT;
- int yIndex = i/COLLS_XCOUNT;
+ 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;
+ 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) {
+ if (tier - 1 >= romans.length || tier - 1 < 0) {
tierString = String.valueOf(tier);
} else {
- tierString = romans[tier-1];
+ tierString = romans[tier - 1];
}
Color color = new Color(128, 128, 128, 255);
int tierStringColour = color.getRGB();
- float completedness = tier/MAX_MINION_TIER;
+ float completedness = tier / MAX_MINION_TIER;
completedness = Math.min(1, completedness);
- if(completedness >= 1) {
+ 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);
+ 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.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);
+ 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) {
+ 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) {
+ if (tier >= 0) {
Utils.drawStringCentered(tierString, fontRendererObj,
- guiLeft+x+10, guiTop+y-4, true,
+ guiLeft + x + 10, guiTop + y - 4, true,
tierStringColour);
}
}
@@ -1922,29 +1918,29 @@ public class GuiProfileViewer extends GuiScreen {
}
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("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"));
+ 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) {
+ 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;
+ 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)) ||
+ if ((specific && item.get("internalname").getAsString().equals(internalname)) ||
(!specific && item.get("internalname").getAsString().contains(internalname))) {
- if(item.has("count")) {
+ if (item.has("count")) {
count += item.get("count").getAsInt();
} else {
count += 1;
@@ -1962,35 +1958,35 @@ public class GuiProfileViewer extends GuiScreen {
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) {
+ 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;
+ 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) {
+ if (Utils.checkItemType(lore, true, typeMatches) >= 0) {
int importance = 0;
- for(int j=0; j<lore.size(); j++) {
+ for (int j = 0; j < lore.size(); j++) {
String line = lore.get(j).getAsString();
- for(Pattern pattern : importantPatterns) {
+ for (Pattern pattern : importantPatterns) {
Matcher matcher = pattern.matcher(Utils.cleanColour(line));
- if(matcher.find()) {
+ if (matcher.find()) {
importance += Integer.parseInt(matcher.group(1));
}
}
}
- map.computeIfAbsent(importance, k->new HashSet<>()).add(
+ map.computeIfAbsent(importance, k -> new HashSet<>()).add(
NotEnoughUpdates.INSTANCE.manager.jsonToStack(item, false));
}
}
}
- int i=0;
+ int i = 0;
outer:
- for(int key : map.descendingKeySet()) {
+ for (int key : map.descendingKeySet()) {
Set<ItemStack> items = map.get(key);
- for(ItemStack item : items) {
+ for (ItemStack item : items) {
bestItems[i] = item;
- if(++i >= bestItems.length) break outer;
+ if (++i >= bestItems.length) break outer;
}
}
@@ -1998,7 +1994,7 @@ public class GuiProfileViewer extends GuiScreen {
}
private int getRowsForInventory(String invName) {
- switch(invName) {
+ switch (invName) {
case "wardrobe_contents":
return 4;
case "backpack_contents":
@@ -2010,7 +2006,7 @@ public class GuiProfileViewer extends GuiScreen {
}
private boolean useActualMax(String invName) {
- switch(invName) {
+ switch (invName) {
case "talisman_bag":
case "fishing_bag":
case "potion_bag":
@@ -2021,7 +2017,7 @@ public class GuiProfileViewer extends GuiScreen {
}
private int getIgnoredRowsForInventory(String invName) {
- switch(invName) {
+ switch (invName) {
case "talisman_bag":
case "fishing_bag":
case "potion_bag":
@@ -2034,68 +2030,69 @@ public class GuiProfileViewer extends GuiScreen {
//Data has been removed from the repo
@Deprecated
private int getAvailableSlotsForInventory(JsonObject inventoryInfo, JsonObject collectionInfo, String invName) {
- if(collectionInfo == null) return -1;
+ 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 (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;
+ 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);
+ JsonElement tierElement = Utils.getElement(collectionInfo, "collection_tiers." + collection);
- if(tierElement == null || !tierElement.isJsonPrimitive()) {
+ if (tierElement == null || !tierElement.isJsonPrimitive()) {
return 0;
}
int tier = tierElement.getAsInt();
int currentSlots = 0;
- for(int i=0; i<sizes.size(); i++) {
+ for (int i = 0; i < sizes.size(); i++) {
JsonObject sizeInfo = sizes.get(i).getAsJsonObject();
- if(sizeInfo.get("tier").getAsInt() <= tier) {
+ 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);
+ 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);
+ if (inventoryItems.containsKey(invName)) return inventoryItems.get(invName);
JsonArray jsonInv = Utils.getElement(inventoryInfo, invName).getAsJsonArray();
- if(jsonInv.size() == 0) return new ItemStack[1][][];
+ if (jsonInv.size() == 0) return new ItemStack[1][][];
int jsonInvSize;
- if(useActualMax(invName)) {
- jsonInvSize = (int)Math.ceil(jsonInv.size()/9f)*9;
+ if (useActualMax(invName)) {
+ jsonInvSize = (int) Math.ceil(jsonInv.size() / 9f) * 9;
} else {
- jsonInvSize = 9*4;
+ jsonInvSize = 9 * 4;
float divideBy = 9f;
- if(invName.equals("wardrobe_contents")){
+ if (invName.equals("wardrobe_contents")) {
divideBy = 36f;
}
- for(int i=9*4; i<jsonInv.size(); i++) {
+ 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);
+ if (item != null && item.isJsonObject()) {
+ jsonInvSize = (int) (Math.ceil((i + 1) / divideBy) * (int) divideBy);
}
}
}
int rowSize = 9;
- int rows = jsonInvSize/rowSize;
+ int rows = jsonInvSize / rowSize;
int maxRowsPerPage = getRowsForInventory(invName);
- int maxInvSize = rowSize*maxRowsPerPage;
+ int maxInvSize = rowSize * maxRowsPerPage;
- int numInventories = (jsonInvSize-1)/maxInvSize+1;
+ int numInventories = (jsonInvSize - 1) / maxInvSize + 1;
JsonArray backPackSizes = (JsonArray) inventoryInfo.get("backpack_sizes");
- if(invName.equals("backpack_contents")) {
+ if (invName.equals("backpack_contents")) {
numInventories = backPackSizes.size();
}
@@ -2104,57 +2101,56 @@ public class GuiProfileViewer extends GuiScreen {
//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;
-
+ 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;
+ if (invName.equals("backpack_contents")) {
+ thisRows = backPackSizes.get(i).getAsInt() / 9;
+ invSize = startNumberJ + (thisRows * 9);
+ maxInvSize = thisRows * 9;
} else {
- startNumberJ = maxInvSize*i;
+ startNumberJ = maxInvSize * i;
invSize = Math.min(jsonInvSize, maxInvSize + maxInvSize * i);
}
- if(thisRows <= 0) break;
+ if (thisRows <= 0) break;
ItemStack[][] items = new ItemStack[thisRows][rowSize];
- for(int j=startNumberJ; j<invSize; j++) {
+ for (int j = startNumberJ; j < invSize; j++) {
- int xIndex = (j%maxInvSize)%rowSize;
- int yIndex = (j%maxInvSize)/rowSize;
- if(invName.equals("inv_contents")) {
+ int xIndex = (j % maxInvSize) % rowSize;
+ int yIndex = (j % maxInvSize) / rowSize;
+ if (invName.equals("inv_contents")) {
yIndex--;
- if(yIndex < 0) yIndex = rows-1;
+ if (yIndex < 0) yIndex = rows - 1;
}
- if(yIndex >= thisRows) {
+ if (yIndex >= thisRows) {
break;
}
- if(j >= jsonInv.size()) {
+ if (j >= jsonInv.size()) {
items[yIndex][xIndex] = fillerStack;
continue;
}
- if(jsonInv.get(j) == null || !jsonInv.get(j).isJsonObject()) {
+ 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")) {
+ 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++) {
+ 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)) {
+ 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")) {
+ for (String key : ea.getKeySet()) {
+ if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) {
ea.setTag(key, new NBTTagByteArray(bytes));
break;
}
@@ -2167,7 +2163,7 @@ public class GuiProfileViewer extends GuiScreen {
items[yIndex][xIndex] = stack;
}
inventories[i] = items;
- if(invName.equals("backpack_contents")) {
+ if (invName.equals("backpack_contents")) {
startNumberJ = startNumberJ + backPackSizes.get(i).getAsInt();
}
}
@@ -2176,7 +2172,6 @@ public class GuiProfileViewer extends GuiScreen {
return inventories;
}
-
private ItemStack[] bestWeapons = null;
private ItemStack[] bestRods = null;
private ItemStack[] armorItems = null;
@@ -2186,41 +2181,42 @@ public class GuiProfileViewer extends GuiScreen {
private int arrowCount = -1;
private int greenCandyCount = -1;
private int purpleCandyCount = -1;
- private GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT);
+ 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;
+ if (inventoryInfo == null) return;
- int invNameIndex=0;
- for(Map.Entry<String, ItemStack> entry : invNameToDisplayMap.entrySet()) {
- int xIndex = invNameIndex%3;
- int yIndex = invNameIndex/3;
+ 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;
+ 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);
+ 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.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));
+ 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) {
+ if (mouseX >= guiLeft + x && mouseX <= guiLeft + x + 16) {
+ if (mouseY >= guiTop + y && mouseY <= guiTop + y + 16) {
tooltipToDisplay = entry.getValue().getTooltip(Minecraft.getMinecraft().thePlayer, false);
}
}
@@ -2228,24 +2224,24 @@ public class GuiProfileViewer extends GuiScreen {
invNameIndex++;
}
- inventoryTextField.render(guiLeft+19, guiTop+sizeY-26-20);
+ inventoryTextField.render(guiLeft + 19, guiTop + sizeY - 26 - 20);
- if(armorItems == null) {
+ 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;
+ 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) {
+ 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);
}
@@ -2255,77 +2251,77 @@ public class GuiProfileViewer extends GuiScreen {
}
ItemStack[][][] inventories = getItemsForInventory(inventoryInfo, selectedInventory);
- if(currentInventoryIndex >= inventories.length) currentInventoryIndex = inventories.length-1;
- if(currentInventoryIndex < 0) currentInventoryIndex = 0;
+ 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);
+ 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);
+ Utils.drawStringCentered(EnumChatFormatting.RED + "Inventory API not enabled!", Minecraft.getMinecraft().fontRendererObj,
+ guiLeft + 317, guiTop + 101, true, 0);
}
return;
}
- if(bestWeapons == null) {
+ if (bestWeapons == null) {
bestWeapons = findBestItems(inventoryInfo, 6, new String[]{"inv_contents", "ender_chest_contents"},
- new String[]{"SWORD","BOW"}, DAMAGE_PATTERN, STRENGTH_PATTERN);
+ new String[]{"SWORD", "BOW"}, DAMAGE_PATTERN, STRENGTH_PATTERN);
}
- if(bestRods == null) {
+ 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;
+ 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) {
+ 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;
+ 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) {
+ 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 (arrowCount == -1) {
+ arrowCount = countItemsInInventory("ARROW", inventoryInfo, false, "quiver");
}
- if(greenCandyCount == -1) {
- greenCandyCount = countItemsInInventory("GREEN_CANDY", inventoryInfo, true,"candy_inventory_contents");
+ if (greenCandyCount == -1) {
+ greenCandyCount = countItemsInInventory("GREEN_CANDY", inventoryInfo, true, "candy_inventory_contents");
}
- if(purpleCandyCount == -1) {
+ 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));
+ 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);
+ 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);
+ 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);
+ tooltipToDisplay = Utils.createList(EnumChatFormatting.DARK_PURPLE + "Purple Candy " + EnumChatFormatting.GRAY + "x" + purpleCandyCount);
}
}
}
@@ -2335,21 +2331,21 @@ public class GuiProfileViewer extends GuiScreen {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
- int invSizeY = inventoryRows*18+17+7;
+ int invSizeY = inventoryRows * 18 + 17 + 7;
- int x = guiLeft+320-176/2;
- int y = guiTop+101-invSizeY/2;
- int staticSelectorHeight = guiTop+177;
+ 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);
+ 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) {
+ 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;
@@ -2359,51 +2355,51 @@ public class GuiProfileViewer extends GuiScreen {
}
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 > 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);
+ 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);
+ 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 yIndex = 0; yIndex < inventory.length; yIndex++) {
+ if (inventory[yIndex] == null) continue;
- for(int xIndex=0; xIndex<inventory[yIndex].length; xIndex++) {
+ 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 (stack != null) Utils.drawItemStack(stack, x + 8 + xIndex * 18, y + 18 + yIndex * 18);
- if(inventoryTextField.getText() != null && !inventoryTextField.getText().isEmpty() &&
+ 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);
+ 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 (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) {
+ 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) {
+ if (stackToRender != null) {
tooltipToDisplay = stackToRender.getTooltip(Minecraft.getMinecraft().thePlayer, false);
}
}
private String niceUuid(String uuidStr) {
- if(uuidStr.length()!=32) return uuidStr;
+ if (uuidStr.length() != 32) return uuidStr;
StringBuilder niceAucId = new StringBuilder();
niceAucId.append(uuidStr, 0, 8);
@@ -2427,33 +2423,33 @@ public class GuiProfileViewer extends GuiScreen {
private ResourceLocation playerLocationCape = null;
private String skinType = null;
- private HashMap<String, ResourceLocation[]> panoramasMap = new HashMap<>();
+ 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);
+ 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");
+ 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);
+ panoramasMap.put(location + identifier, panoramasArray);
return panoramasArray;
- } catch(IOException e) {
+ } 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");
+ 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);
+ panoramasMap.put(location + identifier, panoramasArray);
return panoramasArray;
- } catch(IOException e2) {
+ } 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");
+ for (int i = 0; i < 6; i++) {
+ panoramasArray[i] = new ResourceLocation("notenoughupdates:panoramas/unknown/panorama_" + i + ".jpg");
}
- panoramasMap.put(location+identifier, panoramasArray);
+ panoramasMap.put(location + identifier, panoramasArray);
return panoramasArray;
}
}
@@ -2469,7 +2465,7 @@ public class GuiProfileViewer extends GuiScreen {
Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST);
JsonObject profileInfo = profile.getProfileInformation(profileId);
- if(profileInfo == null) return;
+ if (profileInfo == null) return;
JsonObject skillInfo = profile.getSkillInfo(profileId);
float xStart = 22;
@@ -2481,31 +2477,31 @@ public class GuiProfileViewer extends GuiScreen {
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);
+ 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.toString() + lastSaveText,
+ 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.toString() + 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.toString() + guildInfo.get("name").getAsString(),
+ if (guildInfo != null && guildInfo.has("name")) {
+ Utils.renderAlignedString(EnumChatFormatting.AQUA + "Guild", EnumChatFormatting.WHITE + guildInfo.get("name").getAsString(),
guiLeft + xStart, guiTop + yStartTop + yOffset * 4, 76);
}
}
@@ -2513,12 +2509,12 @@ public class GuiProfileViewer extends GuiScreen {
float fairySouls = Utils.getElementAsFloat(Utils.getElement(profileInfo, "fairy_souls_collected"), 0);
int fairySoulMax = 227;
- if(Constants.FAIRYSOULS != null && Constants.FAIRYSOULS.has("Max Souls")) {
+ 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) {
+ 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;
@@ -2526,16 +2522,16 @@ public class GuiProfileViewer extends GuiScreen {
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;
+ 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")) {
+ } else if (entry.getKey().startsWith("level_slayer")) {
totalSlayerLVL += entry.getValue().getAsFloat();
totalSlayerCount++;
} else if (entry.getKey().startsWith("experience_slayer")) {
@@ -2543,24 +2539,23 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- float avgSkillLVL = totalSkillLVL/totalSkillCount;
- float avgTrueSkillLVL = totalTrueSkillLVL/totalSkillCount;
- float avgSlayerLVL = totalSlayerLVL/totalSlayerCount;
+ 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 + "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 + "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 + "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),
+ 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);
@@ -2568,19 +2563,18 @@ public class GuiProfileViewer extends GuiScreen {
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);
-
+ 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);
@@ -2593,26 +2587,25 @@ public class GuiProfileViewer extends GuiScreen {
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);
+ 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);
@@ -2621,44 +2614,44 @@ public class GuiProfileViewer extends GuiScreen {
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 + "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);
+ 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) {
+ 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()) {
+ 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()) {
+ if (prim.isNumber()) {
String name = WordUtils.capitalizeFully(entry.getKey().substring("kills_".length()).replace("_", " "));
- Set<String> kills = topKills.computeIfAbsent(prim.getAsInt(), k->new HashSet<>());
+ Set<String> kills = topKills.computeIfAbsent(prim.getAsInt(), k -> new HashSet<>());
kills.add(name);
}
}
}
}
}
- if(topDeaths == null) {
+ 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()) {
+ 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()) {
+ if (prim.isNumber()) {
String name = WordUtils.capitalizeFully(entry.getKey().substring("deaths_".length()).replace("_", " "));
- Set<String> deaths = topDeaths.computeIfAbsent(prim.getAsInt(), k->new HashSet<>());
+ Set<String> deaths = topDeaths.computeIfAbsent(prim.getAsInt(), k -> new HashSet<>());
deaths.add(name);
}
}
@@ -2667,48 +2660,48 @@ public class GuiProfileViewer extends GuiScreen {
}
int index = 0;
- for(int killCount : topKills.descendingKeySet()) {
- if(index >= 6) break;
+ 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);
+ 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;
+ 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);
+ 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){
+ 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());
+ LocalDateTime lastSaveTime = LocalDateTime.ofInstant(lastSave, TimeZone.getDefault().toZoneId());
long timeDiff = System.currentTimeMillis() - lastSave.toEpochMilli();
- LocalDateTime sinceOnline= LocalDateTime.ofInstant(Instant.ofEpochMilli(timeDiff), ZoneId.of("UTC"));
+ 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.";
+ 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"));
}
@@ -2719,24 +2712,24 @@ public class GuiProfileViewer extends GuiScreen {
private int backgroundClickedX = -1;
- private static char[] c = new char[]{'k', 'm', 'b', 't'};
+ 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);
+ 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)?
+ 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));
+ : shortNumberFormat(d, iteration + 1));
}
private boolean loadingProfile = false;
@@ -2747,92 +2740,92 @@ public class GuiProfileViewer extends GuiScreen {
String location = null;
JsonObject status = profile.getPlayerStatus();
- if(status != null && status.has("mode")) {
+ 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) {
+ 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) {
+ if (backgroundClickedX != -1) {
backgroundRotation += mouseX - backgroundClickedX;
backgroundClickedX = -1;
}
}
- if(backgroundClickedX == -1) {
- backgroundRotation += (currentTime - lastTime)/400f;
+ 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) {
+ 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));
+ 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) {
+ if (entityPlayer != null && profile.getHypixelProfile() != null) {
String playerName = null;
- if(profile.getHypixelProfile().has("prefix")) {
+ 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")) {
+ 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) {
+ 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"), "");
+ 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")) {
+ 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())) {
+ 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) {
+ playerName = EnumChatFormatting.GRAY + name;
+ if (rankName != null) {
StringBuilder sb = new StringBuilder();
- sb.append("\u00A7"+rankColor);
+ sb.append("\u00A7" + rankColor);
sb.append("[");
sb.append(rankName);
sb.append(rankPlusColor);
sb.append(rankPlus);
- sb.append("\u00A7"+rankColor);
+ sb.append("\u00A7" + rankColor);
sb.append("] ");
sb.append(name);
playerName = sb.toString();
@@ -2841,39 +2834,39 @@ public class GuiProfileViewer extends GuiScreen {
}
}
- if(playerName != null) {
+ if (playerName != null) {
int rankPrefixLen = fr.getStringWidth(playerName);
- int halfRankPrefixLen = rankPrefixLen/2;
+ int halfRankPrefixLen = rankPrefixLen / 2;
- int x = guiLeft+63;
- int y = guiTop+54;
+ 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());
+ 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);
+ 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);
+ 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) {
+ 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(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.");
+ 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]");
+ tooltipToDisplay.add(EnumChatFormatting.GRAY + "[SHIFT for Info]");
}
if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) {
tooltipToDisplay.add("");
@@ -2881,33 +2874,33 @@ public class GuiProfileViewer extends GuiScreen {
}
}
}
- } catch(Exception e){}
+ } catch (Exception ignored) {}
}
- if(status != null) {
+ 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")) {
+ if (profile.getUuid().equals("20934ef9488c465180a78f861586b4cf")) {
locationStr = "Ignoring DMs";
} else {
- if(location != null) {
+ if (location != null) {
JsonObject misc = Constants.MISC;
- if(misc != null) {
- locationStr = Utils.getElementAsString(Utils.getElement(misc, "area_names."+location), "Unknown");
+ if (misc != null) {
+ locationStr = Utils.getElementAsString(Utils.getElement(misc, "area_names." + location), "Unknown");
}
}
}
- if(locationStr != null) {
- statusStr += EnumChatFormatting.GRAY+" - "+EnumChatFormatting.GREEN+locationStr;
+ if (locationStr != null) {
+ statusStr += EnumChatFormatting.GRAY + " - " + EnumChatFormatting.GREEN + locationStr;
}
- Utils.drawStringCentered(statusStr, fr, guiLeft+63, guiTop+160, true, 0);
+ Utils.drawStringCentered(statusStr, fr, guiLeft + 63, guiTop + 160, true, 0);
}
- if(entityPlayer == null) {
- if(!loadingProfile || ((ThreadPoolExecutor)profileLoader).getActiveCount() == 0) {
+ if (entityPlayer == null) {
+ if (!loadingProfile || ((ThreadPoolExecutor) profileLoader).getActiveCount() == 0) {
loadingProfile = true;
UUID playerUUID = UUID.fromString(niceUuid(profile.getUuid()));
@@ -2933,28 +2926,28 @@ public class GuiProfileViewer extends GuiScreen {
} else {
entityPlayer.refreshDisplayName();
byte b = 0;
- for(EnumPlayerModelParts part : EnumPlayerModelParts.values()) {
+ for (EnumPlayerModelParts part : EnumPlayerModelParts.values()) {
b |= part.getPartMask();
}
entityPlayer.getDataWatcher().updateObject(10, b);
}
JsonObject profileInfo = profile.getProfileInformation(profileId);
- if(profileInfo == null) return;
+ if (profileInfo == null) return;
JsonObject skillInfo = profile.getSkillInfo(profileId);
JsonObject inventoryInfo = profile.getInventoryInfo(profileId);
- if(entityPlayer != null) {
- if(backgroundClickedX != -1 && Mouse.isButtonDown(1)) {
+ if (entityPlayer != null) {
+ if (backgroundClickedX != -1 && Mouse.isButtonDown(1)) {
Arrays.fill(entityPlayer.inventory.armorInventory, null);
} else {
- if(inventoryInfo != null && inventoryInfo.has("inv_armor")) {
+ 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++) {
+ 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()) {
+ if (itemElement != null && itemElement.isJsonObject()) {
entityPlayer.inventory.armorInventory[i] = NotEnoughUpdates.INSTANCE.manager.jsonToStack(itemElement.getAsJsonObject(), false);
}
}
@@ -2963,77 +2956,75 @@ public class GuiProfileViewer extends GuiScreen {
Arrays.fill(entityPlayer.inventory.armorInventory, null);
}
}
- if(entityPlayer.getUniqueID().toString().equals("ae6193ab-494a-4719-b6e7-d50392c8f012")) {
+ 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) {
+ 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";
- }
+ 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 = location;
- }
+ break;
+ case CAPE:
+ playerLocationCape = location1;
}
}, false);
- } catch(Exception e){}
+ } catch (Exception ignored) {}
}
GlStateManager.color(1, 1, 1, 1);
JsonObject petsInfo = profile.getPetsInfo(profileId);
- if(petsInfo != null) {
+ if (petsInfo != null) {
JsonElement activePetElement = petsInfo.get("active_pet");
- if(activePetElement != null && activePetElement.isJsonObject()) {
+ 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));
+ 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();
+ 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.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);
+ 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) {
+ if (stats != null) {
Splitter splitter = Splitter.on(" ").omitEmptyStrings().limit(2);
- for(int i=0; i<PlayerStats.defaultStatNames.length; i++) {
+ for (int i = 0; i < PlayerStats.defaultStatNames.length; i++) {
String statName = PlayerStats.defaultStatNames[i];
- if(statName.equals("mining_fortune") || statName.equals("mining_speed")) continue;
+ if (statName.equals("mining_fortune") || statName.equals("mining_speed")) continue;
String statNamePretty = PlayerStats.defaultStatNamesPretty[i];
int val = Math.round(stats.get(statName));
@@ -3041,38 +3032,38 @@ public class GuiProfileViewer extends GuiScreen {
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);
+ 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) {
+ 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));
+ 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));
+ 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);
+ 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) {
+ if (skillInfo != null) {
int position = 0;
- for(Map.Entry<String, ItemStack> entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) {
- if(entry.getValue() == null || entry.getKey() == null) {
+ for (Map.Entry<String, ItemStack> entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) {
+ if (entry.getValue() == null || entry.getKey() == null) {
position++;
continue;
}
@@ -3082,53 +3073,53 @@ public class GuiProfileViewer extends GuiScreen {
String skillName = entry.getValue().getDisplayName();
- float level = Utils.getElementAsFloat(skillInfo.get("level_"+entry.getKey()), 0);
- int levelFloored = (int)Math.floor(level);
+ 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;
+ int x = guiLeft + 237 + 86 * xPosition;
+ int y = guiTop + 31 + 21 * yPosition;
- Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString()+levelFloored, x+14, y-4, 60);
+ Utils.renderAlignedString(skillName, EnumChatFormatting.WHITE.toString() + levelFloored, x + 14, y - 4, 60);
- if(skillInfo.get("maxed_"+entry.getKey()).getAsBoolean()) {
- renderGoldBar(x, y+6, 80);
+ if (skillInfo.get("maxed_" + entry.getKey()).getAsBoolean()) {
+ renderGoldBar(x, y + 6, 80);
} else {
- renderBar(x, y+6, 80, level%1);
+ renderBar(x, y + 6, 80, level % 1);
}
- if(mouseX > x && mouseX < x+80) {
- if(mouseY > y-4 && mouseY < y+13) {
+ 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!");
+ 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));
+ 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);
+ 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.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);
+ 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);
+ 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()) {
+ if (!OpenGlHelper.areShadersSupported()) {
renderBar(x, y, xSize, 1);
return;
}
@@ -3136,10 +3127,10 @@ public class GuiProfileViewer extends GuiScreen {
Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
ShaderManager shaderManager = ShaderManager.getInstance();
shaderManager.loadShader("make_gold");
- shaderManager.loadData("make_gold", "amount", (startTime-System.currentTimeMillis())/10000f);
+ 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);
+ 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);
}
@@ -3147,43 +3138,44 @@ public class GuiProfileViewer extends GuiScreen {
private void renderBar(float x, float y, float xSize, float completed) {
Minecraft.getMinecraft().getTextureManager().bindTexture(icons);
- completed = Math.round(completed/0.05f)*0.05f;
+ completed = Math.round(completed / 0.05f) * 0.05f;
- float notcompleted = 1-completed;
+ 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)) {
+ 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);
+ 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 < 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);
+ 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);
+ 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);
+ 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.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;
@@ -3194,9 +3186,9 @@ public class GuiProfileViewer extends GuiScreen {
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.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();
@@ -3280,15 +3272,15 @@ public class GuiProfileViewer extends GuiScreen {
/**
* 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
@@ -3304,51 +3296,52 @@ public class GuiProfileViewer extends GuiScreen {
* if framebuffers are not available. (Apple machines, for example, have poor framebuffer support).
*/
private double lastBgBlurFactor = -1;
+
private void blurBackground() {
- if(!OpenGlHelper.isFramebufferEnabled()) return;
+ if (!OpenGlHelper.isFramebufferEnabled()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
- if(blurOutputHorz == null) {
+ if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputVert == null) {
+ if (blurOutputVert == null) {
blurOutputVert = new Framebuffer(width, height, false);
blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ 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) {
+ if (blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) {
blurOutputVert.createBindFramebuffer(width, height);
blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- if(blurShaderHorz == null) {
+ 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) { }
+ } catch (Exception ignored) {}
}
- if(blurShaderVert == null) {
+ 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) { }
+ } 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);
+ 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();
@@ -3366,12 +3359,12 @@ public class GuiProfileViewer extends GuiScreen {
* 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;
+ 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;
+ 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);
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..85cadec7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java
@@ -17,8 +17,8 @@ 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 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;
@@ -26,11 +26,11 @@ public class Panorama {
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()) {
+ 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);
+ float aspect = width / (float) height;
+ Utils.drawTexturedRect(x, y, width, height, 0.5f - aspect / 2, 0.5f + aspect / 2, 0, 1);
return;
}
@@ -39,7 +39,7 @@ public class Panorama {
ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- GL11.glViewport(0, 0, width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor());
+ GL11.glViewport(0, 0, width * scaledresolution.getScaleFactor(), height * scaledresolution.getScaleFactor());
float fov = 97;
@@ -49,7 +49,7 @@ public class Panorama {
GlStateManager.matrixMode(5889);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
- Project.gluPerspective(fov, (float)height/width, 0.05F, 10.0F);
+ Project.gluPerspective(fov, (float) height / width, 0.05F, 10.0F);
GlStateManager.matrixMode(5888);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
@@ -75,34 +75,39 @@ public class Panorama {
switch (k) {
case 1:
- GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); break;
+ GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
+ break;
case 2:
- GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); break;
+ GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
+ break;
case 3:
- GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); break;
+ GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
+ break;
case 4:
- GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); break;
+ GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
+ break;
case 5:
- GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); break;
+ 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) {
+ 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;
+ 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 xr = x2 * 2 - 1;
+ float yr = y2 * 2 - 1;
- float distSq = xr*xr+yr*yr+1;
- float scale = (float)Math.sqrt(3/distSq);
+ 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();
+ worldrenderer.pos(xr * scale, yr * scale, scale).tex(x2, y2).color(255, 255, 255, 255).endVertex();
}
@@ -127,27 +132,27 @@ public class Panorama {
GlStateManager.enableDepth();
}
- if(backgroundTexture == null || lastWidth != width*scaledresolution.getScaleFactor() || lastHeight != height*scaledresolution.getScaleFactor()) {
- DynamicTexture viewportTexture = new DynamicTexture(width*scaledresolution.getScaleFactor(), height*scaledresolution.getScaleFactor());
+ 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();
+ 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());
+ 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)
+ worldrenderer.pos(x, y + height, 0)
.tex(0, 1).endVertex();
- worldrenderer.pos(x+width, y+height, 0)
+ worldrenderer.pos(x + width, y + height, 0)
.tex(0, 0).endVertex();
- worldrenderer.pos(x+width, y, 0)
+ worldrenderer.pos(x + width, y, 0)
.tex(1, 0).endVertex();
worldrenderer.pos(x, y, 0)
.tex(1, 1).endVertex();
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..294d0322 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;
@@ -29,13 +34,13 @@ public class PlayerStats {
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 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();
@@ -53,7 +58,7 @@ public class PlayerStats {
public float pet_luck;*/
public Stats(Stats... statses) {
- for(Stats stats : statses) {
+ for (Stats stats : statses) {
add(stats);
}
}
@@ -67,7 +72,7 @@ public class PlayerStats {
}*/
public float get(String statName) {
- if(statsJson.has(statName)) {
+ if (statsJson.has(statName)) {
return statsJson.get(statName).getAsFloat();
} else {
return 0;
@@ -75,9 +80,9 @@ public class PlayerStats {
}
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())) {
+ 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();
@@ -90,19 +95,19 @@ public class PlayerStats {
}
public void scale(String statName, float scale) {
- if(statsJson.has(statName)) {
- statsJson.add(statName, new JsonPrimitive(statsJson.get(statName).getAsFloat()*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));
+ 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)) {
+ if (!statsJson.has(statName)) {
statsJson.add(statName, new JsonPrimitive(amount));
} else {
JsonPrimitive e = statsJson.get(statName).getAsJsonPrimitive();
@@ -113,11 +118,11 @@ public class PlayerStats {
public static Stats getBaseStats() {
JsonObject misc = Constants.MISC;
- if(misc == null) return null;
+ 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));
+ for (String statName : defaultStatNames) {
+ stats.addStat(statName, Utils.getElementAsFloat(Utils.getElement(misc, "base_stats." + statName), 0));
}
return stats;
}
@@ -125,9 +130,9 @@ public class PlayerStats {
private static Stats getFairyBonus(int fairyExchanges) {
Stats bonus = new Stats();
- bonus.addStat(SPEED, fairyExchanges/10);
+ bonus.addStat(SPEED, fairyExchanges / 10);
- for(int i=0; i<fairyExchanges; i++) {
+ 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);
@@ -138,22 +143,22 @@ public class PlayerStats {
private static Stats getSkillBonus(JsonObject skillInfo) {
JsonObject bonuses = Constants.BONUSES;
- if(bonuses == null) return null;
+ if (bonuses == null) return null;
Stats skillBonus = new Stats();
- for(Map.Entry<String, JsonElement> entry : skillInfo.entrySet()) {
- if(entry.getKey().startsWith("level_")) {
+ 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()) {
+ 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)) {
+ 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()) {
+ for (Map.Entry<String, JsonElement> entry2 : skillStatMap.get("" + i).getAsJsonObject().entrySet()) {
currentBonus.addStat(entry2.getKey(), entry2.getValue().getAsFloat());
}
}
@@ -168,34 +173,34 @@ public class PlayerStats {
private static Stats getTamingBonus(JsonObject profile) {
JsonObject bonuses = Constants.BONUSES;
- if(bonuses == null) return null;
+ if (bonuses == null) return null;
JsonElement petsElement = Utils.getElement(profile, "pets");
- if(petsElement == null) return new Stats();
+ if (petsElement == null) return new Stats();
JsonArray pets = petsElement.getAsJsonArray();
HashMap<String, String> highestRarityMap = new HashMap<>();
- for(int i=0; i<pets.size(); i++) {
+ 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);
+ 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;
+ if (petRewardsElement == null) return null;
JsonObject petRewards = petRewardsElement.getAsJsonObject();
Stats petBonus = new Stats();
- for(int i=0; i<=petScore; i++) {
- if(petRewards.has(""+i)) {
+ 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()) {
+ for (Map.Entry<String, JsonElement> entry : petRewards.get("" + i).getAsJsonObject().entrySet()) {
petBonus.addStat(entry.getKey(), entry.getValue().getAsFloat());
}
}
@@ -205,22 +210,21 @@ public class PlayerStats {
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")) {
+ 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 fairyBonus = getFairyBonus((int) Utils.getElementAsFloat(Utils.getElement(profile, "fairy_exchanges"), 0));
Stats skillBonus = getSkillBonus(skillInfo);
Stats petBonus = getTamingBonus(profile);
- if(skillBonus == null || petBonus == null) {
+ if (skillBonus == null || petBonus == null) {
return null;
}
@@ -234,11 +238,11 @@ public class PlayerStats {
private static String getFullset(JsonArray armor, int ignore) {
String fullset = null;
- for(int i=0; i<armor.size(); i++) {
- if(i == ignore) continue;
+ for (int i = 0; i < armor.size(); i++) {
+ if (i == ignore) continue;
JsonElement itemElement = armor.get(i);
- if(itemElement == null || !itemElement.isJsonObject()) {
+ if (itemElement == null || !itemElement.isJsonObject()) {
fullset = null;
break;
}
@@ -246,12 +250,12 @@ public class PlayerStats {
String internalname = item.get("internalname").getAsString();
String[] split = internalname.split("_");
- split[split.length-1] = "";
+ split[split.length - 1] = "";
String armorname = StringUtils.join(split, "_");
- if(fullset == null) {
+ if (fullset == null) {
fullset = armorname;
- } else if(!fullset.equalsIgnoreCase(armorname)){
+ } else if (!fullset.equalsIgnoreCase(armorname)) {
fullset = null;
break;
}
@@ -266,18 +270,17 @@ public class PlayerStats {
String fullset = getFullset(armor, -1);
- if(fullset != null) {
- switch(fullset) {
+ 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 "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;
@@ -288,14 +291,14 @@ public class PlayerStats {
bonuses.addStat(SPEED, 70);
break;
case "MASTIFF_":
- bonuses.addStat(HEALTH, 50*Math.round(stats.get(CRIT_DAMAGE)));
+ 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(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));
+ 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_":
@@ -306,20 +309,20 @@ public class PlayerStats {
}
JsonElement chestplateElement = armor.get(2);
- if(chestplateElement != null && chestplateElement.isJsonObject()) {
+ if (chestplateElement != null && chestplateElement.isJsonObject()) {
JsonObject chestplate = chestplateElement.getAsJsonObject();
- if(chestplate.get("internalname").getAsString().equals("OBSIDIAN_CHESTPLATE")) {
+ if (chestplate.get("internalname").getAsString().equals("OBSIDIAN_CHESTPLATE")) {
JsonArray inventory = Utils.getElement(inventoryInfo, "inv_contents").getAsJsonArray();
- for(int i=0; i<inventory.size(); i++) {
+ for (int i = 0; i < inventory.size(); i++) {
JsonElement itemElement = inventory.get(i);
- if(itemElement != null && itemElement.isJsonObject()) {
+ if (itemElement != null && itemElement.isJsonObject()) {
JsonObject item = itemElement.getAsJsonObject();
- if(item.get("internalname").getAsString().equals("OBSIDIAN")) {
+ if (item.get("internalname").getAsString().equals("OBSIDIAN")) {
int count = 1;
- if(item.has("count")) {
+ if (item.has("count")) {
count = item.get("count").getAsInt();
}
- bonuses.addStat(SPEED, count/20);
+ bonuses.addStat(SPEED, count / 20);
}
}
}
@@ -341,6 +344,7 @@ public class PlayerStats {
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);
@@ -354,36 +358,37 @@ public class PlayerStats {
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++) {
+ for (int i = 0; i < lore.size(); i++) {
String line = lore.get(i).getAsString();
- for(Map.Entry<String, Pattern> entry : STAT_PATTERN_MAP.entrySet()) {
+ for (Map.Entry<String, Pattern> entry : STAT_PATTERN_MAP.entrySet()) {
Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line));
- if(matcher.find()) {
+ if (matcher.find()) {
int bonus = Integer.parseInt(matcher.group(1));
stats.addStat(entry.getKey(), bonus);
}
}
}
- if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) {
+ 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")) {
+ 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++) {
+ 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) {
+ 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)) {
+ 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"));
@@ -392,40 +397,41 @@ public class PlayerStats {
}
}
stats.addStat(HEALTH, cakes.size());
- } catch(IOException e) {
+ } 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;
+ if (misc == null) return null;
JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
- if(talisman_upgrades_element == null) return null;
+ 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++) {
+ for (JsonArray inventory : inventories) {
+ for (int i = 0; i < inventory.size(); i++) {
JsonElement itemElement = inventory.get(i);
- if(itemElement != null && itemElement.isJsonObject()) {
+ if (itemElement != null && itemElement.isJsonObject()) {
JsonObject item = itemElement.getAsJsonObject();
String internalname = item.get("internalname").getAsString();
- if(itemBonuses.containsKey(internalname)) {
+ if (itemBonuses.containsKey(internalname)) {
continue;
}
- if(!talismanOnly || Utils.checkItemType(item.get("lore").getAsJsonArray(), true, "ACCESSORY", "HATCCESSORY") >= 0) {
+ 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()) {
+ 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++) {
+ for (int j = 0; j < upgrades.size(); j++) {
String upgrade = upgrades.get(j).getAsString();
- if(upgrade.equals(internalname)) {
+ if (upgrade.equals(internalname)) {
itemBonuses.put(talisman_upgrades_item.getKey(), new Stats());
break;
}
@@ -436,7 +442,7 @@ public class PlayerStats {
}
}
Stats itemBonusesStats = new Stats();
- for(Stats stats : itemBonuses.values()) {
+ for (Stats stats : itemBonuses.values()) {
itemBonusesStats.add(stats);
}
@@ -446,12 +452,12 @@ public class PlayerStats {
public static Stats getPetStatBonuses(JsonObject petsInfo) {
JsonObject petsJson = Constants.PETS;
JsonObject petnums = Constants.PETNUMS;
- if(petsJson == null || petnums == null) return new Stats();
+ if (petsJson == null || petnums == null) return new Stats();
- if(petsInfo != null && petsInfo.has("active_pet") && petsInfo.get("active_pet") != null &&
+ 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 &&
+ if (pet.has("type") && pet.get("type") != null &&
pet.has("tier") && pet.get("tier") != null &&
pet.has("exp") && pet.get("exp") != null) {
@@ -459,16 +465,16 @@ public class PlayerStats {
String tier = pet.get("tier").getAsString();
String heldItem = Utils.getElementAsString(pet.get("heldItem"), null);
- if(!petnums.has(petname)) {
+ 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 (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);
+ 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);
@@ -480,51 +486,51 @@ public class PlayerStats {
pet.addProperty("currentLevelRequirement", currentLevelRequirement);
pet.addProperty("maxXP", maxXP);
- JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(petname+";"+tierNum);
- if(petItem == null) return new Stats();
+ 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)) {
+ if (petInfo.has(tier)) {
JsonObject petInfoTier = petInfo.get(tier).getAsJsonObject();
- if(petInfoTier == null || !petInfoTier.has("1") || !petInfoTier.has("100")) {
+ 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;
+ float minMix = (100 - level) / 99f;
+ float maxMix = (level - 1) / 99f;
- for(Map.Entry<String, JsonElement> entry : max.get("statNums").getAsJsonObject().entrySet()) {
+ 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;
+ float val = statMin * minMix + statMax * maxMix;
- stats.addStat(entry.getKey().toLowerCase(), (int)Math.floor(val));
+ stats.addStat(entry.getKey().toLowerCase(), (int) Math.floor(val));
}
}
- if(heldItem != null) {
+ 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()) {
+ 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) {}
+ } catch (Exception ignored) {}
}
}
- if(petStatBootsMult != null) {
- for(Map.Entry<String, Float> entryBoost : petStatBootsMult.entrySet()) {
+ 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) {}
+ } catch (Exception ignored) {}
}
}
}
@@ -542,20 +548,20 @@ public class PlayerStats {
String fullset = getFullset(armor, -1);
- if(fullset != null && fullset.equals("SUPERIOR_DRAGON_")) {
+ if (fullset != null && fullset.equals("SUPERIOR_DRAGON_")) {
mult *= 1.05f;
}
- for(int i=0; i<armor.size(); i++) {
+ for (int i = 0; i < armor.size(); i++) {
JsonElement itemElement = armor.get(i);
- if(itemElement == null || !itemElement.isJsonObject()) continue;
+ 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")) {
+ if (reforge.equals("renowned")) {
mult *= 1.01f;
}
}
@@ -569,8 +575,8 @@ public class PlayerStats {
String fullset = getFullset(armor, 3);
- if(fullset != null) {
- switch(fullset) {
+ if (fullset != null) {
+ switch (fullset) {
case "CHEAP_TUXEDO_":
stats.statsJson.add(HEALTH, new JsonPrimitive(Math.min(75, stats.get(HEALTH))));
case "FANCY_TUXEDO_":
@@ -580,8 +586,8 @@ public class PlayerStats {
}
}
- for(Map.Entry<String, JsonElement> statEntry : stats.statsJson.entrySet()) {
- if(statEntry.getKey().equals(CRIT_DAMAGE) ||
+ 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())));
@@ -590,7 +596,7 @@ public class PlayerStats {
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;
+ 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();
@@ -600,12 +606,12 @@ public class PlayerStats {
Stats armorBonuses = getItemBonuses(false, armor);
Stats talismanBonuses = getItemBonuses(true, inventory, talisman_bag);
- if(passiveBonuses == null || armorBonuses == null || talismanBonuses == null) {
+ if (passiveBonuses == null || armorBonuses == null || talismanBonuses == null) {
return null;
}
Stats stats = getBaseStats();
- if(stats == null) {
+ if (stats == null) {
return null;
}
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..1de24257 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;
@@ -35,8 +34,8 @@ public class ProfileViewer {
this.manager = manager;
}
+ private static final HashMap<String, String> petRarityToNumMap = new HashMap<>();
- private static HashMap<String, String> petRarityToNumMap = new HashMap<>();
static {
petRarityToNumMap.put("COMMON", "0");
petRarityToNumMap.put("UNCOMMON", "1");
@@ -47,31 +46,33 @@ public class ProfileViewer {
}
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_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"));
+ 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 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",
@@ -80,7 +81,7 @@ public class ProfileViewer {
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"));
+ "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));
@@ -92,6 +93,7 @@ public class ProfileViewer {
}
private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap = new LinkedHashMap<>();
+
static {
collectionCatToMinionMap.put(CAT_FARMING,
Utils.createList("WHEAT", "CARROT", "POTATO", "PUMPKIN", "MELON", null, "MUSHROOM",
@@ -112,144 +114,145 @@ public class ProfileViewer {
}
private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap = new LinkedHashMap<>();
+
static {
/* FARMING COLLECTIONS **/
collectionToCollectionDisplayMap.put("WHEAT", Utils.createItemStack(Items.wheat,
- EnumChatFormatting.YELLOW+"Wheat"));
+ EnumChatFormatting.YELLOW + "Wheat"));
collectionToCollectionDisplayMap.put("CARROT_ITEM", Utils.createItemStack(Items.carrot,
- EnumChatFormatting.YELLOW+"Carrot"));
+ EnumChatFormatting.YELLOW + "Carrot"));
collectionToCollectionDisplayMap.put("POTATO_ITEM", Utils.createItemStack(Items.potato,
- EnumChatFormatting.YELLOW+"Potato"));
+ EnumChatFormatting.YELLOW + "Potato"));
collectionToCollectionDisplayMap.put("PUMPKIN", Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin),
- EnumChatFormatting.YELLOW+"Pumpkin"));
+ EnumChatFormatting.YELLOW + "Pumpkin"));
collectionToCollectionDisplayMap.put("MELON", Utils.createItemStack(Items.melon,
- EnumChatFormatting.YELLOW+"Melon"));
+ EnumChatFormatting.YELLOW + "Melon"));
collectionToCollectionDisplayMap.put("SEEDS", Utils.createItemStack(Items.wheat_seeds,
- EnumChatFormatting.YELLOW+"Seeds"));
+ EnumChatFormatting.YELLOW + "Seeds"));
collectionToCollectionDisplayMap.put("MUSHROOM_COLLECTION",
Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom)
- , EnumChatFormatting.YELLOW+"Mushroom"));
+ , EnumChatFormatting.YELLOW + "Mushroom"));
collectionToCollectionDisplayMap.put("INK_SACK:3", Utils.createItemStack(Items.dye,
- EnumChatFormatting.YELLOW+"Cocoa Beans", 3));
+ EnumChatFormatting.YELLOW + "Cocoa Beans", 3));
collectionToCollectionDisplayMap.put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus),
- EnumChatFormatting.YELLOW+"Cactus"));
+ EnumChatFormatting.YELLOW + "Cactus"));
collectionToCollectionDisplayMap.put("SUGAR_CANE", Utils.createItemStack(Items.reeds,
- EnumChatFormatting.YELLOW+"Sugar Cane"));
+ EnumChatFormatting.YELLOW + "Sugar Cane"));
collectionToCollectionDisplayMap.put("FEATHER", Utils.createItemStack(Items.feather,
- EnumChatFormatting.YELLOW+"Feather"));
+ EnumChatFormatting.YELLOW + "Feather"));
collectionToCollectionDisplayMap.put("LEATHER", Utils.createItemStack(Items.leather,
- EnumChatFormatting.YELLOW+"Leather"));
+ EnumChatFormatting.YELLOW + "Leather"));
collectionToCollectionDisplayMap.put("PORK", Utils.createItemStack(Items.porkchop,
- EnumChatFormatting.YELLOW+"Porkchop"));
+ EnumChatFormatting.YELLOW + "Porkchop"));
collectionToCollectionDisplayMap.put("RAW_CHICKEN", Utils.createItemStack(Items.chicken,
- EnumChatFormatting.YELLOW+"Chicken"));
+ EnumChatFormatting.YELLOW + "Chicken"));
collectionToCollectionDisplayMap.put("MUTTON", Utils.createItemStack(Items.mutton,
- EnumChatFormatting.YELLOW+"Mutton"));
+ EnumChatFormatting.YELLOW + "Mutton"));
collectionToCollectionDisplayMap.put("RABBIT", Utils.createItemStack(Items.rabbit,
- EnumChatFormatting.YELLOW+"Rabbit"));
+ EnumChatFormatting.YELLOW + "Rabbit"));
collectionToCollectionDisplayMap.put("NETHER_STALK", Utils.createItemStack(Items.nether_wart,
- EnumChatFormatting.YELLOW+"Nether Wart"));
+ EnumChatFormatting.YELLOW + "Nether Wart"));
/* MINING COLLECTIONS **/
collectionToCollectionDisplayMap.put("COBBLESTONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone),
- EnumChatFormatting.GRAY+"Cobblestone"));
+ EnumChatFormatting.GRAY + "Cobblestone"));
collectionToCollectionDisplayMap.put("COAL", Utils.createItemStack(Items.coal,
- EnumChatFormatting.GRAY+"Coal"));
+ EnumChatFormatting.GRAY + "Coal"));
collectionToCollectionDisplayMap.put("IRON_INGOT", Utils.createItemStack(Items.iron_ingot,
- EnumChatFormatting.GRAY+"Iron Ingot"));
+ EnumChatFormatting.GRAY + "Iron Ingot"));
collectionToCollectionDisplayMap.put("GOLD_INGOT", Utils.createItemStack(Items.gold_ingot,
- EnumChatFormatting.GRAY+"Gold Ingot"));
+ EnumChatFormatting.GRAY + "Gold Ingot"));
collectionToCollectionDisplayMap.put("DIAMOND", Utils.createItemStack(Items.diamond,
- EnumChatFormatting.GRAY+"Diamond"));
+ EnumChatFormatting.GRAY + "Diamond"));
collectionToCollectionDisplayMap.put("INK_SACK:4", Utils.createItemStack(Items.dye,
- EnumChatFormatting.GRAY+"Lapis Lazuli", 4));
+ EnumChatFormatting.GRAY + "Lapis Lazuli", 4));
collectionToCollectionDisplayMap.put("EMERALD", Utils.createItemStack(Items.emerald,
- EnumChatFormatting.GRAY+"Emerald"));
+ EnumChatFormatting.GRAY + "Emerald"));
collectionToCollectionDisplayMap.put("REDSTONE", Utils.createItemStack(Items.redstone,
- EnumChatFormatting.GRAY+"Redstone"));
+ EnumChatFormatting.GRAY + "Redstone"));
collectionToCollectionDisplayMap.put("QUARTZ", Utils.createItemStack(Items.quartz,
- EnumChatFormatting.GRAY+"Nether Quartz"));
+ EnumChatFormatting.GRAY + "Nether Quartz"));
collectionToCollectionDisplayMap.put("OBSIDIAN", Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian),
- EnumChatFormatting.GRAY+"Obsidian"));
+ EnumChatFormatting.GRAY + "Obsidian"));
collectionToCollectionDisplayMap.put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust,
- EnumChatFormatting.GRAY+"Glowstone"));
+ EnumChatFormatting.GRAY + "Glowstone"));
collectionToCollectionDisplayMap.put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel),
- EnumChatFormatting.GRAY+"Gravel"));
+ EnumChatFormatting.GRAY + "Gravel"));
collectionToCollectionDisplayMap.put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice),
- EnumChatFormatting.GRAY+"Ice"));
+ EnumChatFormatting.GRAY + "Ice"));
collectionToCollectionDisplayMap.put("NETHERRACK", Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack),
- EnumChatFormatting.GRAY+"Netherrack"));
+ EnumChatFormatting.GRAY + "Netherrack"));
collectionToCollectionDisplayMap.put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand),
- EnumChatFormatting.GRAY+"Sand"));
+ EnumChatFormatting.GRAY + "Sand"));
collectionToCollectionDisplayMap.put("ENDER_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone),
- EnumChatFormatting.GRAY+"End Stone"));
+ EnumChatFormatting.GRAY + "End Stone"));
collectionToCollectionDisplayMap.put("MITHRIL_ORE", Utils.createItemStack(Items.prismarine_crystals,
- EnumChatFormatting.GRAY+"Mithril"));
+ EnumChatFormatting.GRAY + "Mithril"));
collectionToCollectionDisplayMap.put("HARD_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.stone),
- EnumChatFormatting.GRAY+"Hard Stone"));
+ EnumChatFormatting.GRAY + "Hard Stone"));
ItemStack gemstone = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass),
- EnumChatFormatting.GRAY+"Gem Stones");
+ 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"));
+ EnumChatFormatting.RED + "Rotten Flesh"));
collectionToCollectionDisplayMap.put("BONE", Utils.createItemStack(Items.bone,
- EnumChatFormatting.RED+"Bone"));
+ EnumChatFormatting.RED + "Bone"));
collectionToCollectionDisplayMap.put("STRING", Utils.createItemStack(Items.string,
- EnumChatFormatting.RED+"String"));
+ EnumChatFormatting.RED + "String"));
collectionToCollectionDisplayMap.put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye,
- EnumChatFormatting.RED+"Spider Eye"));
+ EnumChatFormatting.RED + "Spider Eye"));
collectionToCollectionDisplayMap.put("SULPHUR", Utils.createItemStack(Items.gunpowder,
- EnumChatFormatting.RED+"Gunpowder"));
+ EnumChatFormatting.RED + "Gunpowder"));
collectionToCollectionDisplayMap.put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl,
- EnumChatFormatting.RED+"Ender Pearl"));
+ EnumChatFormatting.RED + "Ender Pearl"));
collectionToCollectionDisplayMap.put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear,
- EnumChatFormatting.RED+"Ghast Tear"));
+ EnumChatFormatting.RED + "Ghast Tear"));
collectionToCollectionDisplayMap.put("SLIME_BALL", Utils.createItemStack(Items.slime_ball,
- EnumChatFormatting.RED+"Slimeball"));
+ EnumChatFormatting.RED + "Slimeball"));
collectionToCollectionDisplayMap.put("BLAZE_ROD", Utils.createItemStack(Items.blaze_rod,
- EnumChatFormatting.RED+"Blaze Rod"));
+ EnumChatFormatting.RED + "Blaze Rod"));
collectionToCollectionDisplayMap.put("MAGMA_CREAM", Utils.createItemStack(Items.magma_cream,
- EnumChatFormatting.RED+"Magma Cream"));
+ EnumChatFormatting.RED + "Magma Cream"));
/* FORAGING COLLECTIONS **/
collectionToCollectionDisplayMap.put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Oak"));
+ EnumChatFormatting.DARK_GREEN + "Oak"));
collectionToCollectionDisplayMap.put("LOG:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Spruce", 1));
+ EnumChatFormatting.DARK_GREEN + "Spruce", 1));
collectionToCollectionDisplayMap.put("LOG:2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Birch", 2));
+ EnumChatFormatting.DARK_GREEN + "Birch", 2));
collectionToCollectionDisplayMap.put("LOG_2:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2),
- EnumChatFormatting.DARK_GREEN+"Dark Oak", 1));
+ EnumChatFormatting.DARK_GREEN + "Dark Oak", 1));
collectionToCollectionDisplayMap.put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2),
- EnumChatFormatting.DARK_GREEN+"Acacia"));
+ EnumChatFormatting.DARK_GREEN + "Acacia"));
collectionToCollectionDisplayMap.put("LOG:3", Utils.createItemStack(Item.getItemFromBlock(Blocks.log),
- EnumChatFormatting.DARK_GREEN+"Jungle", 3));
+ EnumChatFormatting.DARK_GREEN + "Jungle", 3));
/* FISHING COLLECTIONS **/
collectionToCollectionDisplayMap.put("RAW_FISH", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Fish"));
+ EnumChatFormatting.AQUA + "Fish"));
collectionToCollectionDisplayMap.put("RAW_FISH:1", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Salmon", 1));
+ EnumChatFormatting.AQUA + "Salmon", 1));
collectionToCollectionDisplayMap.put("RAW_FISH:2", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Clownfish", 2));
+ EnumChatFormatting.AQUA + "Clownfish", 2));
collectionToCollectionDisplayMap.put("RAW_FISH:3", Utils.createItemStack(Items.fish,
- EnumChatFormatting.AQUA+"Pufferfish", 3));
+ EnumChatFormatting.AQUA + "Pufferfish", 3));
collectionToCollectionDisplayMap.put("PRISMARINE_SHARD", Utils.createItemStack(Items.prismarine_shard,
- EnumChatFormatting.AQUA+"Prismarine Shard"));
+ EnumChatFormatting.AQUA + "Prismarine Shard"));
collectionToCollectionDisplayMap.put("PRISMARINE_CRYSTALS", Utils.createItemStack(Items.prismarine_crystals,
- EnumChatFormatting.AQUA+"Prismarine Crystals"));
+ EnumChatFormatting.AQUA + "Prismarine Crystals"));
collectionToCollectionDisplayMap.put("CLAY_BALL", Utils.createItemStack(Items.clay_ball,
- EnumChatFormatting.AQUA+"Clay"));
+ EnumChatFormatting.AQUA + "Clay"));
collectionToCollectionDisplayMap.put("WATER_LILY", Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily),
- EnumChatFormatting.AQUA+"Lilypad"));
+ EnumChatFormatting.AQUA + "Lilypad"));
collectionToCollectionDisplayMap.put("INK_SACK", Utils.createItemStack(Items.dye,
- EnumChatFormatting.AQUA+"Ink Sack"));
+ EnumChatFormatting.AQUA + "Ink Sack"));
collectionToCollectionDisplayMap.put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge),
- EnumChatFormatting.AQUA+"Sponge"));
+ EnumChatFormatting.AQUA + "Sponge"));
}
public static LinkedHashMap<ItemStack, List<String>> getCollectionCatToMinionMap() {
@@ -276,29 +279,29 @@ public class ProfileViewer {
public static Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) {
Level levelObj = new Level();
- for(int level=0; level<levelingArray.size(); level++) {
+ for (int level = 0; level < levelingArray.size(); level++) {
float levelXp = levelingArray.get(level).getAsFloat();
- if(levelXp > xp) {
- if(cumulative) {
+ 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;
+ 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;
+ levelObj.level = level + xp / levelXp;
}
- if(levelObj.level > levelCap) {
+ if (levelObj.level > levelCap) {
levelObj.level = levelCap;
levelObj.maxed = true;
}
return levelObj;
} else {
- if(!cumulative) xp -= levelXp;
+ if (!cumulative) xp -= levelXp;
}
}
levelObj.level = levelingArray.size();
- if(levelObj.level > levelCap) {
+ if (levelObj.level > levelCap) {
levelObj.level = levelCap;
}
levelObj.maxed = true;
@@ -319,37 +322,37 @@ public class ProfileViewer {
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 final 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<>();
+ 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 AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false);
private long lastPlayerInfoState = 0;
- private AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
- private AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
private long lastGuildInfoState = 0;
- private AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false);
public JsonObject getPlayerStatus() {
- if(playerStatus != null) return playerStatus;
- if(updatingPlayerStatusState.get()) return null;
+ if (playerStatus != null) return playerStatus;
+ if (updatingPlayerStatusState.get()) return null;
updatingPlayerStatusState.set(true);
HashMap<String, String> args = new HashMap<>();
- args.put("uuid", ""+uuid);
+ args.put("uuid", "" + uuid);
manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiKey.apiKey, "status",
args, jsonObject -> {
- if(jsonObject == null) return;
+ if (jsonObject == null) return;
updatingPlayerStatusState.set(false);
- if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
playerStatus = jsonObject.get("session").getAsJsonObject();
}
}, () -> updatingPlayerStatusState.set(false)
@@ -358,12 +361,11 @@ public class ProfileViewer {
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;
+ 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);
@@ -371,29 +373,29 @@ public class ProfileViewer {
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()) {
+ 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;
+ 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();
+ 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 = (int) manager.auctionManager.getItemAvgBin(internalname);
+ if (auctionPrice <= 0) {
auctionPrice = manager.auctionManager.getLowestBin(internalname);
}
}
try {
- if(item.has("item_contents")) {
+ 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++) {
@@ -401,21 +403,21 @@ public class ProfileViewer {
}
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) {
+ 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;
+ 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();
+ 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 = (int) manager.auctionManager.getItemAvgBin(internalname2);
+ if (auctionPrice2 <= 0) {
auctionPrice2 = manager.auctionManager.getLowestBin(internalname2);
}
}
@@ -428,10 +430,10 @@ public class ProfileViewer {
}
}
}
- } catch(IOException ignored) {}
+ } catch (IOException ignored) {}
int count = 1;
- if(element.getAsJsonObject().has("count")) {
+ if (element.getAsJsonObject().has("count")) {
count = element.getAsJsonObject().get("count").getAsInt();
}
mostExpensiveInternal.put(internalname, auctionPrice * count + mostExpensiveInternal.getOrDefault(internalname, 0L));
@@ -440,31 +442,31 @@ public class ProfileViewer {
}
}
}
- if(networth == 0) return -1;
+ if (networth == 0) return -1;
//System.out.println(profileId);
- for(Map.Entry<String, Long> entry : mostExpensiveInternal.entrySet()) {
+ for (Map.Entry<String, Long> entry : mostExpensiveInternal.entrySet()) {
//System.out.println(entry.getKey() + ":" + entry.getValue());
}
- networth = (int)(networth*1.3f);
+ networth = (int) (networth * 1.3f);
JsonObject petsInfo = getPetsInfo(profileId);
- if(petsInfo != null && petsInfo.has("pets")) {
- if(petsInfo.get("pets").isJsonArray()) {
+ if (petsInfo != null && petsInfo.has("pets")) {
+ if (petsInfo.get("pets").isJsonArray()) {
JsonArray pets = petsInfo.get("pets").getAsJsonArray();
- for(JsonElement element : pets) {
- if(element.isJsonObject()) {
+ 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;
+ 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());
+ if (info2 == null || !info2.has("price") || !info2.has("count")) continue;
+ int auctionPrice2 = (int) (info2.get("price").getAsFloat() / info2.get("count").getAsFloat());
networth += auctionPrice2;
}
@@ -476,7 +478,7 @@ public class ProfileViewer {
float bankBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "banking.balance"), 0);
float purseBalance = Utils.getElementAsFloat(Utils.getElement(profileInfo, "coin_purse"), 0);
- networth += bankBalance+purseBalance;
+ networth += bankBalance + purseBalance;
this.networth.put(profileId, networth);
return networth;
@@ -491,7 +493,7 @@ public class ProfileViewer {
long currentTime = System.currentTimeMillis();
- if (currentTime - lastPlayerInfoState < 15*1000 && updatingPlayerInfoState.get()) return null;
+ if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingPlayerInfoState.get()) return null;
lastPlayerInfoState = currentTime;
updatingPlayerInfoState.set(true);
@@ -520,14 +522,13 @@ public class ProfileViewer {
if (members.has(uuid)) {
JsonObject member = members.get(uuid).getAsJsonObject();
- if(member.has("coop_invitation")) {
+ if (member.has("coop_invitation")) {
JsonObject coop_invitation = member.get("coop_invitation").getAsJsonObject();
- if(!coop_invitation.get("confirmed").getAsBoolean()) {
+ 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);
@@ -544,19 +545,18 @@ public class ProfileViewer {
latestProfile = backup;
if (runnable != null) runnable.run();
}
- }, () -> {
- updatingPlayerInfoState.set(false);
- }
+ }, () -> updatingPlayerInfoState.set(false)
);
- return null;
+ 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;
+ if (currentTime - lastGuildInfoState < 15 * 1000 && updatingGuildInfoState.get()) return null;
lastGuildInfoState = currentTime;
updatingGuildInfoState.set(true);
@@ -573,9 +573,7 @@ public class ProfileViewer {
if (guildInformation == null) return;
if (runnable != null) runnable.run();
}
- }, () -> {
- updatingGuildInfoState.set(false);
- }
+ }, () -> updatingGuildInfoState.set(false)
);
return null;
@@ -587,25 +585,25 @@ public class ProfileViewer {
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);
+ 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()) {
+ 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;
+ 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;
+ if (!members.has(uuid)) continue;
JsonObject profileInfo = members.get(uuid).getAsJsonObject();
- if(profile.has("banking")) {
+ if (profile.has("banking")) {
profileInfo.add("banking", profile.get("banking").getAsJsonObject());
}
- if(profile.has("game_mode")){
+ if (profile.has("game_mode")) {
profileInfo.add("game_mode", profile.get("game_mode"));
}
profileMap.put(profileId, profileInfo);
@@ -618,23 +616,23 @@ public class ProfileViewer {
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);
+ 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()) {
+ 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;
+ 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;
+ if (!members.has(uuid)) return null;
List<JsonObject> coopList = new ArrayList<>();
- for(Map.Entry<String, JsonElement> islandMember : members.entrySet()) {
- if(!islandMember.getKey().equals(uuid)) {
+ for (Map.Entry<String, JsonElement> islandMember : members.entrySet()) {
+ if (!islandMember.getKey().equals(uuid)) {
JsonObject coopProfileInfo = islandMember.getValue().getAsJsonObject();
coopList.add(coopProfileInfo);
}
@@ -666,11 +664,11 @@ public class ProfileViewer {
public int getCap(JsonObject leveling, String skillName) {
JsonElement capsElement = Utils.getElement(leveling, "leveling_caps");
- if(capsElement == null || !capsElement.isJsonObject()) {
+ if (capsElement == null || !capsElement.isJsonObject()) {
return 50;
}
JsonObject caps = capsElement.getAsJsonObject();
- if(caps.has(skillName)) {
+ if (caps.has(skillName)) {
return caps.get(skillName).getAsInt();
}
return 50;
@@ -678,11 +676,11 @@ public class ProfileViewer {
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);
+ 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;
+ 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);
@@ -702,13 +700,12 @@ public class ProfileViewer {
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) {
+ if (totalSkillXP <= 0) {
return null;
}
@@ -733,13 +730,13 @@ public class ProfileViewer {
skillInfo.addProperty("experience_slayer_enderman", experience_slayer_enderman);
JsonArray levelingArray = Utils.getElement(leveling, "leveling_xp").getAsJsonArray();
- int farmingCap = getCap(leveling, "farming") + (int)Utils.getElementAsFloat(
+ 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_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);
@@ -751,13 +748,13 @@ public class ProfileViewer {
experience_skill_catacombs, getCap(leveling, "catacombs"), false);
Level level_slayer_zombie = getLevel(Utils.getElement(leveling, "slayer_xp.zombie").getAsJsonArray(),
- experience_slayer_zombie, 9,true);
+ experience_slayer_zombie, 9, true);
Level level_slayer_spider = getLevel(Utils.getElement(leveling, "slayer_xp.spider").getAsJsonArray(),
- experience_slayer_spider, 9,true);
+ experience_slayer_spider, 9, true);
Level level_slayer_wolf = getLevel(Utils.getElement(leveling, "slayer_xp.wolf").getAsJsonArray(),
- experience_slayer_wolf, 9,true);
+ experience_slayer_wolf, 9, true);
Level level_slayer_enderman = getLevel(Utils.getElement(leveling, "slayer_xp.enderman").getAsJsonArray(),
- experience_slayer_enderman, 9,true);
+ experience_slayer_enderman, 9, true);
skillInfo.addProperty("level_skill_taming", level_skill_taming.level);
skillInfo.addProperty("level_skill_mining", level_skill_mining.level);
@@ -818,9 +815,9 @@ public class ProfileViewer {
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);
+ 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=");
@@ -838,20 +835,19 @@ public class ProfileViewer {
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++) {
+ 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")){
+ 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"));
@@ -866,7 +862,7 @@ public class ProfileViewer {
}
}
inventoryInfo.add(inv_names[i], contents);
- } catch(IOException e) {
+ } catch (IOException e) {
inventoryInfo.add(inv_names[i], new JsonArray());
}
}
@@ -876,14 +872,14 @@ public class ProfileViewer {
return inventoryInfo;
}
- public boolean checkIfValidJson(JsonElement element){
+ 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))){
+ if (!(checkIfValidJson(backpack_contents_json) && checkIfValidJson(backpack_icons))) {
JsonObject bundledReturn = new JsonObject();
bundledReturn.add("contents", new JsonArray());
bundledReturn.add("backpack_sizes", new JsonArray());
@@ -894,15 +890,14 @@ public class ProfileViewer {
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());
+ 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;
@@ -932,11 +927,9 @@ public class ProfileViewer {
JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
contents.add(item);
}
- } catch (IOException ignored) {
- }
+ } catch (IOException ignored) {}
}
-
JsonObject bundledReturn = new JsonObject();
bundledReturn.add("contents", contents);
bundledReturn.add("backpack_sizes", backpackSizes);
@@ -944,8 +937,8 @@ public class ProfileViewer {
return bundledReturn;
}
- public String[] growArray(String bytes, int index, String[] oldArray){
- int newSize = Math.max(index+1, oldArray.length);
+ 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++) {
@@ -956,21 +949,19 @@ public class ProfileViewer {
return newArray;
}
-
-
public JsonObject getPetsInfo(String profileId) {
JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
- if(petsInfoMap.containsKey(profileId)) return petsInfoMap.get(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()) {
+ if (petsElement != null && petsElement.isJsonArray()) {
JsonObject activePet = null;
JsonArray pets = petsElement.getAsJsonArray();
- for(int i=0; i<pets.size(); i++) {
+ for (int i = 0; i < pets.size(); i++) {
JsonObject pet = pets.get(i).getAsJsonObject();
- if(pet.has("active") && pet.get("active").getAsJsonPrimitive().getAsBoolean()) {
+ if (pet.has("active") && pet.get("active").getAsJsonPrimitive().getAsBoolean()) {
activePet = pet;
break;
}
@@ -984,19 +975,20 @@ public class ProfileViewer {
}
private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?[0-9]+)");
+
public JsonObject getCollectionInfo(String profileId) {
JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
+ 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);
+ 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) {
+ if (unlocked_coll_tiers_element == null || collectionInfoElement == null) {
return null;
}
@@ -1006,57 +998,57 @@ public class ProfileViewer {
JsonObject personalAmounts = new JsonObject();
JsonObject totalAmounts = new JsonObject();
- if(collectionInfoElement.isJsonObject()) {
+ if (collectionInfoElement.isJsonObject()) {
personalAmounts = collectionInfoElement.getAsJsonObject();
}
- for(Map.Entry<String, JsonElement> entry : personalAmounts.entrySet()) {
+ 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) {
+ 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()) {
+ 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());
+ totalAmounts.addProperty(entry.getKey(), existing + entry.getValue().getAsInt());
}
}
}
}
- if(unlocked_coll_tiers_element.isJsonArray()) {
+ 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++) {
+ 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()) {
+ 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) {
+ 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()) {
+ 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++) {
+ 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()) {
+ 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) {
+ String coll = unlocked.substring(0, unlocked.length() - (matcher.group().length()));
+ if (!minionTiers.has(coll) || minionTiers.get(coll).getAsInt() < tier) {
minionTiers.addProperty(coll, tier);
}
}
@@ -1065,28 +1057,28 @@ public class ProfileViewer {
JsonObject maxAmount = new JsonObject();
JsonObject updatedCollectionTiers = new JsonObject();
- for(Map.Entry<String, JsonElement> totalAmountsEntry : totalAmounts.entrySet()) {
+ for (Map.Entry<String, JsonElement> totalAmountsEntry : totalAmounts.entrySet()) {
String collName = totalAmountsEntry.getKey();
- int collTier = (int)Utils.getElementAsFloat(collectionTiers.get(collName), 0);
+ 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()) {
+ 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++) {
+ 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) {
+ if (currentAmount >= amountRequired) {
maxTierAcquired = tier;
}
maxAmountRequired = amountRequired;
}
- if(maxTierAcquired >= 0 && maxTierAcquired > collTier) {
+ if (maxTierAcquired >= 0 && maxTierAcquired > collTier) {
updatedCollectionTiers.addProperty(collName, maxTierAcquired);
}
maxAmount.addProperty(collName, maxAmountRequired);
@@ -1095,7 +1087,7 @@ public class ProfileViewer {
}
}
- for(Map.Entry<String, JsonElement> collectionTiersEntry : updatedCollectionTiers.entrySet()) {
+ for (Map.Entry<String, JsonElement> collectionTiersEntry : updatedCollectionTiers.entrySet()) {
collectionTiers.add(collectionTiersEntry.getKey(), collectionTiersEntry.getValue());
}
@@ -1109,13 +1101,13 @@ public class ProfileViewer {
}
public PlayerStats.Stats getPassiveStats(String profileId) {
- if(passiveStats.get(profileId) != null) return passiveStats.get(profileId);
+ if (passiveStats.get(profileId) != null) return passiveStats.get(profileId);
JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) return null;
+ if (profileInfo == null) return null;
PlayerStats.Stats passiveStats = PlayerStats.getPassiveBonuses(getSkillInfo(profileId), profileInfo);
- if(passiveStats != null) {
+ if (passiveStats != null) {
passiveStats.add(PlayerStats.getBaseStats());
}
@@ -1127,7 +1119,7 @@ public class ProfileViewer {
public PlayerStats.Stats getStats(String profileId) {
//if(stats.get(profileId) != null) return stats.get(profileId);
JsonObject profileInfo = getProfileInformation(profileId);
- if(profileInfo == null) {
+ if (profileInfo == null) {
return null;
}
@@ -1141,29 +1133,30 @@ public class ProfileViewer {
return uuid;
}
- public @Nullable JsonObject getHypixelProfile() {
- if(uuidToHypixelProfile.containsKey(uuid)) return uuidToHypixelProfile.get(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<>();
+ 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);
+ 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()
+ 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);
+ if (callback != null) callback.accept(jsonObject);
} else {
- if(callback != null) callback.accept(null);
+ if (callback != null) callback.accept(null);
}
}
);
@@ -1177,15 +1170,15 @@ public class ProfileViewer {
public void getPlayerUUID(String name, Consumer<String> uuidCallback) {
String nameF = name.toLowerCase();
- if(nameToUuid.containsKey(nameF)) {
+ if (nameToUuid.containsKey(nameF)) {
uuidCallback.accept(nameToUuid.get(nameF));
return;
}
- manager.hypixelApi.getApiAsync("https://api.mojang.com/users/profiles/minecraft/"+nameF,
+ 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()) {
+ 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);
@@ -1199,15 +1192,15 @@ public class ProfileViewer {
public void getProfileByName(String name, Consumer<Profile> callback) {
String nameF = name.toLowerCase();
- if(nameToUuid.containsKey(nameF) && nameToUuid.get(nameF) == null) {
+ if (nameToUuid.containsKey(nameF) && nameToUuid.get(nameF) == null) {
callback.accept(null);
return;
}
getPlayerUUID(nameF, (uuid) -> {
- if(uuid == null) {
+ if (uuid == null) {
getHypixelProfile(nameF, jsonObject -> {
- if(jsonObject != null) {
+ if (jsonObject != null) {
callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {}));
} else {
callback.accept(null);
@@ -1215,7 +1208,7 @@ public class ProfileViewer {
}
});
} else {
- if(!uuidToHypixelProfile.containsKey(uuid)) {
+ if (!uuidToHypixelProfile.containsKey(uuid)) {
getHypixelProfile(nameF, jsonObject -> {});
}
callback.accept(getProfileReset(uuid, ignored -> {}));
@@ -1231,7 +1224,7 @@ public class ProfileViewer {
public Profile getProfile(String uuid, Consumer<Profile> callback) {
Profile profile = uuidToProfileMap.computeIfAbsent(uuid, k -> new Profile(uuid));
- if(profile.playerInformation != null) {
+ if (profile.playerInformation != null) {
callback.accept(profile);
} else {
profile.getPlayerInformation(() -> callback.accept(profile));
@@ -1240,15 +1233,16 @@ public class ProfileViewer {
}
public Profile getProfileReset(String uuid, Consumer<Profile> callback) {
- if(uuidToProfileMap.containsKey(uuid)) uuidToProfileMap.get(uuid).resetCache();
+ if (uuidToProfileMap.containsKey(uuid)) uuidToProfileMap.get(uuid).resetCache();
return getProfile(uuid, callback);
}
private static JsonObject resourceCollection = null;
- private static AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
+ private static final AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
+
public static JsonObject getResourceCollectionInformation() {
- if(resourceCollection != null) return resourceCollection;
- if(updatingResourceCollection.get()) return null;
+ if (resourceCollection != null) return resourceCollection;
+ if (updatingResourceCollection.get()) return null;
updatingResourceCollection.set(true);
@@ -1256,12 +1250,10 @@ public class ProfileViewer {
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()) {
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
resourceCollection = jsonObject.get("collections").getAsJsonObject();
}
- }, () -> {
- updatingResourceCollection.set(false);
- }
+ }, () -> updatingResourceCollection.set(false)
);
return null;
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..3524031a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
@@ -14,6 +14,7 @@ public class Constants {
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());
@@ -37,7 +38,7 @@ public class Constants {
public static CollectionConstant COLLECTIONLOG;
private static final ReentrantLock lock = new ReentrantLock();
-
+
public static void reload() {
try {
lock.lock();
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..5a3e55aa 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/GuiTextures.java
@@ -99,5 +99,4 @@ public class GuiTextures {
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..127a5177 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HastebinUploader.java
@@ -26,12 +26,12 @@ public class HastebinUploader {
* @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){
+ public static String upload(String data, Mode mode) {
try {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
- HttpURLConnection connection = (HttpURLConnection)new URL(UPLOAD_URL).openConnection();
+ HttpURLConnection connection = (HttpURLConnection) new URL(UPLOAD_URL).openConnection();
connection.setRequestMethod("POST");
- connection.addRequestProperty("User-Agent", "Minecraft Mod ("+ NotEnoughUpdates.MODID +"/"+NotEnoughUpdates.VERSION+")");
+ connection.addRequestProperty("User-Agent", "Minecraft Mod (" + NotEnoughUpdates.MODID + "/" + NotEnoughUpdates.VERSION + ")");
connection.addRequestProperty("Content-Length", String.valueOf(bytes.length));
connection.setReadTimeout(15000);
connection.setConnectTimeout(15000);
@@ -41,9 +41,12 @@ public class HastebinUploader {
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;
+ case RAW:
+ return RAW_RETURN_URL + key;
+ case NORMAL:
+ return RETURN_URL + key;
+ case NO_URL:
+ return key;
}
} catch (Exception e) {
e.printStackTrace();
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..abb2a453 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
@@ -5,10 +5,7 @@ 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.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
@@ -17,13 +14,12 @@ import java.util.HashMap;
import java.util.Map;
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 final Gson gson = new Gson();
+ private final ExecutorService es = Executors.newFixedThreadPool(3);
private static final int FAILS_BEFORE_SWITCH = 3;
private int currentUrl = 0;
@@ -36,13 +32,13 @@ public class HypixelApi {
}
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);
+ getApiAsync(generateApiUrl(apiKey != null ? apiKey.trim() : null, method, args), consumer, error);
}
private String getMyApiURL() {
- if(currentUrl == 0) {
+ if (currentUrl == 0) {
lastPrimaryUrl = System.currentTimeMillis();
- } else if(System.currentTimeMillis() - lastPrimaryUrl > 1000*60*30) { //Try switch back to main url after 30m
+ } else if (System.currentTimeMillis() - lastPrimaryUrl > 1000 * 60 * 30) { //Try switch back to main url after 30m
currentUrl = 0;
}
@@ -53,12 +49,12 @@ public class HypixelApi {
private void myApiError(int index) {
myApiSuccesses[index] = myApiSuccesses[index] - 2;
- if(myApiSuccesses[index] < 0) {
+ if (myApiSuccesses[index] < 0) {
myApiSuccesses[index] = 0;
- if(index == currentUrl) {
+ if (index == currentUrl) {
currentUrl++;
- if(currentUrl >= myApiURLs.length) {
+ if (currentUrl >= myApiURLs.length) {
currentUrl = 0;
}
}
@@ -69,7 +65,7 @@ public class HypixelApi {
es.submit(() -> {
try {
consumer.accept(getApiSync(urlS));
- } catch(Exception e) {
+ } catch (Exception e) {
error.run();
}
});
@@ -79,9 +75,9 @@ public class HypixelApi {
es.submit(() -> {
int current = currentUrl;
try {
- consumer.accept(getApiSync(getMyApiURL()+urlS));
- } catch(Exception e) {
- if(NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ consumer.accept(getApiSync(getMyApiURL() + urlS));
+ } catch (Exception e) {
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
e.printStackTrace();
}
myApiError(current);
@@ -94,8 +90,8 @@ public class HypixelApi {
es.submit(() -> {
int current = currentUrl;
try {
- consumer.accept(getApiGZIPSync(getMyApiURL()+urlS));
- } catch(Exception e) {
+ consumer.accept(getApiGZIPSync(getMyApiURL() + urlS));
+ } catch (Exception e) {
myApiError(current);
error.run();
}
@@ -106,7 +102,7 @@ public class HypixelApi {
es.submit(() -> {
try {
consumer.accept(getApiGZIPSync(urlS));
- } catch(Exception e) {
+ } catch (Exception e) {
error.run();
}
});
@@ -121,7 +117,7 @@ public class HypixelApi {
String response = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
JsonObject json = gson.fromJson(response, JsonObject.class);
- if(json == null) throw new ConnectException("Invalid JSON");
+ if (json == null) throw new ConnectException("Invalid JSON");
return json;
}
@@ -140,8 +136,8 @@ public class HypixelApi {
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) {
+ for (Map.Entry<String, String> entry : args.entrySet()) {
+ if (first && apiKey == null) {
url.append("?");
first = false;
} else {
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..e66e0edb 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/LerpingFloat.java
@@ -4,7 +4,7 @@ public class LerpingFloat {
private int timeSpent;
private long lastMillis;
- private int timeToReachTarget;
+ private final int timeToReachTarget;
private float targetValue;
private float lerpValue;
@@ -22,23 +22,23 @@ public class LerpingFloat {
int lastTimeSpent = timeSpent;
this.timeSpent += System.currentTimeMillis() - lastMillis;
- float lastDistPercentToTarget = lastTimeSpent/(float)timeToReachTarget;
- float distPercentToTarget = timeSpent/(float)timeToReachTarget;
- float fac = (1-lastDistPercentToTarget)/lastDistPercentToTarget;
+ float lastDistPercentToTarget = lastTimeSpent / (float) timeToReachTarget;
+ float distPercentToTarget = timeSpent / (float) timeToReachTarget;
+ float fac = (1 - lastDistPercentToTarget) / lastDistPercentToTarget;
- float startValue = lerpValue - (targetValue - lerpValue)/fac;
+ float startValue = lerpValue - (targetValue - lerpValue) / fac;
float dist = targetValue - startValue;
- if(dist == 0) return;
+ if (dist == 0) return;
float oldLerpValue = lerpValue;
- if(distPercentToTarget >= 1) {
+ if (distPercentToTarget >= 1) {
lerpValue = targetValue;
} else {
- lerpValue = startValue + dist*distPercentToTarget;
+ lerpValue = startValue + dist * distPercentToTarget;
}
- if(lerpValue == oldLerpValue) {
+ if (lerpValue == oldLerpValue) {
timeSpent = lastTimeSpent;
} else {
this.lastMillis = System.currentTimeMillis();
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..3d0177d4 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;
@@ -11,7 +10,7 @@ import java.util.Set;
public class NEUResourceManager implements IResourceManager {
- private IResourceManager parentResourceManager;
+ private final IResourceManager parentResourceManager;
public NEUResourceManager(IResourceManager parentResourceManager) {
this.parentResourceManager = parentResourceManager;
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..8cb9bfa7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ProfileApiSyncer.java
@@ -9,11 +9,11 @@ import java.util.function.Consumer;
public class ProfileApiSyncer {
- private static ProfileApiSyncer INSTANCE = new ProfileApiSyncer();
+ private static final 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 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() {
@@ -36,26 +36,26 @@ public class ProfileApiSyncer {
public long getCurrentResyncTime() {
long time = -1;
- for(long l : resyncTimes.values()) {
- if(l > 0 && (l < time || time == -1)) time = l;
+ 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;
+ if (Minecraft.getMinecraft().thePlayer == null) return;
long resyncTime = getCurrentResyncTime();
- if(resyncTime < 0) return;
+ if (resyncTime < 0) return;
long currentTime = System.currentTimeMillis();
- if(currentTime - lastResync > resyncTime) {
+ if (currentTime - lastResync > resyncTime) {
lastResync = currentTime;
resyncTimes.clear();
- for(Runnable r : syncingCallbacks.values()) r.run();
+ for (Runnable r : syncingCallbacks.values()) r.run();
syncingCallbacks.clear();
forceResync();
@@ -63,11 +63,11 @@ public class ProfileApiSyncer {
}
private void forceResync() {
- if(Minecraft.getMinecraft().thePlayer == null) return;
+ 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);
+ 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..6a63e454 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/RequestFocusListener.java
@@ -1,35 +1,34 @@
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;
+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()
- {
+ public RequestFocusListener() {
this(true);
}
@@ -40,19 +39,17 @@ public class RequestFocusListener implements AncestorListener
* @param removeListener when true this listener is only invoked once
* otherwise it can be invoked multiple times.
*/
- public RequestFocusListener(boolean removeListener)
- {
+ public RequestFocusListener(boolean removeListener) {
this.removeListener = removeListener;
}
@Override
- public void ancestorAdded(AncestorEvent e)
- {
+ public void ancestorAdded(AncestorEvent e) {
JComponent component = e.getComponent();
component.requestFocusInWindow();
if (removeListener)
- component.removeAncestorListener( this );
+ component.removeAncestorListener(this);
}
@Override
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..c34625b6 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,6 +9,11 @@ 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;
@@ -77,20 +72,16 @@ public class ReverseWorldRenderer {
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; ++k) {
- ainteger[k] = Integer.valueOf(k);
+ ainteger[k] = 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()]);
- }
- });
+ 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].intValue();
+ int i1 = ainteger[l1];
if (i1 != l1) {
this.rawIntBuffer.limit(i1 * l + l);
@@ -98,7 +89,7 @@ public class ReverseWorldRenderer {
this.rawIntBuffer.get(aint);
int j1 = i1;
- for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue()) {
+ 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();
@@ -328,9 +319,7 @@ public class ReverseWorldRenderer {
}
public ReverseWorldRenderer color(int red, int green, int blue, int alpha) {
- if (this.noColor) {
- return this;
- } else {
+ if (!this.noColor) {
int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.getType()) {
@@ -371,8 +360,8 @@ public class ReverseWorldRenderer {
}
this.nextVertexFormatIndex();
- return this;
}
+ return this;
}
public void addVertexData(int[] vertexData) {
@@ -523,12 +512,12 @@ public class ReverseWorldRenderer {
}
public boolean isColorDisabled() {
- /** None */
+ /* None */
return noColor;
}
@SideOnly(Side.CLIENT)
- public class State {
+ public static class State {
private final int[] stateRawBuffer;
private final VertexFormat stateVertexFormat;
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..15906884 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -28,6 +28,7 @@ import java.util.regex.Pattern;
public class SBInfo {
private static final SBInfo INSTANCE = new SBInfo();
+
public static SBInfo getInstance() {
return INSTANCE;
}
@@ -59,9 +60,9 @@ public class SBInfo {
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(event.gui instanceof GuiChest) {
+ if (event.gui instanceof GuiChest) {
GuiChest chest = (GuiChest) event.gui;
ContainerChest container = (ContainerChest) chest.inventorySlots;
String containerName = container.getLowerChestInventory().getDisplayName().getUnformattedText();
@@ -87,7 +88,7 @@ public class SBInfo {
private static final Pattern JSON_BRACKET_PATTERN = Pattern.compile("\\{.+}");
public void onSendChatMessage(String msg) {
- if(msg.trim().startsWith("/locraw") || msg.trim().startsWith("/locraw ")) {
+ if (msg.trim().startsWith("/locraw") || msg.trim().startsWith("/locraw ")) {
lastManualLocRaw = System.currentTimeMillis();
}
}
@@ -95,24 +96,24 @@ public class SBInfo {
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
public void onChatMessage(ClientChatReceivedEvent event) {
Matcher matcher = JSON_BRACKET_PATTERN.matcher(event.message.getUnformattedText());
- if(matcher.find()) {
+ 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")) {
+ 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) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
}
public String getLocation() {
- if(mode == null) {
+ if (mode == null) {
return null;
}
return mode;
@@ -128,7 +129,7 @@ public class SBInfo {
long currentTime = System.currentTimeMillis();
- if(Minecraft.getMinecraft().thePlayer != null &&
+ if (Minecraft.getMinecraft().thePlayer != null &&
Minecraft.getMinecraft().theWorld != null &&
locraw == null &&
(currentTime - joinedWorld) > 1000 &&
@@ -138,22 +139,22 @@ public class SBInfo {
}
try {
- for(NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
+ for (NetworkPlayerInfo info : Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()) {
String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info);
- if(name.startsWith(profilePrefix)) {
+ if (name.startsWith(profilePrefix)) {
currentProfile = Utils.cleanColour(name.substring(profilePrefix.length()));
- } else if(name.startsWith(skillsPrefix)) {
+ } 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()) {
+ 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 ignored) {}
}
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
@@ -165,36 +166,36 @@ public class SBInfo {
List<Score> scores = new ArrayList<>(scoreboard.getSortedScores(sidebarObjective));
List<String> lines = new ArrayList<>();
- for(int i=scores.size()-1; i>=0; i--) {
+ 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("%")) {
+ if (cleanLine.contains("Dungeon") && cleanLine.contains("Cleared:") && cleanLine.contains("%")) {
tempIsInDungeon = true;
}
lines.add(line);
}
- isInDungeon= tempIsInDungeon;
+ isInDungeon = tempIsInDungeon;
- if(lines.size() >= 5) {
+ if (lines.size() >= 5) {
date = Utils.cleanColour(lines.get(1)).trim();
//§74:40am
Matcher matcher = timePattern.matcher(lines.get(2));
- if(matcher.find()) {
+ 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) {}
+ } catch (ParseException ignored) {}
}
//Replaced with for loop because in crystal hollows with events the line it's on can shift.
- for (String line : lines){
+ for (String line : lines) {
if (line.contains("⏣")) {
location = Utils.cleanColour(line).replaceAll("[^A-Za-z0-9() ]", "").trim();
break;
@@ -204,14 +205,14 @@ public class SBInfo {
objective = null;
boolean objTextLast = false;
- for(String line : lines) {
- if(objTextLast) {
+ for (String line : lines) {
+ if (objTextLast) {
objective = line;
}
objTextLast = line.equals("Objective");
}
- } catch(Exception e) {
+ } 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..50f22382 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java
@@ -25,9 +25,8 @@ public class SpecialColour {
int[] arr = new int[split.length];
-
- for(int i=0; i<split.length; i++) {
- arr[i] = Integer.parseInt(split[split.length-1-i], RADIX);
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
}
return arr;
}
@@ -48,15 +47,16 @@ public class SpecialColour {
}
public static float getSecondsForSpeed(int speed) {
- return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS;
+ 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();
+ if (startTime < 0) startTime = System.currentTimeMillis();
int[] d = decompose(special);
int chr = d[4];
@@ -67,11 +67,11 @@ public class SpecialColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- if(chr > 0) {
+ if (chr > 0) {
float seconds = getSecondsForSpeed(chr);
- hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds;
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
hsv[0] %= 1;
- if(hsv[0] < 0) hsv[0] += 1;
+ if (hsv[0] < 0) hsv[0] += 1;
}
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
@@ -85,11 +85,10 @@ public class SpecialColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- hsv[0] += degrees/360f;
+ 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..8fb31cc4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java
@@ -9,7 +9,7 @@ public class TexLoc {
public int x;
public int y;
- private int toggleKey;
+ private final int toggleKey;
private boolean toggled;
private boolean pressedLastTick;
private boolean dirPressed;
@@ -21,28 +21,28 @@ public class TexLoc {
}
public boolean handleKeyboardInput() {
- int mult=1;
- if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) mult=10;
- if(Keyboard.isKeyDown(toggleKey)) {
- if(!pressedLastTick) {
+ 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;
+ 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;
+ } else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) {
+ if (!dirPressed) x += mult;
dirPressed = true;
- } else if(Keyboard.isKeyDown(Keyboard.KEY_UP)) {
- if(!dirPressed) y-=mult;
+ } else if (Keyboard.isKeyDown(Keyboard.KEY_UP)) {
+ if (!dirPressed) y -= mult;
dirPressed = true;
- } else if(Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
- if(!dirPressed) y+=mult;
+ } else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) {
+ if (!dirPressed) y += mult;
dirPressed = true;
} else {
dirPressed = 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..0845c7f6 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,23 @@ 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.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,17 +28,12 @@ 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.util.*;
import net.minecraftforge.fml.common.Loader;
import org.lwjgl.BufferUtils;
-import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
-import org.lwjgl.util.glu.Project;
-import javax.swing.*;
import java.awt.*;
import java.io.BufferedReader;
import java.io.File;
@@ -56,8 +41,6 @@ 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;
@@ -70,15 +53,15 @@ public class Utils {
public static boolean hasEffectOverride = false;
public static boolean disableCustomDungColours = false;
- private static LinkedList<Integer> guiScales = new LinkedList<>();
+ private static final 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);
+ 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<>();
- for(T value : values)list.add(value);
+ Collections.addAll(list, values);
return list;
}
@@ -91,19 +74,19 @@ public class Utils {
}
public static ScaledResolution pushGuiScale(int scale) {
- if(guiScales.size() == 0) {
- if(Loader.isModLoaded("labymod")) {
+ 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) {
+ if (scale < 0) {
+ if (guiScales.size() > 0) {
guiScales.pop();
}
} else {
- if(scale == 0) {
+ if (scale == 0) {
guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale);
} else {
guiScales.push(scale);
@@ -111,14 +94,14 @@ public class Utils {
}
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;
+ 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) {
+ if (guiScales.size() > 0) {
GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
GlStateManager.matrixMode(GL11.GL_PROJECTION);
GlStateManager.loadIdentity();
@@ -129,7 +112,7 @@ public class Utils {
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, 0.0F, -2000.0F);
} else {
- if(Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) {
+ if (Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) {
GlStateManager.matrixMode(GL11.GL_PROJECTION);
GL11.glLoadMatrix(projectionMatrixOld);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
@@ -163,7 +146,9 @@ public class Utils {
hasEffectOverride = true;
try {
itemRender.renderItemAndEffectIntoGUI(stack, x, y);
- } catch(Exception e) {e.printStackTrace();} //Catch exceptions to ensure that hasEffectOverride is set back to false.
+ } 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;
@@ -172,7 +157,7 @@ public class Utils {
}
public static void drawItemStackWithText(ItemStack stack, int x, int y, String text) {
- if(stack == null)return;
+ if (stack == null) return;
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
@@ -187,7 +172,7 @@ public class Utils {
}
public static void drawItemStack(ItemStack stack, int x, int y) {
- if(stack == null) return;
+ if (stack == null) return;
drawItemStackWithText(stack, x, y, null);
}
@@ -209,12 +194,12 @@ public class Utils {
private static final Pattern CHROMA_REPLACE_PATTERN = Pattern.compile("\u00a7z(.+?)(?=\u00a7|$)");
public static String chromaStringByColourCode(String str) {
- if(str.contains("\u00a7z")) {
+ if (str.contains("\u00a7z")) {
Matcher matcher = CHROMA_REPLACE_PATTERN.matcher(str);
StringBuffer sb = new StringBuffer();
- while(matcher.find()) {
+ while (matcher.find()) {
matcher.appendReplacement(sb,
Utils.chromaString(matcher.group(1))
.replace("\\", "\\\\")
@@ -229,41 +214,43 @@ public class Utils {
}
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;
+ if (startTime == 0) startTime = currentTimeMillis;
int chromaSpeed = NotEnoughUpdates.INSTANCE.config.misc.chromaSpeed;
- if(chromaSpeed < 10) chromaSpeed = 10;
- if(chromaSpeed > 5000) chromaSpeed = 5000;
+ 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++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
- int index = ((int)(offset+len/12f-(currentTimeMillis-startTime)/chromaSpeed))%rainbow.length;
+ int index = ((int) (offset + len / 12f - (currentTimeMillis - startTime) / chromaSpeed)) % rainbow.length;
len += Minecraft.getMinecraft().fontRendererObj.getCharWidth(c);
- if(bold) len++;
+ if (bold) len++;
- if(index < 0) index += rainbow.length;
+ if (index < 0) index += rainbow.length;
rainbowText.append(rainbow[index]);
- if(bold) rainbowText.append(EnumChatFormatting.BOLD);
+ if (bold) rainbowText.append(EnumChatFormatting.BOLD);
rainbowText.append(c);
}
return rainbowText.toString();
}
- private static char[] c = new char[]{'k', 'm', 'b', 't'};
+ 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)?
+ 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));
+ : shortNumberFormat(d, iteration + 1));
}
public static String trimIgnoreColour(String str) {
@@ -274,16 +261,16 @@ public class Utils {
str = str.trim();
boolean colourCodeLast = false;
StringBuilder colours = new StringBuilder();
- for(int i=0; i<str.length(); i++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
- if(colourCodeLast) {
+ if (colourCodeLast) {
colours.append('\u00a7').append(c);
colourCodeLast = false;
continue;
}
- if(c == '\u00A7') {
+ if (c == '\u00A7') {
colourCodeLast = true;
- } else if(c != ' ') {
+ } else if (c != ' ') {
return colours.append(str.substring(i)).toString();
}
}
@@ -293,23 +280,23 @@ public class Utils {
public static String trimIgnoreColourEnd(String str) {
str = str.trim();
- for(int i=str.length()-1; i>=0; i--) {
+ for (int i = str.length() - 1; i >= 0; i--) {
char c = str.charAt(i);
- if(c == ' ') {
+ if (c == ' ') {
continue;
- } else if(i > 0 && str.charAt(i-1) == '\u00a7') {
+ } else if (i > 0 && str.charAt(i - 1) == '\u00a7') {
i--;
continue;
}
- return str.substring(0, i+1);
+ return str.substring(0, i + 1);
}
return "";
}
public static List<String> getRawTooltip(ItemStack stack) {
- List<String> list = Lists.<String>newArrayList();
+ List<String> list = Lists.newArrayList();
String s = stack.getDisplayName();
if (stack.hasDisplayName()) {
@@ -348,15 +335,15 @@ public class Utils {
}
public static String floatToString(float f, int decimals) {
- if(decimals <= 0) {
+ if (decimals <= 0) {
return String.valueOf(Math.round(f));
} else {
- return String.format("%."+decimals+"f", f + 0.00001f);
+ return String.format("%." + decimals + "f", f + 0.00001f);
}
}
public static void drawItemStackLinear(ItemStack stack, int x, int y) {
- if(stack == null)return;
+ if (stack == null) return;
RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
@@ -389,7 +376,7 @@ public class Utils {
}
private static void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d) {
- GlStateManager.translate((float)xPosition, (float)yPosition, 5);
+ 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);
@@ -407,50 +394,49 @@ public class Utils {
}
public static Method getMethod(Class<?> clazz, Class<?>[] params, String... methodNames) {
- for(String methodName : methodNames) {
+ for (String methodName : methodNames) {
try {
return clazz.getDeclaredMethod(methodName, params);
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
}
return null;
}
public static Object getField(Class<?> clazz, Object o, String... fieldNames) {
Field field = null;
- for(String fieldName : fieldNames) {
+ for (String fieldName : fieldNames) {
try {
field = clazz.getDeclaredField(fieldName);
break;
- } catch(Exception e) {}
+ } catch (Exception ignored) {}
}
- if(field != null) {
+ if (field != null) {
field.setAccessible(true);
try {
return field.get(o);
- } catch(IllegalAccessException e) {
- }
+ } 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){
+ 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);
+ 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);
+ 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);
+ drawTexturedRect(x, y, width, height, uMin, uMax, vMin, vMax, GL11.GL_LINEAR);
}
public static String cleanColour(String in) {
@@ -469,24 +455,25 @@ public class Utils {
return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
}
- public static String[] rarityArr = new String[] {
+ 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 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]);
@@ -501,16 +488,18 @@ public class Utils {
}
- public static String getRarityFromInt(int rarity){
- if(rarity < 0|| rarity >= rarityArr.length){ return rarityArr[0]; }
+ 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--){
+ 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])){
+ if (line.equals(rarityArr[i1])) {
return i1;
}
}
@@ -519,11 +508,11 @@ public class Utils {
}
public static int checkItemType(JsonArray lore, boolean contains, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
String line = lore.get(i).getAsString();
int returnType = checkItemType(line, contains, typeMatches);
- if(returnType != -1){
+ if (returnType != -1) {
return returnType;
}
}
@@ -531,11 +520,11 @@ public class Utils {
}
public static int checkItemType(String[] lore, boolean contains, String... typeMatches) {
- for(int i=lore.length-1; i>=0; i--) {
+ for (int i = lore.length - 1; i >= 0; i--) {
String line = lore[i];
int returnType = checkItemType(line, contains, typeMatches);
- if(returnType != -1){
+ if (returnType != -1) {
return returnType;
}
}
@@ -543,11 +532,11 @@ public class Utils {
}
public static int checkItemType(List<String> lore, boolean contains, String... typeMatches) {
- for(int i=lore.size()-1; i>=0; i--) {
+ for (int i = lore.size() - 1; i >= 0; i--) {
String line = lore.get(i);
int returnType = checkItemType(line, contains, typeMatches);
- if(returnType != -1){
+ if (returnType != -1) {
return returnType;
}
}
@@ -575,19 +564,17 @@ public class Utils {
return -1;
}
- public static float round (float value, int precision) {
+ 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) {
+ if (NotEnoughUpdates.INSTANCE.config.misc.guiButtonClicks || !gui) {
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(sound, 1.0F));
}
}
@@ -596,14 +583,14 @@ public class Utils {
StringBuilder sb = new StringBuilder();
char currentColourCode = 'r';
boolean sectionSymbolLast = false;
- for(char c : line.toCharArray()) {
- if((int)c > 50000) continue;
+ for (char c : line.toCharArray()) {
+ if ((int) c > 50000) continue;
- if(c == '\u00a7') {
+ if (c == '\u00a7') {
sectionSymbolLast = true;
} else {
- if(sectionSymbolLast) {
- if(currentColourCode != c) {
+ if (sectionSymbolLast) {
+ if (currentColourCode != c) {
sb.append('\u00a7');
sb.append(c);
currentColourCode = c;
@@ -630,13 +617,13 @@ public class Utils {
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
worldrenderer
- .pos(x, y+height, 0.0D)
+ .pos(x, y + height, 0.0D)
.tex(uMin, vMax).endVertex();
worldrenderer
- .pos(x+width, y+height, 0.0D)
+ .pos(x + width, y + height, 0.0D)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x+width, y, 0.0D)
+ .pos(x + width, y, 0.0D)
.tex(uMax, vMin).endVertex();
worldrenderer
.pos(x, y, 0.0D)
@@ -659,13 +646,13 @@ public class Utils {
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
worldrenderer
- .pos(x, y+height, 0.0D)
+ .pos(x, y + height, 0.0D)
.tex(uMin, vMax).endVertex();
worldrenderer
- .pos(x+width, y+height, 0.0D)
+ .pos(x + width, y + height, 0.0D)
.tex(uMax, vMax).endVertex();
worldrenderer
- .pos(x+width, y, 0.0D)
+ .pos(x + width, y, 0.0D)
.tex(uMax, vMin).endVertex();
worldrenderer
.pos(x, y, 0.0D)
@@ -686,7 +673,7 @@ public class Utils {
NBTTagCompound display = new NBTTagCompound();
NBTTagList Lore = new NBTTagList();
- for(String line : lore) {
+ for (String line : lore) {
Lore.appendTag(new NBTTagString(line));
}
@@ -701,12 +688,12 @@ public class Utils {
return stack;
}
- public static ItemStack editItemStackInfo(ItemStack itemStack, String displayName, boolean disableNeuToolTips, String... lore){
+ 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) {
+ for (String line : lore) {
Lore.appendTag(new NBTTagString(line));
}
@@ -715,7 +702,7 @@ public class Utils {
tag.setTag("display", display);
tag.setInteger("HideFlags", 254);
- if(disableNeuToolTips){
+ if (disableNeuToolTips) {
tag.setBoolean("disableNeuTooltip", true);
}
@@ -729,7 +716,7 @@ public class Utils {
}
public static int getCharVertLen(char c) {
- if("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
+ if ("acegmnopqrsuvwxyz".indexOf(c) >= 0) {
return 5;
} else {
return 7;
@@ -739,9 +726,9 @@ public class Utils {
public static float getVerticalHeight(String str) {
str = cleanColour(str);
float height = 0;
- for(int i=0; i<str.length(); i++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
- int charHeight = getCharVertLen(c);
+ int charHeight = getCharVertLen(c);
height += charHeight + 1.5f;
}
return height;
@@ -750,12 +737,12 @@ public class Utils {
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++) {
+ for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
-
- int charHeight = getCharVertLen(c);
+
+ int charHeight = getCharVertLen(c);
int charWidth = fr.getCharWidth(c);
- fr.drawString(format+c, x+(5-charWidth)/2f, y-7+charHeight, colour, shadow);
+ fr.drawString(format + c, x + (5 - charWidth) / 2f, y - 7 + charHeight, colour, shadow);
y += charHeight + 1.5f;
}
@@ -764,39 +751,39 @@ public class Utils {
public static void renderShadowedString(String str, float x, float y, int maxLength) {
int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
float factor;
- if(maxLength < 0) {
+ if (maxLength < 0) {
factor = 1;
} else {
- factor = maxLength/(float)strLen;
+ 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)) {
+ 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());
+ 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);
+ 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);
+ 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)) {
+ 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);
+ x + xOff / 2f, y + yOff / 2f,
+ new Color(0, 0, 0, 200 / Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false);
}
}
}
@@ -804,24 +791,24 @@ public class Utils {
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)) {
+ 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);
+ 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);
+ 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;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
drawStringScaled(str, fr, x, y, shadow, colour, factor);
@@ -830,8 +817,8 @@ public class Utils {
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;
+ float x2 = x - strLen / 2f;
+ float y2 = y - fr.FONT_HEIGHT / 2f;
GL11.glTranslatef(x2, y2, 0);
fr.drawString(str, 0, 0, colour, shadow);
@@ -840,26 +827,26 @@ public class Utils {
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);
+ 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;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
int newLen = Math.min(strLen, len);
- float fontHeight = 8*factor;
+ float fontHeight = 8 * factor;
- drawStringScaled(str, fr, x-newLen/2, y-fontHeight/2, shadow, colour, 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();
+ Matrix4f projMatrix = new Matrix4f();
projMatrix.setIdentity();
- projMatrix.m00 = 2.0F / (float)width;
- projMatrix.m11 = 2.0F / (float)(-height);
+ projMatrix.m00 = 2.0F / (float) width;
+ projMatrix.m11 = 2.0F / (float) (-height);
projMatrix.m22 = -0.0020001999F;
projMatrix.m33 = 1.0F;
projMatrix.m03 = -1.0F;
@@ -870,27 +857,27 @@ public class Utils {
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;
+ float factor = len / (float) strLen;
+ float fontHeight = 8 * factor;
- drawStringScaled(str, fr, x-len/2, y-fontHeight/2, shadow, colour, 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;
+ float factor = len / (float) strLen;
+ float fontHeight = 8 * factor;
- drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, 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;
+ float factor = len / (float) strLen;
factor = Math.min(1, factor);
- float fontHeight = 8*factor;
+ float fontHeight = 8 * factor;
- drawStringScaled(str, fr, x, y-fontHeight/2, shadow, colour, 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) {
@@ -898,7 +885,7 @@ public class Utils {
}
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);
+ len = (int) (len / scale);
int yOff = 0;
String excess;
@@ -907,36 +894,36 @@ public class Utils {
String colourCodes = "";
Pattern pattern = Pattern.compile("\\u00A7.");
Matcher matcher = pattern.matcher(trimmed);
- while(matcher.find()) {
+ 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);
+ 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;
+ } else if (trimmed.isEmpty()) {
+ yOff -= 12 * scale;
break;
} else {
- if(firstLine) {
- drawStringScaled(trimmed, fr, x, y+yOff, shadow, colour, scale);
+ if (firstLine) {
+ drawStringScaled(trimmed, fr, x, y + yOff, shadow, colour, scale);
firstLine = false;
} else {
- if(trimmed.startsWith(" ")) {
+ if (trimmed.startsWith(" ")) {
trimmed = trimmed.substring(1);
}
- drawStringScaled(colourCodes + trimmed, fr, x, y+yOff, shadow, colour, scale);
+ drawStringScaled(colourCodes + trimmed, fr, x, y + yOff, shadow, colour, scale);
}
excess = str.substring(trimmedCharacters);
trimmed = trimToWidth(excess, len);
trimmedCharacters += trimmed.length();
- yOff += 12*scale;
+ yOff += 12 * scale;
}
}
return yOff;
@@ -946,13 +933,13 @@ public class Utils {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
String trim = fr.trimStringToWidth(str, len);
- if(str.length() != trim.length() && !trim.endsWith(" ")) {
+ if (str.length() != trim.length() && !trim.endsWith(" ")) {
char next = str.charAt(trim.length());
- if(next != ' ') {
+ if (next != ' ') {
String[] split = trim.split(" ");
- String last = split[split.length-1];
- if(last.length() < 8) {
- trim = trim.substring(0, trim.length()-last.length());
+ String last = split[split.length - 1];
+ if (last.length() < 8) {
+ trim = trim.substring(0, trim.length() - last.length());
}
}
}
@@ -961,14 +948,14 @@ public class Utils {
}
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;
+ 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();
@@ -977,10 +964,10 @@ public class Utils {
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();
+ 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();
@@ -989,14 +976,14 @@ public class Utils {
}
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;
+ 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();
@@ -1005,10 +992,10 @@ public class Utils {
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();
+ 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();
@@ -1026,38 +1013,41 @@ public class Utils {
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))) {
+ 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; }
+ } 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;
+ if (element == null) return def;
+ if (!element.isJsonPrimitive()) return def;
JsonPrimitive prim = element.getAsJsonPrimitive();
- if(!prim.isNumber()) return def;
+ 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;
+ if (element == null) return def;
+ if (!element.isJsonPrimitive()) return def;
JsonPrimitive prim = element.getAsJsonPrimitive();
- if(!prim.isString()) return def;
+ 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) {
+ if (element instanceof JsonObject) {
JsonElement e = element.getAsJsonObject().get(path_split.get(0));
- if(path_split.size() > 1) {
+ if (path_split.size() > 1) {
return getElement(e, path_split.get(1));
} else {
return e;
@@ -1070,9 +1060,10 @@ public class Utils {
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)));
+ 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)));
@@ -1080,8 +1071,8 @@ public class Utils {
}
public static void recursiveDelete(File file) {
- if(file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
- for(File child : file.listFiles()) {
+ if (file.isDirectory() && !Files.isSymbolicLink(file.toPath())) {
+ for (File child : file.listFiles()) {
recursiveDelete(child);
}
}
@@ -1091,27 +1082,27 @@ public class Utils {
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++) {
+ 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') {
+ if (c == '\u00A7') {
lastColourCode = i;
- } else if(lastColourCode == i-1) {
+ } else if (lastColourCode == i - 1) {
int colIndex = "0123456789abcdef".indexOf(c);
- if(colIndex >= 0) {
+ if (colIndex >= 0) {
currentColour = colIndex;
} else {
currentColour = 0;
}
- } else if("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(c) >= 0){
- if(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) {
+ for (int index = 0; index < mostCommon.length; index++) {
+ if (mostCommon[index] > mostCommonCount) {
mostCommonCount = mostCommon[index];
currentColour = index;
}
@@ -1126,26 +1117,24 @@ public class Utils {
}
public static void scrollTooltip(int dY) {
- scrollY.setTarget(scrollY.getTarget()+dY/10f);
+ scrollY.setTarget(scrollY.getTarget() + dY / 10f);
scrollY.resetTimer();
}
- private static LerpingFloat scrollY = new LerpingFloat(0, 100);
+ 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())
- {
+ if (!textLines.isEmpty()) {
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableLighting();
GlStateManager.enableDepth();
int tooltipTextWidth = 0;
- for (String textLine : textLines)
- {
+ for (String textLine : textLines) {
int textLineWidth = font.getStringWidth(textLine);
- if (textLineWidth > tooltipTextWidth)
- {
+ if (textLineWidth > tooltipTextWidth) {
tooltipTextWidth = textLineWidth;
}
}
@@ -1154,47 +1143,37 @@ public class Utils {
int titleLinesCount = 1;
int tooltipX = mouseX + 12;
- if (tooltipX + tooltipTextWidth + 4 > screenWidth)
- {
+ 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)
- {
+ if (mouseX > screenWidth / 2) {
tooltipTextWidth = mouseX - 12 - 8;
- }
- else
- {
+ } else {
tooltipTextWidth = screenWidth - 16 - mouseX;
}
needsWrap = true;
}
}
- if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth)
- {
+ if (maxTextWidth > 0 && tooltipTextWidth > maxTextWidth) {
tooltipTextWidth = maxTextWidth;
needsWrap = true;
}
- if (needsWrap)
- {
+ if (needsWrap) {
int wrappedTooltipWidth = 0;
- List<String> wrappedTextLines = new ArrayList<String>();
- for (int i = 0; i < textLines.size(); i++)
- {
+ 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)
- {
+ if (i == 0) {
titleLinesCount = wrappedLine.size();
}
- for (String line : wrappedLine)
- {
+ for (String line : wrappedLine) {
int lineWidth = font.getStringWidth(line);
- if (lineWidth > wrappedTooltipWidth)
- {
+ if (lineWidth > wrappedTooltipWidth) {
wrappedTooltipWidth = lineWidth;
}
wrappedTextLines.add(line);
@@ -1203,12 +1182,9 @@ public class Utils {
tooltipTextWidth = wrappedTooltipWidth;
textLines = wrappedTextLines;
- if (mouseX > screenWidth / 2)
- {
+ if (mouseX > screenWidth / 2) {
tooltipX = mouseX - 16 - tooltipTextWidth;
- }
- else
- {
+ } else {
tooltipX = mouseX + 12;
}
}
@@ -1216,8 +1192,7 @@ public class Utils {
int tooltipY = mouseY - 12;
int tooltipHeight = 8;
- if (textLines.size() > 1)
- {
+ if (textLines.size() > 1) {
tooltipHeight += (textLines.size() - 1) * 10;
if (textLines.size() > titleLinesCount) {
tooltipHeight += 2; // gap between title lines and next lines
@@ -1225,11 +1200,11 @@ public class Utils {
}
//Scrollable tooltips
- if(tooltipHeight + 6 > screenHeight) {
- if(scrollY.getTarget() < 0) {
+ if (tooltipHeight + 6 > screenHeight) {
+ if (scrollY.getTarget() < 0) {
scrollY.setTarget(0);
scrollY.resetTimer();
- } else if(screenHeight - tooltipHeight - 12 + (int)scrollY.getTarget() > 0) {
+ } else if (screenHeight - tooltipHeight - 12 + (int) scrollY.getTarget() > 0) {
scrollY.setTarget(-screenHeight + tooltipHeight + 12);
scrollY.resetTimer();
}
@@ -1239,9 +1214,8 @@ public class Utils {
}
scrollY.tick();
- if (tooltipY + tooltipHeight + 6 > screenHeight)
- {
- tooltipY = screenHeight - tooltipHeight - 6 + (int)scrollY.getValue();
+ if (tooltipY + tooltipHeight + 6 > screenHeight) {
+ tooltipY = screenHeight - tooltipHeight - 6 + (int) scrollY.getValue();
}
final int zLevel = 300;
@@ -1253,8 +1227,8 @@ public class Utils {
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) {
+ 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);
@@ -1267,13 +1241,11 @@ public class Utils {
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)
- {
+ for (int lineNumber = 0; lineNumber < textLines.size(); ++lineNumber) {
String line = textLines.get(lineNumber);
- font.drawStringWithShadow(line, (float)tooltipX, (float)tooltipY, -1);
+ font.drawStringWithShadow(line, (float) tooltipX, (float) tooltipY, -1);
- if (lineNumber + 1 == titleLinesCount)
- {
+ if (lineNumber + 1 == titleLinesCount) {
tooltipY += 2;
}
@@ -1289,14 +1261,14 @@ public class Utils {
}
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;
+ 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();
@@ -1332,19 +1304,19 @@ public class Utils {
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;
+ 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();
+ 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();
}
@@ -1356,14 +1328,14 @@ public class Utils {
long days = (millis / 1000 / 60 / 60 / 24);
String endsIn = "";
- if(millis < 0) {
+ if (millis < 0) {
endsIn += "Ended!";
- } else if(minutes == 0 && hours == 0 && days == 0) {
+ } else if (minutes == 0 && hours == 0 && days == 0) {
endsIn += seconds + "s";
- } else if(hours==0 && days==0) {
+ } else if (hours == 0 && days == 0) {
endsIn += minutes + "m" + seconds + "s";
- } else if(days==0) {
- if(hours <= 6) {
+ } else if (days == 0) {
+ if (hours <= 6) {
endsIn += hours + "h" + minutes + "m" + seconds + "s";
} else {
endsIn += hours + "h";
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..061780cf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/XPInformation.java
@@ -16,7 +16,7 @@ import java.util.regex.Pattern;
public class XPInformation {
- private static XPInformation INSTANCE = new XPInformation();
+ private static final XPInformation INSTANCE = new XPInformation();
public static XPInformation getInstance() {
return INSTANCE;
@@ -30,15 +30,15 @@ public class XPInformation {
public boolean fromApi = false;
}
- private HashMap<String, SkillInfo> skillInfoMap = new HashMap<>();
+ private final 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?)?)%\\)");
+ 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;
@@ -52,25 +52,25 @@ public class XPInformation {
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onChatReceived(ClientChatReceivedEvent event) {
- if(event.type == 2) {
+ if (event.type == 2) {
JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
+ if (leveling == null) return;
String actionBar = StringUtils.cleanColour(event.message.getUnformattedText());
- if(lastActionBar != null && lastActionBar.equalsIgnoreCase(actionBar)) {
+ if (lastActionBar != null && lastActionBar.equalsIgnoreCase(actionBar)) {
return;
}
lastActionBar = actionBar;
List<String> components = SPACE_SPLITTER.splitToList(actionBar);
- for(String component : components) {
+ for (String component : components) {
Matcher matcher = SKILL_PATTERN.matcher(component);
- if(matcher.matches()) {
+ if (matcher.matches()) {
String skillS = matcher.group(2);
- String currentXpS = matcher.group(3).replace(",","");
- String maxXpS = matcher.group(4).replace(",","");
+ String currentXpS = matcher.group(3).replace(",", "");
+ String maxXpS = matcher.group(4).replace(",", "");
float currentXp = Float.parseFloat(currentXpS);
float maxXp = Float.parseFloat(maxXpS);
@@ -81,9 +81,9 @@ public class XPInformation {
skillInfo.totalXp = currentXp;
JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
- for(int i=0; i<levelingArray.size(); i++) {
+ for (int i = 0; i < levelingArray.size(); i++) {
float cap = levelingArray.get(i).getAsFloat();
- if(maxXp > 0 && maxXp <= cap) {
+ if (maxXp > 0 && maxXp <= cap) {
break;
}
@@ -95,30 +95,30 @@ public class XPInformation {
return;
} else {
matcher = SKILL_PATTERN_PERCENTAGE.matcher(component);
- if(matcher.matches()) {
+ if (matcher.matches()) {
String skillS = matcher.group(2);
- String xpPercentageS = matcher.group(3).replace(",","");
+ 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()) {
+ if (matcher.matches()) {
String skillS = matcher.group(2);
- String currentXpS = matcher.group(3).replace(",","");
- String maxXpS = matcher.group(4).replace(",","");
+ String currentXpS = matcher.group(3).replace(",", "");
+ String maxXpS = matcher.group(4).replace(",", "");
float maxMult = 1;
- if(maxXpS.endsWith("k")) {
+ if (maxXpS.endsWith("k")) {
maxMult = 1000;
- maxXpS = maxXpS.substring(0, maxXpS.length()-1);
- } else if(maxXpS.endsWith("m")) {
+ 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")) {
+ maxXpS = maxXpS.substring(0, maxXpS.length() - 1);
+ } else if (maxXpS.endsWith("b")) {
maxMult = 1000000000;
- maxXpS = maxXpS.substring(0, maxXpS.length()-1);
+ maxXpS = maxXpS.substring(0, maxXpS.length() - 1);
}
float currentXp = Float.parseFloat(currentXpS);
@@ -130,9 +130,9 @@ public class XPInformation {
skillInfo.totalXp = currentXp;
JsonArray levelingArray = leveling.getAsJsonArray("leveling_xp");
- for(int i=0; i<levelingArray.size(); i++) {
+ for (int i = 0; i < levelingArray.size(); i++) {
float cap = levelingArray.get(i).getAsFloat();
- if(maxXp > 0 && maxXp <= cap) {
+ if (maxXp > 0 && maxXp <= cap) {
break;
}
@@ -150,19 +150,19 @@ public class XPInformation {
}
public void updateLevel(String skill, int level) {
- if(updateWithPercentage.containsKey(skill)) {
+ if (updateWithPercentage.containsKey(skill)) {
JsonObject leveling = Constants.LEVELING;
- if(leveling == null) return;
+ 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++) {
+ for (int i = 0; i < levelingArray.size(); i++) {
float cap = levelingArray.get(i).getAsFloat();
- if(i == level) {
- skillInfo.currentXp += updateWithPercentage.get(skill)/100f * cap;
+ if (i == level) {
+ skillInfo.currentXp += updateWithPercentage.get(skill) / 100f * cap;
skillInfo.totalXp += skillInfo.currentXp;
skillInfo.currentXpMax = cap;
} else {
@@ -172,12 +172,12 @@ public class XPInformation {
SkillInfo old = skillInfoMap.get(skill.toLowerCase());
- if(old.totalXp <= skillInfo.totalXp) {
+ if (old.totalXp <= skillInfo.totalXp) {
correctionCounter--;
- if(correctionCounter < 0) correctionCounter = 0;
+ if (correctionCounter < 0) correctionCounter = 0;
skillInfoMap.put(skill.toLowerCase(), skillInfo);
- } else if(++correctionCounter >= 10) {
+ } else if (++correctionCounter >= 10) {
correctionCounter = 0;
skillInfoMap.put(skill.toLowerCase(), skillInfo);
}
@@ -186,24 +186,24 @@ public class XPInformation {
}
public void tick() {
- ProfileApiSyncer.getInstance().requestResync("xpinformation", 5*60*1000,
+ 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 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) {
+ for (String skill : skills) {
SkillInfo info = new SkillInfo();
- float level = skillInfo.get("level_skill_"+skill).getAsFloat();
+ 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.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);