fix: should also work with boats
This commit is contained in:
parent
53e24b2e08
commit
adb72b9c58
1 changed files with 23 additions and 13 deletions
|
@ -15,6 +15,8 @@ import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.client.util.InputMappings;
|
import net.minecraft.client.util.InputMappings;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.MovementInput;
|
||||||
import net.minecraftforge.client.event.InputUpdateEvent;
|
import net.minecraftforge.client.event.InputUpdateEvent;
|
||||||
import net.minecraftforge.common.ForgeConfigSpec;
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -59,19 +61,19 @@ public class GuiMove extends AbstractModule {
|
||||||
CustomizeSkinScreen.class,
|
CustomizeSkinScreen.class,
|
||||||
};
|
};
|
||||||
|
|
||||||
private void forceMovementTick() {
|
private void forceMovementTick(MovementInput input) {
|
||||||
// TODO can we patch to make this always happen instead of duplicating code?
|
// TODO can we patch to make this always happen instead of duplicating code?
|
||||||
MC.player.input.up = this.isKeyDown(MC.options.keyUp);
|
input.up = this.isKeyDown(MC.options.keyUp);
|
||||||
MC.player.input.down = this.isKeyDown(MC.options.keyDown);
|
input.down = this.isKeyDown(MC.options.keyDown);
|
||||||
MC.player.input.left = this.isKeyDown(MC.options.keyLeft);
|
input.left = this.isKeyDown(MC.options.keyLeft);
|
||||||
MC.player.input.right = this.isKeyDown(MC.options.keyRight);
|
input.right = this.isKeyDown(MC.options.keyRight);
|
||||||
MC.player.input.jumping = this.isKeyDown(MC.options.keyJump);
|
input.jumping = this.isKeyDown(MC.options.keyJump);
|
||||||
MC.player.input.shiftKeyDown = this.isKeyDown(MC.options.keyShift);
|
input.shiftKeyDown = this.isKeyDown(MC.options.keyShift);
|
||||||
|
|
||||||
MC.player.input.forwardImpulse = MC.player.input.up == MC.player.input.down ? 0.0F : (MC.player.input.up ? 1.0F : -1.0F);
|
input.forwardImpulse = input.up == input.down ? 0.0F : (input.up ? 1.0F : -1.0F);
|
||||||
MC.player.input.leftImpulse = MC.player.input.left == MC.player.input.right ? 0.0F : (MC.player.input.left ? 1.0F : -1.0F);
|
input.leftImpulse = input.left == input.right ? 0.0F : (input.left ? 1.0F : -1.0F);
|
||||||
|
|
||||||
if (MC.player.input.shiftKeyDown && !MC.player.isSprinting()) {
|
if (input.shiftKeyDown && !MC.player.isSprinting()) {
|
||||||
MC.player.setSprinting(true);
|
MC.player.setSprinting(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,10 +94,18 @@ public class GuiMove extends AbstractModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean overrideEntityInput(Entity in) {
|
||||||
|
if (MC.player == null) return false;
|
||||||
|
if (MC.player.getVehicle() != null) {
|
||||||
|
if (in.equals(MC.player.getVehicle())) return true;
|
||||||
|
}
|
||||||
|
if (in.equals(MC.player)) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInputUpdate(InputUpdateEvent event) {
|
public void onInputUpdate(InputUpdateEvent event) {
|
||||||
if (MC.player == null) return;
|
if (!this.overrideEntityInput(event.getEntityLiving())) return;
|
||||||
if (event.getEntityLiving() != MC.player) return;
|
|
||||||
|
|
||||||
if (this.allowMovementOnThisScreen(MC.screen)) {
|
if (this.allowMovementOnThisScreen(MC.screen)) {
|
||||||
for (KeyBinding key : this.keys) {
|
for (KeyBinding key : this.keys) {
|
||||||
|
@ -105,7 +115,7 @@ public class GuiMove extends AbstractModule {
|
||||||
key.setDown(state);
|
key.setDown(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.forceMovementTick();
|
this.forceMovementTick(MC.player.input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue