diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2023-05-29 22:20:27 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-29 14:20:27 +0200 |
| commit | 85f6fa03d235e2b3ca09b9ae2b3b34dd4bf4fcfb (patch) | |
| tree | ccb6037b2a967449b61ffe7e9425273f3943f036 | |
| parent | 1e851e0ff4293633d2977e1a3d125fdc01193ab5 (diff) | |
| download | skyhanni-85f6fa03d235e2b3ca09b9ae2b3b34dd4bf4fcfb.tar.gz skyhanni-85f6fa03d235e2b3ca09b9ae2b3b34dd4bf4fcfb.tar.bz2 skyhanni-85f6fa03d235e2b3ca09b9ae2b3b34dd4bf4fcfb.zip | |
Fortune guide - Mostly done (#160)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
37 files changed, 2180 insertions, 174 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 95bbdfbe3..ef8ba9814 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -28,6 +28,7 @@ import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.composter.GardenComposterInventoryFeatures import at.hannibal2.skyhanni.features.garden.contest.* import at.hannibal2.skyhanni.features.garden.farming.* +import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.inventory.* import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorColorNames import at.hannibal2.skyhanni.features.garden.visitor.GardenVisitorDropStatistics @@ -275,6 +276,7 @@ class SkyHanniMod { loadModule(TrevorSolver) loadModule(BingoCardTips()) loadModule(GardenVisitorDropStatistics) + loadModule(CaptureFarmingGear()) loadModule(SackDisplay()) loadModule(GardenStartLocation) loadModule(PetCandyUsedDisplay()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt index dbd197436..44044fa48 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.NEUItems import com.google.gson.GsonBuilder import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader @@ -13,6 +14,7 @@ import io.github.moulberry.moulconfig.observer.PropertyTypeAdapterFactory import io.github.moulberry.moulconfig.processor.BuiltinMoulConfigGuis import io.github.moulberry.moulconfig.processor.ConfigProcessorDriver import io.github.moulberry.moulconfig.processor.MoulConfigProcessor +import net.minecraft.item.ItemStack import java.io.* import java.nio.charset.StandardCharsets import java.util.* @@ -43,6 +45,15 @@ class ConfigManager { return LorenzVec(x, y, z) } }.nullSafe()) + .registerTypeAdapter(ItemStack::class.java, object : TypeAdapter<ItemStack>() { + override fun write(out: JsonWriter, value: ItemStack) { + out.value(NEUItems.saveNBTData(value)) + } + + override fun read(reader: JsonReader): ItemStack { + return NEUItems.loadNBTData(reader.nextString()) + } + }.nullSafe()) .enableComplexMapKeySerialization() .create() } diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 9b51acddd..8f9aba6bf 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -3,9 +3,11 @@ package at.hannibal2.skyhanni.config; import at.hannibal2.skyhanni.data.model.ComposterUpgrade; import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; +import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; import at.hannibal2.skyhanni.utils.LorenzVec; import com.google.gson.annotations.Expose; +import net.minecraft.item.ItemStack; import java.util.*; @@ -25,7 +27,8 @@ public class Storage { @Expose public Map<String, ProfileSpecific> profiles = new HashMap<>(); // profile name - // TODO save community shop account upgrades here + @Expose + public Integer gardenCommunityUpgrade = -1; } public static class ProfileSpecific { @@ -140,6 +143,9 @@ public class Storage { public long farmingExp = 0; @Expose + public int gardenExp = 0; + + @Expose public long coinsSpent = 0; @Expose @@ -148,7 +154,30 @@ public class Storage { @Expose public Map<CropType, LorenzVec> cropStartLocations = new HashMap<>(); - } + @Expose + public Fortune fortune = new Fortune(); + + public static class Fortune { + + @Expose + public int anitaUpgrade = -1; + + @Expose + public int farmingStrength = -1; + + @Expose + public int farmingLevel = -1; + + @Expose + public int plotsUnlocked = -1; + + @Expose + public long cakeExpiring = -1L; + + @Expose + public Map<FarmingItems, ItemStack> farmingItems = new HashMap<>(); + } + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 72abc47ca..657f675d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -14,6 +14,8 @@ import at.hannibal2.skyhanni.features.garden.GardenCropTimeCommand import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter +import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionCounter @@ -24,6 +26,7 @@ import at.hannibal2.skyhanni.test.SkyHanniTestCommand import at.hannibal2.skyhanni.test.TestBingo import at.hannibal2.skyhanni.test.command.* import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.command.ICommandSender import net.minecraftforge.client.ClientCommandHandler @@ -46,6 +49,8 @@ object Commands { // main commands registerCommand("sh", openMainMenu) registerCommand("skyhanni", openMainMenu) + + registerCommand("ff") { openFortuneGuide() } // for users - regular commands registerCommand("shmarkplayer") { MarkedPlayerManager.command(it) } @@ -90,6 +95,15 @@ object Commands { registerCommand("shcopyerror") { CopyErrorCommand.command(it) } } + @JvmStatic + fun openFortuneGuide() { + if (!LorenzUtils.inSkyBlock) { + LorenzUtils.chat("§cJoin Skyblock to open the fortune guide!") + } else { + CaptureFarmingGear.captureFarmingGear() + SkyHanniMod.screenToOpen = FFGuideGUI() + } + } private fun registerCommand(name: String, function: (Array<String>) -> Unit) { ClientCommandHandler.instance.registerCommand(SimpleCommand(name, createCommand(function))) diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt index c80ad2ea5..0044ed6ea 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt @@ -22,8 +22,8 @@ import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize +import at.hannibal2.skyhanni.utils.GuiRenderUtils import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.RenderUtils import net.minecraft.client.Minecraft import net.minecraft.client.gui.GuiScreen import net.minecraft.client.gui.ScaledResolution @@ -52,10 +52,7 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde } private fun renderLabels(hoveredPos: Int) { - RenderUtils.drawStringCentered( - "§cSkyHanni Position Editor", - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 8f, true, 0xffffff - ) + GuiRenderUtils.drawStringCentered("§cSkyHanni Position Editor", getScaledWidth() / 2, 8) var displayPos = -1 if (clickedPos != -1) { @@ -67,30 +64,17 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde displayPos = hoveredPos } - // When the mouse is not currently hovering over an gui element + // When the mouse is not currently hovering over a gui element if (displayPos == -1) { - RenderUtils.drawStringCentered( - "§eTo edit hidden GUI elements set a key in /sh edit", - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 20f, true, 0xffffff - ) - - RenderUtils.drawStringCentered( - "§ethen click that key while the GUI element is visible", - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 32f, true, 0xffffff - ) + GuiRenderUtils.drawStringCentered("§eTo edit hidden GUI elements set a key in /sh edit", getScaledWidth() / 2, 20) + GuiRenderUtils.drawStringCentered("§ethen click that key while the GUI element is visible", getScaledWidth() / 2, 32) return } val pos = positions[displayPos] - RenderUtils.drawStringCentered( - "§b" + pos.internalName, - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 18f, true, 0xffffff - ) val location = "§7x: §e${pos.rawX}§7, y: §e${pos.rawY}" - RenderUtils.drawStringCentered( - location, - Minecraft.getMinecraft().fontRendererObj, (getScaledWidth() / 2).toFloat(), 28f, true, 0xffffff - ) + GuiRenderUtils.drawStringCentered("§b" + pos.internalName, getScaledWidth() / 2, 18) + GuiRenderUtils.drawStringCentered(location, getScaledWidth() / 2, 28) } private fun renderRectangles(): Int { @@ -114,7 +98,7 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde elementHeight = position.getDummySize().y drawRect(x - border, y - border, x + elementWidth + border * 2, y + elementHeight + border * 2, -0x7fbfbfc0) - if (inXY(mouseX, x, mouseY, y, elementWidth, elementHeight)) { + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x - border, y - border, elementWidth + border * 2, elementHeight + border * 2)) { hoveredPos = index } } @@ -140,7 +124,7 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde val x = position.getAbsX() val y = position.getAbsY() if (!position.clicked) { - if (inXY(mouseX, x, mouseY, y, elementWidth, elementHeight)) { + if (GuiRenderUtils.isPointInRect(mouseX, mouseY, x - border, y - border, elementWidth + border * 2, elementHeight + border * 2)) { clickedPos = i position.clicked = true grabbedX = mouseX @@ -151,16 +135,6 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde } } - private fun inXY( - mouseX: Int, - x: Int, - mouseY: Int, - y: Int, - elementWidth: Int, - elementHeight: Int, - ) = - mouseX >= x - border && mouseY >= y - border && mouseX <= x + elementWidth + border * 2 && mouseY <= y + elementHeight + border * 2 - @Throws(IOException::class) override fun keyTyped(typedChar: Char, keyCode: Int) { super.keyTyped(typedChar, keyCode) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index d4c3a5859..b4ebe1ff0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config.features; +import at.hannibal2.skyhanni.config.commands.Commands; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.moulberry.moulconfig.annotations.*; @@ -205,7 +206,7 @@ public class Garden { "§c254 Denied", " ", "§c62,072 Copper", - "§23.2m Farming EXP", + "§33.2m Farming EXP", "§647.2m Coins Spent", "§b23 §9Flowering Bouquet", "§b4 §9Overgrown Grass", @@ -214,6 +215,7 @@ public class Garden { "§b6 §9Music Rune", "§b1 §cSpace Helmet", " ", // If they want another empty row + "§212,735 Garden EXP", } ) public List<Integer> textFormat = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12)); @@ -1013,14 +1015,14 @@ public class Garden { public Position composterDisplayPos = new Position(-363, 13, false, true); @Expose - @ConfigOption(name = "True Farming Fortune", desc = "") + @ConfigOption(name = "Farming Fortune Display", desc = "") @ConfigEditorAccordion(id = 22) public boolean farmingFortune = false; @Expose @ConfigOption( name = "FF Display", - desc = "Displays current farming fortune, including crop-specific bonuses." + desc = "Displays the true farming fortune for the current crop, including all crop-specific and hidden bonuses." ) @ConfigEditorBoolean @ConfigAccordionId(id = 22) @@ -1036,6 +1038,10 @@ public class Garden { @ConfigAccordionId(id = 22) public boolean farmingFortuneDropMultiplier = true; + @ConfigOption(name = "Farming Fortune Guide", desc = "Opens a guide that breaks down your farming fortune.\n§eCommand: /ff") + @ConfigEditorButton(buttonText = "§2Open") + public Runnable positions = Commands::openFortuneGuide; + @Expose public Position farmingFortunePos = new Position(-375, -200, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt index 3f0562f0d..53815366e 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/RenderGuiData.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.client.gui.inventory.GuiInventory @@ -15,7 +16,7 @@ class RenderGuiData { fun onRenderOverlay(event: RenderGameOverlayEvent.Pre) { // if (!ProfileStorage.loaded) return if (event.type != RenderGameOverlayEvent.ElementType.HOTBAR) return - if (GuiEditManager.isInGui()) return + if (GuiEditManager.isInGui() || FFGuideGUI.isInGui()) return GuiRenderEvent.GameOverlayRenderEvent().postAndCatch() } @@ -23,7 +24,7 @@ class RenderGuiData { @SubscribeEvent fun onBackgroundDraw(event: GuiScreenEvent.BackgroundDrawnEvent) { // if (!ProfileStorage.loaded) return - if (GuiEditManager.isInGui()) return + if (GuiEditManager.isInGui() || FFGuideGUI.isInGui()) return val currentScreen = Minecraft.getMinecraft().currentScreen ?: return if (currentScreen !is GuiInventory && currentScreen !is GuiChest) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index a4bff0222..f501dd910 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -148,6 +148,9 @@ class FarmingFortuneDisplay { } private val collectionPattern = "§7You have §6\\+([\\d]{1,3})☘ Farming Fortune".toRegex() + private val tooltipFortunePattern = + "^§7Farming Fortune: §a\\+([\\d.]+)(?: §2\\(\\+\\d\\))?(?: §9\\(\\+(\\d+)\\))?$".toRegex() + private val armorAbilityPattern = "§6Tiered Bonus: .* [(](?<pieces>.*)/4[)]".toPattern() var displayedFortune = 0.0 var reforgeFortune = 0.0 @@ -156,6 +159,9 @@ class FarmingFortuneDisplay { fun getToolFortune(tool: ItemStack?): Double { val internalName = tool?.getInternalName() ?: return 0.0 + if (internalName == "THEORETICAL_HOE") { + return 0.0 + } return if (internalName.startsWith("THEORETICAL_HOE")) { listOf(10.0, 25.0, 50.0)[internalName.last().digitToInt() - 1] } else when (internalName) { @@ -200,27 +206,45 @@ class FarmingFortuneDisplay { fun getHarvestingFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("harvesting") ?: 0) * 12.5 } fun getCultivatingFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("cultivating") ?: 0).toDouble()} - fun getAbilityFortune(tool: ItemStack?): Double { // add armor ability stuff here + fun getAbilityFortune(tool: ItemStack?): Double { val lotusAbilityPattern = "§7Piece Bonus: §6+(?<bonus>.*)☘".toPattern() - if (tool?.getInternalName()?.contains("LOTUS") == true) { - for (line in tool.getLore()) { + // todo confirm it works on Melon and Cropie armor + val armorAbilityFortune = "§7.*§7Grants §6(?<bonus>.*)☘.*".toPattern() + var pieces = 0.0 + for (line in tool?.getLore()!!) { + if (tool.getInternalName().contains("LOTUS")) { lotusAbilityPattern.matchMatcher(line) { return group("bonus").toDouble() } } + armorAbilityPattern.matchMatcher(line) { + pieces = group("pieces").toDouble() + } + + armorAbilityFortune.matchMatcher(line) { + return group("bonus").toDouble() / pieces + } } return 0.0 } - fun loadFortuneLineData(tool: ItemStack?, enchantmentFortune: Double, match: MatchGroupCollection) { - displayedFortune = match[1]!!.value.toDouble() - reforgeFortune = match[2]!!.value.toDouble() - if (tool != null) { - itemBaseFortune = if (tool.getInternalName().contains("LOTUS")) 5.0 - else displayedFortune - reforgeFortune - enchantmentFortune - greenThumbFortune = if (tool.getInternalName().contains("LOTUS")) { - displayedFortune - reforgeFortune - itemBaseFortune - } else 0.0 + fun loadFortuneLineData(tool: ItemStack?, enchantmentFortune: Double) { + displayedFortune = 0.0 + reforgeFortune = 0.0 + itemBaseFortune = 0.0 + greenThumbFortune = 0.0 + for (line in tool?.getLore()!!) { + val match = tooltipFortunePattern.matchEntire(line)?.groups + if (match != null) { + displayedFortune = match[1]!!.value.toDouble() + reforgeFortune = match[2]?.value?.toDouble() ?: 0.0 + + itemBaseFortune = if (tool.getInternalName().contains("LOTUS")) 5.0 + else displayedFortune - reforgeFortune - enchantmentFortune + greenThumbFortune = if (tool.getInternalName().contains("LOTUS")) { + displayedFortune - reforgeFortune - itemBaseFortune + } else 0.0 + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt index 34a8e96a3..dbf3486b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenAPI.kt @@ -181,4 +181,75 @@ object GardenAPI { lastLocation = position CropClickEvent(cropBroken, blockState, event.clickType, event.itemInHand).postAndCatch() } + + fun getExpForLevel(requestedLevel: Int): Long { + var totalExp = 0L + var tier = 0 + for (tierExp in gardenExperience) { + totalExp += tierExp + tier++ + if (tier == requestedLevel) { + return totalExp + } + } + return 0 + } + + fun getLevelForExp(gardenExp: Long): Int { + var tier = 0 + var totalExp = 0L + for (tierExp in gardenExperience) { + totalExp += tierExp + if (totalExp > gardenExp) { + return tier + } + tier++ + } + return tier + } + + private val gardenExperience = listOf( + 0, + 70, + 100, + 140, + 240, + 600, + 1500, + 2000, + 2500, + 3000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, // level 15 + + // overflow levels till 40 for now, in 10k steps + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + 10_000, + ) }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt index be00854f4..8948c88e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt @@ -43,9 +43,9 @@ class GardenLevelDisplay { } private fun addExp(moreExp: Int) { - val oldLevel = getLevelForExp(gardenExp.toLong()) + val oldLevel = GardenAPI.getLevelForExp(gardenExp.toLong()) gardenExp += moreExp - val newLevel = getLevelForExp(gardenExp.toLong()) + val newLevel = GardenAPI.getLevelForExp(gardenExp.toLong()) if (newLevel == oldLevel + 1) { if (newLevel > 15) { LorenzUtils.chat( @@ -77,7 +77,7 @@ class GardenLevelDisplay { return } } - val expForLevel = getExpForLevel(currentLevel).toInt() + |
