From ca5374842862e8f7258bb8d4ff9dc42b623cac6d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 23 Sep 2022 19:24:00 +0200 Subject: renamed sword to dagger and support for higher tier daggers --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 4 +- .../damageindicator/DamageIndicatorManager.kt | 4 +- .../slayer/blaze/BlazeSlayerDaggerHelper.kt | 163 +++++++++++++++++++++ .../slayer/blaze/BlazeSlayerWeaponHelper.kt | 155 -------------------- .../skyhanni/features/slayer/blaze/DaggerMode.kt | 11 ++ .../skyhanni/features/slayer/blaze/SwordMode.kt | 11 -- 6 files changed, 178 insertions(+), 170 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerWeaponHelper.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/DaggerMode.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/SwordMode.kt (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 05dc52499..2805354b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -32,8 +32,8 @@ import at.hannibal2.skyhanni.features.nether.ashfang.*; import at.hannibal2.skyhanni.features.slayer.EndermanSlayerBeacon; import at.hannibal2.skyhanni.features.slayer.HideMobNames; import at.hannibal2.skyhanni.features.slayer.HighlightSlayerMiniboss; +import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerDaggerHelper; import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerPillarTimer; -import at.hannibal2.skyhanni.features.slayer.blaze.BlazeSlayerWeaponHelper; import at.hannibal2.skyhanni.features.summonings.SummoningMobManager; import at.hannibal2.skyhanni.features.summonings.SummoningSoulsName; import at.hannibal2.skyhanni.test.LorenzTest; @@ -134,7 +134,7 @@ public class SkyHanniMod { registerEvent(new HideDamageSplash()); registerEvent(new ThunderSparksHighlight()); registerEvent(new BlazeSlayerPillarTimer()); - registerEvent(new BlazeSlayerWeaponHelper()); + registerEvent(new BlazeSlayerDaggerHelper()); registerEvent(new PlayerChatFilter()); registerEvent(new HideArmor()); 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 a8237e4b1..6f5fadb27 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/damageindicator/DamageIndicatorManager.kt @@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.dungeon.DungeonData -import at.hannibal2.skyhanni.features.slayer.blaze.SwordMode +import at.hannibal2.skyhanni.features.slayer.blaze.DaggerMode import at.hannibal2.skyhanni.test.LorenzTest import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.EntityUtils.getNameTagWith @@ -342,7 +342,7 @@ class DamageIndicatorManager { } private fun checkBlazeSlayer(entity: EntityLiving, entityData: EntityData): String { - for (swordMode in SwordMode.values()) { + for (swordMode in DaggerMode.values()) { if (entity.hasNameTagWith(3, swordMode.name)) { entityData.namePrefix = swordMode.formattedName + " " entityData.color = swordMode.color diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt new file mode 100644 index 000000000..b9022842b --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -0,0 +1,163 @@ +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.PacketEvent +import at.hannibal2.skyhanni.utils.ItemUtils.name +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP +import net.minecraft.client.gui.ScaledResolution +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.network.play.client.C07PacketPlayerDigging +import net.minecraft.network.play.server.S45PacketTitle +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class BlazeSlayerDaggerHelper { + + var textToRenderMain = "" + var textToRenderOther = "" + var clientSideClicked = false + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + if (!isEnabled()) return + + val dagger = getDaggerInHand() + if (dagger != null) { + textToRenderMain = getDaggerText(dagger) + textToRenderOther = getDaggerText(dagger.other()) + return + } + + textToRenderMain = "" + textToRenderOther = "" + } + + private fun getDaggerInHand(): Dagger? { + val player = Minecraft.getMinecraft().thePlayer + val itemName = getName(player) + for (dagger in Dagger.values()) { + if (dagger.daggerNames.any { itemName.contains(it) }) { + return dagger + } + } + + return null + } + + private fun getDaggerText(dagger: Dagger): String { + var activeAbility = "" + var inactiveAbility = "" + for (mode in dagger.modes) { + if (mode.active) { + activeAbility = mode.chatColor + "§l" + mode + } else { + inactiveAbility = " §7/ " + mode.chatColor + mode.toString().lowercase() + } + } + if (activeAbility == "") return "" + return "$activeAbility$inactiveAbility" + + } + + private fun getName(player: EntityPlayerSP): String { + val itemStack = player.inventory.mainInventory[player.inventory.currentItem] ?: return "" + return itemStack.name ?: "" + } + + @SubscribeEvent + fun onReceiveCurrentMode(event: PacketEvent.ReceiveEvent) { + if (!isEnabled()) return + + val packet = event.packet + + if (packet !is S45PacketTitle) return + val message = packet.message ?: return + val formattedText = message.formattedText + + for (mode in DaggerMode.values()) { + if (mode.formattedName + "§r" == formattedText) { + Dagger.values().filter { mode in it.modes }.forEach { + it.modes.forEach { mode -> mode.active = false } + } + mode.active = true + event.isCanceled = true + clientSideClicked = false + return + } + } + } + + private fun isEnabled(): Boolean { + return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.blazeDaggers + } + + @SubscribeEvent + fun onRightClick(event: PacketEvent.SendEvent) { + if (!isEnabled()) return + + if (clientSideClicked) return + + val packet = event.packet + + if (packet is C07PacketPlayerDigging) { + val status = packet.status + if (status == C07PacketPlayerDigging.Action.RELEASE_USE_ITEM) { + val dagger = getDaggerInHand() + dagger?.modes?.forEach { mode -> mode.active = !mode.active } + clientSideClicked = true + } + } + } + + enum class Dagger(val daggerNames: List, vararg val modes: DaggerMode) { + TWILIGHT( + listOf("Twilight Dagger", "Mawdredge Dagger", "Deathripper Dagger"), + DaggerMode.SPIRIT, + DaggerMode.CRYSTAL + ), + FIREDUST( + listOf("Firedust Dagger", "Kindlebane Dagger", "Pyrochaos Dagger"), + DaggerMode.ASHEN, + DaggerMode.AURIC + ), + ; + + fun other(): Dagger = if (this == TWILIGHT) { + FIREDUST + } else { + TWILIGHT + } + } + + @SubscribeEvent + fun renderOverlay(event: RenderGameOverlayEvent.Post) { + if (event.type != RenderGameOverlayEvent.ElementType.ALL) return + if (!isEnabled()) return + + if (Minecraft.getMinecraft().currentScreen != null) 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 / 3.8).toFloat(), 0.0f) + GlStateManager.scale(4.0f, 4.0f, 4.0f) + TextRenderUtils.drawStringCenteredScaledMaxWidth(textToRenderMain, renderer, 0f, 0f, false, 55, 0) + GlStateManager.popMatrix() + + GlStateManager.pushMatrix() + GlStateManager.translate((width / 2).toFloat(), (height / 3.2).toFloat(), 0.0f) + GlStateManager.scale(4.0f, 4.0f, 4.0f) + TextRenderUtils.drawStringCenteredScaledMaxWidth(textToRenderOther, renderer, 0f, 0f, false, 40, 0) + GlStateManager.popMatrix() + } +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerWeaponHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerWeaponHelper.kt deleted file mode 100644 index cc05b08a3..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerWeaponHelper.kt +++ /dev/null @@ -1,155 +0,0 @@ -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.PacketEvent -import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils -import net.minecraft.client.Minecraft -import net.minecraft.client.entity.EntityPlayerSP -import net.minecraft.client.gui.ScaledResolution -import net.minecraft.client.renderer.GlStateManager -import net.minecraft.network.play.client.C07PacketPlayerDigging -import net.minecraft.network.play.server.S45PacketTitle -import net.minecraftforge.client.event.RenderGameOverlayEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import net.minecraftforge.fml.common.gameevent.TickEvent - -class BlazeSlayerWeaponHelper { - - var textToRenderA = "" - var textToRenderB = "" - var clientSideClicked = false - - @SubscribeEvent - fun onTick(event: TickEvent.ClientTickEvent) { - if (!isEnabled()) return - - val sword = getSwordInHand() - if (sword != null) { - textToRenderA = getSwordText(sword) - textToRenderB = getSwordText(sword.other()) - return - } - - textToRenderA = "" - textToRenderB = "" - } - - private fun getSwordInHand(): Sword? { - val player = Minecraft.getMinecraft().thePlayer - val itemName = getName(player) - for (sword in Sword.values()) { - if (itemName.contains(sword.swordName)) { - return sword - } - } - - return null - } - - private fun getSwordText(sword: Sword): String { - var activeAbility = "" - var inactiveAbility = "" - for (mode in sword.modes) { - if (mode.active) { - activeAbility = mode.chatColor + "§l" + mode - } else { - inactiveAbility = " §7/ " + mode.chatColor + mode.toString().lowercase() - } - } - if (activeAbility == "") return "" - return "$activeAbility$inactiveAbility" - - } - - private fun getName(player: EntityPlayerSP): String { - val itemStack = player.inventory.mainInventory[player.inventory.currentItem] ?: return "" - return itemStack.name ?: "" - } - - @SubscribeEvent - fun onReceiveCurrentMode(event: PacketEvent.ReceiveEvent) { - if (!isEnabled()) return - - val packet = event.packet - - if (packet !is S45PacketTitle) return - val message = packet.message ?: return - val formattedText = message.formattedText - - for (swordMode in SwordMode.values()) { - if (swordMode.formattedName + "§r" == formattedText) { - Sword.values().filter { swordMode in it.modes }.forEach { - it.modes.forEach { mode -> mode.active = false } - } - swordMode.active = true - event.isCanceled = true - clientSideClicked = false - return - } - } - } - - private fun isEnabled(): Boolean { - return LorenzUtils.inSkyblock && SkyHanniMod.feature.slayer.blazeDaggers - } - - @SubscribeEvent - fun onRightClick(event: PacketEvent.SendEvent) { - if (!isEnabled()) return - - if (clientSideClicked) return - - val packet = event.packet - - if (packet is C07PacketPlayerDigging) { - val status = packet.status - if (status == C07PacketPlayerDigging.Action.RELEASE_USE_ITEM) { - val sword = getSwordInHand() - sword?.modes?.forEach { mode -> mode.active = !mode.active } - clientSideClicked = true - } - } - } - - enum class Sword(val swordName: String, vararg val modes: SwordMode) { - TWILIGHT("Twilight Dagger", SwordMode.SPIRIT, SwordMode.CRYSTAL), - FIREDUST("Firedust Dagger", SwordMode.ASHEN, SwordMode.AURIC), - ; - - fun other(): Sword = if (this == TWILIGHT) { - FIREDUST - } else { - TWILIGHT - } - } - - @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { - if (event.type != RenderGameOverlayEvent.ElementType.ALL) return - if (!isEnabled()) return - - if (Minecraft.getMinecraft().currentScreen != null) 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 / 3.8).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth(textToRenderA, renderer, 0f, 0f, false, 55, 0) - GlStateManager.popMatrix() - - GlStateManager.pushMatrix() - GlStateManager.translate((width / 2).toFloat(), (height / 3.2).toFloat(), 0.0f) - GlStateManager.scale(4.0f, 4.0f, 4.0f) - TextRenderUtils.drawStringCenteredScaledMaxWidth(textToRenderB, renderer, 0f, 0f, false, 40, 0) - GlStateManager.popMatrix() - } -} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/DaggerMode.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/DaggerMode.kt new file mode 100644 index 000000000..d6a8ab711 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/DaggerMode.kt @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.features.slayer.blaze + +import at.hannibal2.skyhanni.utils.LorenzColor + +enum class DaggerMode(val formattedName: String, val color: LorenzColor, val chatColor: String = color.getChatColor(), var active: Boolean = false) { + AURIC("§e§lAURIC", LorenzColor.YELLOW), + ASHEN("§8§lASHEN", LorenzColor.DARK_GRAY), + SPIRIT("§f§lSPIRIT", LorenzColor.WHITE), + CRYSTAL("§b§lCRYSTAL", LorenzColor.AQUA), + ; +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/SwordMode.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/SwordMode.kt deleted file mode 100644 index b2dfc9e28..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/SwordMode.kt +++ /dev/null @@ -1,11 +0,0 @@ -package at.hannibal2.skyhanni.features.slayer.blaze - -import at.hannibal2.skyhanni.utils.LorenzColor - -enum class SwordMode(val formattedName: String, val color: LorenzColor, val chatColor: String = color.getChatColor(), var active: Boolean = false) { - AURIC("§e§lAURIC", LorenzColor.YELLOW), - ASHEN("§8§lASHEN", LorenzColor.DARK_GRAY), - SPIRIT("§f§lSPIRIT", LorenzColor.WHITE), - CRYSTAL("§b§lCRYSTAL", LorenzColor.AQUA), - ; -} \ No newline at end of file -- cgit