aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-16 02:32:07 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-16 02:32:07 +0200
commit6a057410182ca7671215e6fecc9e289e50ceb0fc (patch)
treed472441699497cad6d4aaa3a56ea1db19cca7fdc /src/main/java/at/hannibal2
parent679689ad55e2ff4fa73e026b202f1cd7d19ddfaf (diff)
downloadskyhanni-6a057410182ca7671215e6fecc9e289e50ceb0fc.tar.gz
skyhanni-6a057410182ca7671215e6fecc9e289e50ceb0fc.tar.bz2
skyhanni-6a057410182ca7671215e6fecc9e289e50ceb0fc.zip
hide damage splashes around damage indicator
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/damageindicator/DamageCounter.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/damageindicator/OldDamage.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt64
6 files changed, 111 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 03495f695..a4f608824 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -34,6 +34,7 @@ public class Misc {
@ConfigEditorDropdown(values = {"Disabled", "Full Name", "Short Name"})
@ConfigAccordionId(id = 1)
public int damageIndicatorBossName = 1;
+
@Expose
@ConfigOption(
name = "Select Boss",
@@ -65,6 +66,11 @@ public class Misc {
//TODO only show currently working and tested features
public List<Integer> damageIndicatorBossesToShow = new ArrayList<>(Arrays.asList(0, 1, 2, 5, 6, 7, 8, 9));
+ @Expose
+ @ConfigOption(name = "Hide Damage Splash", desc = "Hiding damage splashes around the damage indicator")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean damageIndicatorHideDamageSplash = false;
@Expose
@ConfigOption(name = "Pet Display", desc = "Show the currently active pet.")
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt
index 0841984d3..4f372bee8 100644
--- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt
@@ -13,17 +13,21 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.entity.EntityLivingBase
+import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.monster.EntityEnderman
import net.minecraft.entity.monster.EntityMagmaCube
import net.minecraft.entity.monster.EntityZombie
import net.minecraft.entity.passive.EntityWolf
+import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.event.entity.EntityJoinWorldEvent
import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
import java.text.DecimalFormat
import java.util.*
+import java.util.regex.Pattern
import kotlin.math.max
class BossDamageIndicator {
@@ -32,6 +36,7 @@ class BossDamageIndicator {
private var bossFinder: BossFinder? = null
private val decimalFormat = DecimalFormat("0.0")
private val maxHealth = mutableMapOf<UUID, Int>()
+ private val damagePattern = Pattern.compile("✧?(\\d+[⚔+✧❤♞☄✷ﬗ]*)")
@SubscribeEvent
fun onWorldLoad(event: WorldEvent.Load) {
@@ -445,4 +450,26 @@ class BossDamageIndicator {
fun onWorldRender(event: EntityJoinWorldEvent) {
bossFinder?.handleNewEntity(event.entity)
}
+
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ fun onRenderLiving(e: RenderLivingEvent.Specials.Pre<EntityLivingBase>) {
+ if (!SkyHanniMod.feature.misc.damageIndicatorHideDamageSplash) return
+
+ val entity = e.entity
+ if (entity.ticksExisted > 300 || entity !is EntityArmorStand) return
+ if (!entity.hasCustomName()) return
+ if (entity.isDead) return
+ val strippedName = entity.customNameTag.removeColor()
+ val damageMatcher = damagePattern.matcher(strippedName)
+ if (damageMatcher.matches()) {
+ if (data.values.any {
+ val distance = it.entity.getLorenzVec().distance(entity.getLorenzVec())
+ val found = distance < 4.5
+ found
+ }) {
+ e.isCanceled = true
+ }
+ }
+ }
+
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/DamageCounter.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/DamageCounter.kt
new file mode 100644
index 000000000..a7732a8a9
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/DamageCounter.kt
@@ -0,0 +1,9 @@
+package at.hannibal2.skyhanni.damageindicator
+
+class DamageCounter {
+
+ var currentDamage = 0L
+ var oldDamages = mutableListOf<OldDamage>()
+ var firstTick = 0L
+
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt
index 2f2738095..f1514ae93 100644
--- a/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/EntityData.kt
@@ -9,6 +9,7 @@ class EntityData(
var delayedStart: Long,
val finalDungeonBoss: Boolean,
val bossType: BossType,
+ val damageCounter: DamageCounter = DamageCounter(),
var lastHealth: Int = 0,
var healthText: String = "",
@@ -17,5 +18,5 @@ class EntityData(
var namePrefix: String = "",
var nameSuffix: String = "",
var dead: Boolean = false,
- var deathLocation: LorenzVec? = null
+ var deathLocation: LorenzVec? = null,
) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/OldDamage.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/OldDamage.kt
new file mode 100644
index 000000000..20fb9cbfa
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/OldDamage.kt
@@ -0,0 +1,4 @@
+package at.hannibal2.skyhanni.damageindicator
+
+class OldDamage(val time: Long, val damage: Long) {
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
index 1b0864385..d6f90d7b0 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
@@ -10,6 +10,9 @@ import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
import net.minecraft.client.Minecraft
import net.minecraft.nbt.NBTTagCompound
+import net.minecraft.network.play.server.S0EPacketSpawnObject
+import net.minecraft.network.play.server.S0FPacketSpawnMob
+import net.minecraft.network.play.server.S1CPacketEntityMetadata
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -20,6 +23,7 @@ class LorenzTest {
companion object {
var enabled = false
+ var togglePacketLog = false
var text = ""
val debugLogger = LorenzLogger("debug/test")
@@ -95,6 +99,7 @@ class LorenzTest {
}
fun testCommand(args: Array<String>) {
+ togglePacketLog = !togglePacketLog
}
}
@@ -109,7 +114,64 @@ class LorenzTest {
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
fun onChatPacket(event: PacketEvent.ReceiveEvent) {
-// packetLog.log(event.packet.toString())
+ val packet = event.packet
+ val name = packet.javaClass.simpleName
+ if (!togglePacketLog) return
+
+ packetLog.log(name)
+
+ if (packet is S0FPacketSpawnMob) {
+ packetLog.log("")
+ packetLog.log("Spawn Mob!")
+ for (watchableObject in packet.func_149027_c()) {
+ val any = watchableObject.`object`
+ val simpleName = any.javaClass.simpleName
+
+ packetLog.log("javaClass: $simpleName")
+ packetLog.log("object: $any")
+ packetLog.log(" ")
+ }
+ packetLog.log(" ")
+ }
+ if (packet is S1CPacketEntityMetadata) {
+ packetLog.log("")
+ packetLog.log("Entity Metadata")
+ for (watchableObject in packet.func_149376_c()) {
+ val any = watchableObject.`object`
+ val simpleName = any.javaClass.simpleName
+
+ packetLog.log("javaClass: $simpleName")
+ packetLog.log("object: $any")
+ packetLog.log(" ")
+ }
+ packetLog.log(" ")
+ }
+// if (packet is S20PacketEntityProperties) {
+// packetLog.log("")
+// packetLog.log("Entity Properties")
+// for (watchableObject in packet.func_149441_d()) {
+// val any = watchableObject.`object`
+// val simpleName = any.javaClass.simpleName
+//
+// packetLog.log("javaClass: $simpleName")
+// packetLog.log("object: $any")
+// packetLog.log(" ")
+// }
+// packetLog.log(" ")
+//
+//
+// }
+ if (packet is S0EPacketSpawnObject) {
+ packetLog.log("Spawn Object")
+ }
+
+
+// if (packet is S2CPacketSpawnGlobalEntity) {
+//
+// }
+// if (packet is S2CPacketSpawnGlobalEntity) {
+//
+// }
}
// @SubscribeEvent