diff --git a/src/main/java/gregtech/GregTechMod.java b/src/main/java/gregtech/GregTechMod.java index f0006367776..e2c67349321 100644 --- a/src/main/java/gregtech/GregTechMod.java +++ b/src/main/java/gregtech/GregTechMod.java @@ -18,7 +18,7 @@ import gregtech.api.util.AnnotatedMaterialHandlerLoader; import gregtech.api.util.GTLog; import gregtech.api.util.NBTUtil; -import gregtech.api.util.input.Keybinds; +import gregtech.api.util.input.KeyBinds; import gregtech.api.worldgen.config.WorldGenRegistry; import gregtech.common.*; import gregtech.common.blocks.MetaBlocks; @@ -116,7 +116,7 @@ public void onPreInit(FMLPreInitializationEvent event) { AnnotatedComponentHandlerLoader.discoverAndLoadAnnotatedComponentHandlers(event.getAsmData()); proxy.onPreLoad(); - Keybinds.register(); + KeyBinds.register(); } @Mod.EventHandler diff --git a/src/main/java/gregtech/api/items/armor/ArmorUtils.java b/src/main/java/gregtech/api/items/armor/ArmorUtils.java index d1d2fa85903..35210a9233d 100644 --- a/src/main/java/gregtech/api/items/armor/ArmorUtils.java +++ b/src/main/java/gregtech/api/items/armor/ArmorUtils.java @@ -6,7 +6,7 @@ import gregtech.api.util.ItemStackKey; import gregtech.api.util.input.EnumKey; import gregtech.api.util.input.Key; -import gregtech.api.util.input.Keybinds; +import gregtech.api.util.input.KeyBinds; import gregtech.common.ConfigHolder; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -135,10 +135,10 @@ public static ActionResult canEat(EntityPlayer player, ItemStack food */ public static boolean isKeyDown(EntityPlayer player, EnumKey type) { if (SIDE.isClient()) { - return Keybinds.REGISTERY.get(type.getID()).state; + return KeyBinds.REGISTRY.get(type.getID()).state; } else { - if (Keybinds.PLAYER_KEYS.get(player) == null) return false; - List playerKeys = Keybinds.PLAYER_KEYS.get(player); + if (KeyBinds.PLAYER_KEYS.get(player) == null) return false; + List playerKeys = KeyBinds.PLAYER_KEYS.get(player); if (playerKeys.isEmpty()) return false; return playerKeys.get(type.getID()).state; } diff --git a/src/main/java/gregtech/api/net/KeysPacket.java b/src/main/java/gregtech/api/net/KeysPacket.java index 314104ac89a..cce38444eb8 100644 --- a/src/main/java/gregtech/api/net/KeysPacket.java +++ b/src/main/java/gregtech/api/net/KeysPacket.java @@ -3,7 +3,7 @@ import gregtech.api.util.input.EnumKey; import gregtech.api.util.input.Key; -import gregtech.api.util.input.Keybinds; +import gregtech.api.util.input.KeyBinds; import io.netty.buffer.ByteBuf; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -35,7 +35,7 @@ public void toBytes(ByteBuf buf) { @Override public void fromBytes(ByteBuf buf) { keys = new ArrayList<>(); - for (int i = 0; i < Keybinds.REGISTERY.size(); i++) { + for (int i = 0; i < KeyBinds.REGISTRY.size(); i++) { int id = buf.readByte(); Key current = new Key(EnumKey.getKeyByID(id)); current.state = buf.readBoolean(); diff --git a/src/main/java/gregtech/api/net/KeysUpdateHandler.java b/src/main/java/gregtech/api/net/KeysUpdateHandler.java index 3898df1d03a..2a87a94f71b 100644 --- a/src/main/java/gregtech/api/net/KeysUpdateHandler.java +++ b/src/main/java/gregtech/api/net/KeysUpdateHandler.java @@ -2,7 +2,7 @@ import gregtech.api.util.input.Key; -import gregtech.api.util.input.Keybinds; +import gregtech.api.util.input.KeyBinds; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -17,10 +17,10 @@ public IMessage onMessage(KeysPacket message, MessageContext ctx) { EntityPlayerMP player = ctx.getServerHandler().player; List keys = message.getList(); if (keys.isEmpty()) return null; - if (Keybinds.PLAYER_KEYS.containsKey(player)) { - Keybinds.PLAYER_KEYS.replace(player, keys); + if (KeyBinds.PLAYER_KEYS.containsKey(player)) { + KeyBinds.PLAYER_KEYS.replace(player, keys); } else { - Keybinds.PLAYER_KEYS.put(player, keys); + KeyBinds.PLAYER_KEYS.put(player, keys); } return null; } diff --git a/src/main/java/gregtech/api/util/input/EnumKey.java b/src/main/java/gregtech/api/util/input/EnumKey.java index fc887d8ff0a..ea6ea5d1001 100644 --- a/src/main/java/gregtech/api/util/input/EnumKey.java +++ b/src/main/java/gregtech/api/util/input/EnumKey.java @@ -5,6 +5,7 @@ import javax.annotation.Nullable; public enum EnumKey { + MENU("ALT Menu", Keyboard.KEY_LMENU, Key.KEYS_CATEGORY), MODE_SWITCH("Mode Switch", Keyboard.KEY_M, Key.KEYS_CATEGORY), FORWARD(null, 0, null), @@ -41,5 +42,4 @@ private void setID() { public int getID() { return this.ID; } - } diff --git a/src/main/java/gregtech/api/util/input/Key.java b/src/main/java/gregtech/api/util/input/Key.java index 61197494d3d..3360735d614 100644 --- a/src/main/java/gregtech/api/util/input/Key.java +++ b/src/main/java/gregtech/api/util/input/Key.java @@ -5,12 +5,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class Key { - @SideOnly(Side.CLIENT) - private KeyBinding binding; + public final EnumKey KEY; public boolean state; public static final String KEYS_CATEGORY = "gregtech"; + @SideOnly(Side.CLIENT) + private KeyBinding binding; + public Key(EnumKey type) { this.KEY = type; this.state = false; diff --git a/src/main/java/gregtech/api/util/input/Keybinds.java b/src/main/java/gregtech/api/util/input/KeyBinds.java similarity index 84% rename from src/main/java/gregtech/api/util/input/Keybinds.java rename to src/main/java/gregtech/api/util/input/KeyBinds.java index adeb1ac38fe..a4f49e1cd33 100644 --- a/src/main/java/gregtech/api/util/input/Keybinds.java +++ b/src/main/java/gregtech/api/util/input/KeyBinds.java @@ -11,10 +11,10 @@ import java.util.*; +public class KeyBinds { -public class Keybinds { - // Just registery of all used keys - public static final List REGISTERY = new ArrayList<>(); + // Registry of all used keys + public static final List REGISTRY = new ArrayList<>(); // Logical server-sided variable, where is state of any keys from players public static final Map> PLAYER_KEYS = new HashMap<>(); @@ -34,7 +34,7 @@ public static void initBinds() { @SideOnly(Side.CLIENT) public static void registerClient() { - for (Key key : REGISTERY) { + for (Key key : REGISTRY) { if (!ArrayUtils.contains(Minecraft.getMinecraft().gameSettings.keyBindings, key.getBind())) ClientRegistry.registerKeyBinding(key.getBind()); } @@ -43,9 +43,9 @@ public static void registerClient() { public static void register() { for (EnumKey type : EnumKey.values()) { if (ArmorUtils.SIDE.isClient()) { - REGISTERY.add(new Key(type, bindings.get(type.getID()))); + REGISTRY.add(new Key(type, bindings.get(type.getID()))); } else { - REGISTERY.add(new Key(type)); + REGISTRY.add(new Key(type)); } } } diff --git a/src/main/java/gregtech/common/ClientProxy.java b/src/main/java/gregtech/common/ClientProxy.java index 13769fec8c0..98c4def67aa 100644 --- a/src/main/java/gregtech/common/ClientProxy.java +++ b/src/main/java/gregtech/common/ClientProxy.java @@ -14,7 +14,7 @@ import gregtech.api.util.FluidTooltipUtil; import gregtech.api.util.GTLog; import gregtech.api.util.ModCompatibility; -import gregtech.api.util.input.Keybinds; +import gregtech.api.util.input.KeyBinds; import gregtech.common.blocks.*; import gregtech.common.covers.facade.FacadeRenderer; import gregtech.common.items.MetaItems; @@ -103,7 +103,7 @@ public class ClientProxy extends CommonProxy { public void onPreLoad() { super.onPreLoad(); - Keybinds.initBinds(); + KeyBinds.initBinds(); MetaTileEntityRenderer.preInit(); CableRenderer.preInit(); FluidPipeRenderer.preInit(); @@ -117,7 +117,7 @@ public void onPreLoad() { @Override public void onLoad() { - Keybinds.registerClient(); + KeyBinds.registerClient(); super.onLoad(); registerColors(); } diff --git a/src/main/java/gregtech/common/EventHandlers.java b/src/main/java/gregtech/common/EventHandlers.java index 108067a5d7d..83afb094998 100644 --- a/src/main/java/gregtech/common/EventHandlers.java +++ b/src/main/java/gregtech/common/EventHandlers.java @@ -11,7 +11,7 @@ import gregtech.api.net.KeysPacket; import gregtech.api.net.NetworkHandler; import gregtech.api.util.input.Key; -import gregtech.api.util.input.Keybinds; +import gregtech.api.util.input.KeyBinds; import gregtech.common.items.armor.PowerlessJetpack; import gregtech.common.items.MetaItems; import net.minecraft.entity.EntityLivingBase; @@ -118,14 +118,14 @@ public static void onRender(final TickEvent.RenderTickEvent event) { public static void onKeyInput(InputEvent.KeyInputEvent event) { if (ArmorUtils.SIDE.isClient()) { boolean needNewPacket = false; - for (Key key : Keybinds.REGISTERY) { + for (Key key : KeyBinds.REGISTRY) { boolean keyState = key.getBind().isKeyDown(); if (key.state != keyState) { key.state = keyState; needNewPacket = true; } } - if (needNewPacket) NetworkHandler.INSTANCE.sendToServer(new KeysPacket(Keybinds.REGISTERY)); + if (needNewPacket) NetworkHandler.INSTANCE.sendToServer(new KeysPacket(KeyBinds.REGISTRY)); } }