From fbdc927f118e636396a67e62fd193f1948239b79 Mon Sep 17 00:00:00 2001 From: Wide_Cat Date: Mon, 23 Dec 2024 21:04:51 +0000 Subject: [PATCH] Fix meteor rotations being rendered on other players in third person --- .../mixin/PlayerEntityRendererMixin.java | 8 ++++---- .../mixininterface/IEntityRenderState.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java index 14800b114b..60e33cedce 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/PlayerEntityRendererMixin.java @@ -7,8 +7,6 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import meteordevelopment.meteorclient.MeteorClient; -import meteordevelopment.meteorclient.mixininterface.IEntityRenderState; import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.Chams; @@ -28,6 +26,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import static meteordevelopment.meteorclient.MeteorClient.mc; + @Mixin(PlayerEntityRenderer.class) public abstract class PlayerEntityRendererMixin { // Chams @@ -45,7 +45,7 @@ public abstract class PlayerEntityRendererMixin { @Inject(method = "updateRenderState(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/render/entity/state/PlayerEntityRenderState;F)V", at = @At("RETURN")) private void updateRenderState$scale(AbstractClientPlayerEntity player, PlayerEntityRenderState state, float f, CallbackInfo info) { if (!chams.isActive() || !chams.players.get()) return; - if (chams.ignoreSelf.get() && player == MeteorClient.mc.player) return; + if (chams.ignoreSelf.get() && player == mc.player) return; float v = chams.playersScale.get().floatValue(); state.baseScale *= v; @@ -82,7 +82,7 @@ public abstract class PlayerEntityRendererMixin { @Inject(method = "updateRenderState(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/client/render/entity/state/PlayerEntityRenderState;F)V", at = @At("RETURN")) private void updateRenderState$rotations(AbstractClientPlayerEntity player, PlayerEntityRenderState state, float f, CallbackInfo info) { - if (Rotations.rotating && ((IEntityRenderState) state).meteor$getEntity() == MeteorClient.mc.player) { + if (Rotations.rotating && player == mc.player) { state.bodyYaw = Rotations.serverYaw; state.pitch = Rotations.serverPitch; } diff --git a/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityRenderState.java b/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityRenderState.java index 41d4dc2d56..24df7003f3 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityRenderState.java +++ b/src/main/java/meteordevelopment/meteorclient/mixininterface/IEntityRenderState.java @@ -5,9 +5,26 @@ package meteordevelopment.meteorclient.mixininterface; +import meteordevelopment.meteorclient.mixin.EntityRenderDispatcherMixin; +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.render.entity.state.EntityRenderState; +import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.Entity; public interface IEntityRenderState { + /** + * Returns the entity that the render state refers to; necessary in scenarios when you want to perform an entity + * rendering task with data that isn't present in the render state.

+ * + * The entity is only set after the render state is retrieved in EntityRenderDispatcher#render, so make sure not + * to call this before that point (e.g. mixing into an updateRenderState method), otherwise the entity returned will + * not be the same one that the render state is referring to. + * + * @return The entity that the render state refers to + * + * @see EntityRenderDispatcherMixin#render$getAndUpdateRenderState(EntityRenderState, Entity, double, double, double, float, MatrixStack, VertexConsumerProvider, int, EntityRenderer) + */ Entity meteor$getEntity(); void meteor$setEntity(Entity entity);