|
19 | 19 |
|
20 | 20 | import com.lambda.Lambda; |
21 | 21 | import com.lambda.interaction.request.rotation.RotationManager; |
22 | | -import net.minecraft.client.render.VertexConsumerProvider; |
23 | 22 | import net.minecraft.client.render.entity.LivingEntityRenderer; |
24 | | -import net.minecraft.client.render.entity.model.EntityModel; |
25 | 23 | import net.minecraft.client.render.entity.state.LivingEntityRenderState; |
26 | | -import net.minecraft.client.util.math.MatrixStack; |
27 | 24 | import net.minecraft.entity.LivingEntity; |
28 | | -import net.minecraft.util.math.MathHelper; |
29 | 25 | import org.spongepowered.asm.mixin.Mixin; |
30 | 26 | import org.spongepowered.asm.mixin.Unique; |
31 | 27 | import org.spongepowered.asm.mixin.injection.At; |
|
35 | 31 |
|
36 | 32 | import java.util.Objects; |
37 | 33 |
|
| 34 | +// This mixin's purpose is to set the player's pitch the current render pitch to correctly show the rotation |
| 35 | +// regardless of the camera position |
38 | 36 | @Mixin(LivingEntityRenderer.class) |
39 | | -public class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState, M extends EntityModel<? super S>> { |
| 37 | +public class LivingEntityRendererMixin<T extends LivingEntity, S extends LivingEntityRenderState> { |
40 | 38 | @Unique |
41 | 39 | private Float lambda$pitch = null; |
42 | 40 |
|
43 | | - // TODO: Fix all of this |
44 | | - @Inject(method = "render(Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD")) |
45 | | - private void injectRender(S livingEntityRenderState, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) { |
| 41 | + @Inject(method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V", at = @At("HEAD")) |
| 42 | + private void injectRender(T livingEntity, S livingEntityRenderState, float f, CallbackInfo ci) { |
46 | 43 | Float rotationPitch = RotationManager.getRenderPitch(); |
47 | 44 |
|
48 | 45 | this.lambda$pitch = null; |
49 | 46 |
|
50 | | - /*if (livingEntity != Lambda.getMc().player || rotationPitch == null) { |
| 47 | + if (livingEntity != Lambda.getMc().player || rotationPitch == null) { |
51 | 48 | return; |
52 | | - }*/ |
| 49 | + } |
53 | 50 |
|
54 | 51 | this.lambda$pitch = rotationPitch; |
55 | 52 | } |
56 | 53 |
|
57 | | - /*@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/util/math/MathHelper;lerp(FFF)F", ordinal = 0), require = 0) |
58 | | - private float injectRotationPitch(float g, float f, float s) { |
59 | | - return Objects.requireNonNullElseGet(lambda$pitch, () -> MathHelper.lerp(g, f, s)); |
60 | | - }*/ |
| 54 | + // FixMe: When there are no rotations, the pitch is always set to 0 |
| 55 | + @Redirect(method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getLerpedPitch(F)F", ordinal = 0), require = 0) |
| 56 | + private float injectRotationPitch(LivingEntity instance, float v) { |
| 57 | + return Objects.requireNonNullElse(lambda$pitch, v); |
| 58 | + } |
61 | 59 | } |
0 commit comments