1 Keybinds
Juniper Gardiner edited this page 2026-04-19 11:39:17 +01:00

WIP Wiki Page

package com.example.examplemod.client;

import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.KeyMapping;
import net.minecraft.network.chat.Component;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW;
import xyz.sillyjune.mlem.api.client.ClientEntrypoint;
import xyz.sillyjune.mlem.api.client.ClientTickEvents;
import xyz.sillyjune.mlem.api.client.KeyMappings;

public class ExampleModClient implements ClientEntrypoint {
    private static final Logger LOGGER = LogManager.getLogger();

    public static final KeyMapping MEOW_KEY = new KeyMapping(
            "examplemod.meow",
            InputConstants.Type.KEYSYM,
            GLFW.GLFW_KEY_M,
            KeyMapping.Category.GAMEPLAY
    );

    @Override
    public void init() {
        LOGGER.info("Hello from example mod!");

        KeyMappings.registerKeyMapping(MEOW_KEY);
        ClientTickEvents.After.subscribe(client -> {
            while (MEOW_KEY.consumeClick()) {
                client.player.sendSystemMessage(Component.literal("<Cat> Meow"));
            }
        });
    }
}