diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-22 23:39:56 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-05-22 23:39:56 +0200 |
commit | 5999f152a69549c951d14ad10faea392d3c965dd (patch) | |
tree | 0a2ea66ca63eca9e2556ea081f47a8f24f31ad43 /src/main/java/at/hannibal2/skyhanni | |
parent | a9b0676ccc090ad2947f6990fc620de2f3f00d9b (diff) | |
download | skyhanni-5999f152a69549c951d14ad10faea392d3c965dd.tar.gz skyhanni-5999f152a69549c951d14ad10faea392d3c965dd.tar.bz2 skyhanni-5999f152a69549c951d14ad10faea392d3c965dd.zip |
Added Garden Crop Start Location
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
5 files changed, 90 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index d31d50325..1a2e27e96 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -275,6 +275,7 @@ class SkyHanniMod { loadModule(BingoCardTips()) loadModule(GardenVisitorDropStatistics) loadModule(SackDisplay()) + loadModule(GardenStartLocation) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 797f8d941..9b51acddd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -145,6 +145,9 @@ public class Storage { @Expose public Map<VisitorReward, Integer> rewardsCount = new HashMap<>(); } + + @Expose + public Map<CropType, LorenzVec> cropStartLocations = 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 b0a43cb05..72abc47ca 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,7 @@ 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.farming.GardenStartLocation import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionCounter import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager @@ -54,6 +55,7 @@ object Commands { registerCommand("shcroptime") { GardenCropTimeCommand.onCommand(it) } registerCommand("shshareinquis") { InquisitorWaypointShare.sendInquisitor() } registerCommand("shrpcstart") { DiscordRPCManager.startCommand() } + registerCommand("shcropstartlocation") { GardenStartLocation.setLocationCommand() } // for users - fix bugs registerCommand("shupdaterepo") { SkyHanniMod.repo.updateRepo() } 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 ff5febe26..b20b04e96 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -1122,6 +1122,20 @@ public class Garden { } @Expose + @ConfigOption(name = "Crop Start Location", desc = "") + @Accordion + public CropStartLocation cropStartLocation = new CropStartLocation(); + + public static class CropStartLocation { + + @Expose + @ConfigOption(name = "Enable", desc = "Show the start waypoint for your farm with the currently holding tool.") + @ConfigEditorBoolean + public boolean enabled = false; + + } + + @Expose @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean public boolean plotPrice = true; diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt new file mode 100644 index 000000000..2d02fa941 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenStartLocation.kt @@ -0,0 +1,70 @@ +package at.hannibal2.skyhanni.features.garden.farming + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CropClickEvent +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.LocationUtils +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object GardenStartLocation { + + fun setLocationCommand() { + if (!GardenAPI.inGarden()) { + LorenzUtils.chat("§c[SkyHanni] This Command only works in the garden!") + return + } + if (!SkyHanniMod.feature.garden.cropStartLocation.enabled) { + LorenzUtils.clickableChat( + "§c[SkyHanni] This feature is disabled. Enable it in the config: §e/sh crop start location", + "sh crop start location" + ) + return + } + + val startLocations = GardenAPI.config?.cropStartLocations + if (startLocations == null) { + LorenzUtils.chat("§c[SkyHanni] The config is not yet loaded, retry in a second.") + return + } + + val crop = GardenAPI.getCurrentlyFarmedCrop() + if (crop == null) { + LorenzUtils.chat("§c[SkyHanni] Hold a crop specific farming tool in the hand!") + return + } + + startLocations[crop] = LocationUtils.playerLocation() + LorenzUtils.chat("§e[SkyHanni] You changed your Crop Start Location for ${crop.cropName}!") + } + + @SubscribeEvent + fun onBlockClick(event: CropClickEvent) { + if (!isEnabled()) return + val startLocations = GardenAPI.config?.cropStartLocations ?: return + val crop = GardenAPI.getCurrentlyFarmedCrop() ?: return + if (crop != GardenCropSpeed.lastBrokenCrop) return + + if (!startLocations.contains(crop)) { + startLocations[crop] = LocationUtils.playerLocation() + LorenzUtils.chat("§e[SkyHanni] Auto updated your Crop Start Location for ${crop.cropName}") + } + } + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!isEnabled()) return + val startLocations = GardenAPI.config?.cropStartLocations ?: return + val crop = GardenAPI.cropInHand ?: return + val location = startLocations[crop] ?: return + + event.drawWaypointFilled(location, LorenzColor.WHITE.toColor()) + event.drawDynamicText(location, crop.cropName, 1.5) + } + + fun isEnabled() = GardenAPI.inGarden() && SkyHanniMod.feature.garden.cropStartLocation.enabled +} |