diff --git a/build.properties b/build.properties index 693395b..f5922e9 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ minecraft.version=1.12.2 minecraft.mappings=snapshot_20180114 forge.version=14.23.4.2705 -smartmoving.version=0.0.1 +smartmoving.version=0.0.2 diff --git a/src/main/java/com/tommsy/smartmoving/client/model/SmartMovingModelBipedHandler.java b/src/main/java/com/tommsy/smartmoving/client/model/SmartMovingModelBipedHandler.java index 2bc713f..d3be60a 100644 --- a/src/main/java/com/tommsy/smartmoving/client/model/SmartMovingModelBipedHandler.java +++ b/src/main/java/com/tommsy/smartmoving/client/model/SmartMovingModelBipedHandler.java @@ -212,7 +212,7 @@ public boolean preSetRotationAngles(float totalHorizontalDistance, float current float walkFactor = factor(horizontalSpeed, 0F, 0.12951545F); float standFactor = factor(horizontalSpeed, 0.12951545F, 0F); - bipedTorso.offsetZ = -0.85f; + bipedTorso.offsetZ = -0.87f; bipedHead.rotateAngleZ = -headYawAngle / RadianToAngle; bipedHead.rotateAngleX = -Eighth; diff --git a/src/main/java/com/tommsy/smartmoving/mixin/client/MixinEntityPlayerSP.java b/src/main/java/com/tommsy/smartmoving/mixin/client/MixinEntityPlayerSP.java index d0f9dce..664fb77 100644 --- a/src/main/java/com/tommsy/smartmoving/mixin/client/MixinEntityPlayerSP.java +++ b/src/main/java/com/tommsy/smartmoving/mixin/client/MixinEntityPlayerSP.java @@ -99,9 +99,12 @@ private void preOnLivingUpdate(CallbackInfo ci) { @Redirect(method = "onLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MovementInput;updatePlayerMoveState()V")) private void movementInputCorrection(MovementInput movementInput) { movementInput.updatePlayerMoveState(); - if (!movementInput.sneak && this.playerState.isCrawling) { + if (this.playerState.isCrouching) { movementInput.moveStrafe = (float) ((double) movementInput.moveStrafe * 0.3D); movementInput.moveForward = (float) ((double) movementInput.moveForward * 0.3D); + } else if (this.playerState.isCrawling) { + movementInput.moveStrafe = (float) ((double) movementInput.moveStrafe * 0.15D); + movementInput.moveForward = (float) ((double) movementInput.moveForward * 0.15D); } } diff --git a/src/main/java/com/tommsy/smartmoving/mixin/client/MixinMovementInputFromOptions.java b/src/main/java/com/tommsy/smartmoving/mixin/client/MixinMovementInputFromOptions.java new file mode 100644 index 0000000..d579fb5 --- /dev/null +++ b/src/main/java/com/tommsy/smartmoving/mixin/client/MixinMovementInputFromOptions.java @@ -0,0 +1,38 @@ +/* +* Smart Moving Reloaded +* Copyright (C) 2018 Tommsy64 +* +* Smart Moving Reloaded is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* Smart Moving Reloaded is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with Smart Moving Reloaded. If not, see . +*/ + +package com.tommsy.smartmoving.mixin.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.util.MovementInputFromOptions; + +@Mixin(MovementInputFromOptions.class) +public class MixinMovementInputFromOptions { + /** + * This prevents moveStrafe and moveForward from being multiplied by .3 when the sneak key is pressed. Instead, this logic will be handled in {@link MixinEntityPlayerSP}. + */ + @Inject(method = "updatePlayerMoveState", slice = @Slice(from = @At(value = "FIELD:LAST", target = "Lnet/minecraft/util/MovementInputFromOptions;sneak:Z")), at = @At(value = "FIELD", target = "Lnet/minecraft/util/MovementInputFromOptions;sneak:Z"), cancellable = true) + public void updatePlayerMoveState(CallbackInfo ci) { + ci.cancel(); + } +} diff --git a/src/main/resources/mixins.smartmoving.core.json b/src/main/resources/mixins.smartmoving.core.json index 85276c4..b6e2a9e 100644 --- a/src/main/resources/mixins.smartmoving.core.json +++ b/src/main/resources/mixins.smartmoving.core.json @@ -16,7 +16,8 @@ "client.MixinEntityOtherPlayerMP", "client.MixinEntityPlayerSP", "client.MixinRenderPlayer", - "client.MixinModelPlayer" + "client.MixinModelPlayer", + "client.MixinMovementInputFromOptions" ], "injectors": { "defaultRequire": 1