diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java index 758a11a99..589f0dbde 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinMultiplayerServerListWidget_ServerEntry.java @@ -32,6 +32,7 @@ import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget; import net.minecraft.client.gui.screen.world.WorldIcon; import net.minecraft.client.network.ServerInfo; +import net.minecraft.client.render.RenderLayer; import net.minecraft.text.OrderedText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Text; @@ -44,6 +45,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ThreadPoolExecutor; +import java.util.function.Function; @Mixin(MultiplayerServerListWidget.ServerEntry.class) public abstract class MixinMultiplayerServerListWidget_ServerEntry { @@ -98,11 +100,10 @@ private int disableServerPinging(int x) { return x; } - // TODO UPDATE-1.21.3 -// @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0)) -// private boolean disableServerPinging(DrawContext instance, Identifier texture, int x, int y, int width, int height) { -// return !viaFabricPlus$disableServerPinging; // Remove ping bar -// } + @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0)) + private boolean disableServerPinging(DrawContext instance, Function renderLayers, Identifier sprite, int x, int y, int width, int height) { + return !viaFabricPlus$disableServerPinging; // Remove ping bar + } @WrapWithCondition(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;setTooltip(Ljava/util/List;)V")) private boolean disableServerPinging(MultiplayerScreen instance, List tooltip) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java index 2b72ff945..143c2be15 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinClientPlayerEntity.java @@ -140,12 +140,6 @@ private boolean allowElytraWhenClimbing(boolean original) { return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_15_1) && original; } - // TODO UPDATE-1.21.3 -// @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z", ordinal = 3)) -// private boolean allowElytraInVehicle(ClientPlayerEntity instance) { -// return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_4) && instance.hasVehicle(); -// } - @Inject(method = "tickMovement()V", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isCamera()Z")), at = @At(value = "INVOKE", target = "Lnet/minecraft/util/PlayerInput;sneak()Z", ordinal = 0)) @@ -209,13 +203,14 @@ private int moveLastPosPacketIncrement(ClientPlayerEntity instance) { } } - // TODO UPDATE-1.21.3 -// @Inject(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;hasVehicle()Z")) -// private void moveLastPosPacketIncrement(CallbackInfo ci) { -// if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { -// this.ticksSinceLastPositionPacketSent++; -// } -// } + @Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;ticksSinceLastPositionPacketSent:I", ordinal = 2)) + private int moveLastPosPacketIncrement2(ClientPlayerEntity instance) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) { + return this.ticksSinceLastPositionPacketSent++; // Return previous value, then increment + } else { + return this.ticksSinceLastPositionPacketSent; + } + } @Redirect(method = "sendMovementPackets", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerEntity;lastOnGround:Z", ordinal = 0)) private boolean sendIdlePacket(ClientPlayerEntity instance) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java index f96829956..53c988538 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinEntity.java @@ -163,15 +163,16 @@ private void modifyPosWithYOffset(float offset, CallbackInfoReturnable } } - // TODO UPDATE-1.21.3: No longer subtracts 1.0E-7 from the box values, instead the boundingBox is contracted -// @ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 1.0E-7)) -// private double fixBlockCollisionMargin(double constant) { -// if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) { -// return 1E-3; -// } else { -// return constant; -// } -// } + @ModifyConstant(method = "checkBlockCollision", constant = @Constant(doubleValue = 9.999999747378752E-6)) + private double fixBlockCollisionMargin(double constant) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_19_1)) { + return 1E-3; + } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_1)) { + return 1E-7; + } else { + return constant; + } + } @Inject(method = "getVelocityAffectingPos", at = @At("HEAD"), cancellable = true) private void modifyVelocityAffectingPos(CallbackInfoReturnable cir) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java index df9e06bde..0de02b41f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinLivingEntity.java @@ -136,14 +136,14 @@ private void preventEntityPush(CallbackInfo ci) { } } -// @Redirect(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D", remap = false)) -// private double fixCosTable(double a) { TODO UPDATE-1.21.3 -// if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) { -// return MathHelper.cos((float) a); -// } else { -// return Math.cos(a); -// } -// } + @Redirect(method = "calcGlidingVelocity", at = @At(value = "INVOKE", target = "Ljava/lang/Math;cos(D)D", remap = false)) + private double fixCosTable(double a) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_18)) { + return MathHelper.cos((float) a); + } else { + return Math.cos(a); + } + } @Redirect(method = "travelInFluid", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getFluidHeight(Lnet/minecraft/registry/tag/TagKey;)D")) private double dontApplyLavaMovement(LivingEntity instance, TagKey tagKey) { @@ -159,6 +159,11 @@ private boolean allowElytraWhenLevitating(LivingEntity instance, RegistryEntry