aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-05-29 22:20:27 +1000
committerGitHub <noreply@github.com>2023-05-29 14:20:27 +0200
commit85f6fa03d235e2b3ca09b9ae2b3b34dd4bf4fcfb (patch)
treeccb6037b2a967449b61ffe7e9425273f3943f036 /src/main/java/at/hannibal2/skyhanni/config
parent1e851e0ff4293633d2977e1a3d125fdc01193ab5 (diff)
downloadskyhanni-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>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt14
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java12
5 files changed, 74 insertions, 40 deletions
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);