diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt | 33 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 11 |
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 |