aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-09-11 22:59:37 +0200
committerLorenz <lo.scherf@gmail.com>2022-09-11 22:59:37 +0200
commit7693ee41d191cec6584c9d5761e644fe4f738ea9 (patch)
tree3a608e88f9bd23625ffa0c669573e7d15308d86c /src/main/java/at/hannibal2/skyhanni/utils
parent8b152bcddf4a99a64bda5974fefe1d50cc0a8f19 (diff)
downloadskyhanni-7693ee41d191cec6584c9d5761e644fe4f738ea9.tar.gz
skyhanni-7693ee41d191cec6584c9d5761e644fe4f738ea9.tar.bz2
skyhanni-7693ee41d191cec6584c9d5761e644fe4f738ea9.zip
using method hasMaxHealth
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt11
2 files changed, 33 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
index 990812b11..d057abd90 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
@@ -1,6 +1,8 @@
package at.hannibal2.skyhanni.utils
+import at.hannibal2.skyhanni.utils.LorenzUtils.baseMaxHealth
import net.minecraft.entity.EntityLiving
+import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.util.AxisAlignedBB
@@ -43,13 +45,13 @@ object EntityUtils {
}
}
- fun EntityLiving.getNameTagWith(
- y: Int,
- contains: String,
- debugRightEntity: Boolean = false,
- inaccuracy: Double = 1.6,
- debugWrongEntity: Boolean = false,
- ): EntityArmorStand? {
+ fun EntityLiving.getNameTagWith(
+ y: Int,
+ contains: String,
+ debugRightEntity: Boolean = false,
+ inaccuracy: Double = 1.6,
+ debugWrongEntity: Boolean = false,
+ ): EntityArmorStand? {
val center = getLorenzVec().add(0, y, 0)
val a = center.add(-inaccuracy, -inaccuracy - 3, -inaccuracy).toBlocPos()
val b = center.add(inaccuracy, inaccuracy + 3, inaccuracy).toBlocPos()
@@ -69,4 +71,21 @@ object EntityUtils {
result
}
}
+
+ fun EntityLivingBase.hasMaxHealth(health: Int): Boolean {
+ return when (this.baseMaxHealth) {
+ health.toDouble() -> true
+
+ //Derpy
+ health.toDouble() * 2 -> true
+
+ //Corrupted
+ health.toDouble() * 3 -> true
+
+ //Derpy + Corrupted
+ health.toDouble() * 2 * 3 -> true
+
+ else -> false
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index afc35b3ec..86829a4b0 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -106,26 +106,32 @@ object NumberUtil {
decimal = processDecimal(1000, lastNumber, decimal)
lastNumber = 1000
}
+
'D' -> {
decimal = processDecimal(500, lastNumber, decimal)
lastNumber = 500
}
+
'C' -> {
decimal = processDecimal(100, lastNumber, decimal)
lastNumber = 100
}
+
'L' -> {
decimal = processDecimal(50, lastNumber, decimal)
lastNumber = 50
}
+
'X' -> {
decimal = processDecimal(10, lastNumber, decimal)
lastNumber = 10
}
+
'V' -> {
decimal = processDecimal(5, lastNumber, decimal)
lastNumber = 5
}
+
'I' -> {
decimal = processDecimal(1, lastNumber, decimal)
lastNumber = 1
@@ -157,10 +163,7 @@ object NumberUtil {
return isNotEmpty() && pattern.matcher(this).matches()
}
- fun percentageColor(
- have: Int,
- max: Int,
- ): LorenzColor {
+ fun percentageColor(have: Long, max: Long): LorenzColor {
val percentage = have.toDouble() / max.toDouble()
return when {
percentage > 0.9 -> LorenzColor.DARK_GREEN