aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/mixins/hooks
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-02 20:38:55 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-02-02 20:38:55 +0100
commitee0ae23560e911fbec5e5262feaaa58dc5d52e7a (patch)
treeecd2221d199c8768aae9442c4c81922b0e0352f1 /src/main/java/at/hannibal2/skyhanni/mixins/hooks
parent6173d681603839168db97e3fbd2cb74c2e7a2897 (diff)
downloadskyhanni-ee0ae23560e911fbec5e5262feaaa58dc5d52e7a.tar.gz
skyhanni-ee0ae23560e911fbec5e5262feaaa58dc5d52e7a.tar.bz2
skyhanni-ee0ae23560e911fbec5e5262feaaa58dc5d52e7a.zip
Created EntityMaxHealthUpdateEvent, started with better logic for colored mobs.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/mixins/hooks')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
new file mode 100644
index 000000000..371f97a68
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
@@ -0,0 +1,63 @@
+package at.hannibal2.skyhanni.mixins.hooks
+
+import at.hannibal2.skyhanni.events.RenderMobColoredEvent
+import at.hannibal2.skyhanni.events.ResetEntityHurtEvent
+import net.minecraft.entity.EntityLivingBase
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class RenderLivingEntityHelper {
+
+ @SubscribeEvent
+ fun onWorldChange(event: WorldEvent.Load) {
+ entityColorMap.clear()
+ entityNoHurTime.clear()
+ }
+
+ companion object {
+ private val entityColorMap = mutableMapOf<EntityLivingBase, Int>()
+ private val entityNoHurTime = mutableListOf<EntityLivingBase>()
+
+ fun <T : EntityLivingBase> setEntityColor(entity: T, color: Int) {
+ entityColorMap[entity] = color
+ }
+
+ fun <T : EntityLivingBase> setNoHurtTime(entity: T) {
+ entityNoHurTime.add(entity)
+ }
+
+ fun <T : EntityLivingBase> setColorMultiplier(entity: T, ): Int {
+ if (entityColorMap.containsKey(entity)) {
+ return entityColorMap[entity]!!
+ }
+
+ //TODO remove event
+ val event = RenderMobColoredEvent(entity, 0)
+ event.postAndCatch()
+ val color = event.color
+ if (color != 0) {
+ //TODO remove?
+ entityColorMap[entity] = color
+ }
+
+ return color
+ }
+
+ fun <T : EntityLivingBase> changeHurtTime(entity: T): Int {
+ if (entityNoHurTime.contains(entity)) {
+ return 0
+ }
+
+ //TODO remove event
+ val event = ResetEntityHurtEvent(entity, false)
+ event.postAndCatch()
+ val shouldReset = event.shouldReset
+
+ if (shouldReset) {
+ //TODO remove?
+ entityNoHurTime.add(entity)
+ }
+ return if (shouldReset) 0 else entity.hurtTime
+ }
+ }
+} \ No newline at end of file