Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SwappingKeybinds implements ModInitializer {
- public static final String MOD_ID = "swapping-keybinds";
- private static KeyBinding swapKey;
- private static KeyBinding swapSwapKey;
- private static int swapTo = 4;
- private static boolean toggleState = false;
- public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
- @Override
- public void onInitialize() {
- LOGGER.info("swapping keys init");
- swapKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
- "swap",
- InputUtil.Type.KEYSYM,
- GLFW.GLFW_KEY_R,
- "swapping keybinds"
- ));
- swapSwapKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
- "change what to swap to",
- InputUtil.Type.KEYSYM,
- GLFW.GLFW_KEY_X,
- "swapping keybinds"
- ));
- ClientTickEvents.END_CLIENT_TICK.register(client -> {
- while (swapKey.wasPressed()) {
- toggleState = !toggleState;
- int newSlot = toggleState ? swapTo : 0;
- client.player.getInventory().selectedSlot = newSlot;
- }
- while (swapSwapKey.wasPressed()) {
- int newSlot;
- if (swapTo == 6) {
- newSlot = 4;
- swapTo = 4;
- } else {
- newSlot = ++swapTo;
- }
- client.player.getInventory().selectedSlot = newSlot;
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment