Hello !
KeyInputEvent is not working for some reason... I've searched the internet and I can't figure out what is wrong, there isn't even an error, it just doesn't do anything. I put a System.out.println at the start as you can see, and even that doesn't appear in the console...
Please help. And I'm sorry in advance if it is a stupid mistake that I have made, I've been on it for hours and I just can't figure it out.
This is the KeyInputHandler
package com.vizins.redscorpion;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
public class KeyInputHandler{
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onKeyInput(KeyInputEvent event) {
System.out.println("key input detected");
if(RedScorpion.passivePowers.isPressed()) {
System.out.println("V is pressed");
if(!Minecraft.getMinecraft().theWorld.isRemote) {
System.out.println("world is remote");
if(Minecraft.getMinecraft().thePlayer.inventory.hasItem(RedScorpion.gadget)) {
Minecraft.getMinecraft().displayGuiScreen(new PassivePowersGui());
}
}
}
if(RedScorpion.changeGadget.isPressed()) {
if(!Minecraft.getMinecraft().theWorld.isRemote) {
if(Minecraft.getMinecraft().thePlayer.inventory.hasItem(RedScorpion.gadget)) {
Minecraft.getMinecraft().displayGuiScreen(new ChangeGadgetGui());
}
}
}
}
}
This is the main mod file.
public class RedScorpion {
//Key Binds
public static KeyBinding changeGadget;
public static KeyBinding passivePowers;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
passivePowers = new KeyBinding("key.passivePowers", Keyboard.KEY_V, "key.categories.redscorpionsuit");
changeGadget = new KeyBinding("key.changeGadget", Keyboard.KEY_F, "key.categories.redscorpionsuit");
ClientRegistry.registerKeyBinding(passivePowers);
ClientRegistry.registerKeyBinding(changeGadget);
}
@EventHandler
public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new KeyInputHandler());
}
}
Thanks
EDIT : This is for minecraft 1.7.10