-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLivingEntityRendererMixin.java
More file actions
58 lines (51 loc) · 3.19 KB
/
LivingEntityRendererMixin.java
File metadata and controls
58 lines (51 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.denizenscript.clientizen.mixin.render;
import com.denizenscript.clientizen.scripts.commands.AttachCommand;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LivingEntityRenderer.class)
public abstract class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> {
private Entity clientizen$renderingEntity;
@Inject(method = "setupTransforms", cancellable = true, at = @At("HEAD"))
private void clientizen$cancelAttachAnimation(T entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, CallbackInfo ci) {
AttachCommand.AttachData data = AttachCommand.attachedEntities.get(entity.getUuid());
if (data != null && data.noAnimation()) {
ci.cancel();
}
}
@Inject(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"))
private void clientizen$captureRenderingEntity(T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) {
clientizen$renderingEntity = livingEntity;
}
// TODO fix this (ordinal wrong maybe)
@ModifyVariable(
method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
at = @At(value = "STORE"), ordinal = 8)
private float clientizen$cancelAttachAngles(float animationProgress) {
if (clientizen$renderingEntity != null) {
AttachCommand.AttachData data = AttachCommand.attachedEntities.get(clientizen$renderingEntity.getUuid());
if (data != null && data.noAnimation()) {
return 0.0f;
}
}
return animationProgress;
}
@Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;setAngles(Lnet/minecraft/entity/Entity;FFFFF)V"))
private void clienizen$disableAnimations(M instance, Entity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
AttachCommand.AttachData data = AttachCommand.attachedEntities.get(entity.getUuid());
if (data == null || !data.noAnimation()) {
//noinspection unchecked
instance.setAngles((T) entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
}
}
}