From 6dd0d8cbfee9a9fe27c108548cdb56e228769e4c Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sat, 26 Oct 2024 02:13:50 +0200 Subject: [PATCH] We continue to fall --- ...ltiplayerServerListWidget_ServerEntry.java | 11 ++-- .../entity/MixinClientPlayerEntity.java | 21 +++----- .../fixes/minecraft/entity/MixinEntity.java | 19 +++---- .../minecraft/entity/MixinLivingEntity.java | 21 +++++--- .../minecraft/screen/hud/MixinInGameHud.java | 50 +++++++++---------- 5 files changed, 61 insertions(+), 61 deletions(-) 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 758a11a9..589f0dbd 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.MultiplayerScreen; 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 org.spongepowered.asm.mixin.injection.Redirect; 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 @@ public abstract class MixinMultiplayerServerListWidget_ServerEntry { 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 2b72ff94..143c2be1 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 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity 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 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity } } - // 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 f9682995..53c98853 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 @@ public abstract class MixinEntity implements IEntity { } } - // 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 df9e06bd..0de02b41 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 @@ public abstract class MixinLivingEntity extends Entity { } } -// @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 @@ public abstract class MixinLivingEntity extends Entity { return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_15_2) && instance.hasStatusEffect(effect); } + @Redirect(method = "canGlide", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;hasVehicle()Z")) + private boolean allowElytraInVehicle(LivingEntity instance) { + return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_14_4) && instance.hasVehicle(); + } + @Redirect(method = "travelMidAir", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isChunkLoaded(Lnet/minecraft/util/math/BlockPos;)Z")) private boolean modifyLoadedCheck(World instance, BlockPos blockPos) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java index fa4e596c..8f9db41b 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/hud/MixinInGameHud.java @@ -61,31 +61,29 @@ public abstract class MixinInGameHud { } } - // TODO UPDATE-1.21.3 -// @ModifyArgs(method = "renderArmor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), require = 0) -// private static void moveArmorPositions(Args args, @Local(ordinal = 3, argsOnly = true) int x, @Local(ordinal = 6) int n) { -// if (!VisualSettings.global().hideModernHUDElements.isEnabled()) { -// return; -// } -// final MinecraftClient client = MinecraftClient.getInstance(); -// -// final int armorWidth = 10 * viaFabricPlus$ARMOR_ICON_WIDTH; -// final int offset = n * viaFabricPlus$ARMOR_ICON_WIDTH; -// -// args.set(1, client.getWindow().getScaledWidth() - x - armorWidth + offset - 1); -// args.set(2, (int) args.get(2) + client.textRenderer.fontHeight + 1); -// } -// -// @ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice( -// from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 2), -// to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")), index = 1, require = 0) -// private int moveAir(int value) { -// if (VisualSettings.global().hideModernHUDElements.isEnabled()) { -// final MinecraftClient client = MinecraftClient.getInstance(); -// return client.getWindow().getScaledWidth() - value - client.textRenderer.fontHeight; -// } else { -// return value; -// } -// } + @ModifyArgs(method = "renderArmor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V"), require = 0) + private static void moveArmorPositions(Args args, @Local(ordinal = 3, argsOnly = true) int x, @Local(ordinal = 6) int n) { + if (!VisualSettings.global().hideModernHUDElements.isEnabled()) { + return; + } + final MinecraftClient client = MinecraftClient.getInstance(); + + final int armorWidth = 10 * viaFabricPlus$ARMOR_ICON_WIDTH; + final int offset = n * viaFabricPlus$ARMOR_ICON_WIDTH; + + args.set(1, client.getWindow().getScaledWidth() - x - armorWidth + offset - 1); + args.set(2, (int) args.get(2) + client.textRenderer.fontHeight + 1); + } + + @ModifyArg(method = "renderAirBubbles", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V"), + index = 2, require = 0) + private int moveAirBubbles(int value) { + if (VisualSettings.global().hideModernHUDElements.isEnabled()) { + final MinecraftClient client = MinecraftClient.getInstance(); + return client.getWindow().getScaledWidth() - value - client.textRenderer.fontHeight; + } else { + return value; + } + } } \ No newline at end of file