aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-24 11:39:26 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2022-09-24 11:39:26 +0200
commit169c9dbd29c6015fda3c482feec0bdee78e00fef (patch)
tree7a13c82ecdbcfd20ba94ecd615f43d009e89217c /src/main
parent531506dcf7b61e2dea50e14bfe32e9547f7997be (diff)
downloadskyhanni-169c9dbd29c6015fda3c482feec0bdee78e00fef.tar.gz
skyhanni-169c9dbd29c6015fda3c482feec0bdee78e00fef.tar.bz2
skyhanni-169c9dbd29c6015fda3c482feec0bdee78e00fef.zip
fire pillar sound and entities
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Features.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt130
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt34
4 files changed, 170 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java
index 85c01417f..adf1262d3 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Features.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java
@@ -63,8 +63,8 @@ public class Features extends Config {
return;
}
- if (runnableId.equals("firePillars")) {
- editOverlay(activeConfigCategory, 200, 16, slayer.firePillarsPos);
+ if (runnableId.equals("firePillar")) {
+ editOverlay(activeConfigCategory, 200, 16, slayer.firePillarPos);
return;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java b/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java
index 9ad0a8047..eadb19cbb 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Slayer.java
@@ -27,16 +27,28 @@ public class Slayer {
public boolean damageSplash = false;
@Expose
- @ConfigOption(name = "Fire Pillars", desc = "Cooldown when the Fire Pillars from the blaze slayer will kill you.")
+ @ConfigOption(name = "Pillar Display", desc = "Cooldown when the Fire Pillar from the blaze slayer will kill you.")
@ConfigEditorBoolean
@ConfigAccordionId(id = 0)
- public boolean firePillars = false;
+ public boolean firePillarDisplay = false;
@Expose
- @ConfigOption(name = "Fire Pillars Position", desc = "")
- @ConfigEditorButton(runnableId = "firePillars", buttonText = "Edit")
+ @ConfigOption(name = "Pillar Display Position", desc = "")
+ @ConfigEditorButton(runnableId = "firePillar", buttonText = "Edit")
@ConfigAccordionId(id = 0)
- public Position firePillarsPos = new Position(10, 10, false, true);
+ public Position firePillarPos = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(name = "Pillar Sound", desc = "Custom countdown sound for the Fire Pillar timer for the blaze slayer.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean firePillarSound = false;
+
+ @Expose
+ @ConfigOption(name = "Hide Pillar", desc = "Hide sound and entities when building the Fire Pillar for the blaze slayer.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 0)
+ public boolean firePillarBuildHider = false;
@Expose
@ConfigOption(name = "Blaze Daggers", desc = "Faster and permanent display for the blaze slayer daggers")
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 2612f8aa8..f75f31e9d 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
@@ -2,11 +2,17 @@ package at.hannibal2.skyhanni.features.slayer.blaze
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.PlaySoundEvent
import at.hannibal2.skyhanni.features.damageindicator.BossType
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
+import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
+import at.hannibal2.skyhanni.utils.LocationUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.SoundUtils.playSound
+import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.client.Minecraft
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.client.event.RenderGameOverlayEvent
@@ -15,25 +21,61 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.text.DecimalFormat
import java.util.regex.Pattern
+import kotlin.math.roundToInt
class BlazeSlayerPillar {
+ private var patternPillarExploded =
+ Pattern.compile("§cYou took §r§f(.+) §r§ctrue damage from an exploding fire pillar!")
+ private val pillarEntities = mutableListOf<EntityArmorStand>()
+ private val pillarWarningTexture =
+ "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWMyZTlkODM5NWNhY2Q5OTIyODY5YzE1MzczY2Y3Y2IxNmRhMGE1Y2U1ZjNjNjMyYjE5Y2ViMzkyOWM5YTExIn19fQ=="
- private var patternPillarExploded = Pattern.compile("§cYou took §r§f(.+) §r§ctrue damage from an exploding fire pillar!")
private var lastPillarSpawnTime = -1L
- private val pillarEntities = mutableListOf<EntityArmorStand>()
+ private var lastSoundMoment = 0.0
+ private var lastPillarBuildEntitiesFound = 0L
+ private var pillarBuildEntityList = mutableListOf<EntityArmorStand>()
@SubscribeEvent
fun onTick(event: TickEvent.ClientTickEvent) {
if (!isEnabled()) return
+
+ val list = mutableListOf<EntityArmorStand>()
+ val playerLocation = LocationUtils.playerLocation()
for (armorStand in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>()) {
val name = armorStand.name
if (name.matchRegex("§6§l.s §c§l8 hits")) {
if (armorStand !in pillarEntities) {
pillarEntities.add(armorStand)
- lastPillarSpawnTime = System.currentTimeMillis()
+
+ val lastPillarEntities = System.currentTimeMillis() - lastPillarBuildEntitiesFound
+ if (lastPillarEntities in 2500..4500) {
+ lastPillarSpawnTime = System.currentTimeMillis()
+ }
+ }
+ }
+
+ if (armorStand in pillarBuildEntityList || armorStand.inventory.any { it != null && it.getSkullTexture() == pillarWarningTexture }) {
+ if (armorStand !in pillarBuildEntityList) {
+ pillarBuildEntityList.add(armorStand)
+ if (SkyHanniMod.feature.slayer.firePillarBuildHider) {
+ armorStand.inventory[0] = null
+ armorStand.inventory[1] = null
+ armorStand.inventory[2] = null
+ armorStand.inventory[3] = null
+ }
+ }
+ if (armorStand.getLorenzVec().distance(playerLocation) < 15) {
+ list.add(armorStand)
}
}
}
+ val size = list.size
+ if (size == 0) return
+ if (size % 12 == 0) {
+ if (System.currentTimeMillis() > lastPillarBuildEntitiesFound + 10_000) {
+ lastPillarBuildEntitiesFound = System.currentTimeMillis()
+ }
+ }
}
@SubscribeEvent
@@ -44,13 +86,14 @@ class BlazeSlayerPillar {
val matcher = patternPillarExploded.matcher(message)
if (matcher.matches()) {
lastPillarSpawnTime = -1L
- }
- if (message == " §r§a§lSLAYER QUEST COMPLETE!") {
- lastPillarSpawnTime = -1L
+ SoundUtils.createSound("note.pling", 0.7f).playSound()
}
- if (message == "§eYour Slayer boss was despawned, but you have kept your quest progress!") {
- lastPillarSpawnTime = -1L
+ when (message) {
+ " §r§a§lSLAYER QUEST COMPLETE!",
+ " §r§c§lSLAYER QUEST FAILED!",
+ "§eYour Slayer boss was despawned, but you have kept your quest progress!",
+ -> lastPillarSpawnTime = -1L
}
}
@@ -61,21 +104,82 @@ class BlazeSlayerPillar {
val duration = System.currentTimeMillis() - lastPillarSpawnTime
val maxDuration = 7_000
-
val remainingLong = maxDuration - duration
val remaining = (remainingLong.toFloat() / 1000)
- val format = DecimalFormat("0.0").format(remaining + 0.1)
- SkyHanniMod.feature.slayer.firePillarsPos.renderString("§cBlaze Pillar: §a${format}s")
+ if (SkyHanniMod.feature.slayer.firePillarSound) {
+ playSound(remaining)
+ }
+
+ if (SkyHanniMod.feature.slayer.firePillarDisplay) {
+ val format = DecimalFormat("0.0").format(remaining + 0.1)
+ SkyHanniMod.feature.slayer.firePillarPos.renderString("§cBlaze Pillar: §a${format}s")
+ }
+ }
+
+ private fun playSound(remaining: Float) {
+ val time = (remaining * 10).roundToInt().toDouble() / 10
+ if (time == lastSoundMoment) return
+ lastSoundMoment = time
+
+ val playSound = if (time < 0) {
+ false
+ } else if (time <= 0.7) {
+ true
+ } else if (time <= 2.1) {
+ when (time) {
+ 0.9 -> true
+ 1.2 -> true
+ 1.5 -> true
+ 1.8 -> true
+ 2.1 -> true
+ else -> false
+ }
+ } else if (time <= 4 && time % 0.5 == 0.0) {
+ true
+ } else time % 1.0 == 0.0
+
+ if (playSound) {
+// SoundUtils.createSound("random.orb", 11.2f).playSound()
+ SoundUtils.createSound("random.click", 1.3f).playSound()
+ }
}
private fun isEnabled(): Boolean {
- return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.firePillars && DamageIndicatorManager.isBossSpawned(
- BossType.SLAYER_BLAZE_2, BossType.SLAYER_BLAZE_3, BossType.SLAYER_BLAZE_4
+ return LorenzUtils.inSkyblock && DamageIndicatorManager.isBossSpawned(
+ BossType.SLAYER_BLAZE_2,
+ BossType.SLAYER_BLAZE_3,
+ BossType.SLAYER_BLAZE_4,
+ BossType.SLAYER_BLAZE_QUAZII_2,
+ BossType.SLAYER_BLAZE_QUAZII_3,
+ BossType.SLAYER_BLAZE_QUAZII_4,
+ BossType.SLAYER_BLAZE_TYPHOEUS_2,
+ BossType.SLAYER_BLAZE_TYPHOEUS_3,
+ BossType.SLAYER_BLAZE_TYPHOEUS_4,
)
}
@SubscribeEvent
fun onWorldChange(event: WorldEvent.Load) {
pillarEntities.clear()
+ lastPillarSpawnTime = -1
+ }
+
+ @SubscribeEvent
+ fun onSoundEvent(event: PlaySoundEvent) {
+ if (!isEnabled()) return
+
+ if (!SkyHanniMod.feature.slayer.firePillarBuildHider) return
+
+ when (event.soundName) {
+ "mob.chicken.plop",
+ "mob.bat.takeoff",
+ -> {
+ event.isCanceled = true
+ }
+ }
}
+
+ private fun isPillarWarningEntity(armorStand: EntityArmorStand) =
+ armorStand.inventory.any { it != null && it.getSkullTexture() == pillarWarningTexture }
+
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
new file mode 100644
index 000000000..1fb107375
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
@@ -0,0 +1,34 @@
+package at.hannibal2.skyhanni.utils
+
+import net.minecraft.client.Minecraft
+import net.minecraft.client.audio.ISound
+import net.minecraft.client.audio.PositionedSound
+import net.minecraft.client.audio.SoundCategory
+import net.minecraft.util.ResourceLocation
+
+object SoundUtils {
+ fun ISound.playSound() {
+ val gameSettings = Minecraft.getMinecraft().gameSettings
+ val oldLevel = gameSettings.getSoundLevel(SoundCategory.PLAYERS)
+ gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1f)
+ try {
+ Minecraft.getMinecraft().soundHandler.playSound(this)
+ } catch (e: Exception) {
+ e.printStackTrace()
+ }
+ gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel)
+ }
+
+ fun createSound(name: String, pitch: Float): ISound {
+ val sound: ISound = object : PositionedSound(ResourceLocation(name)) {
+ init {
+ volume = 50f
+ repeat = false
+ repeatDelay = 0
+ attenuationType = ISound.AttenuationType.NONE
+ this.pitch = pitch
+ }
+ }
+ return sound
+ }
+} \ No newline at end of file