diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-05 11:26:50 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-02-05 11:26:50 +0100 |
commit | 62f4d8cd10210ea255860f37ffde62180d3400fe (patch) | |
tree | 6f9401c22e8355c249a2f4d06de1920ba20d72b4 /src/main | |
parent | 0c42c67396e2c77bd2dc5db78c1b3199f9f1a532 (diff) | |
download | skyhanni-62f4d8cd10210ea255860f37ffde62180d3400fe.tar.gz skyhanni-62f4d8cd10210ea255860f37ffde62180d3400fe.tar.bz2 skyhanni-62f4d8cd10210ea255860f37ffde62180d3400fe.zip |
Added Deep Caverns Parkour.
Diffstat (limited to 'src/main')
5 files changed, 189 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index d6e13743c..af6bf4d64 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -223,6 +223,7 @@ import at.hannibal2.skyhanni.features.inventory.tiarelay.TiaRelayWaypoints import at.hannibal2.skyhanni.features.itemabilities.ChickenHeadTimer import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown +import at.hannibal2.skyhanni.features.mining.DeepCavernsParkour import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs import at.hannibal2.skyhanni.features.mining.KingTalismanHelper import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesInCore @@ -436,6 +437,7 @@ class SkyHanniMod { loadModule(AdvancedPlayerList) loadModule(ItemAddManager()) loadModule(BingoCardReader()) + loadModule(DeepCavernsParkour()) loadModule(GardenBestCropTime()) loadModule(TrackerManager) loadModule(UtilsPatterns) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/DeepCavernsParkourConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/DeepCavernsParkourConfig.java new file mode 100644 index 000000000..ab1ba6a49 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/DeepCavernsParkourConfig.java @@ -0,0 +1,38 @@ +package at.hannibal2.skyhanni.config.features.mining; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.observer.Property; + +public class DeepCavernsParkourConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Shows a parkour to the bottom of Deep Caverns and to Rhys.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Look Ahead", desc = "Change how many waypoints should be shown in front of you.") + @ConfigEditorSlider(minStep = 1, maxValue = 30, minValue = 1) + public Property<Integer> lookAhead = Property.of(3); + + @Expose + @ConfigOption(name = "Rainbow Color", desc = "Show the rainbow color effect instead of a boring monochrome.") + @ConfigEditorBoolean + public Property<Boolean> rainbowColor = Property.of(true); + + @Expose + @ConfigOption(name = "Monochrome Color", desc = "Set a boring monochrome color for the parkour platforms.") + @ConfigEditorColour + public Property<String> monochromeColor = Property.of("0:60:0:0:255"); + + @Expose + @ConfigOption(name = "Hilight all Lines", desc = "Show all lines in gray. Useful for debugging.") + @ConfigEditorBoolean + public boolean highlightAllLines = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java index feeb465ab..462908f6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java @@ -19,6 +19,11 @@ public class MiningConfig { public KingTalismanConfig kingTalisman = new KingTalismanConfig(); @Expose + @ConfigOption(name = "Deep Caverns Parkour", desc = "") + @Accordion + public DeepCavernsParkourConfig deepCavernsParkour = new DeepCavernsParkourConfig(); + + @Expose @ConfigOption(name = "Highlight Commission Mobs", desc = "Highlight Mobs that are part of active commissions.") @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt new file mode 100644 index 000000000..0c08c8b17 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/DeepCavernsParkour.kt @@ -0,0 +1,136 @@ +package at.hannibal2.skyhanni.features.mining + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.jsonobjects.repo.ParkourJson +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.LorenzUtils.toChromaColor +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack +import at.hannibal2.skyhanni.utils.ParkourHelper +import io.github.moulberry.notenoughupdates.events.ReplaceItemEvent +import io.github.moulberry.notenoughupdates.events.SlotClickEvent +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.client.player.inventory.ContainerLocalMenu +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class DeepCavernsParkour { + private val config get() = SkyHanniMod.feature.mining.deepCavernsParkour + + private var parkourHelper: ParkourHelper? = null + private var show = false + private var showStartIcon = false + + private val startIcon by lazy { + val neuItem = "MAP".asInternalName().getItemStack() + Utils.createItemStack( + neuItem.item, + "§bDeep Caverns Parkour", + "§8(From SkyHanni)", + "", + "§7Manually enable the ", + "§7Parkour to the bottom", + "§7of Deep Caverns." + ) + } + + @SubscribeEvent + fun onIslandChange(event: IslandChangeEvent) { + parkourHelper?.reset() + show = false + } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant<ParkourJson>("DeepCavernsParkour") + parkourHelper = ParkourHelper( + data.locations, + data.shortCuts, + platformSize = 1.0, + detectionRange = 3.5, + depth = false, + onEndReach = { + show = false + } + ) + updateConfig() + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + LorenzUtils.onToggle(config.rainbowColor, config.monochromeColor, config.lookAhead) { + updateConfig() + } + } + + private fun updateConfig() { + parkourHelper?.run { + rainbowColor = config.rainbowColor.get() + monochromeColor = config.monochromeColor.get().toChromaColor() + lookAhead = config.lookAhead.get() + 1 + } + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + showStartIcon = false + if (!isEnabled()) return + if (event.inventoryName != "Lift") return + if (LorenzUtils.skyBlockArea != "Gunpowder Mines") return + showStartIcon = true + + event.inventoryItems[30]?.let { + if (it.displayName != "§aObsidian Sanctuary") { + if (!show) { + start() + LorenzUtils.chat("Automatically enabling Deep Caverns Parkour, helping you find the way to the bottom of Deep Caverns and the path to Ryst.") + } + } + } + } + + private fun start() { + show = true + parkourHelper?.reset() + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + showStartIcon = false + } + + @SubscribeEvent + fun replaceItem(event: ReplaceItemEvent) { + if (show) return + if (event.inventory is ContainerLocalMenu && showStartIcon && event.slotNumber == 40) { + event.replaceWith(startIcon) + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onStackClick(event: SlotClickEvent) { + if (showStartIcon && event.slotId == 40) { + event.isCanceled = true + LorenzUtils.chat("Manually enabled Deep Caverns Parkour.") + start() + } + } + + @SubscribeEvent + fun onRenderWorld(event: LorenzRenderWorldEvent) { + if (!isEnabled()) return + if (!show) return + + parkourHelper?.render(event) + } + + fun isEnabled() = IslandType.DEEP_CAVERNS.isInIsland() && config.enabled +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt index e80aa7f62..c9ebdc5a6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ParkourHelper.kt @@ -20,7 +20,9 @@ class ParkourHelper( val locations: List<LorenzVec>, private val shortCuts: List<ShortCut>, val platformSize: Double = 1.0, - val detectionRange: Double = 1.0 + val detectionRange: Double = 1.0, + val depth: Boolean = true, + val onEndReach: () -> Unit = {} ) { private var current = -1 private var visible = false @@ -77,6 +79,9 @@ class ParkourHelper( } val inProgressVec = getInProgressPair().toSingletonListOrEmpty() + if (locations.size == current + 1) { + onEndReach() + } for ((prev, next) in locations.asSequence().withIndex().zipWithNext().drop(current) .take(lookAhead - 1) + inProgressVec) { event.draw3DLine_nea( @@ -98,7 +103,7 @@ class ParkourHelper( val aabb = axisAlignedBB(locations[shortCut.to]) event.drawFilledBoundingBox_nea(aabb, Color.RED, 1f) - if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, true) + if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, depth) } } @@ -113,7 +118,7 @@ class ParkourHelper( } else { val aabb = axisAlignedBB(location) event.drawFilledBoundingBox_nea(aabb, colorForIndex(index), 1f) - if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, true) + if (outline) event.outlineTopFace(aabb, 2, Color.BLACK, depth) } if (SkyHanniMod.feature.dev.waypoint.showPlatformNumber && !isMovingPlatform) { event.drawString(location.offsetCenter().add(y = 1), "§a§l$index", seeThroughBlocks = true) |