diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index 46fb6dccbc..eae8a022e7 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -196,8 +196,8 @@ public class FMLClientHandler implements IFMLSidedHandler } try { - Loader.instance().loadMods(); - } + Loader.instance().loadMods(); + } catch (LoaderException le) { haltGame("There was a severe problem during mod loading that has caused the game to fail", le); @@ -219,7 +219,7 @@ public class FMLClientHandler implements IFMLSidedHandler { try { - Loader.instance().initializeMods(); + Loader.instance().initializeMods(); } catch (LoaderException le) { @@ -263,11 +263,11 @@ public class FMLClientHandler implements IFMLSidedHandler */ public void onPreWorldTick() { -// if (client.field_6324_e != null) { -// // For the client world ticks and game ticks are the same -// FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD), client.field_6324_e, client.field_6313_p, client.field_6324_e); -// FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e); -// } + if (client.field_6324_e != null) { + // For the client world ticks and game ticks are the same + FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD), client.field_6324_e, client.field_6313_p, client.field_6324_e); + FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e); + } } /** @@ -280,10 +280,6 @@ public class FMLClientHandler implements IFMLSidedHandler // FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), client.field_6324_e, client.field_6313_p, client.field_6324_e); // FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6313_p, client.field_6324_e); // } - for (IKeyHandler entry : keyHandlers) - { - entry.onEndTick(); - } } public void onWorldLoadTick() @@ -750,7 +746,7 @@ public class FMLClientHandler implements IFMLSidedHandler public void registerKeyHandler(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat) { ModLoaderModContainer mlmc=ModLoaderHelper.registerKeyHelper(mod); - mlmc.addKeyHandler(new KeyBindingHandler(keyHandler, allowRepeat, mlmc)); + mlmc.addKeyHandler(new ModLoaderKeyBindingHandler(keyHandler, allowRepeat, mlmc)); } /** diff --git a/fml/client/cpw/mods/fml/client/KeyBindingHandler.java b/fml/client/cpw/mods/fml/client/ModLoaderKeyBindingHandler.java similarity index 63% rename from fml/client/cpw/mods/fml/client/KeyBindingHandler.java rename to fml/client/cpw/mods/fml/client/ModLoaderKeyBindingHandler.java index 72744c8600..a0056723e3 100644 --- a/fml/client/cpw/mods/fml/client/KeyBindingHandler.java +++ b/fml/client/cpw/mods/fml/client/ModLoaderKeyBindingHandler.java @@ -14,36 +14,42 @@ package cpw.mods.fml.client; +import java.util.EnumSet; + import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import net.minecraft.src.KeyBinding; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.IKeyHandler; import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.modloader.ModLoaderModContainer; /** * @author cpw * */ -public class KeyBindingHandler implements IKeyHandler +public class ModLoaderKeyBindingHandler implements IKeyHandler { private boolean shouldRepeat; private KeyBinding keyBinding; private ModContainer modContainer; private boolean lastState = false; + private boolean armed; /** * @param keyHandler * @param allowRepeat - * @param modContainer + * @param modContainer */ - public KeyBindingHandler(KeyBinding keyHandler, boolean allowRepeat, ModContainer modContainer) + public ModLoaderKeyBindingHandler(KeyBinding keyHandler, boolean allowRepeat, ModContainer modContainer) { this.keyBinding=keyHandler; this.shouldRepeat=allowRepeat; this.modContainer=modContainer; + FMLCommonHandler.instance().registerTickHandler(this); } @Override @@ -60,8 +66,7 @@ public class KeyBindingHandler implements IKeyHandler return modContainer; } - @Override - public void onEndTick() + public void onRenderEndTick() { int keyCode = keyBinding.field_1370_b; boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode)); @@ -71,4 +76,36 @@ public class KeyBindingHandler implements IKeyHandler } lastState = state; } + + @Override + public void tickStart(EnumSet type, Object... tickData) + { + // NO-OP for ML + } + + @Override + public void tickEnd(EnumSet type, Object... tickData) + { + if (type.contains(TickType.GUILOAD)|| type.contains(TickType.GAME)) + { + armed = true; + } + if (type.contains(TickType.RENDER) && armed) + { + onRenderEndTick(); + armed = false; + } + } + + @Override + public EnumSet ticks() + { + return EnumSet.of(TickType.GAME, TickType.RENDER, TickType.GUILOAD); + } + + @Override + public String getLabel() + { + return getOwningContainer()+" KB "+keyBinding.field_1371_a; + } } diff --git a/fml/common/cpw/mods/fml/common/IKeyHandler.java b/fml/common/cpw/mods/fml/common/IKeyHandler.java index e93c9ff2f1..5e846fae06 100644 --- a/fml/common/cpw/mods/fml/common/IKeyHandler.java +++ b/fml/common/cpw/mods/fml/common/IKeyHandler.java @@ -18,7 +18,7 @@ package cpw.mods.fml.common; * @author cpw * */ -public interface IKeyHandler +public interface IKeyHandler extends ITickHandler { Object getKeyBinding(); @@ -27,7 +27,4 @@ public interface IKeyHandler * @return */ ModContainer getOwningContainer(); - - void onEndTick(); - } diff --git a/fml/common/cpw/mods/fml/common/modloader/BaseModTicker.java b/fml/common/cpw/mods/fml/common/modloader/BaseModTicker.java index 866b139316..3e915202bd 100644 --- a/fml/common/cpw/mods/fml/common/modloader/BaseModTicker.java +++ b/fml/common/cpw/mods/fml/common/modloader/BaseModTicker.java @@ -60,7 +60,7 @@ public class BaseModTicker implements ITickHandler private void tickBaseMod(EnumSet types, boolean end, Object... tickData) { - if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.GAME) || ticks.contains(TickType.WORLDLOAD)) || ticks.contains(TickType.RENDER)) + if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.GAME) || ticks.contains(TickType.WORLDLOAD))) { EnumSet cTypes=EnumSet.copyOf(types); if ( ( end && types.contains(TickType.GAME)) || types.contains(TickType.WORLDLOAD))