46 lines
1.4 KiB
Java
46 lines
1.4 KiB
Java
package com.aranroig.client;
|
|
|
|
import com.aranroig.Codecraft;
|
|
import com.aranroig.client.editor.EditorManager;
|
|
import com.mojang.blaze3d.platform.InputConstants;
|
|
import net.fabricmc.api.ClientModInitializer;
|
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
|
import net.minecraft.client.KeyMapping;
|
|
import net.minecraft.resources.Identifier;
|
|
import org.lwjgl.glfw.GLFW;
|
|
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
|
|
|
|
|
|
import javax.swing.text.JTextComponent;
|
|
|
|
public class CodecraftClient implements ClientModInitializer {
|
|
|
|
public static JTextComponent.KeyBinding OPEN_EDITOR;
|
|
|
|
@Override
|
|
public void onInitializeClient() {
|
|
KeyMapping.Category CATEGORY = KeyMapping.Category.register(
|
|
Identifier.fromNamespaceAndPath(Codecraft.MOD_ID, "codecraft")
|
|
);
|
|
|
|
|
|
KeyMapping openEditor = KeyMappingHelper.registerKeyMapping(
|
|
new KeyMapping(
|
|
"key.codecraft.open_editor", // The translation key for the key mapping.
|
|
InputConstants.Type.KEYSYM, // The type of the keybinding; KEYSYM for keyboard, MOUSE for mouse.
|
|
GLFW.GLFW_KEY_J, // The GLFW keycode of the key.
|
|
CATEGORY // The category of the mapping.
|
|
)
|
|
);
|
|
|
|
EditorManager editorOverlay = new EditorManager();
|
|
|
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
|
while(openEditor.consumeClick()){
|
|
if(client.player != null) {
|
|
editorOverlay.toggleVisible();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
} |