diff options
4 files changed, 175 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index ddd334c76..e04015783 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -69,6 +69,7 @@ import at.hannibal2.skyhanni.features.rift.VampireSlayerFeatures import at.hannibal2.skyhanni.features.rift.area.RiftLarva import at.hannibal2.skyhanni.features.rift.area.colosseum.BlobbercystsHighlight import at.hannibal2.skyhanni.features.rift.area.dreadfarm.RiftAgaricusCap +import at.hannibal2.skyhanni.features.rift.area.dreadfarm.RiftWiltedBerberisHelper import at.hannibal2.skyhanni.features.rift.area.dreadfarm.VoltHighlighter import at.hannibal2.skyhanni.features.rift.area.livingcave.LivingCaveDefenseBlocks import at.hannibal2.skyhanni.features.rift.area.livingcave.LivingCaveLivingMetalHelper @@ -356,8 +357,9 @@ class SkyHanniMod { loadModule(LivingCaveLivingMetalHelper()) loadModule(RiftMotesOrb()) loadModule(SlayerBossSpawnSoon()) - // loadModule(RiftBloodEffigies()) + loadModule(RiftWiltedBerberisHelper()) + // init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java index 1585c390b..0a7caf5ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/RiftConfig.java @@ -208,6 +208,30 @@ public class RiftConfig { @ConfigEditorBoolean public boolean voltMoodMeter = false; } + + @ConfigOption(name = "Wilted Berberis", desc = "") + @Accordion + @Expose + public WiltedBerberisConfig wiltedBerberis = new WiltedBerberisConfig(); + + public static class WiltedBerberisConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show Wilted Berberis helper.") + @ConfigEditorBoolean + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Only on Farmland", desc = "Only show the helper while standing on Farmland blocks.") + @ConfigEditorBoolean + public boolean onlyOnFarmland = false; + + @Expose + @ConfigOption(name = "Hide Particles", desc = "Hide the wilted berberis particles.") + @ConfigEditorBoolean + public boolean hideparticles = false; + + } } @ConfigOption(name = "Mirror Verse", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt new file mode 100644 index 000000000..c7d2605e6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/dreadfarm/RiftWiltedBerberisHelper.kt @@ -0,0 +1,147 @@ +package at.hannibal2.skyhanni.features.rift.area.dreadfarm + +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI +import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LocationUtils +import at.hannibal2.skyhanni.utils.LocationUtils.distanceToPlayer +import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.drawDynamicText +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox +import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock +import net.minecraft.client.Minecraft +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.awt.Color + +class RiftWiltedBerberisHelper { + private val config get() = RiftAPI.config.area.dreadfarmConfig.wiltedBerberis + private var isOnFarmland = false + private var hasFarmingToolInHand = false + private var list = listOf<WiltedBerberis>() + + class WiltedBerberis(var currentParticles: LorenzVec) { + var previous: LorenzVec? = null + var moving = true + var y = 0.0 + var lastTime = System.currentTimeMillis() + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + if (!event.isMod(5)) return + + list = list.editCopy { removeIf { System.currentTimeMillis() > it.lastTime + 500 } } + + hasFarmingToolInHand = InventoryUtils.getItemInHand()?.getInternalName()?.let { + it == "FARMING_WAND" + } ?: false + + if (Minecraft.getMinecraft().thePlayer.onGround) { + val block = LocationUtils.playerLocation().add(0, -1, 0).getBlockAt().toString() + val currentY = LocationUtils.playerLocation().y + isOnFarmland = block == "Block{minecraft:farmland}" && (currentY % 1 == 0.0) + } + } + + fun nearestBerberis(location: LorenzVec): WiltedBerberis? { + return list.filter { it.currentParticles.distanceSq(location) < 8 } + .sortedBy { it.currentParticles.distanceSq(location) }.firstOrNull() + } + + @SubscribeEvent + fun onReceiveParticle(event: ReceiveParticleEvent) { + if (!isEnabled()) return + if (!hasFarmingToolInHand) return + +// if (event.distanceToPlayer > 10) return + + val location = event.location + val berberis = nearestBerberis(location) + + if (event.type != EnumParticleTypes.FIREWORKS_SPARK) { + if (config.hideparticles) { + if (berberis != null) { + event.isCanceled = true + } + } + return + } + + if (config.hideparticles) { + event.isCanceled = true + } + + if (berberis == null) { + list = list.editCopy { add(WiltedBerberis(location)) } + return + } + + with(berberis) { + val isMoving = currentParticles != location + if (isMoving) { + if (currentParticles.distance(location) > 3) { + previous = null + moving = true + } + if (!moving) { + previous = currentParticles + } + } + if (!isMoving) { + y = location.y - 1 + } + + moving = isMoving + currentParticles = location + lastTime = System.currentTimeMillis() + } + } + + + @SubscribeEvent + fun onRenderWorld(event: RenderWorldLastEvent) { + if (!isEnabled()) return + if (!hasFarmingToolInHand) return + + if (config.onlyOnFarmland && !isOnFarmland) return + + for (berberis in list) { + with(berberis) { + if (currentParticles.distanceToPlayer() > 20) continue + if (y == 0.0) continue + + val location = currentParticles.fixLocation(berberis) + if (!moving) { + event.drawFilledBoundingBox(axisAlignedBB(location), Color.YELLOW, 0.7f) + event.drawDynamicText(location.add(0, 1, 0), "§eWilted Berberis", 1.5, ignoreBlocks = false) + } else { + event.drawFilledBoundingBox(axisAlignedBB(location), Color.WHITE, 0.5f) + previous?.fixLocation(berberis)?.let { + event.drawFilledBoundingBox(axisAlignedBB(it), Color.LIGHT_GRAY, 0.2f) + event.draw3DLine(it.add(0.5, 0.0, 0.5), location.add(0.5, 0.0, 0.5), Color.WHITE, 3, false) + } + } + } + } + } + + private fun axisAlignedBB(loc: LorenzVec) = loc.add(0.1, -0.1, 0.1).boundingToOffset(0.8, 1.0, 0.8).expandBlock() + + private fun LorenzVec.fixLocation(wiltedBerberis: WiltedBerberis): LorenzVec { + val x = x - 0.5 + val y = wiltedBerberis.y + val z = z - 0.5 + return LorenzVec(x, y, z) + } + + private fun isEnabled() = RiftAPI.inRift() && RiftAPI.inDreadfarm() && config.enabled + +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt index d3be9a77e..8eac74b30 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/RiftAPI.kt @@ -25,4 +25,5 @@ object RiftAPI { fun inLivingCave() = LorenzUtils.skyBlockArea == "Living Cave" fun inLivingStillness() = LorenzUtils.skyBlockArea == "Living Stillness" fun inStillgoreChateau() = LorenzUtils.skyBlockArea == "Stillgore Château" || LorenzUtils.skyBlockArea == "Oubliette" + fun inDreadfarm() = LorenzUtils.skyBlockArea == "Dreadfarm" }
\ No newline at end of file |