aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/mixins
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-06-08 23:46:53 +1000
committerGitHub <noreply@github.com>2024-06-08 23:46:53 +1000
commita2f29b2bfe846c9d0cd2a45b2b8352bab556da37 (patch)
tree53f830999399a1d005e16a53beec041337629285 /src/main/java/at/hannibal2/skyhanni/mixins
parentf5aa000de598fd4f367ca37cb8f2e1935f64b634 (diff)
downloadskyhanni-a2f29b2bfe846c9d0cd2a45b2b8352bab556da37.tar.gz
skyhanni-a2f29b2bfe846c9d0cd2a45b2b8352bab556da37.tar.bz2
skyhanni-a2f29b2bfe846c9d0cd2a45b2b8352bab556da37.zip
Even more annotation (#2031)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/mixins')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt95
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java4
2 files changed, 50 insertions, 49 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
index eb7456b4c..ba8efc2b5 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderLivingEntityHelper.kt
@@ -1,75 +1,76 @@
package at.hannibal2.skyhanni.mixins.hooks
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.SkyHanniDebugsAndTests
import net.minecraft.entity.EntityLivingBase
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-class RenderLivingEntityHelper {
+@SkyHanniModule
+object RenderLivingEntityHelper {
+
+ private val entityColorMap = mutableMapOf<EntityLivingBase, Int>()
+ private val entityColorCondition = mutableMapOf<EntityLivingBase, () -> Boolean>()
+
+ private val entityNoHurtTimeCondition = mutableMapOf<EntityLivingBase, () -> Boolean>()
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
entityColorMap.clear()
entityColorCondition.clear()
- entityNoHurTimeCondition.clear()
+ entityNoHurtTimeCondition.clear()
}
- companion object {
-
- private val entityColorMap = mutableMapOf<EntityLivingBase, Int>()
- private val entityColorCondition = mutableMapOf<EntityLivingBase, () -> Boolean>()
-
- private val entityNoHurTimeCondition = mutableMapOf<EntityLivingBase, () -> Boolean>()
-
- fun <T : EntityLivingBase> removeEntityColor(entity: T) {
- entityColorMap.remove(entity)
- entityColorCondition.remove(entity)
- }
+ fun <T : EntityLivingBase> removeEntityColor(entity: T) {
+ entityColorMap.remove(entity)
+ entityColorCondition.remove(entity)
+ }
- fun <T : EntityLivingBase> setEntityColor(entity: T, color: Int, condition: () -> Boolean) {
- entityColorMap[entity] = color
- entityColorCondition[entity] = condition
- }
+ fun <T : EntityLivingBase> setEntityColor(entity: T, color: Int, condition: () -> Boolean) {
+ entityColorMap[entity] = color
+ entityColorCondition[entity] = condition
+ }
- fun <T : EntityLivingBase> setNoHurtTime(entity: T, condition: () -> Boolean) {
- entityNoHurTimeCondition[entity] = condition
- }
+ fun <T : EntityLivingBase> setNoHurtTime(entity: T, condition: () -> Boolean) {
+ entityNoHurtTimeCondition[entity] = condition
+ }
- fun <T : EntityLivingBase> setEntityColorWithNoHurtTime(entity: T, color: Int, condition: () -> Boolean) {
- setEntityColor(entity, color, condition)
- setNoHurtTime(entity, condition)
- }
+ fun <T : EntityLivingBase> setEntityColorWithNoHurtTime(entity: T, color: Int, condition: () -> Boolean) {
+ setEntityColor(entity, color, condition)
+ setNoHurtTime(entity, condition)
+ }
- fun <T : EntityLivingBase> removeNoHurtTime(entity: T) {
- entityNoHurTimeCondition.remove(entity)
- }
+ fun <T : EntityLivingBase> removeNoHurtTime(entity: T) {
+ entityNoHurtTimeCondition.remove(entity)
+ }
- fun <T : EntityLivingBase> removeCustomRender(entity: T) {
- removeEntityColor(entity)
- removeNoHurtTime(entity)
- }
+ fun <T : EntityLivingBase> removeCustomRender(entity: T) {
+ removeEntityColor(entity)
+ removeNoHurtTime(entity)
+ }
- fun <T : EntityLivingBase> internalSetColorMultiplier(entity: T): Int {
- if (!SkyHanniDebugsAndTests.globalRender) return 0
- if (entityColorMap.containsKey(entity)) {
- val condition = entityColorCondition[entity]!!
- if (condition.invoke()) {
- return entityColorMap[entity]!!
- }
+ @JvmStatic
+ fun <T : EntityLivingBase> internalSetColorMultiplier(entity: T): Int {
+ if (!SkyHanniDebugsAndTests.globalRender) return 0
+ if (entityColorMap.containsKey(entity)) {
+ val condition = entityColorCondition[entity]!!
+ if (condition.invoke()) {
+ return entityColorMap[entity]!!
}
- return 0
}
+ return 0
+ }
- fun <T : EntityLivingBase> internalChangeHurtTime(entity: T): Int {
- if (!SkyHanniDebugsAndTests.globalRender) return entity.hurtTime
- run {
- val condition = entityNoHurTimeCondition[entity] ?: return@run
- if (condition.invoke()) {
- return 0
- }
+ @JvmStatic
+ fun <T : EntityLivingBase> internalChangeHurtTime(entity: T): Int {
+ if (!SkyHanniDebugsAndTests.globalRender) return entity.hurtTime
+ run {
+ val condition = entityNoHurtTimeCondition[entity] ?: return@run
+ if (condition.invoke()) {
+ return 0
}
- return entity.hurtTime
}
+ return entity.hurtTime
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
index f23b290f1..5ef136e3f 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.java
@@ -23,12 +23,12 @@ public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> exte
@Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true)
private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable<Integer> cir) {
- cir.setReturnValue(RenderLivingEntityHelper.Companion.internalSetColorMultiplier(entity));
+ cir.setReturnValue(RenderLivingEntityHelper.internalSetColorMultiplier(entity));
}
@Redirect(method = "setBrightness", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/EntityLivingBase;hurtTime:I", opcode = Opcodes.GETFIELD))
private int changeHurtTime(EntityLivingBase entity) {
- return RenderLivingEntityHelper.Companion.internalChangeHurtTime(entity);
+ return RenderLivingEntityHelper.internalChangeHurtTime(entity);
}
@Inject(method = "renderLayers", at = @At("HEAD"), cancellable = true)