From 49db8cb3cbfbe63eb8fbf5f4be38fd35ee4e4025 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sun, 27 Oct 2024 17:28:30 +0100 Subject: [PATCH] Fix entity position behaviour in <= 1.21.1 as well EntityPositionPacket's now support entities where the logical movement side is on the client, revert this behaviour and fixup our previous injection for <= 1.19.3 which already implemented that behaviour. --- .../minecraft/network/MixinClientPlayNetworkHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java index 7055cb7e..afbfaee0 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/network/MixinClientPlayNetworkHandler.java @@ -90,6 +90,11 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH super(client, connection, connectionState); } + @WrapWithCondition(method = "onEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/TrackedPosition;setPos(Lnet/minecraft/util/math/Vec3d;)V", ordinal = 0)) + private boolean dontHandleEntityPositionChange(TrackedPosition instance, Vec3d pos) { + return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_2); + } + @Redirect(method = "onEntityPosition", at = @At(value = "INVOKE", target = "Ljava/util/OptionalInt;isPresent()Z")) private boolean dontHandleRemovedVehiclePositionChange(OptionalInt instance) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) { @@ -202,7 +207,8 @@ public abstract class MixinClientPlayNetworkHandler extends ClientCommonNetworkH @Redirect(method = {"onEntityPosition", "onEntity"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isLogicalSideForUpdatingMovement()Z")) private boolean allowPlayerToBeMovedByEntityPackets(Entity instance) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_3) || ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { - return instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient; + final boolean logicalMovementSide = instance.getControllingPassenger() instanceof PlayerEntity player ? player.isMainPlayer() : !instance.getWorld().isClient; + return !logicalMovementSide; // Older versions had the logic which is now executed if logicalMovementSide is false, so we need to invert values } else { return instance.isLogicalSideForUpdatingMovement(); }