diff options
Diffstat (limited to 'src/main/java')
6 files changed, 108 insertions, 84 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 2521a9654..52e512a35 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -98,16 +98,6 @@ public class Misc { public boolean hideDamageSplash = false; @Expose - @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.") - @ConfigEditorBoolean - public boolean hideExpBottles = false; - - @Expose - @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.") - @ConfigEditorBoolean - public boolean configButtonOnPause = true; - - @Expose @ConfigOption(name = "Potion Effects", desc = "") @ConfigEditorAccordion(id = 5) public boolean potionEffects = false; @@ -123,4 +113,19 @@ public class Misc { @ConfigEditorButton(runnableId = "nonGodPotEffect", buttonText = "Edit") @ConfigAccordionId(id = 5) public Position nonGodPotEffectPos = new Position(10, 10, false, true); + + @Expose + @ConfigOption(name = "Exp Bottles", desc = "Hides all the experience bottles lying on the ground.") + @ConfigEditorBoolean + public boolean hideExpBottles = false; + + @Expose + @ConfigOption(name = "Blaze Particles", desc = "Hide Blaze Particles") + @ConfigEditorBoolean + public boolean hideBlazeParticles = false; + + @Expose + @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.") + @ConfigEditorBoolean + public boolean configButtonOnPause = true; }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/events/SpawnParticleEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SpawnParticleEvent.kt new file mode 100644 index 000000000..9cfa12dd6 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/SpawnParticleEvent.kt @@ -0,0 +1,6 @@ +package at.hannibal2.skyhanni.events + +import net.minecraftforge.fml.common.eventhandler.Cancelable + +@Cancelable +class SpawnParticleEvent(val id: Int, val x: Double, val y: Double, val z: Double) : LorenzEvent()
\ No newline at end of file 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 90be9e0d1..10d991bd6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -67,8 +67,14 @@ class DamageIndicatorManager { return types.any { isBossSpawned(it) } } - fun getBosses(): Collection<EntityData> { - return data.values + fun getDistanceTo(vararg types: BossType): Double { + val playerLocation = LocationUtils.playerLocation() + val list = data.values.filter { it.bossType in types }.map { it.entity.getLorenzVec().distance(playerLocation) } + return if (list.isEmpty()) { + Double.MAX_VALUE + } else { + list.minOf { it } + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt index c6c5f8786..feb13b2eb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangHideParticles.kt @@ -1,29 +1,44 @@ package at.hannibal2.skyhanni.features.nether.ashfang import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.BlazeParticleEvent import at.hannibal2.skyhanni.events.PlayParticleEvent +import at.hannibal2.skyhanni.events.SpawnParticleEvent import at.hannibal2.skyhanni.features.damageindicator.BossType import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent class AshfangHideParticles { + var tick = 0 + var hideParticles = false + @SubscribeEvent - fun onReceivePacket(event: PlayParticleEvent) { - if (isEnabled()) { - event.isCanceled = true + fun onTick(event: TickEvent.ClientTickEvent) { + if (!LorenzUtils.inSkyblock) return + + if (tick++ % 60 == 0) { + val distance = DamageIndicatorManager.getDistanceTo(BossType.NETHER_ASHFANG) + hideParticles = distance < 40 } } @SubscribeEvent - fun onBlazeParticle(event: BlazeParticleEvent) { - if (isEnabled()) { - event.isCanceled = true - } + fun onReceivePacket(event: PlayParticleEvent) { + if (!isEnabled()) return + if (!hideParticles) return + + event.isCanceled = true + } + + @SubscribeEvent + fun onSpawnParticle(event: SpawnParticleEvent) { + if (!isEnabled()) return + if (!hideParticles) return + + event.isCanceled = true } - private fun isEnabled() = LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.hideParticles && - DamageIndicatorManager.isBossSpawned(BossType.NETHER_ASHFANG) + private fun isEnabled() = LorenzUtils.inSkyblock && SkyHanniMod.feature.ashfang.hideParticles }
\ No newline at end of file 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 index c2036984b..b595f3cfa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerClearView.kt @@ -3,91 +3,64 @@ 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.events.SpawnParticleEvent 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 +import net.minecraftforge.fml.common.gameevent.TickEvent class BlazeSlayerClearView { - private val hiddenFireBalls = mutableListOf<EntityFireball>() + var tick = 0 + var hideParticles = false @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 + fun onTick(event: TickEvent.ClientTickEvent) { + if (!LorenzUtils.inSkyblock) return + if (tick++ % 60 == 0) { + hideParticles = DamageIndicatorManager.getDistanceTo( + 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, + ) < 10 } } @SubscribeEvent - fun onCheckRender(event: CheckRenderEntityEvent<*>) { - if (!isEnabled()) return - - val entity = event.entity - if (entity !is EntityFireball) return - - if (entity in hiddenFireBalls) { + fun onReceivePacket(event: PlayParticleEvent) { + if (isEnabled()) { 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) + @SubscribeEvent + fun onSpawnParticle(event: SpawnParticleEvent) { + if (isEnabled()) { event.isCanceled = true } } - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.blazeClearView - } - @SubscribeEvent - fun onWorldChange(event: WorldEvent.Load) { - hiddenFireBalls.clear() + fun onCheckRender(event: CheckRenderEntityEvent<*>) { + if (isEnabled()) { + if (event.entity is EntityFireball) { + event.isCanceled = true + } + } } - 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 - } + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.blazeClearView && hideParticles } }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderGlobal.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderGlobal.java new file mode 100644 index 000000000..64f9b1c9a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderGlobal.java @@ -0,0 +1,19 @@ +package at.hannibal2.skyhanni.mixins.transformers; + +import at.hannibal2.skyhanni.events.SpawnParticleEvent; +import net.minecraft.client.renderer.RenderGlobal; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RenderGlobal.class) +public class MixinRenderGlobal { + + @Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD"), cancellable = true) + private void spawnParticle(int id, boolean ignoreRange, double x, double y, double z, double xOffset, double yOffset, double zOffset, int[] p_180442_15_, CallbackInfo ci) { + if (new SpawnParticleEvent(id, x, y, z).postAndCatch()) { + ci.cancel(); + } + } +} |