aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/lorenz/mod/LorenzMod.java1
-rw-r--r--src/main/java/at/lorenz/mod/config/Features.java5
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/DungeonCleanEnd.kt120
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossDamageIndicator.kt9
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossFinder.kt20
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/damageindicator/EntityResult.kt2
-rw-r--r--src/main/java/at/lorenz/mod/events/DamageIndicatorFinalBossEvent.kt3
-rw-r--r--src/main/java/at/lorenz/mod/test/LorenzTest.kt30
8 files changed, 178 insertions, 12 deletions
diff --git a/src/main/java/at/lorenz/mod/LorenzMod.java b/src/main/java/at/lorenz/mod/LorenzMod.java
index 1c5dac597..4a12e16db 100644
--- a/src/main/java/at/lorenz/mod/LorenzMod.java
+++ b/src/main/java/at/lorenz/mod/LorenzMod.java
@@ -66,6 +66,7 @@ public class LorenzMod {
MinecraftForge.EVENT_BUS.register(new ItemAbilityCooldown());
MinecraftForge.EVENT_BUS.register(new DungeonMilestoneDisplay());
MinecraftForge.EVENT_BUS.register(new DungeonDeathCounter());
+ MinecraftForge.EVENT_BUS.register(new DungeonCleanEnd());
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 2c04e9238..20b9ecad8 100644
--- a/src/main/java/at/lorenz/mod/config/Features.java
+++ b/src/main/java/at/lorenz/mod/config/Features.java
@@ -151,6 +151,11 @@ public class Features {
@ConfigOption(name = "Death Counter Position", desc = "")
@ConfigEditorButton(runnableId = "dungeonDeathCounter", buttonText = "Edit")
public Position deathCounterDisplay = new Position(10, 10, false, true);
+
+ @Expose
+ @ConfigOption(name = "Clean End", desc = "Hide entities and particles after the boss in Floor 1 - 6 has died.")
+ @ConfigEditorBoolean
+ public boolean cleanEnd = false;
}
public static class Items {
diff --git a/src/main/java/at/lorenz/mod/dungeon/DungeonCleanEnd.kt b/src/main/java/at/lorenz/mod/dungeon/DungeonCleanEnd.kt
new file mode 100644
index 000000000..62191a370
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/dungeon/DungeonCleanEnd.kt
@@ -0,0 +1,120 @@
+package at.lorenz.mod.dungeon
+
+import at.lorenz.mod.LorenzMod
+import at.lorenz.mod.events.CheckRenderEntityEvent
+import at.lorenz.mod.events.DamageIndicatorFinalBossEvent
+import at.lorenz.mod.events.LorenzChatEvent
+import at.lorenz.mod.events.PacketEvent
+import at.lorenz.mod.utils.LorenzUtils
+import at.lorenz.mod.utils.LorenzUtils.matchRegex
+import net.minecraft.client.Minecraft
+import net.minecraft.client.entity.EntityOtherPlayerMP
+import net.minecraft.entity.item.EntityArmorStand
+import net.minecraft.network.play.server.S1CPacketEntityMetadata
+import net.minecraft.network.play.server.S2APacketParticles
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DungeonCleanEnd {
+
+ private var bossDone = false
+ private var chestsSpawned = false
+ private var lastBossId: Int = -1
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzUtils.inDungeons) return
+ if (!LorenzMod.feature.dungeon.cleanEnd) return
+
+ val message = event.message
+
+ if (message.matchRegex("([ ]*)§r§c(The|Master Mode) Catacombs §r§8- §r§eFloor (.*)")) {
+ chestsSpawned = true
+ }
+ }
+
+ private fun shouldBlock(): Boolean {
+ if (!LorenzUtils.inDungeons) return false
+ if (!LorenzMod.feature.dungeon.cleanEnd) return false
+
+ if (!bossDone) return false
+
+ //TODO remove
+ if (Minecraft.getMinecraft().thePlayer.isSneaking) return false
+
+ return true
+ }
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ bossDone = false
+ chestsSpawned = false
+ lastBossId = -1
+ }
+
+ @SubscribeEvent
+ fun onBossDead(event: DamageIndicatorFinalBossEvent) {
+ if (!LorenzUtils.inDungeons) return
+ if (bossDone) return
+
+ if (lastBossId == -1) {
+ lastBossId = event.id
+ }
+ }
+
+ @SubscribeEvent
+ fun onHealthUpdatePacket(event: PacketEvent.ReceiveEvent) {
+ if (!LorenzUtils.inDungeons) return
+ if (!LorenzMod.feature.dungeon.cleanEnd) return
+
+ if (bossDone) return
+ if (lastBossId == -1) return
+
+ val packet = event.packet
+ if (packet !is S1CPacketEntityMetadata) return
+ if (packet.entityId != lastBossId) return
+
+ for (watchableObject in packet.func_149376_c()) {
+ if (watchableObject.dataValueId == 6) {
+ val health = watchableObject.`object` as Float
+ if (health < 1) {
+ val dungeonFloor = DungeonData.dungeonFloor
+ LorenzUtils.chat("§eFloor $dungeonFloor done!")
+ bossDone = true
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onCheckRender(event: CheckRenderEntityEvent<*>) {
+ if (!shouldBlock()) return
+
+ val entity = event.entity
+
+ if (entity == Minecraft.getMinecraft().thePlayer) return
+
+ if (chestsSpawned) {
+ if (entity is EntityArmorStand) {
+ if (!entity.hasCustomName()) {
+ return
+ }
+ }
+ if (entity is EntityOtherPlayerMP) {
+ return
+ }
+ }
+
+ event.isCanceled = true
+ }
+
+ @SubscribeEvent
+ fun onReceivePacket(event: PacketEvent.ReceiveEvent) {
+ if (!shouldBlock()) return
+
+
+ if (event.packet is S2APacketParticles) {
+ event.isCanceled = true
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossDamageIndicator.kt b/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossDamageIndicator.kt
index 93de52220..5901dd29e 100644
--- a/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossDamageIndicator.kt
+++ b/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossDamageIndicator.kt
@@ -1,6 +1,7 @@
package at.lorenz.mod.dungeon.damageindicator
import at.lorenz.mod.LorenzMod
+import at.lorenz.mod.events.DamageIndicatorFinalBossEvent
import at.lorenz.mod.events.DungeonEnterEvent
import at.lorenz.mod.events.LorenzChatEvent
import at.lorenz.mod.utils.LorenzColor
@@ -25,6 +26,7 @@ class DungeonBossDamageIndicator {
var data = mutableMapOf<EntityLivingBase, EntityData>()
private var bossFinder: DungeonBossFinder? = null
private val decimalFormat = DecimalFormat("0.0")
+ private val maxHealth = mutableMapOf<UUID, Double>()
@SubscribeEvent
fun onDungeonStart(event: DungeonEnterEvent) {
@@ -101,6 +103,7 @@ class DungeonBossDamageIndicator {
try {
val entity = event.entity
val result = bossFinder?.shouldShow(entity) ?: return
+ checkLastBossDead(result.finalBoss, entity.entityId)
val ignoreBlocks = result.ignoreBlocks
val delayedStart = result.delayedStart
@@ -139,7 +142,11 @@ class DungeonBossDamageIndicator {
}
}
- private val maxHealth = mutableMapOf<UUID, Double>()
+ private fun checkLastBossDead(finalBoss: Boolean, id: Int) {
+ if (finalBoss) {
+ DamageIndicatorFinalBossEvent(id).postAndCatch()
+ }
+ }
private fun setMaxHealth(entity: EntityLivingBase, currentMaxHealth: Double) {
maxHealth[entity.uniqueID!!] = currentMaxHealth
diff --git a/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossFinder.kt b/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossFinder.kt
index 4b6607d92..33f09967c 100644
--- a/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossFinder.kt
+++ b/src/main/java/at/lorenz/mod/dungeon/damageindicator/DungeonBossFinder.kt
@@ -64,7 +64,7 @@ class DungeonBossFinder {
if (floor1bonzo2) {
if (entity is EntityOtherPlayerMP) {
if (entity.name == "Bonzo ") {
- return EntityResult(floor1bonzo2SpawnTime)
+ return EntityResult(floor1bonzo2SpawnTime, finalBoss = true)
}
}
}
@@ -93,7 +93,7 @@ class DungeonBossFinder {
//TODO only show scarf after (all/at least x) summons are dead?
val result = entity.name == "Scarf "
if (result) {
- return EntityResult(floor2secondPhaseSpawnTime)
+ return EntityResult(floor2secondPhaseSpawnTime, finalBoss = true)
}
}
}
@@ -123,7 +123,10 @@ class DungeonBossFinder {
if (floor3Professor) {
if (entity is EntityOtherPlayerMP) {
if (entity.name == "The Professor") {
- return EntityResult(floor3ProfessorSpawnTime, floor3ProfessorSpawnTime + 1_000 > System.currentTimeMillis())
+ return EntityResult(
+ floor3ProfessorSpawnTime,
+ floor3ProfessorSpawnTime + 1_000 > System.currentTimeMillis()
+ )
}
}
}
@@ -138,7 +141,7 @@ class DungeonBossFinder {
if (entity is EntityGuardian) {
if (floor3ProfessorGuardian) {
if (entity == floor3ProfessorGuardianEntity) {
- return EntityResult()
+ return EntityResult(finalBoss = true)
}
}
}
@@ -148,7 +151,7 @@ class DungeonBossFinder {
if (entity is EntityOtherPlayerMP) {
if (entity == floor5lividEntity) {
// ignoreBlocks(entity.getLorenzVec().distance(5.5, 69.0, -2.5) < 5)
- return EntityResult(floor5lividEntitySpawnTime, true)
+ return EntityResult(floor5lividEntitySpawnTime, true, finalBoss = true)
}
}
}
@@ -157,11 +160,14 @@ class DungeonBossFinder {
if (entity is EntityGiantZombie && !entity.isInvisible) {
if (floor6Giants && entity.posY > 68) {
val extraDelay = checkExtraF6GiantsDelay(entity)
- return EntityResult(floor6GiantsSpawnTime + extraDelay, floor6GiantsSpawnTime + extraDelay + 1_000 > System.currentTimeMillis())
+ return EntityResult(
+ floor6GiantsSpawnTime + extraDelay,
+ floor6GiantsSpawnTime + extraDelay + 1_000 > System.currentTimeMillis()
+ )
}
if (floor6Sadan) {
- return EntityResult(floor6SadanSpawnTime)
+ return EntityResult(floor6SadanSpawnTime, finalBoss = true)
}
}
}
diff --git a/src/main/java/at/lorenz/mod/dungeon/damageindicator/EntityResult.kt b/src/main/java/at/lorenz/mod/dungeon/damageindicator/EntityResult.kt
index ae229cf70..f0642b953 100644
--- a/src/main/java/at/lorenz/mod/dungeon/damageindicator/EntityResult.kt
+++ b/src/main/java/at/lorenz/mod/dungeon/damageindicator/EntityResult.kt
@@ -1,3 +1,3 @@
package at.lorenz.mod.dungeon.damageindicator
-class EntityResult(val delayedStart: Long = -1L, val ignoreBlocks: Boolean = false) \ No newline at end of file
+class EntityResult(val delayedStart: Long = -1L, val ignoreBlocks: Boolean = false, val finalBoss: Boolean = false) \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/events/DamageIndicatorFinalBossEvent.kt b/src/main/java/at/lorenz/mod/events/DamageIndicatorFinalBossEvent.kt
new file mode 100644
index 000000000..5b2715910
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/events/DamageIndicatorFinalBossEvent.kt
@@ -0,0 +1,3 @@
+package at.lorenz.mod.events
+
+class DamageIndicatorFinalBossEvent(val id: Int): LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/test/LorenzTest.kt b/src/main/java/at/lorenz/mod/test/LorenzTest.kt
index 480317608..01ecf3dcd 100644
--- a/src/main/java/at/lorenz/mod/test/LorenzTest.kt
+++ b/src/main/java/at/lorenz/mod/test/LorenzTest.kt
@@ -2,15 +2,39 @@ package at.lorenz.mod.test
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import at.lorenz.mod.LorenzMod
+import at.lorenz.mod.utils.GuiRender.renderString
+import at.lorenz.mod.utils.LorenzLogger
import net.minecraftforge.client.event.RenderGameOverlayEvent
class LorenzTest {
+
+ var log = LorenzLogger("debug/packets")
+
+ companion object {
+ var enabled = false
+ var text = ""
+
+ val debugLogger = LorenzLogger("debug/test")
+ }
@SubscribeEvent
fun renderOverlay(event: RenderGameOverlayEvent.Post) {
if (!LorenzMod.feature.debug.enabled) return
-// val currentScreen = Minecraft.getMinecraft().currentScreen
-//
-// LorenzMod.feature.debug.testPos.renderString("currentScreen: $currentScreen")
+ if (enabled) {
+ LorenzMod.feature.debug.testPos.renderString(text)
+ }
}
+
+// @SubscribeEvent
+// fun onReceivePacket(event: PacketEvent.ReceiveEvent) {
+// if (!LorenzMod.feature.debug.enabled) return
+//
+// var packet = event.packet
+// var javaClass = packet.javaClass
+// var name = javaClass.name
+//
+// if (enabled) {
+// log.log(name)
+// }
+// }
} \ No newline at end of file