Fix bad idle packets in <= 1.21.1

This commit is contained in:
FlorianMichael 2024-10-27 16:27:24 +01:00
parent 3b34d6349b
commit b37115fa33
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126

View File

@ -79,6 +79,8 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Shadow protected abstract void sendSneakingPacket();
@Shadow private boolean lastHorizontalCollision;
@WrapWithCondition(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;sendSneakingPacket()V"))
private boolean sendSneakingAfterSprinting(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_2);
@ -91,6 +93,16 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
}
}
@Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;lastHorizontalCollision:Z", ordinal = 0))
private boolean removeHorizontalCollisionFromOnGroundCheck(ClientPlayerEntity instance) {
// Since it doesn't exist in older versions, we need to exclude it from the check to prevent bad packets
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) {
return this.horizontalCollision;
} else {
return this.lastHorizontalCollision;
}
}
@WrapWithCondition(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;jump()V"))
private boolean dontJumpBeforeFlying(ClientPlayerEntity instance) {
return ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_20_5);