diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-11 12:28:07 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-10-11 12:28:07 +0200 |
| commit | 8ccfdc9b7d22352c23d4bff5ee240fa71e302262 (patch) | |
| tree | a11139ca4bdfba81fcc538ea76424fe66ca1b409 /src/main/java/at/hannibal2/skyhanni/features/garden | |
| parent | 4f9fe89aac7b97741f7079ab1ad5f7051e0fa7f7 (diff) | |
| download | skyhanni-8ccfdc9b7d22352c23d4bff5ee240fa71e302262.tar.gz skyhanni-8ccfdc9b7d22352c23d4bff5ee240fa71e302262.tar.bz2 skyhanni-8ccfdc9b7d22352c23d4bff5ee240fa71e302262.zip | |
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
3 files changed, 60 insertions, 59 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt index fc3ad61d3..65c6c54b2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFGuideGUI.kt @@ -217,7 +217,7 @@ open class FFGuideGUI : GuiScreen() { fun mouseClickEvent() { var x = guiLeft + 15 var y = guiTop - 28 - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + if (isMouseIn(x, y, 25, 28)) { SoundUtils.playClickSound() if (currentCrop != null) { currentCrop = null @@ -234,7 +234,7 @@ open class FFGuideGUI : GuiScreen() { } for (crop in CropType.entries) { x += 30 - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + if (isMouseIn(x, y, 25, 28)) { SoundUtils.playClickSound() if (currentCrop != crop) { currentCrop = crop @@ -269,102 +269,109 @@ open class FFGuideGUI : GuiScreen() { x = guiLeft - 28 y = guiTop + 15 - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25) && selectedPage != FortuneGuidePage.CROP && selectedPage != FortuneGuidePage.OVERVIEW) { - SoundUtils.playClickSound() - selectedPage = if (currentCrop == null) { - FortuneGuidePage.OVERVIEW - } else { - FortuneGuidePage.CROP - } + if (isMouseIn(x, y, 28, 25) && + selectedPage != FortuneGuidePage.CROP && selectedPage != FortuneGuidePage.OVERVIEW) { + SoundUtils.playClickSound() + selectedPage = if (currentCrop == null) { + FortuneGuidePage.OVERVIEW + } else { + FortuneGuidePage.CROP + } } y += 30 - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25) && selectedPage != FortuneGuidePage.UPGRADES) { - selectedPage = FortuneGuidePage.UPGRADES - SoundUtils.playClickSound() + if (isMouseIn(x, y, 28, 25) && selectedPage != FortuneGuidePage.UPGRADES) { + selectedPage = FortuneGuidePage.UPGRADES + SoundUtils.playClickSound() } if (selectedPage != FortuneGuidePage.UPGRADES) { if (currentCrop == null) { when { - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 130, 16, 16) && - currentPet != FarmingItems.ELEPHANT -> { + isMouseInRect(guiLeft + 142, guiTop + 130) && currentPet != FarmingItems.ELEPHANT -> { SoundUtils.playClickSound() currentPet = FarmingItems.ELEPHANT FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 130, 16, 16) && - currentPet != FarmingItems.MOOSHROOM_COW -> { + + isMouseInRect(guiLeft + 162, guiTop + 130) && currentPet != FarmingItems.MOOSHROOM_COW -> { SoundUtils.playClickSound() currentPet = FarmingItems.MOOSHROOM_COW FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 130, 16, 16) && - currentPet != FarmingItems.RABBIT -> { + + isMouseInRect(guiLeft + 182, guiTop + 130) && currentPet != FarmingItems.RABBIT -> { SoundUtils.playClickSound() currentPet = FarmingItems.RABBIT FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 130, 16, 16) && - currentPet != FarmingItems.BEE -> { + + isMouseInRect(guiLeft + 202, guiTop + 130) && currentPet != FarmingItems.BEE -> { SoundUtils.playClickSound() currentPet = FarmingItems.BEE FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 142, guiTop + 5) -> { SoundUtils.playClickSound() currentArmor = if (currentArmor == 1) 0 else 1 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 162, guiTop + 5) -> { SoundUtils.playClickSound() currentArmor = if (currentArmor == 2) 0 else 2 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 182, guiTop + 5) -> { SoundUtils.playClickSound() currentArmor = if (currentArmor == 3) 0 else 3 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 202, guiTop + 5) -> { SoundUtils.playClickSound() currentArmor = if (currentArmor == 4) 0 else 4 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 262, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 262, guiTop + 5) -> { SoundUtils.playClickSound() currentEquipment = if (currentEquipment == 1) 0 else 1 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 282, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 282, guiTop + 5) -> { SoundUtils.playClickSound() currentEquipment = if (currentEquipment == 2) 0 else 2 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 302, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 302, guiTop + 5) -> { SoundUtils.playClickSound() currentEquipment = if (currentEquipment == 3) 0 else 3 } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 322, guiTop + 5, 16, 16) -> { + + isMouseInRect(guiLeft + 322, guiTop + 5) -> { SoundUtils.playClickSound() currentEquipment = if (currentEquipment == 4) 0 else 4 } } } else { when { - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 142, guiTop + 160, 16, 16) && - currentPet != FarmingItems.ELEPHANT -> { + isMouseInRect(guiLeft + 142, guiTop + 160) && currentPet != FarmingItems.ELEPHANT -> { SoundUtils.playClickSound() currentPet = FarmingItems.ELEPHANT FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 162, guiTop + 160, 16, 16) && - currentPet != FarmingItems.MOOSHROOM_COW -> { + + isMouseInRect(guiLeft + 162, guiTop + 160) && currentPet != FarmingItems.MOOSHROOM_COW -> { SoundUtils.playClickSound() currentPet = FarmingItems.MOOSHROOM_COW FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 182, guiTop + 160, 16, 16) && - currentPet != FarmingItems.RABBIT -> { + + isMouseInRect(guiLeft + 182, guiTop + 160) && currentPet != FarmingItems.RABBIT -> { SoundUtils.playClickSound() currentPet = FarmingItems.RABBIT FFStats.getTotalFF() } - GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft + 202, guiTop + 160, 16, 16) && - currentPet != FarmingItems.BEE -> { + + isMouseInRect(guiLeft + 202, guiTop + 160) && currentPet != FarmingItems.BEE -> { SoundUtils.playClickSound() currentPet = FarmingItems.BEE FFStats.getTotalFF() @@ -372,12 +379,17 @@ open class FFGuideGUI : GuiScreen() { } } } else { - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, guiLeft, guiTop, sizeX, sizeY)) { + if (isMouseIn(guiLeft, guiTop, sizeX, sizeY)) { lastClickedHeight = mouseY } } } + private fun isMouseInRect(left: Int, top: Int) = isMouseIn(left, top, 16, 16) + + private fun isMouseIn(x: Int, y: Int, width: Int, height: Int) = + GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, width, height) + private fun renderTabs() { var x = guiLeft + 15 var y = guiTop - 28 @@ -385,7 +397,7 @@ open class FFGuideGUI : GuiScreen() { val notSelectedColor = 0x50303030 drawRect(x, y, x + 25, y + 28, if (currentCrop == null) selectedColor else notSelectedColor) GuiRenderUtils.renderItemStack(ItemStack(Blocks.grass), x + 5, y + 5) - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + if (isMouseIn(x, y, 25, 28)) { tooltipToDisplay.add("§eOverview") } @@ -393,7 +405,7 @@ open class FFGuideGUI : GuiScreen() { x += 30 drawRect(x, y, x + 25, y + 28, if (currentCrop == crop) selectedColor else notSelectedColor) GuiRenderUtils.renderItemStack(crop.icon, x + 5, y + 5) - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 25, 28)) { + if (isMouseIn(x, y, 25, 28)) { tooltipToDisplay.add("§e${crop.cropName}") } } @@ -407,7 +419,7 @@ open class FFGuideGUI : GuiScreen() { if (selectedPage != FortuneGuidePage.UPGRADES) selectedColor else notSelectedColor ) GuiRenderUtils.renderItemStack(ItemStack(Items.gold_ingot), x + 5, y + 5) - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25)) { + if (isMouseIn(x, y, 28, 25)) { tooltipToDisplay.add("§eBreakdown") } y += 30 @@ -417,7 +429,7 @@ open class FFGuideGUI : GuiScreen() { if (selectedPage == FortuneGuidePage.UPGRADES) selectedColor else notSelectedColor ) GuiRenderUtils.renderItemStack(ItemStack(Items.map), x + 5, y + 5) - if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x, y, 28, 25)) { + if (isMouseIn(x, y, 28, 25)) { tooltipToDisplay.add("§eUpgrades") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt index 61a777a63..d37d94920 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/FFStats.kt @@ -245,21 +245,14 @@ object FFStats { if (strength != null) { val rawInternalName = pet.getInternalName() return when { - rawInternalName.contains("ELEPHANT;4") -> { - 1.5 * petLevel - } + rawInternalName.contains("ELEPHANT;4") -> 1.5 * petLevel rawInternalName.contains("MOOSHROOM_COW;4") -> { (10 + petLevel).toDouble() + floor(floor(strength / (40 - petLevel * .2)) * .7) } - rawInternalName.contains("MOOSHROOM") -> { - (10 + petLevel).toDouble() - } - rawInternalName.contains("BEE;2") -> { - 0.2 * petLevel - } - rawInternalName.contains("BEE;3") || rawInternalName.contains("BEE;4") -> { - 0.3 * petLevel - } + + rawInternalName.contains("MOOSHROOM") -> (10 + petLevel).toDouble() + rawInternalName.contains("BEE;2") -> 0.2 * petLevel + rawInternalName.contains("BEE;3") || rawInternalName.contains("BEE;4") -> 0.3 * petLevel else -> 0.0 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt index 2e785ea89..4e06ee1cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/OverviewPage.kt @@ -92,15 +92,11 @@ class OverviewPage: FFGuideGUI.FFGuidePage() { line = if (currentArmor == 0) "§7§2The base fortune from your armor\n§2Select a piece for more info" else "§7§2Base fortune from your\n${armorItem.getItem().displayName}" value = when (currentArmor) { - 0 -> { - if (FFStats.usingSpeedBoots) 160 else 130 - } + 0 -> if (FFStats.usingSpeedBoots) 160 else 130 1 -> 30 2 -> 35 3 -> 35 - else -> { - if (FFStats.usingSpeedBoots) 60 else 30 - } + else -> if (FFStats.usingSpeedBoots) 60 else 30 } GuiRenderUtils.drawFarmingBar("§2Base $word Fortune", line, armorFF[FFTypes.BASE] ?: 0, value, FFGuideGUI.guiLeft + 135, |
