diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/slayer')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt | 107 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt | 6 |
2 files changed, 107 insertions, 6 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt new file mode 100644 index 000000000..a5b7ae229 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerFirePitsWarning.kt @@ -0,0 +1,107 @@ +package at.hannibal2.skyhanni.features.slayer.blaze + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.config.core.util.render.TextRenderUtils +import at.hannibal2.skyhanni.events.BossHealthChangeEvent +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.SoundUtils +import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.renderer.GlStateManager +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class BlazeSlayerFirePitsWarning { + + companion object { + private var textToRender = "" + private var lastFirePitsWarning = 0L + private var nextTickIn = 0 + + fun fireFirePits() { + lastFirePitsWarning = System.currentTimeMillis() + textToRender = "§cFire Pits!" + nextTickIn = 0 + } + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!isEnabled()) return + + val difference = System.currentTimeMillis() - lastFirePitsWarning + + if (difference > 0) { + if (difference > 2_000) { + textToRender = "" + } else { + if (nextTickIn++ % 10 == 0) { + if (SkyHanniMod.feature.slayer.firePitsWarning) { + SoundUtils.createSound("random.orb", 0.8f).playSound() + } + } + } + } + } + + @SubscribeEvent + fun onBossHealthChange(event: BossHealthChangeEvent) { + if (!isEnabled()) return + val entityData = event.entityData + + val health = event.health + val maxHealth = event.maxHealth + val lastHealth = event.lastHealth + + val percentHealth = maxHealth * 0.33 + if (health < percentHealth) { + if (lastHealth > percentHealth) { + when (entityData.bossType) { + BossType.SLAYER_BLAZE_3, + //TODO blaze slayer tier 4 + //BossType.SLAYER_BLAZE_4, + -> { + fireFirePits() + } + + else -> {} + } + } + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && DamageIndicatorManager.isBossSpawned( + BossType.SLAYER_BLAZE_3, + //TODO blaze slayer tier 4 +// BossType.SLAYER_BLAZE_4, + BossType.SLAYER_BLAZE_QUAZII_34, + BossType.SLAYER_BLAZE_TYPHOEUS_34, + ) + } + + @SubscribeEvent + fun renderOverlay(event: RenderGameOverlayEvent.Post) { + if (event.type != RenderGameOverlayEvent.ElementType.ALL) return + if (!isEnabled()) return + if (!SkyHanniMod.feature.slayer.firePitsWarning) return + + val scaledResolution = ScaledResolution(Minecraft.getMinecraft()) + val width = scaledResolution.scaledWidth + val height = scaledResolution.scaledHeight + + GlStateManager.enableBlend() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + val renderer = Minecraft.getMinecraft().fontRendererObj + + GlStateManager.pushMatrix() + GlStateManager.translate((width / 2).toFloat(), (height / 1.8).toFloat(), 0.0f) + GlStateManager.scale(4.0f, 4.0f, 4.0f) + TextRenderUtils.drawStringCenteredScaledMaxWidth(textToRender, renderer, 0f, 0f, false, 75, 0) + GlStateManager.popMatrix() + } +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt index 457a4c6af..da812bcb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt @@ -139,7 +139,6 @@ class BlazeSlayerPillar { } else time % 1.0 == 0.0 if (playSound) { -// SoundUtils.createSound("random.orb", 11.2f).playSound() SoundUtils.createSound("random.click", 1.3f).playSound() } } @@ -165,7 +164,6 @@ class BlazeSlayerPillar { @SubscribeEvent fun onSoundEvent(event: PlaySoundEvent) { if (!isEnabled()) return - if (!SkyHanniMod.feature.slayer.firePillarBuildHider) return when (event.soundName) { @@ -176,8 +174,4 @@ class BlazeSlayerPillar { } } } - - private fun isPillarWarningEntity(armorStand: EntityArmorStand) = - armorStand.inventory.any { it != null && it.getSkullTexture() == pillarWarningTexture } - }
\ No newline at end of file |