Merge remote-tracking branch 'mainlap/newkeys' into newfmlmod

Conflicts:
	client/cpw/mods/fml/client/FMLClientHandler.java
This commit is contained in:
Christian committed 2012-07-22 20:30:42 -02:30
commit 8b5ddf1739
4 files changed
+53 -23

No files matched your search

@@ -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));
}
/**
@@ -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<TickType> type, Object... tickData)
{
// NO-OP for ML
}
@Override
public void tickEnd(EnumSet<TickType> 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<TickType> ticks()
{
return EnumSet.of(TickType.GAME, TickType.RENDER, TickType.GUILOAD);
}
@Override
public String getLabel()
{
return getOwningContainer()+" KB "+keyBinding.field_1371_a;
}
}
@@ -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();
}
@@ -60,7 +60,7 @@ public class BaseModTicker implements ITickHandler
private void tickBaseMod(EnumSet<TickType> 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))