aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-15 09:10:40 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-15 09:10:40 +0200
commit5d5c79f783b604ee84dbf131430a9d28252b88ea (patch)
tree14354d0eba148c63cd89b8cbac5a8d767c3109be
parent5d2045ce2b2a0da2b70987ccf373877370edb490 (diff)
downloadskyhanni-5d5c79f783b604ee84dbf131430a9d28252b88ea.tar.gz
skyhanni-5d5c79f783b604ee84dbf131430a9d28252b88ea.tar.bz2
skyhanni-5d5c79f783b604ee84dbf131430a9d28252b88ea.zip
fixed ender slayer damage indicator and added derpy support for damage indicator
-rw-r--r--src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt84
-rw-r--r--src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt65
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt14
3 files changed, 84 insertions, 79 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt
index 84d19f81e..e47efff76 100644
--- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossDamageIndicator.kt
@@ -165,7 +165,9 @@ class BossDamageIndicator {
//Hides the damage indicator when in hit phase or in laser phase
if (entity is EntityEnderman) {
var hidden = false
- if (entity.hasNameTagWith(3, " Hit")) hidden = true
+ val hasNameTagWith = entity.hasNameTagWith(3, " Hit")
+// println("is in hit phase: $hasNameTagWith")
+ if (hasNameTagWith) hidden = true
if (entity.ridingEntity != null) hidden = true
entityData.hidden = hidden
}
@@ -173,62 +175,23 @@ class BossDamageIndicator {
if (!entityData.hidden) {
//custom prefix and health for the four different ender slayers
when (maxHealth) {
- 300_000 -> {
- calcMaxHealth = 100_000
- if (health > 200_000) {
- calcHealth -= 200_000
- extraPrefix = "1/3"
- } else if (health > 100_000) {
- calcHealth -= 100_000
- extraPrefix = "2/3"
- } else {
- calcHealth = health
- extraPrefix = "3/3"
- }
- }
- 15_000_000 -> {
- calcMaxHealth = 5_000_000
- if (health > 10_000_000) {
- extraPrefix = "1/3"
- calcHealth -= 10_000_000
- } else if (health > 5_000_000) {
- calcHealth -= 5_000_000
- extraPrefix = "2/3"
- } else {
- calcHealth = health
- extraPrefix = "3/3"
- }
- }
- 66_666_666 -> {
- calcMaxHealth = 22_222_222
- if (health > 44_444_444) {
- calcHealth -= 44_444_444
- extraPrefix = "1/3"
- } else if (health > 22_222_222) {
- calcHealth -= 22_222_222
- extraPrefix = "2/3"
- } else {
- calcHealth = health
- extraPrefix = "3/3"
- }
-
- }
- 300_000_000 -> {
- calcMaxHealth = 50_000_000
- if (health > 250_000_000) {
- calcHealth -= 250_000_000
+ 300_000_000, 600_000_000 -> {
+ val step = maxHealth / 6
+ calcMaxHealth = step
+ if (health > step * 5) {
+ calcHealth -= step * 5
extraPrefix = "1/6"
- } else if (health > 200_000_000) {
- calcHealth -= 200_000_000
+ } else if (health > step * 4) {
+ calcHealth -= step * 4
extraPrefix = "2/6"
- } else if (health > 150_000_000) {
- calcHealth -= 150_000_000
+ } else if (health > step * 3) {
+ calcHealth -= step * 3
extraPrefix = "3/6"
- } else if (health > 100_000_000) {
- calcHealth -= 100_000_000
+ } else if (health > step * 2) {
+ calcHealth -= step * 2
extraPrefix = "4/6"
- } else if (health > 50_000_000) {
- calcHealth -= 50_000_000
+ } else if (health > step) {
+ calcHealth -= step
extraPrefix = "5/6"
} else {
calcHealth = health
@@ -236,10 +199,19 @@ class BossDamageIndicator {
}
}
else -> {
- //TODO this is a workaround, find a sweet solution pls?
- LorenzUtils.warning("§c[SkyHanni] Unknown max enderman health: $maxHealth")
- entityData.hidden = true
+ val step = maxHealth / 3
+ calcMaxHealth = step
+ if (health > step * 2) {
+ calcHealth -= step * 2
+ extraPrefix = "1/3"
+ } else if (health > step) {
+ calcHealth -= step
+ extraPrefix = "2/3"
+ } else {
+ calcHealth = health
+ extraPrefix = "3/3"
+ }
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt
index 80d480e00..2560a44ed 100644
--- a/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/damageindicator/BossFinder.kt
@@ -195,6 +195,10 @@ class BossFinder {
if (entity.baseMaxHealth == 50_000_000.0) {
return EntityResult(bossType = BossType.NETHER_ASHFANG)
}
+ //Derpy
+ if (entity.baseMaxHealth == 100_000_000.0) {
+ return EntityResult(bossType = BossType.NETHER_ASHFANG)
+ }
}
}
}
@@ -228,6 +232,14 @@ class BossFinder {
) {
return EntityResult(bossType = BossType.END_ENDERMAN_SLAYER)
}
+ //Derpy
+ if (entity.baseMaxHealth == 600_000.0 ||
+ entity.baseMaxHealth == 30_000_000.0 ||
+ entity.baseMaxHealth == 66_666_666.0 * 2.0 ||
+ entity.baseMaxHealth == 600_000_000.0
+ ) {
+ return EntityResult(bossType = BossType.END_ENDERMAN_SLAYER)
+ }
}
}
@@ -248,19 +260,31 @@ class BossFinder {
if (entity.baseMaxHealth == 10_000_000.0) {
return EntityResult(bossType = BossType.HUB_REVENANT_HORROR)
}
+ //Derpy
+ if (entity.baseMaxHealth == 20_000_000.0) {
+ return EntityResult(bossType = BossType.HUB_REVENANT_HORROR)
+ }
}
}
if (entity is EntityMagmaCube) {
- if (entity.baseMaxHealth == 200_000_000.0) {
- if (entity.hasNameTagWith(15, "§e﴾ §8[§7Lv500§8] §l§4§lMagma Boss§r ")) {
+ if (entity.hasNameTagWith(15, "§e﴾ §8[§7Lv500§8] §l§4§lMagma Boss§r ")) {
+ if (entity.baseMaxHealth == 200_000_000.0) {
+ return EntityResult(bossType = BossType.NETHER_MAGMA_BOSS, ignoreBlocks = true)
+ }
+ //Derpy
+ if (entity.baseMaxHealth == 400_000_000.0) {
return EntityResult(bossType = BossType.NETHER_MAGMA_BOSS, ignoreBlocks = true)
}
}
}
if (entity is EntityHorse) {
- if (entity.baseMaxHealth == 3_000_000.0) {
- if (entity.hasNameTagWith(15, "§8[§7Lv100§8] §c§6Headless Horseman§r ")) {
+ if (entity.hasNameTagWith(15, "§8[§7Lv100§8] §c§6Headless Horseman§r ")) {
+ if (entity.baseMaxHealth == 3_000_000.0) {
+ return EntityResult(bossType = BossType.HUB_HEADLESS_HORSEMAN)
+ }
+ //Derpy
+ if (entity.baseMaxHealth == 6_000_000.0) {
return EntityResult(bossType = BossType.HUB_HEADLESS_HORSEMAN)
}
}
@@ -470,33 +494,28 @@ class BossFinder {
fun EntityLiving.hasNameTagWith(
y: Int,
contains: String,
- debug: Boolean = false,
+ debugRightEntity: Boolean = false,
consumer: (EntityArmorStand) -> Unit = {},
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
): Boolean {
val center = getLorenzVec().add(0, y, 0)
- val a = center.add(-1.6, -1.6 - y, -1.6).toBlocPos()
- val b = center.add(1.6, 1.6, 1.6).toBlocPos()
+ val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
+ val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
val alignedBB = AxisAlignedBB(a, b)
val clazz = EntityArmorStand::class.java
- return worldObj.getEntitiesWithinAABB(clazz, alignedBB).any {
+ val found = worldObj.getEntitiesWithinAABB(clazz, alignedBB)
+ return found.any {
val result = it.name.contains(contains)
- if (!result) {
- if (debug) {
- println("wrong entity in aabb: '" + it.name + "'")
- }
+ if (debugWrongEntity && !result) {
+ println("wrong entity in aabb: '" + it.name + "'")
}
- if (result && debug) {
- println("hasNameTagWith debug!")
- val locNametag = it.getLorenzVec()
- val locMob = this.getLorenzVec()
- println("mob: $locMob")
- println("nametag: $locNametag")
- val distance = locMob.distance(locNametag)
- println("distance: $distance")
-
-
+ if (debugRightEntity && result) {
+ println("mob: " + center.printWithAccuracy(2))
+ println("nametag: " + it.getLorenzVec().printWithAccuracy(2))
+ println("accuracy: " + it.getLorenzVec().subtract(center).printWithAccuracy(3))
}
if (result) consumer(it)
- return result
+ result
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 510b04fb8..1388c076a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -6,6 +6,7 @@ import net.minecraft.util.Rotations
import net.minecraft.util.Vec3
import kotlin.math.cos
import kotlin.math.pow
+import kotlin.math.round
import kotlin.math.sin
data class LorenzVec(
@@ -54,6 +55,19 @@ data class LorenzVec(
fun add(other: LorenzVec) = LorenzVec(x + other.x, y + other.y, z + other.z)
+ fun subtract(other: LorenzVec) = LorenzVec(x - other.x, y - other.y, z - other.z)
+
+ fun printWithAccuracy(accuracy: Int): String {
+ val x = (round(x * accuracy) / accuracy)
+ val y = (round(y * accuracy) / accuracy)
+ val z = (round(z * accuracy) / accuracy)
+ return LorenzVec(x, y, z).toCleanString()
+ }
+
+ private fun toCleanString(): String {
+ return "$x $y $z"
+ }
+
companion object {
fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec {
val yaw: Double = (yaw + 90) * Math.PI / 180