diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-30 18:18:51 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-30 18:18:51 +0200 |
| commit | caf9a771f270db8213730fa3097185eed1d427d4 (patch) | |
| tree | 552f40e9ef0dc2ceced4b7ae103a949fa38e655e /src/main/java/at/hannibal2/skyhanni/features | |
| parent | 9be7649e6f094c24b6c93f54ac8ba179bb2d3709 (diff) | |
| download | SkyHanni-caf9a771f270db8213730fa3097185eed1d427d4.tar.gz SkyHanni-caf9a771f270db8213730fa3097185eed1d427d4.tar.bz2 SkyHanni-caf9a771f270db8213730fa3097185eed1d427d4.zip | |
added BlazeSlayerClearView
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt | 4 | ||||
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt | 93 |
2 files changed, 97 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt index d8daab906..7b8809df1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -66,6 +66,10 @@ class DamageIndicatorManager { fun isBossSpawned(vararg types: BossType): Boolean { return types.any { isBossSpawned(it) } } + + fun getBosses(): Collection<EntityData> { + return data.values + } } @SubscribeEvent diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt new file mode 100644 index 000000000..c2036984b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt @@ -0,0 +1,93 @@ +package at.hannibal2.skyhanni.features.slayer.blaze + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import at.hannibal2.skyhanni.events.PlayParticleEvent +import at.hannibal2.skyhanni.features.damageindicator.BossType +import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.entity.projectile.EntityFireball +import net.minecraft.util.EnumParticleTypes +import net.minecraftforge.event.world.WorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class BlazeSlayerClearView { + + private val hiddenFireBalls = mutableListOf<EntityFireball>() + + @SubscribeEvent + fun onChatPacket(event: PlayParticleEvent) { + if (!isEnabled()) return + + when (event.type) { + EnumParticleTypes.SPELL_MOB, + EnumParticleTypes.REDSTONE, + EnumParticleTypes.FLAME, + -> { + } + + else -> return + } + + val bossLocations = DamageIndicatorManager.getBosses() + .filter { isBlazeBoss(it.bossType) } + .map { it.entity.getLorenzVec() } + val location = event.location + if (bossLocations.any { it.distance(location) < 3 }) { + event.isCanceled = true + } + } + + @SubscribeEvent + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (!isEnabled()) return + + val entity = event.entity + if (entity !is EntityFireball) return + + if (entity in hiddenFireBalls) { + event.isCanceled = true + return + } + + val bossLocations = DamageIndicatorManager.getBosses() + .filter { isBlazeBoss(it.bossType) } + .map { it.entity.getLorenzVec() } + + val location = entity.getLorenzVec() + if (bossLocations.any { it.distance(location) < 5 }) { + hiddenFireBalls.add(entity) + event.isCanceled = true + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.blazeClearView + } + + @SubscribeEvent + fun onWorldChange(event: WorldEvent.Load) { + hiddenFireBalls.clear() + } + + private fun isBlazeBoss(type: BossType): Boolean { + return when (type) { + BossType.SLAYER_BLAZE_1, + BossType.SLAYER_BLAZE_2, + BossType.SLAYER_BLAZE_3, + BossType.SLAYER_BLAZE_4, + BossType.SLAYER_BLAZE_TYPHOEUS_1, + BossType.SLAYER_BLAZE_TYPHOEUS_2, + BossType.SLAYER_BLAZE_TYPHOEUS_3, + BossType.SLAYER_BLAZE_TYPHOEUS_4, + BossType.SLAYER_BLAZE_QUAZII_1, + BossType.SLAYER_BLAZE_QUAZII_2, + BossType.SLAYER_BLAZE_QUAZII_3, + BossType.SLAYER_BLAZE_QUAZII_4, + -> true + + else -> false + } + } +}
\ No newline at end of file |
