diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-12 13:40:58 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-07-12 13:40:58 +0200 |
commit | 32a18dbb83d2c676406491d9439609fe3369b276 (patch) | |
tree | e4ff853bb21d342d2c4ecfbbb6c1afdb4e204f2b /src/main/java | |
parent | 10af579e5160ef3c55835c3ed64a277acfe87209 (diff) | |
download | skyhanni-32a18dbb83d2c676406491d9439609fe3369b276.tar.gz skyhanni-32a18dbb83d2c676406491d9439609fe3369b276.tar.bz2 skyhanni-32a18dbb83d2c676406491d9439609fe3369b276.zip |
Removed Living Cave Defence Blocks when the mob dies
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/rift/area/livingcave/LivingCaveDefenseBlocks.kt | 22 |
1 files changed, 17 insertions, 5 deletions
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 18304c25e..5a23ee650 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 @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.rift.area.livingcave +import at.hannibal2.skyhanni.events.LorenzTickEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.events.ServerBlockChangeEvent import at.hannibal2.skyhanni.events.withAlpha @@ -28,6 +29,15 @@ class LivingCaveDefenseBlocks { class DefenseBlock(val entity: EntityOtherPlayerMP, val location: LorenzVec, var hidden: Boolean = false) + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) return + if (event.isMod(20)) { + staticBlocks = staticBlocks.editCopy { removeIf { it.entity.isDead } } + } + } + @SubscribeEvent fun onReceiveParticle(event: ReceiveParticleEvent) { if (!isEnabled()) return @@ -68,10 +78,11 @@ 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<EntityOtherPlayerMP>(compareLocation, 2.0) - .filter { isCorrectMob(it.name) } - .filter { !it.isAtFullHealth() } - .minByOrNull { it.distanceTo(compareLocation) } + entity = + Minecraft.getMinecraft().theWorld.getEntitiesNearby<EntityOtherPlayerMP>(compareLocation, 2.0) + .filter { isCorrectMob(it.name) } + .filter { !it.isAtFullHealth() } + .minByOrNull { it.distanceTo(compareLocation) } } val defenseBlock = entity?.let { DefenseBlock(it, location) } ?: return @@ -122,7 +133,8 @@ class LivingCaveDefenseBlocks { } private fun getNearestMovingDefenseBlock(location: LorenzVec) = - movingBlocks.keys.filter { it.location.distance(location) < 15 }.minByOrNull { it.location.distance(location) } + movingBlocks.keys.filter { it.location.distance(location) < 15 } + .minByOrNull { it.location.distance(location) } private fun getNearestStaticDefenseBlock(location: LorenzVec) = staticBlocks.filter { it.location.distance(location) < 15 }.minByOrNull { it.location.distance(location) } |