From 5597d58047a2232274c7d2a094b5276f4a7795c6 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Sat, 27 Apr 2024 13:43:51 +0200 Subject: Feature: Matriarch Helper (#1385) Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/nether/MatriarchHelper.kt | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt (limited to 'src/main/java/at/hannibal2/skyhanni/features/nether') diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt new file mode 100644 index 000000000..24d70e12c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt @@ -0,0 +1,71 @@ +package at.hannibal2.skyhanni.features.nether + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.mob.Mob +import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent +import at.hannibal2.skyhanni.events.MobEvent +import at.hannibal2.skyhanni.test.command.CopyNearbyEntitiesCommand.getMobInfo +import at.hannibal2.skyhanni.test.command.ErrorManager +import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RenderUtils.draw3DLine +import at.hannibal2.skyhanni.utils.RenderUtils.drawFilledBoundingBox_nea +import at.hannibal2.skyhanni.utils.RenderUtils.exactPlayerEyeLocation +import at.hannibal2.skyhanni.utils.RenderUtils.expandBlock +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.TreeSet + +class MatriarchHelper { + + private val config get() = SkyHanniMod.feature.crimsonIsle.matriarchHelper + + private val pearlList = TreeSet { first, second -> + first.baseEntity.getLorenzVec().y.compareTo(second.baseEntity.getLorenzVec().y) + } + + @SubscribeEvent + fun onMobSpawn(event: MobEvent.Spawn.Special) { + if (!isHeavyPearl(event)) return + pearlList.add(event.mob) + if (pearlList.size > 3) { + ErrorManager.logErrorStateWithData( + "Something went wrong with the Heavy Pearl detection", + "More then 3 pearls", + "pearList" to pearlList.map { getMobInfo(it) } + ) + pearlList.clear() + } + } + + private fun isHeavyPearl(event: MobEvent) = isEnabled() && event.mob.name == "Heavy Pearl" + + @SubscribeEvent + fun onMobDespawn(event: MobEvent.DeSpawn.Special) { + if (!isHeavyPearl(event)) return + pearlList.remove(event.mob) + } + + @SubscribeEvent + fun onRender(event: LorenzRenderWorldEvent) { + if (!isEnabled()) return + if (config.highlight) { + val color = config.highlightColor.toChromaColor() + pearlList.forEach { + event.drawFilledBoundingBox_nea(it.boundingBox.expandBlock(), color, 1.0f) + } + } + if (config.line) { + val color = config.lineColor.toChromaColor() + var prePoint = event.exactPlayerEyeLocation() + pearlList.forEach { + val point = it.baseEntity.getLorenzVec().add(y = 1.2) + event.draw3DLine(prePoint, point, color, 10, true) + prePoint = point + } + } + } + + fun isEnabled() = config.enabled && IslandType.CRIMSON_ISLE.isInIsland() +} -- cgit