feat: crude autowalk mod
This commit is contained in:
parent
20e953f15f
commit
a259fbcc33
1 changed files with 44 additions and 0 deletions
44
src/main/java/ftbsc/bscv/modules/motion/AutoWalk.java
Normal file
44
src/main/java/ftbsc/bscv/modules/motion/AutoWalk.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package ftbsc.bscv.modules.motion;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
|
||||
import ftbsc.bscv.api.ILoadable;
|
||||
import ftbsc.bscv.modules.QuickModule;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraftforge.client.settings.IKeyConflictContext;
|
||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
@AutoService(ILoadable.class)
|
||||
public class AutoWalk extends QuickModule {
|
||||
|
||||
private IKeyConflictContext previous_ctx;
|
||||
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
this.previous_ctx = MC.options.keyUp.getKeyConflictContext();
|
||||
MC.options.keyUp.setKeyConflictContext(KeyConflictContext.UNIVERSAL);
|
||||
|
||||
super.enable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
super.disable();
|
||||
if (!InputMappings.isKeyDown(MC.getWindow().getWindow(), MC.options.keyUp.getKey().getValue())) {
|
||||
MC.options.keyUp.setDown(false);
|
||||
}
|
||||
MC.options.keyUp.setKeyConflictContext(this.previous_ctx);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == Phase.END) return;
|
||||
|
||||
MC.options.keyUp.setDown(true);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue