Skip to content

Commit ecdd35b

Browse files
committed
Fix crawl movement speed
1 parent 818e7ab commit ecdd35b

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
minecraft.version=1.12.2
22
minecraft.mappings=snapshot_20180114
33
forge.version=14.23.4.2705
4-
smartmoving.version=0.0.1
4+
smartmoving.version=0.0.2

src/main/java/com/tommsy/smartmoving/client/model/SmartMovingModelBipedHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public boolean preSetRotationAngles(float totalHorizontalDistance, float current
212212
float walkFactor = factor(horizontalSpeed, 0F, 0.12951545F);
213213
float standFactor = factor(horizontalSpeed, 0.12951545F, 0F);
214214

215-
bipedTorso.offsetZ = -0.85f;
215+
bipedTorso.offsetZ = -0.87f;
216216

217217
bipedHead.rotateAngleZ = -headYawAngle / RadianToAngle;
218218
bipedHead.rotateAngleX = -Eighth;

src/main/java/com/tommsy/smartmoving/mixin/client/MixinEntityPlayerSP.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ private void preOnLivingUpdate(CallbackInfo ci) {
9999
@Redirect(method = "onLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MovementInput;updatePlayerMoveState()V"))
100100
private void movementInputCorrection(MovementInput movementInput) {
101101
movementInput.updatePlayerMoveState();
102-
if (!movementInput.sneak && this.playerState.isCrawling) {
102+
if (this.playerState.isCrouching) {
103103
movementInput.moveStrafe = (float) ((double) movementInput.moveStrafe * 0.3D);
104104
movementInput.moveForward = (float) ((double) movementInput.moveForward * 0.3D);
105+
} else if (this.playerState.isCrawling) {
106+
movementInput.moveStrafe = (float) ((double) movementInput.moveStrafe * 0.15D);
107+
movementInput.moveForward = (float) ((double) movementInput.moveForward * 0.15D);
105108
}
106109
}
107110

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Smart Moving Reloaded
3+
* Copyright (C) 2018 Tommsy64
4+
*
5+
* Smart Moving Reloaded is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* Smart Moving Reloaded is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with Smart Moving Reloaded. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package com.tommsy.smartmoving.mixin.client;
20+
21+
import org.spongepowered.asm.mixin.Mixin;
22+
import org.spongepowered.asm.mixin.injection.At;
23+
import org.spongepowered.asm.mixin.injection.Inject;
24+
import org.spongepowered.asm.mixin.injection.Slice;
25+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
26+
27+
import net.minecraft.util.MovementInputFromOptions;
28+
29+
@Mixin(MovementInputFromOptions.class)
30+
public class MixinMovementInputFromOptions {
31+
/**
32+
* 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}.
33+
*/
34+
@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)
35+
public void updatePlayerMoveState(CallbackInfo ci) {
36+
ci.cancel();
37+
}
38+
}

src/main/resources/mixins.smartmoving.core.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"client.MixinEntityOtherPlayerMP",
1717
"client.MixinEntityPlayerSP",
1818
"client.MixinRenderPlayer",
19-
"client.MixinModelPlayer"
19+
"client.MixinModelPlayer",
20+
"client.MixinMovementInputFromOptions"
2021
],
2122
"injectors": {
2223
"defaultRequire": 1

0 commit comments

Comments
 (0)