From a77937670e752cc9a322d98de474a96a31b9cd51 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Wed, 4 Dec 2024 01:44:51 +0100 Subject: [PATCH] Finalize some things --- .../entity/MixinClientPlayerEntity.java | 24 +++++++++---------- .../minecraft/item/MixinHeldItemRenderer.java | 3 +-- .../viafabricplus/screen/VFPListEntry.java | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) 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 fb7f7321..8eb58415 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 @@ -87,19 +87,8 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity super(world, profile); } - @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;shouldSlowDown()Z")) - private boolean moveSlowDownAbove(ClientPlayerEntity instance) { - if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { - return instance.input.playerInput.sneak(); - } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { - return !MinecraftClient.getInstance().player.isSpectator() && (instance.input.playerInput.sneak() || instance.shouldSlowDown()); - } else { - return instance.shouldSlowDown(); - } - } - @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;shouldStopSprinting()Z")) - private boolean keepSprintingStateOff(ClientPlayerEntity instance) { + private boolean dontUnsprint(ClientPlayerEntity instance) { return shouldStopSprinting() && ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_4); } @@ -178,6 +167,17 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity return ProtocolTranslator.getTargetVersion().newerThan(ProtocolVersion.v1_15_1) && original; } + @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;shouldSlowDown()Z")) + private boolean changeSneakSlowdownCondition(ClientPlayerEntity instance) { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { + return instance.input.playerInput.sneak(); + } else if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_14_4)) { + return !MinecraftClient.getInstance().player.isSpectator() && (instance.input.playerInput.sneak() || instance.shouldSlowDown()); + } else { + return instance.shouldSlowDown(); + } + } + @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)) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java index 7c79e029..8e099f88 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/item/MixinHeldItemRenderer.java @@ -62,8 +62,7 @@ public abstract class MixinHeldItemRenderer { @Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", ordinal = 1)) - private void transformItemPosition1_7(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack stack, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - // Modifies the handheld position to be slightly tilted like in 1.7 and prior + private void slightlyTiltItemPosition(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack stack, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { if (VisualSettings.global().tiltItemPositions.isEnabled() && !(stack.getItem() instanceof BlockItem)) { final Arm arm = hand == Hand.MAIN_HAND ? player.getMainArm() : player.getMainArm().getOpposite(); final int direction = arm == Arm.RIGHT ? 1 : -1; diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java b/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java index 054853d2..25fd86b3 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java @@ -96,7 +96,7 @@ public abstract class VFPListEntry extends AlwaysSelectedEntryListWidget.Entry