2019-10-27 15:45:44 +00:00
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.module.Module ;
2021-02-21 16:54:09 +00:00
import me.rigamortis.seppuku.api.value.Value ;
2019-10-27 15:45:44 +00:00
import net.minecraft.client.Minecraft ;
import net.minecraft.client.gui.GuiChat ;
2021-02-21 16:54:09 +00:00
import net.minecraft.client.gui.inventory.GuiEditSign ;
2019-10-27 15:45:44 +00:00
import net.minecraft.client.settings.KeyBinding ;
import org.lwjgl.input.Keyboard ;
import org.lwjgl.input.Mouse ;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener ;
/ * *
* Author Seth
* 4 / 16 / 2019 @ 8 : 37 PM .
* /
public final class GuiMoveModule extends Module {
2021-02-21 16:54:09 +00:00
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 ) ;
2019-10-27 15:45:44 +00:00
public GuiMoveModule ( ) {
2020-11-25 20:00:59 +00:00
super ( " GUIMove " , new String [ ] { " InvMove " , " InventoryMove " , " GUIM " } , " Allows you to move while guis are open " , " NONE " , - 1 , ModuleType . MOVEMENT ) ;
2019-10-27 15:45:44 +00:00
}
@Listener
public void onUpdate ( EventPlayerUpdate event ) {
if ( event . getStage ( ) = = EventStageable . EventStage . PRE ) {
final Minecraft mc = Minecraft . getMinecraft ( ) ;
2021-02-21 16:54:09 +00:00
if ( mc . currentScreen instanceof GuiChat | | ( ! allowSignMove . getValue ( ) & & mc . currentScreen instanceof GuiEditSign ) | | mc . currentScreen = = null ) {
2019-10-27 15:45:44 +00:00
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 ( ) ;
}
}
}
if ( Mouse . isButtonDown ( 2 ) ) {
Mouse . setGrabbed ( true ) ;
mc . inGameHasFocus = true ;
} else {
Mouse . setGrabbed ( false ) ;
mc . inGameHasFocus = false ;
}
}
}
}