aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-12 12:35:19 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-12 12:35:19 +0200
commitafdba2c6a3b27a53817cef0b0a306c05162fbcac (patch)
tree4dfeeac095fc394cdc4114a29cc3a0dbf0f65023 /src/main
parent08a857ae8d599fcc9206420cc14c164289ce1297 (diff)
downloadskyhanni-afdba2c6a3b27a53817cef0b0a306c05162fbcac.tar.gz
skyhanni-afdba2c6a3b27a53817cef0b0a306c05162fbcac.tar.bz2
skyhanni-afdba2c6a3b27a53817cef0b0a306c05162fbcac.zip
add dungeon death counter display
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/lorenz/mod/LorenzMod.java6
-rw-r--r--src/main/java/at/lorenz/mod/config/Features.java19
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/DungeonDeathCounter.kt97
3 files changed, 116 insertions, 6 deletions
diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java
index d19737a4e..b4b420555 100644
--- a/src/main/java/at/lorenz/mod/LorenzMod.java
+++ b/src/main/java/at/lorenz/mod/LorenzMod.java
@@ -6,10 +6,7 @@ import at.lorenz.mod.chat.ChatFilter;
import at.lorenz.mod.chat.ChatManager;
import at.lorenz.mod.chat.PlayerChatFilter;
import at.lorenz.mod.config.Features;
-import at.lorenz.mod.dungeon.DungeonChatFilter;
-import at.lorenz.mod.dungeon.DungeonData;
-import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks;
-import at.lorenz.mod.dungeon.DungeonMilestoneDisplay;
+import at.lorenz.mod.dungeon.*;
import at.lorenz.mod.dungeon.damageindicator.DungeonBossDamageIndicator;
import at.lorenz.mod.items.HideNotClickableItems;
import at.lorenz.mod.items.abilitycooldown.ItemAbilityCooldown;
@@ -68,6 +65,7 @@ public class LorenzMod {
MinecraftForge.EVENT_BUS.register(new DungeonBossDamageIndicator());
MinecraftForge.EVENT_BUS.register(new ItemAbilityCooldown());
MinecraftForge.EVENT_BUS.register(new DungeonMilestoneDisplay());
+ MinecraftForge.EVENT_BUS.register(new DungeonDeathCounter());
Commands.init();
diff --git a/src/main/java/at/lorenz/mod/config/Features.java b/src/main/java/at/lorenz/mod/config/Features.java
index cf386accc..109258420 100644
--- a/src/main/java/at/lorenz/mod/config/Features.java
+++ b/src/main/java/at/lorenz/mod/config/Features.java
@@ -40,6 +40,11 @@ public class Features {
editOverlay(activeConfigCategory, 200, 16, dungeon.milestoneDisplayPos);
return;
}
+
+ if (runnableId.equals("dungeonDeathCounter")) {
+ editOverlay(activeConfigCategory, 200, 16, dungeon.deathCounterDisplay);
+ return;
+ }
}
@Expose
@@ -123,12 +128,12 @@ public class Features {
public boolean highlightClickedBlocks = false;
@Expose
- @ConfigOption(name = "Boss Damage Indicator", desc = "Shows the missing health of a boss in the dungeon and the cooldown time until the boss becomes attackable.")
+ @ConfigOption(name = "Boss Damage Indicator", desc = "Show the missing health of a boss in the dungeon and the cooldown time until the boss becomes attackable.")
@ConfigEditorBoolean
public boolean bossDamageIndicator = false;
@Expose
- @ConfigOption(name = "Milestone Display", desc = "Shows the current milestone inside Dungeons.")
+ @ConfigOption(name = "Milestone Display", desc = "Show the current milestone inside Dungeons.")
@ConfigEditorBoolean
public boolean showMilestoneDisplay = false;
@@ -136,6 +141,16 @@ public class Features {
@ConfigOption(name = "Milestone Display Position", desc = "")
@ConfigEditorButton(runnableId = "dungeonMilestoneDisplay", buttonText = "Edit")
public Position milestoneDisplayPos = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(name = "Death Counter", desc = "Display the total amount of deaths in the current dungeon.")
+ @ConfigEditorBoolean
+ public boolean deathCounter = false;
+
+ @Expose
+ @ConfigOption(name = "Death Counter Position", desc = "")
+ @ConfigEditorButton(runnableId = "dungeonDeathCounter", buttonText = "Edit")
+ public Position deathCounterDisplay = new Position(10, 10, false, true);
}
public static class Items {
diff --git a/src/main/java/at/lorenz/mod/dungeon/DungeonDeathCounter.kt b/src/main/java/at/lorenz/mod/dungeon/DungeonDeathCounter.kt
new file mode 100644
index 000000000..156b641c4
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/dungeon/DungeonDeathCounter.kt
@@ -0,0 +1,97 @@
+package at.lorenz.mod.dungeon
+
+import at.lorenz.mod.LorenzMod
+import at.lorenz.mod.events.DungeonEnterEvent
+import at.lorenz.mod.events.LorenzChatEvent
+import at.lorenz.mod.utils.GuiRender.renderString
+import at.lorenz.mod.utils.LorenzUtils
+import at.lorenz.mod.utils.LorenzUtils.matchRegex
+import net.minecraftforge.client.event.RenderGameOverlayEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DungeonDeathCounter {
+
+ private var textToRender = ""
+ private var deaths = 0
+
+ private fun isDeathMessage(message: String): Boolean = when {
+ message.matchRegex("§c ☠ §r§7You were killed by (.*)§r§7 and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r§7(.*) was killed by (.*) and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You were crushed and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r§7§r(.*)§r§7 was crushed and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You died to a trap and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r(.*)§r§7 died to a trap and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You burnt to death and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r(.*)§r§7 burnt to death and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You died and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r(.*)§r§7 died and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You suffocated and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r§7§r(.*)§r§7 suffocated and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You died to a mob and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r(.*)§7 died to a mob and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7You fell into a deep hole and became a ghost§r§7.") -> true
+ message.matchRegex("§c ☠ §r(.*)§r§7 fell into a deep hole and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§(.*)§r§7 disconnected from the Dungeon and became a ghost§r§7.") -> true
+
+ message.matchRegex("§c ☠ §r§7(.*)§r§7 fell to their death with help from §r(.*)§r§7 and became a ghost§r§7.") -> true
+
+ else -> false
+ }
+
+ @SubscribeEvent(receiveCanceled = true)
+ fun onChatPacket(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+
+ if (isDeathMessage(event.message)) {
+ deaths++
+ LorenzUtils.chat("§c§l$deaths. DEATH!")
+ update()
+ }
+ }
+
+ private fun update() {
+ if (deaths == 0) {
+ textToRender = ""
+ return
+ }
+
+ val color = when (deaths) {
+ 1, 2 -> "§e"
+ 3 -> "§c"
+ else -> "§4"
+ }
+ textToRender = color + "Deaths: $deaths"
+ }
+
+ @SubscribeEvent
+ fun onDungeonStart(event: DungeonEnterEvent) {
+ deaths = 0
+ update()
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ deaths = 0
+ update()
+ }
+
+ @SubscribeEvent
+ fun renderOverlay(event: RenderGameOverlayEvent.Post) {
+ if (!isEnabled()) return
+
+ LorenzMod.feature.dungeon.deathCounterDisplay.renderString(DungeonMilestoneDisplay.color + textToRender)
+ }
+
+ private fun isEnabled(): Boolean {
+ return LorenzUtils.inDungeons && LorenzMod.feature.dungeon.deathCounter
+ }
+} \ No newline at end of file