mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-17 09:43:44 +01:00
6c390977d8
- Refactor AllContainerTypes to use Registrate - Replace RegistryEntry in AllEntityTypes and AllFluids with EntityEntry and FluidEntry, respectively - Make AllEntityTypes use Registrate to register entity renderers instead of a separate method - Refactor AllColorHandlers - Fix error when a POI block is moved by a contraption - Rename some static final fields to be upper snake case - Make static fields in Create and CreateClient final - Add I prefix to Coordinate interface - Fix typo (BracketedTileEntityBehaviour#isBacketPresent) - Make mixins go in alphabetical order - Make pack.mcmeta use 2 spaces for indents
77 lines
1.6 KiB
Java
77 lines
1.6 KiB
Java
package com.simibubi.create;
|
|
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.screen.Screen;
|
|
import net.minecraft.client.settings.KeyBinding;
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
|
|
|
public enum AllKeys {
|
|
|
|
TOOL_MENU("toolmenu", GLFW.GLFW_KEY_LEFT_ALT),
|
|
ACTIVATE_TOOL("", GLFW.GLFW_KEY_LEFT_CONTROL),
|
|
|
|
;
|
|
|
|
private KeyBinding 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 KeyBinding(key.description, key.key, Create.NAME);
|
|
if (!key.modifiable)
|
|
continue;
|
|
|
|
ClientRegistry.registerKeyBinding(key.keybind);
|
|
}
|
|
}
|
|
|
|
public KeyBinding getKeybind() {
|
|
return keybind;
|
|
}
|
|
|
|
public boolean isPressed() {
|
|
if (!modifiable)
|
|
return isKeyDown(key);
|
|
return keybind.isKeyDown();
|
|
}
|
|
|
|
public String getBoundKey() {
|
|
return keybind.getBoundKeyLocalizedText()
|
|
.getString()
|
|
.toUpperCase();
|
|
}
|
|
|
|
public int getBoundCode() {
|
|
return keybind.getKey()
|
|
.getKeyCode();
|
|
}
|
|
|
|
public static boolean isKeyDown(int key) {
|
|
return GLFW.glfwGetKey(Minecraft.getInstance()
|
|
.getWindow()
|
|
.getHandle(), key) != 0;
|
|
}
|
|
|
|
public static boolean ctrlDown() {
|
|
return Screen.hasControlDown();
|
|
}
|
|
|
|
public static boolean shiftDown() {
|
|
return Screen.hasShiftDown();
|
|
}
|
|
|
|
public static boolean altDown() {
|
|
return Screen.hasAltDown();
|
|
}
|
|
|
|
}
|