mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Interm implementation of keyboardEvent for ModLoader.
This commit is contained in:
1 parent
c6de498904
commit
5997bd3b87
9 files changed
+51
-1
No files matched your search
@@ -143,6 +143,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
private HashMap<String, ArrayList<OverrideInfo>> overrideInfo = new HashMap<String, ArrayList<OverrideInfo>>();
|
||||
private HashMap<Integer, BlockRenderInfo> blockModelIds = new HashMap<Integer, BlockRenderInfo>();
|
||||
private HashMap<KeyBinding, ModContainer> keyBindings = new HashMap<KeyBinding, ModContainer>();
|
||||
private List<IKeyHandler> keyHandlers = new ArrayList<IKeyHandler>();
|
||||
private HashSet<OverrideInfo> animationSet = new HashSet<OverrideInfo>();
|
||||
|
||||
private List<TextureFX> addedTextureFX = new ArrayList<TextureFX>();
|
||||
@@ -256,6 +257,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
keys[i++]=(KeyBinding)key.getKeyBinding();
|
||||
keyBindings.put((KeyBinding) key.getKeyBinding(), key.getOwningContainer());
|
||||
}
|
||||
keyHandlers = allKeys;
|
||||
return keys;
|
||||
}
|
||||
/**
|
||||
@@ -278,6 +280,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
FMLCommonHandler.instance().worldTickEnd();
|
||||
FMLCommonHandler.instance().tickEnd(TickType.WORLDGUI, 0.0f, client.field_6313_p);
|
||||
}
|
||||
for (IKeyHandler entry : keyHandlers)
|
||||
{
|
||||
entry.onEndTick();
|
||||
}
|
||||
}
|
||||
|
||||
public void onWorldLoadTick()
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.src.KeyBinding;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
@@ -29,6 +32,7 @@ public class KeyBindingHandler implements IKeyHandler
|
||||
private boolean shouldRepeat;
|
||||
private KeyBinding keyBinding;
|
||||
private ModContainer modContainer;
|
||||
private boolean lastState = false;
|
||||
|
||||
/**
|
||||
* @param keyHandler
|
||||
@@ -55,4 +59,16 @@ public class KeyBindingHandler implements IKeyHandler
|
||||
{
|
||||
return modContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndTick()
|
||||
{
|
||||
int keyCode = keyBinding.field_1370_b;
|
||||
boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
|
||||
if (state && (!lastState || (lastState && shouldRepeat)))
|
||||
{
|
||||
modContainer.keyBindEvent(keyBinding);
|
||||
}
|
||||
lastState = state;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,11 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
|
||||
public void keyBindingEvent(Object keybinding)
|
||||
{
|
||||
this.keyboardEvent((KeyBinding)keybinding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
|
||||
Reference in new issue
Block a user