mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-24 22:14:32 +00:00
Reorganize basemod ticking to use ITickHandler. Introduce "GAME" tick vs "WORLD" tick for
mods that want to tick per world and "globally"
This commit is contained in:
1 parent
11652d597f
commit
9fd6f89fc3
13 files changed
+197
-147
No files matched your search
@@ -25,6 +25,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
@@ -266,8 +267,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
public void onPreWorldTick()
|
||||
{
|
||||
if (client.field_6324_e != null) {
|
||||
FMLCommonHandler.instance().worldTickStart(client.field_6324_e);
|
||||
FMLCommonHandler.instance().tickStart(TickType.WORLDGUI, 0.0f, client.field_6313_p);
|
||||
// For the client world ticks and game ticks are the same
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD,TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6324_e, client.field_6313_p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,8 +278,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
public void onPostWorldTick()
|
||||
{
|
||||
if (client.field_6324_e != null) {
|
||||
FMLCommonHandler.instance().worldTickEnd(client.field_6324_e);
|
||||
FMLCommonHandler.instance().tickEnd(TickType.WORLDGUI, 0.0f, client.field_6313_p);
|
||||
// For the client world ticks and game ticks are the same
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD,TickType.GAME,TickType.WORLDGUI), 0.0f, client.field_6324_e, client.field_6313_p);
|
||||
}
|
||||
for (IKeyHandler entry : keyHandlers)
|
||||
{
|
||||
@@ -294,21 +295,18 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
loadTextures(fallbackTexturePack);
|
||||
firstTick = false;
|
||||
}
|
||||
FMLCommonHandler.instance().tickStart(TickType.WORLDLOADTICK);
|
||||
FMLCommonHandler.instance().tickStart(TickType.GUILOADTICK);
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD,TickType.GUILOAD));
|
||||
}
|
||||
}
|
||||
|
||||
public void onRenderTickStart(float partialTickTime)
|
||||
{
|
||||
FMLCommonHandler.instance().tickStart(TickType.RENDER, partialTickTime);
|
||||
FMLCommonHandler.instance().tickStart(TickType.GUI, partialTickTime, client.field_6313_p);
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
|
||||
}
|
||||
|
||||
public void onRenderTickEnd(float partialTickTime)
|
||||
{
|
||||
FMLCommonHandler.instance().tickEnd(TickType.RENDER, partialTickTime);
|
||||
FMLCommonHandler.instance().tickEnd(TickType.GUI, partialTickTime, client.field_6313_p);
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.RENDER,TickType.GUI), partialTickTime, client.field_6313_p);
|
||||
}
|
||||
/**
|
||||
* Get the server instance
|
||||
|
||||
@@ -44,13 +44,13 @@ public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
||||
Minecraft mc = (Minecraft) minecraftInstance;
|
||||
boolean hasWorld = mc.field_6324_e != null;
|
||||
// World and render ticks
|
||||
if (((tickEnd && tick==TickType.WORLD) || (tickEnd && tick==TickType.RENDER)) && hasWorld) {
|
||||
if (((tickEnd && tick==TickType.GAME) || (tickEnd && tick==TickType.RENDER)) && hasWorld) {
|
||||
return onTickInGame((Float) data[0], mc);
|
||||
} else if (((tickEnd && tick==TickType.WORLDGUI) || (tickEnd && tick==TickType.GUI))) {
|
||||
return onTickInGUI((Float) data[0], mc, (GuiScreen)data[1]);
|
||||
} else if (tick == TickType.WORLDLOADTICK && hasWorld) {
|
||||
} else if (tick == TickType.WORLDLOAD && hasWorld) {
|
||||
return onTickInGame(0.0f, mc);
|
||||
} else if (tick == TickType.GUILOADTICK) {
|
||||
} else if (tick == TickType.GUILOAD) {
|
||||
return onTickInGUI(0.0f, mc, mc.field_6313_p);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user