Reorganize ticking a bit

This commit is contained in:
Christian Weeks 2012-05-07 01:39:55 -04:00
parent 56e7270dee
commit 0438fbd47e
3 changed files with 46 additions and 27 deletions

View File

@ -148,17 +148,14 @@ public class FMLClientHandler implements IFMLSidedHandler
FMLCommonHandler.instance().worldTickEnd();
}
public void onRenderTickStart(float partialTickTime) {
for (ModContainer mod : Loader.getModList()) {
mod.tickStart(TickType.RENDER, partialTickTime);
}
public void onRenderTickStart(float partialTickTime)
{
FMLCommonHandler.instance().tickStart(TickType.RENDER, partialTickTime);
}
public void onRenderTickEnd(float partialTickTime) {
for (ModContainer mod : Loader.getModList()) {
mod.tickEnd(TickType.RENDER, partialTickTime);
}
public void onRenderTickEnd(float partialTickTime)
{
FMLCommonHandler.instance().tickEnd(TickType.RENDER, partialTickTime);
}
/**
* Get the server instance

View File

@ -15,13 +15,17 @@ package cpw.mods.fml.common;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Logger;
import cpw.mods.fml.common.ModContainer.TickType;
import net.minecraft.src.StringTranslate;
/**
@ -62,6 +66,7 @@ public class FMLCommonHandler
private int uniqueEntityListId = 220;
private List<ModContainer> extraTickers = new ArrayList<ModContainer>();
/**
* We register our delegate here
@ -77,10 +82,7 @@ public class FMLCommonHandler
*/
public void worldTickStart()
{
for (ModContainer mod : Loader.getModList())
{
mod.tickStart(ModContainer.TickType.WORLD,0.0);
}
tickStart(ModContainer.TickType.WORLD,0.0);
}
/**
@ -88,12 +90,32 @@ public class FMLCommonHandler
*/
public void worldTickEnd()
{
for (ModContainer mod : Loader.getModList())
{
mod.tickEnd(ModContainer.TickType.WORLD,0.0);
}
tickEnd(ModContainer.TickType.WORLD,0.0);
}
public void tickStart(TickType type, Object ... data)
{
for (ModContainer mod : Loader.getModList())
{
mod.tickStart(type, data);
}
for (ModContainer mod : extraTickers)
{
mod.tickStart(type, data);
}
}
public void tickEnd(TickType type, Object ... data)
{
for (ModContainer mod : Loader.getModList())
{
mod.tickEnd(type, data);
}
for (ModContainer mod : extraTickers)
{
mod.tickEnd(type, data);
}
}
/**
* @return the instance
*/
@ -308,16 +330,6 @@ public class FMLCommonHandler
languagePack.putAll(langPack);
}
/**
* @param modLoaderModContainer
* @return
*/
public boolean shouldTickMod(ModContainer modContainer)
{
// TODO Auto-generated method stub
return false;
}
/**
* @return
*/
@ -333,4 +345,9 @@ public class FMLCommonHandler
{
return sidedDelegate.isClient();
}
public void registerTicker(ModContainer ticker)
{
extraTickers.add(ticker);
}
}

View File

@ -58,7 +58,12 @@ public class ModLoaderModContainer implements ModContainer
this.ticks = EnumSet.noneOf(TickType.class);
}
/**
* We only instantiate this for "not mod mods"
* @param instance
*/
ModLoaderModContainer(BaseMod instance) {
FMLCommonHandler.instance().registerTicker(this);
this.mod=instance;
this.ticks = EnumSet.noneOf(TickType.class);
}