From a21c3298d2ae7790b3d3770ee4a135c1817f3018 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 23 Jul 2023 23:19:30 +0200 Subject: Hide particles around enderman slayer bosses and mini bosses --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 3 + .../skyhanni/config/features/SlayerConfig.java | 8 +- .../skyhanni/features/misc/ParticleHider.kt | 2 +- .../area/livingcave/LivingCaveDefenseBlocks.kt | 6 +- .../features/slayer/EndermanSlayerFeatures.kt | 136 --------------------- .../slayer/enderman/EndermanSlayerFeatures.kt | 136 +++++++++++++++++++++ .../slayer/enderman/EndermanSlayerHideParticles.kt | 49 ++++++++ .../at/hannibal2/skyhanni/utils/EntityUtils.kt | 9 +- 8 files changed, 205 insertions(+), 144 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerFeatures.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 9d1a21042..60254162c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -85,6 +85,8 @@ import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerClearView import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerFirePitsWarning import at.hannibal2.skyhanni.features.slayer.blaze.HellionShieldHelper +import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerFeatures +import at.hannibal2.skyhanni.features.slayer.enderman.EndermanSlayerHideParticles import at.hannibal2.skyhanni.features.summonings.SummoningMobManager import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper @@ -225,6 +227,7 @@ class SkyHanniMod { loadModule(HellionShieldHelper()) loadModule(BlazeSlayerFirePitsWarning()) loadModule(BlazeSlayerClearView()) + loadModule(EndermanSlayerHideParticles()) loadModule(PlayerChatFilter()) loadModule(HideArmor()) loadModule(SlayerQuestWarning()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java index e3aa63c89..e5aba386f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/SlayerConfig.java @@ -30,11 +30,17 @@ public class SlayerConfig { public boolean endermanHighlightNukekebi = false; @Expose - @ConfigOption(name = "Phase Display", desc = "Show the current phase of the enderman slayer.") + @ConfigOption(name = "Phase Display", desc = "Show the current phase of the enderman slayer in damage indcator.") @ConfigEditorBoolean @ConfigAccordionId(id = 0) public boolean endermanPhaseDisplay = false; + @Expose + @ConfigOption(name = "Hide Particles", desc = "Hide particles around enderman slayer bosses and mini bosses.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 0) + public boolean endermanHideParticles = false; + @Expose @ConfigOption(name = "Blaze", desc = "") @ConfigEditorAccordion(id = 1) diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt index befaa09f3..ca12ceea3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ParticleHider.kt @@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ParticleHider { - fun inM7Boss() = LorenzUtils.inDungeons && DungeonData.dungeonFloor == "M7" && DungeonData.inBossRoom + private fun inM7Boss() = LorenzUtils.inDungeons && DungeonData.dungeonFloor == "M7" && DungeonData.inBossRoom @SubscribeEvent fun onHypExplosions(event: ReceiveParticleEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt index 5a23ee650..e96ae7e31 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.events.withAlpha import at.hannibal2.skyhanni.features.rift.everywhere.RiftAPI import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled -import at.hannibal2.skyhanni.utils.EntityUtils.getEntitiesNearby +import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.isAtFullHealth import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LorenzUtils.editCopy @@ -16,7 +16,6 @@ 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.getLorenzVec -import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.EnumParticleTypes import net.minecraftforge.client.event.RenderWorldLastEvent @@ -78,8 +77,7 @@ class LivingCaveDefenseBlocks { if (entity == null) { // read new entity data val compareLocation = event.location.add(-0.5, -1.5, -0.5) - entity = - Minecraft.getMinecraft().theWorld.getEntitiesNearby(compareLocation, 2.0) + entity = EntityUtils.getEntitiesNearby(compareLocation, 2.0) .filter { isCorrectMob(it.name) } .filter { !it.isAtFullHealth() } .minByOrNull { it.distanceTo(compareLocation) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerFeatures.kt deleted file mode 100644 index f55524d91..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/EndermanSlayerFeatures.kt +++ /dev/null @@ -1,136 +0,0 @@ -package at.hannibal2.skyhanni.features.slayer - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.TitleUtils -import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.ServerBlockChangeEvent -import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled -import at.hannibal2.skyhanni.utils.* -import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand -import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.RenderUtils.drawColor -import at.hannibal2.skyhanni.utils.RenderUtils.drawString -import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.entity.monster.EntityEnderman -import net.minecraft.init.Blocks -import net.minecraftforge.client.event.RenderWorldLastEvent -import net.minecraftforge.event.world.WorldEvent -import net.minecraftforge.fml.common.eventhandler.EventPriority -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -class EndermanSlayerFeatures { - private val config get() = SkyHanniMod.feature.slayer - private val endermenWithBeacons = mutableListOf() - private val flyingBeacons = mutableListOf() - private val nukekebiSkulls = mutableListOf() - private val sittingBeacon = mutableListOf() - private val logger = LorenzLogger("slayer/enderman") - private val nukekebiSkulTexture = - "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=" - - @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!IslandType.THE_END.isInIsland()) return - val entity = event.entity - if (entity in endermenWithBeacons || entity in flyingBeacons) return - - if (entity is EntityEnderman) { - if (config.slayerEndermanBeacon) { - if (hasBeaconInHand(entity) && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) { - endermenWithBeacons.add(entity) - logger.log("Added enderman with beacon at ${entity.getLorenzVec()}") - } - } - } - - if (entity is EntityArmorStand) { - if (config.slayerEndermanBeacon) { - val stack = entity.inventory[4] ?: return - if (stack.name == "Beacon" && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) { - flyingBeacons.add(entity) - if (config.slayerEndermanBeaconWaring) - TitleUtils.sendTitle("§4Beacon", 2_00) - logger.log("Added flying beacons at ${entity.getLorenzVec()}") - } - } - - if (config.endermanHighlightNukekebi) { - if (entity.inventory.any { it?.getSkullTexture() == nukekebiSkulTexture }) { - nukekebiSkulls.add(entity) - logger.log("Added nukekebi skulls at ${entity.getLorenzVec()}") - nukekebiSkulls.also { it.removeAll { it.isDead } } - } - } - } - } - - private fun hasBeaconInHand(enderman: EntityEnderman) = enderman.getBlockInHand()?.block == Blocks.beacon - - private fun canSee(a: LorenzVec, b: LorenzVec) = LocationUtils.canSee(a, b) || a.distance(b) < 15 - - @SubscribeEvent - fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!IslandType.THE_END.isInIsland()) return - - if (config.slayerEndermanBeacon && event.entity in flyingBeacons) { - event.color = LorenzColor.DARK_RED.toColor().withAlpha(1) - } - - if (config.endermanHighlightNukekebi && event.entity in nukekebiSkulls) { - event.color = LorenzColor.GOLD.toColor().withAlpha(1) - } - } - - @SubscribeEvent(priority = EventPriority.HIGH) - fun onWorldRender(event: RenderWorldLastEvent) { - if (!IslandType.THE_END.isInIsland()) return - if (!config.slayerEndermanBeacon) return - - endermenWithBeacons.removeIf { it.isDead || !hasBeaconInHand(it) } - - endermenWithBeacons.map { it.getLorenzVec().add(-0.5, 0.2, -0.5) } - .forEach { event.drawColor(it, LorenzColor.DARK_RED, alpha = 1f) } - - for (location in sittingBeacon.toMutableList()) { - event.drawColor(location, LorenzColor.DARK_RED, alpha = 1f) - event.drawWaypointFilled(location, LorenzColor.RED.toColor(), true, true) - event.drawString(location.add(0.5, 0.5, 0.5), "§4Beacon", true) - - } - } - - @SubscribeEvent - fun onBlockChange(event: ServerBlockChangeEvent) { - if (!IslandType.THE_END.isInIsland()) return - if (!config.slayerEndermanBeacon) return - - val location = event.location - if (event.new == "beacon") { - val armorStand = flyingBeacons.find { location.distance(it.getLorenzVec()) < 3 } - if (armorStand != null) { - flyingBeacons.remove(armorStand) - sittingBeacon.add(location) - logger.log("Replaced flying beacon with sitting beacon at $location") - } - } else { - if (location in sittingBeacon) { - logger.log("Removed sitting beacon $location") - sittingBeacon.remove(location) - } - } - } - - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - endermenWithBeacons.clear() - flyingBeacons.clear() - nukekebiSkulls.clear() - sittingBeacon.clear() - logger.log("Reset everything (world change)") - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt new file mode 100644 index 000000000..fb577cfce --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -0,0 +1,136 @@ +package at.hannibal2.skyhanni.features.slayer.enderman + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.TitleUtils +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.RenderMobColoredEvent +import at.hannibal2.skyhanni.events.ServerBlockChangeEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.test.GriffinUtils.drawWaypointFilled +import at.hannibal2.skyhanni.utils.* +import at.hannibal2.skyhanni.utils.EntityUtils.getBlockInHand +import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.RenderUtils.drawColor +import at.hannibal2.skyhanni.utils.RenderUtils.drawString +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.init.Blocks +import net.minecraftforge.client.event.RenderWorldLastEvent +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class EndermanSlayerFeatures { + private val config get() = SkyHanniMod.feature.slayer + private val endermenWithBeacons = mutableListOf() + private val flyingBeacons = mutableListOf() + private val nukekebiSkulls = mutableListOf() + private val sittingBeacon = mutableListOf() + private val logger = LorenzLogger("slayer/enderman") + private val nukekebiSkulTexture = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWIwNzU5NGUyZGYyNzM5MjFhNzdjMTAxZDBiZmRmYTExMTVhYmVkNWI5YjIwMjllYjQ5NmNlYmE5YmRiYjRiMyJ9fX0=" + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!IslandType.THE_END.isInIsland()) return + val entity = event.entity + if (entity in endermenWithBeacons || entity in flyingBeacons) return + + if (entity is EntityEnderman) { + if (config.slayerEndermanBeacon) { + if (hasBeaconInHand(entity) && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) { + endermenWithBeacons.add(entity) + logger.log("Added enderman with beacon at ${entity.getLorenzVec()}") + } + } + } + + if (entity is EntityArmorStand) { + if (config.slayerEndermanBeacon) { + val stack = entity.inventory[4] ?: return + if (stack.name == "Beacon" && canSee(LocationUtils.playerEyeLocation(), entity.getLorenzVec())) { + flyingBeacons.add(entity) + if (config.slayerEndermanBeaconWaring) + TitleUtils.sendTitle("§4Beacon", 2_00) + logger.log("Added flying beacons at ${entity.getLorenzVec()}") + } + } + + if (config.endermanHighlightNukekebi) { + if (entity.inventory.any { it?.getSkullTexture() == nukekebiSkulTexture }) { + nukekebiSkulls.add(entity) + logger.log("Added nukekebi skulls at ${entity.getLorenzVec()}") + nukekebiSkulls.also { it.removeAll { it.isDead } } + } + } + } + } + + private fun hasBeaconInHand(enderman: EntityEnderman) = enderman.getBlockInHand()?.block == Blocks.beacon + + private fun canSee(a: LorenzVec, b: LorenzVec) = LocationUtils.canSee(a, b) || a.distance(b) < 15 + + @SubscribeEvent + fun onRenderMobColored(event: RenderMobColoredEvent) { + if (!IslandType.THE_END.isInIsland()) return + + if (config.slayerEndermanBeacon && event.entity in flyingBeacons) { + event.color = LorenzColor.DARK_RED.toColor().withAlpha(1) + } + + if (config.endermanHighlightNukekebi && event.entity in nukekebiSkulls) { + event.color = LorenzColor.GOLD.toColor().withAlpha(1) + } + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onWorldRender(event: RenderWorldLastEvent) { + if (!IslandType.THE_END.isInIsland()) return + if (!config.slayerEndermanBeacon) return + + endermenWithBeacons.removeIf { it.isDead || !hasBeaconInHand(it) } + + endermenWithBeacons.map { it.getLorenzVec().add(-0.5, 0.2, -0.5) } + .forEach { event.drawColor(it, LorenzColor.DARK_RED, alpha = 1f) } + + for (location in sittingBeacon.toMutableList()) { + event.drawColor(location, LorenzColor.DARK_RED, alpha = 1f) + event.drawWaypointFilled(location, LorenzColor.RED.toColor(), true, true) + event.drawString(location.add(0.5, 0.5, 0.5), "§4Beacon", true) + + } + } + + @SubscribeEvent + fun onBlockChange(event: ServerBlockChangeEvent) { + if (!IslandType.THE_END.isInIsland()) return + if (!config.slayerEndermanBeacon) return + + val location = event.location + if (event.new == "beacon") { + val armorStand = flyingBeacons.find { location.distance(it.getLorenzVec()) < 3 } + if (armorStand != null) { + flyingBeacons.remove(armorStand) + sittingBeacon.add(location) + logger.log("Replaced flying beacon with sitting beacon at $location") + } + } else { + if (location in sittingBeacon) { + logger.log("Removed sitting beacon $location") + sittingBeacon.remove(location) + } + } + } + + @SubscribeEvent + fun onWorldChange(event: WorldEvent.Load) { + endermenWithBeacons.clear() + flyingBeacons.clear() + nukekebiSkulls.clear() + sittingBeacon.clear() + logger.log("Reset everything (world change)") + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt new file mode 100644 index 000000000..d6ae27f3b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerHideParticles.kt @@ -0,0 +1,49 @@ +package at.hannibal2.skyhanni.features.slayer.enderman + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.ReceiveParticleEvent +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.LorenzVec +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class EndermanSlayerHideParticles { + + private var endermanLocations = listOf() + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + + endermanLocations = EntityUtils.getEntities().map { it.getLorenzVec() } + } + + @SubscribeEvent + fun onReceivePacket(event: ReceiveParticleEvent) { + if (!isEnabled()) return + + when (event.type) { + EnumParticleTypes.SMOKE_LARGE, + EnumParticleTypes.FLAME, + EnumParticleTypes.SPELL_WITCH, + -> { + } + + else -> return + } + + val distance = event.location.distanceToNearestEnderman() ?: return + if (distance < 9) { + event.isCanceled = true + } + } + + private fun LorenzVec.distanceToNearestEnderman() = endermanLocations.minOfOrNull { it.distanceSq(this) } + + fun isEnabled() = IslandType.THE_END.isInIsland() && SkyHanniMod.feature.slayer.endermanHideParticles +} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index a8eda1617..fcdfb5cc4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.LocationUtils.distanceTo import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth +import net.minecraft.client.Minecraft import net.minecraft.client.multiplayer.WorldClient import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase @@ -126,10 +127,10 @@ object EntityUtils { ?.value } - inline fun WorldClient.getEntitiesNextToPlayer(radius: Double): List = + inline fun getEntitiesNextToPlayer(radius: Double): List = getEntitiesNearby(LocationUtils.playerLocation(), radius) - inline fun WorldClient.getEntitiesNearby(location: LorenzVec, radius: Double): List = + inline fun getEntitiesNearby(location: LorenzVec, radius: Double): List = getLoadedEntityList().filterIsInstance().filter { it.distanceTo(location) < radius } fun EntityLivingBase.isAtFullHealth() = baseMaxHealth == health.toInt() @@ -155,4 +156,8 @@ object EntityUtils { if (this is EntityPlayer) inventory.armorInventory else null fun EntityEnderman.getBlockInHand() = heldBlockState + + inline fun getEntities(): List = getLoadedEntityList().filterIsInstance() + + fun getLoadedEntityList(): List = Minecraft.getMinecraft().theWorld.getLoadedEntityList() } \ No newline at end of file -- cgit