Skip to content

Commit

Permalink
Fix crawl movement speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommsy64 committed Jul 2, 2018
1 parent 818e7ab commit ecdd35b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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();
}
}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.smartmoving.core.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"client.MixinEntityOtherPlayerMP",
"client.MixinEntityPlayerSP",
"client.MixinRenderPlayer",
"client.MixinModelPlayer"
"client.MixinModelPlayer",
"client.MixinMovementInputFromOptions"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit ecdd35b

Please sign in to comment.