2013-10-14 18:44:07 +02:00
|
|
|
package mekanism.client;
|
|
|
|
|
|
|
|
import java.util.EnumSet;
|
|
|
|
|
|
|
|
import net.minecraft.client.settings.KeyBinding;
|
|
|
|
|
|
|
|
import org.lwjgl.input.Keyboard;
|
|
|
|
|
|
|
|
import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler;
|
|
|
|
import cpw.mods.fml.common.TickType;
|
2013-10-14 20:25:04 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-10-14 18:44:07 +02:00
|
|
|
|
2013-10-14 20:25:04 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-10-14 18:44:07 +02:00
|
|
|
public class MekanismKeyHandler extends KeyHandler
|
|
|
|
{
|
|
|
|
public static KeyBinding modeSwitch = new KeyBinding("Mekanism Mode Switch", Keyboard.KEY_M);
|
|
|
|
public static KeyBinding voice = new KeyBinding("Mekanism Voice", Keyboard.KEY_U);
|
|
|
|
|
2013-10-14 19:27:38 +02:00
|
|
|
public static boolean modeSwitchDown = false;
|
2013-10-14 18:44:07 +02:00
|
|
|
public static boolean voiceDown = false;
|
|
|
|
|
|
|
|
public MekanismKeyHandler()
|
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
super(new KeyBinding[] {modeSwitch, voice}, new boolean[] {false, false});
|
2013-10-14 18:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getLabel()
|
|
|
|
{
|
|
|
|
return "MekanismKey";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
|
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
if(kb.keyCode == modeSwitch.keyCode)
|
|
|
|
{
|
|
|
|
modeSwitchDown = true;
|
|
|
|
}
|
|
|
|
else if(kb.keyCode == voice.keyCode)
|
2013-10-14 18:44:07 +02:00
|
|
|
{
|
|
|
|
voiceDown = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
|
|
|
|
{
|
2013-10-14 19:27:38 +02:00
|
|
|
if(kb.keyCode == modeSwitch.keyCode)
|
|
|
|
{
|
|
|
|
modeSwitchDown = false;
|
|
|
|
}
|
|
|
|
else if(kb.keyCode == voice.keyCode)
|
2013-10-14 18:44:07 +02:00
|
|
|
{
|
|
|
|
voiceDown = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumSet<TickType> ticks()
|
|
|
|
{
|
|
|
|
return EnumSet.of(TickType.CLIENT);
|
|
|
|
}
|
|
|
|
}
|