diff --git a/ee3_client/ee3/client/EEProxy.java b/ee3_client/ee3/client/EEProxy.java index 8014c051..d0c3d3ad 100644 --- a/ee3_client/ee3/client/EEProxy.java +++ b/ee3_client/ee3/client/EEProxy.java @@ -5,14 +5,18 @@ import java.lang.reflect.Field; import cpw.mods.fml.common.ReflectionHelper; +import ee3.client.core.KeyHandler; +import ee3.client.core.SoundHandler; import ee3.core.interfaces.IProxy; import static ee3.lib.CustomItemRarity.*; import net.minecraft.client.Minecraft; import net.minecraft.src.EntityPlayer; import net.minecraft.src.EnumRarity; +import net.minecraft.src.KeyBinding; import net.minecraft.src.ModLoader; import net.minecraft.src.NetworkManager; import net.minecraft.src.World; +import net.minecraft.src.mod_EE3; import net.minecraft.src.forge.EnumHelperClient; import net.minecraft.src.forge.MinecraftForgeClient; @@ -99,5 +103,15 @@ public class EEProxy implements IProxy { } return EnumRarity.common; } + + @Override + public void registerKeyBindings() { + KeyHandler.init(); + } + + @Override + public void keyBindingEvent(Object event) { + KeyHandler.keyboardEvent((KeyBinding)event); + } } diff --git a/ee3_client/ee3/client/core/KeyHandler.java b/ee3_client/ee3/client/core/KeyHandler.java new file mode 100644 index 00000000..0367566f --- /dev/null +++ b/ee3_client/ee3/client/core/KeyHandler.java @@ -0,0 +1,36 @@ +package ee3.client.core; + +import net.minecraft.src.KeyBinding; +import net.minecraft.src.ModLoader; +import net.minecraft.src.mod_EE3; + +/** + * TODO Class Description + * @author pahimar + * + */ +public class KeyHandler { + + public static KeyBinding Extra; + public static KeyBinding Charge; + public static KeyBinding Toggle; + public static KeyBinding Release; + + + public static void init() { + Extra = new KeyBinding("ee3.mod.key.extra", 46); + Charge = new KeyBinding("ee3.mod.key.charge", 47); + Toggle = new KeyBinding("ee3.mod.key.toggle", 34); + Release = new KeyBinding("ee3.mod.key.release", 19); + + ModLoader.registerKey(mod_EE3.instance(), Extra, false); + ModLoader.registerKey(mod_EE3.instance(), Charge, false); + ModLoader.registerKey(mod_EE3.instance(), Toggle, false); + ModLoader.registerKey(mod_EE3.instance(), Release, false); + } + + public static void keyboardEvent(KeyBinding event) { + System.out.println(event.keyDescription); + } + +} diff --git a/ee3_client/ee3/client/SoundHandler.java b/ee3_client/ee3/client/core/SoundHandler.java similarity index 92% rename from ee3_client/ee3/client/SoundHandler.java rename to ee3_client/ee3/client/core/SoundHandler.java index bd1a1912..9c561598 100644 --- a/ee3_client/ee3/client/SoundHandler.java +++ b/ee3_client/ee3/client/core/SoundHandler.java @@ -1,4 +1,4 @@ -package ee3.client; +package ee3.client.core; import static ee3.lib.Sounds.soundFiles; diff --git a/ee3_common/ee3/core/interfaces/IProxy.java b/ee3_common/ee3/core/interfaces/IProxy.java index 607adc53..e34dfa81 100644 --- a/ee3_common/ee3/core/interfaces/IProxy.java +++ b/ee3_common/ee3/core/interfaces/IProxy.java @@ -32,6 +32,10 @@ public interface IProxy { public abstract void registerSoundHandler(); + public abstract void registerKeyBindings(); + + public abstract void keyBindingEvent(Object event); + public abstract void handleControl(NetworkManager network, int key); public abstract void handlePedestalPacket(int x, int y, int z, int itemId, boolean activated); diff --git a/ee3_common/ee3/lib/Keys.java b/ee3_common/ee3/lib/Keys.java deleted file mode 100644 index 11de2fc2..00000000 --- a/ee3_common/ee3/lib/Keys.java +++ /dev/null @@ -1,38 +0,0 @@ -package ee3.lib; - -/** - * TODO Class Description - * @author pahimar - * - */ -public class Keys { - - public static final int EXTRA = 0; - public static final int CHARGE = 1; - public static final int TOGGLE = 2; - public static final int RELEASE = 3; - public static final int LEFT_CLICK = 4; - public static final int JUMP = 5; - public static final int SNEAK = 6; - - public static String toString(int key) { - switch (key) { - case Keys.CHARGE: - return "KEYS.CHARGE"; - case Keys.EXTRA: - return "KEYS.EXTRA"; - case Keys.TOGGLE: - return "KEYS.TOGGLE"; - case Keys.RELEASE: - return "KEYS.RELEASE"; - case Keys.LEFT_CLICK: - return "KEYS.LEFT_CLICK"; - case Keys.JUMP: - return "KEYS.JUMP"; - case Keys.SNEAK: - return "KEYS.SNEAK"; - default: - return "Unknown Key"; - } - } -} diff --git a/ee3_common/net/minecraft/src/mod_EE3.java b/ee3_common/net/minecraft/src/mod_EE3.java index c3937de3..9d13715d 100644 --- a/ee3_common/net/minecraft/src/mod_EE3.java +++ b/ee3_common/net/minecraft/src/mod_EE3.java @@ -1,7 +1,6 @@ package net.minecraft.src; import cpw.mods.fml.common.FMLCommonHandler; -import ee3.addons.BuildCraftAddon; import ee3.core.ConfigurationManager; import ee3.core.CraftingHandler; import ee3.core.EntityLivingHandler; @@ -27,7 +26,7 @@ import net.minecraft.src.forge.NetworkMod; */ public class mod_EE3 extends NetworkMod { - public static mod_EE3 instance; + private static mod_EE3 instance; @SidedProxy(clientSide="ee3.client.EEProxy", serverSide="ee3.server.EEProxy") public static IProxy proxy; public static EMCList emcList; @@ -75,8 +74,20 @@ public class mod_EE3 extends NetworkMod { // Initialise the EMC List //this.emcList.initEMCList(); + + // Register KeyBindings + this.proxy.registerKeyBindings(); } + public static BaseMod instance() { + return instance; + } + + @Override + public void keyBindingEvent(Object event) { + this.proxy.keyBindingEvent(event); + } + @Override public String getVersion() { return Version.getVersion(); diff --git a/ee3_server/ee3/server/EEProxy.java b/ee3_server/ee3/server/EEProxy.java index c906ba4b..93b12cf9 100644 --- a/ee3_server/ee3/server/EEProxy.java +++ b/ee3_server/ee3/server/EEProxy.java @@ -83,4 +83,11 @@ public class EEProxy implements IProxy { public EnumRarity getCustomEnumRarityType(String custom) { return null; } + + @Override + public void registerKeyBindings() { } + + @Override + public void keyBindingEvent(Object event) { } + }