mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-16 07:24:32 +01:00
061b85d515
- Port to 1.18 - ChunkUtil discontinued - SmartTileEntities write to metadata - Features generate from -64 up - World Wrappers weren't convoluted enough - Haunted bell considers >0 safe - Missing GuiUtils methods continued in RemovedGuiUtils
79 lines
1.6 KiB
Java
79 lines
1.6 KiB
Java
package com.simibubi.create;
|
|
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
import net.minecraft.client.KeyMapping;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.screens.Screen;
|
|
import net.minecraftforge.client.ClientRegistry;
|
|
|
|
public enum AllKeys {
|
|
|
|
TOOL_MENU("toolmenu", GLFW.GLFW_KEY_LEFT_ALT),
|
|
ACTIVATE_TOOL("", GLFW.GLFW_KEY_LEFT_CONTROL),
|
|
TOOLBELT("toolbelt", GLFW.GLFW_KEY_LEFT_ALT),
|
|
|
|
;
|
|
|
|
private KeyMapping keybind;
|
|
private String description;
|
|
private int key;
|
|
private boolean modifiable;
|
|
|
|
private AllKeys(String description, int defaultKey) {
|
|
this.description = Create.ID + ".keyinfo." + description;
|
|
this.key = defaultKey;
|
|
this.modifiable = !description.isEmpty();
|
|
}
|
|
|
|
public static void register() {
|
|
for (AllKeys key : values()) {
|
|
key.keybind = new KeyMapping(key.description, key.key, Create.NAME);
|
|
if (!key.modifiable)
|
|
continue;
|
|
|
|
ClientRegistry.registerKeyBinding(key.keybind);
|
|
}
|
|
}
|
|
|
|
public KeyMapping getKeybind() {
|
|
return keybind;
|
|
}
|
|
|
|
public boolean isPressed() {
|
|
if (!modifiable)
|
|
return isKeyDown(key);
|
|
return keybind.isDown();
|
|
}
|
|
|
|
public String getBoundKey() {
|
|
return keybind.getTranslatedKeyMessage()
|
|
.getString()
|
|
.toUpperCase();
|
|
}
|
|
|
|
public int getBoundCode() {
|
|
return keybind.getKey()
|
|
.getValue();
|
|
}
|
|
|
|
public static boolean isKeyDown(int key) {
|
|
return GLFW.glfwGetKey(Minecraft.getInstance()
|
|
.getWindow()
|
|
.getWindow(), key) != 0;
|
|
}
|
|
|
|
public static boolean ctrlDown() {
|
|
return Screen.hasControlDown();
|
|
}
|
|
|
|
public static boolean shiftDown() {
|
|
return Screen.hasShiftDown();
|
|
}
|
|
|
|
public static boolean altDown() {
|
|
return Screen.hasAltDown();
|
|
}
|
|
|
|
}
|