-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2fca56
commit e80d1cc
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...java/com/mmodding/mmodding_lib/library/client/render/entity/animation/DeathAnimation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.mmodding.mmodding_lib.library.client.render.entity.animation; | ||
|
||
public interface DeathAnimation { | ||
|
||
boolean applyRedOverlayOnDeath(); | ||
|
||
int getDeathTime(); | ||
|
||
Runnable executeDeathAnimation(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...main/java/com/mmodding/mmodding_lib/mixin/injectors/client/LivingEntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.mmodding.mmodding_lib.mixin.injectors.client; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.mmodding.mmodding_lib.library.client.render.entity.animation.DeathAnimation; | ||
import net.minecraft.client.render.OverlayTexture; | ||
import net.minecraft.client.render.entity.LivingEntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.util.math.Quaternion; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(LivingEntityRenderer.class) | ||
public class LivingEntityRendererMixin<T extends LivingEntity> { | ||
|
||
@ModifyExpressionValue(method = "getOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/OverlayTexture;getV(Z)I")) | ||
private static int conditionallyCancelDeathAnimationRedOverlay(int original, LivingEntity entity, float whiteOverlayProgress) { | ||
if (!(entity instanceof DeathAnimation animation) || animation.executeDeathAnimation() != null) { | ||
return original; | ||
} | ||
else { | ||
boolean bool = entity.hurtTime > 0 || (animation.applyRedOverlayOnDeath() && entity.deathTime > 0); | ||
return OverlayTexture.packUv(OverlayTexture.getU(whiteOverlayProgress), OverlayTexture.getV(bool)); | ||
} | ||
} | ||
|
||
@WrapOperation(method = "setupTransforms", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lnet/minecraft/util/math/Quaternion;)V", ordinal = 1)) | ||
private void conditionallyCancelDeathAnimationTransform(MatrixStack instance, Quaternion quaternion, Operation<Void> original, @Local(argsOnly = true) T entity) { | ||
if (!(entity instanceof DeathAnimation animation) || animation.executeDeathAnimation() != null) { | ||
original.call(instance, quaternion); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters