GuiMove: Fixed bugs, added new mode

This commit is contained in:
noil 2021-04-27 15:06:31 -04:00
parent 1dd2b94329
commit 1b02722dce
1 changed files with 46 additions and 25 deletions

View File

@ -2,10 +2,13 @@ package me.rigamortis.seppuku.impl.module.movement;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate;
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiRepair;
import net.minecraft.client.gui.GuiScreenBook;
import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraft.client.settings.KeyBinding;
import org.lwjgl.input.Keyboard;
@ -13,11 +16,16 @@ import org.lwjgl.input.Mouse;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
/**
* Author Seth
* 4/16/2019 @ 8:37 PM.
* @author Seth
* @author noil
*/
public final class GuiMoveModule extends Module {
public enum Mode {
NEW, OLD
}
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"mod", "m"}, "Change between modes.", Mode.NEW);
public final Value<Boolean> allowSignMove = new Value<Boolean>("AllowSignMove", new String[]{"sign", "allowsign", "as"}, "If enabled you will be able to move while in a sign GUI.", false);
public GuiMoveModule() {
@ -25,34 +33,15 @@ public final class GuiMoveModule extends Module {
}
@Listener
public void onUpdate(EventPlayerUpdate event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
public void onUpdateWalkingPlayer(EventUpdateWalkingPlayer event) {
if (event.getStage() == EventStageable.EventStage.POST) {
final Minecraft mc = Minecraft.getMinecraft();
if (mc.currentScreen instanceof GuiChat || (!allowSignMove.getValue() && mc.currentScreen instanceof GuiEditSign) || mc.currentScreen == null) {
if (mc.currentScreen instanceof GuiChat || mc.currentScreen == null || (!this.allowSignMove.getValue() && (mc.currentScreen instanceof GuiEditSign || mc.currentScreen instanceof GuiScreenBook || mc.currentScreen instanceof GuiRepair))) {
return;
}
final int[] keys = new int[]{mc.gameSettings.keyBindForward.getKeyCode(), mc.gameSettings.keyBindLeft.getKeyCode(), mc.gameSettings.keyBindRight.getKeyCode(), mc.gameSettings.keyBindBack.getKeyCode()};
for (int keyCode : keys) {
if (Keyboard.isKeyDown(keyCode)) {
KeyBinding.setKeyBindState(keyCode, true);
} else {
KeyBinding.setKeyBindState(keyCode, false);
}
}
if (Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode())) {
if (mc.player.isInLava() || mc.player.isInWater()) {
mc.player.motionY += 0.039f;
} else {
if (mc.player.onGround) {
mc.player.jump();
}
}
}
// handle mouse
if (Mouse.isButtonDown(2)) {
Mouse.setGrabbed(true);
mc.inGameHasFocus = true;
@ -60,6 +49,38 @@ public final class GuiMoveModule extends Module {
Mouse.setGrabbed(false);
mc.inGameHasFocus = false;
}
// handle movement
switch (this.mode.getValue()) {
case NEW:
final KeyBinding[] keyBindings = {
mc.gameSettings.keyBindForward, mc.gameSettings.keyBindBack, mc.gameSettings.keyBindLeft, mc.gameSettings.keyBindRight,
mc.gameSettings.keyBindJump, mc.gameSettings.keyBindSneak, mc.gameSettings.keyBindSprint};
for (KeyBinding keyBinding : keyBindings) {
KeyBinding.setKeyBindState(keyBinding.getKeyCode(), Keyboard.isKeyDown(keyBinding.getKeyCode()));
}
break;
case OLD:
mc.gameSettings.keyBindForward.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindForward.getKeyCode());
mc.gameSettings.keyBindBack.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindBack.getKeyCode());
mc.gameSettings.keyBindRight.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindRight.getKeyCode());
mc.gameSettings.keyBindLeft.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindLeft.getKeyCode());
mc.gameSettings.keyBindJump.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode());
mc.gameSettings.keyBindSneak.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode());
mc.gameSettings.keyBindSprint.pressed = Keyboard.isKeyDown(mc.gameSettings.keyBindSprint.getKeyCode());
break;
}
// handle y
/*if (Keyboard.isKeyDown(mc.gameSettings.keyBindJump.getKeyCode())) {
if (mc.player.isInLava() || mc.player.isInWater()) {
mc.player.motionY += 0.039f;
} else {
if (mc.player.onGround) {
mc.player.jump();
}
}
}*/
}
}