Skip to content

Commit

Permalink
Update slowdown fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Dec 3, 2024
1 parent 0811482 commit 6efe7f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 46 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,29 @@ public abstract class MixinClientPlayerEntity extends AbstractClientPlayerEntity
@Shadow
protected abstract void sendSneakingPacket();

@Shadow
protected abstract boolean shouldStopSprinting();

public MixinClientPlayerEntity(ClientWorld world, GameProfile profile) {
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) {
return shouldStopSprinting() && ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_4);
}

@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);
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"fixes.minecraft.MixinGameOptions",
"fixes.minecraft.MixinGameRenderer",
"fixes.minecraft.MixinKeyboard",
"fixes.minecraft.MixinKeyboardInput",
"fixes.minecraft.MixinLanguageManager",
"fixes.minecraft.MixinMinecraftClient",
"fixes.minecraft.MixinMouse",
Expand Down

0 comments on commit 6efe7f1

Please sign in to comment.