From 49be023eabfde3938cd18003c9dd7ec17020f800 Mon Sep 17 00:00:00 2001 From: Christian Weeks Date: Sun, 6 May 2012 00:58:40 -0400 Subject: [PATCH] Halfway through ticking- won't compile --- fml/client/net/minecraft/src/BaseMod.java | 2 +- fml/client/net/minecraft/src/ModLoader.java | 7 +++- .../cpw/mods/fml/common/FMLCommonHandler.java | 12 +++++- .../cpw/mods/fml/common/ModContainer.java | 10 ++++- .../modloader/ModLoaderModContainer.java | 42 ++++++++++++++++--- .../net/minecraft/client/Minecraft.java.patch | 16 +++++++ 6 files changed, 77 insertions(+), 12 deletions(-) diff --git a/fml/client/net/minecraft/src/BaseMod.java b/fml/client/net/minecraft/src/BaseMod.java index 3b3254e19..c6db51e76 100644 --- a/fml/client/net/minecraft/src/BaseMod.java +++ b/fml/client/net/minecraft/src/BaseMod.java @@ -33,7 +33,7 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp * @param minecraftInstance * @return */ - public final boolean doTickInGame(Object minecraftInstance) + public final boolean doTickInGame(float clock, Object minecraftInstance) { return onTickInGame((Minecraft)minecraftInstance); } diff --git a/fml/client/net/minecraft/src/ModLoader.java b/fml/client/net/minecraft/src/ModLoader.java index 6dfe03e24..126a58d02 100644 --- a/fml/client/net/minecraft/src/ModLoader.java +++ b/fml/client/net/minecraft/src/ModLoader.java @@ -720,12 +720,15 @@ public class ModLoader { ModLoaderModContainer mlmc = (ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod); mlmc.setTicking(enable); + mlmc.setClockTicks(useClock); } - static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock) + public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock) { - //TODO + ModLoaderModContainer mlmc = (ModLoaderModContainer) ModLoaderModContainer.findContainerFor(mod); + mlmc.setGUITicking(enable); + mlmc.setGUIClockTicks(useClock); } /** diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 10e2d10ad..e2b6d4e4d 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -60,7 +60,7 @@ public class FMLCommonHandler */ private IFMLSidedHandler sidedDelegate; - private int uniqueEntityListId = 250; + private int uniqueEntityListId = 220; /** @@ -307,4 +307,14 @@ public class FMLCommonHandler } languagePack.putAll(langPack); } + + /** + * @param modLoaderModContainer + * @return + */ + public boolean shouldTickMod(ModContainer modContainer) + { + // TODO Auto-generated method stub + return false; + } } diff --git a/fml/common/cpw/mods/fml/common/ModContainer.java b/fml/common/cpw/mods/fml/common/ModContainer.java index f7728e732..864ed2c39 100644 --- a/fml/common/cpw/mods/fml/common/ModContainer.java +++ b/fml/common/cpw/mods/fml/common/ModContainer.java @@ -55,14 +55,20 @@ public interface ModContainer * @return */ String getName(); + /** + * Should the mod tick + * @param clock + * @return + */ + boolean shouldTick(float clock); /** * A tick has started */ - void tickStart(); + void tickStart(float clock); /** * A tick has ended */ - void tickEnd(); + void tickEnd(float clock); /** * Does this mod match the supplied mod? * @param mod diff --git a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java index 886a05626..19aa2814c 100644 --- a/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java +++ b/fml/common/cpw/mods/fml/common/modloader/ModLoaderModContainer.java @@ -47,6 +47,9 @@ public class ModLoaderModContainer implements ModContainer private ArrayList dependencies; private ArrayList preDependencies; private ArrayList postDependencies; + private boolean clockTicks; + private boolean guiTicks; + private boolean guiClockTicks; public ModLoaderModContainer(Class modClazz, File modSource) { this.modClazz = modClazz; @@ -278,15 +281,18 @@ public class ModLoaderModContainer implements ModContainer } @Override - public void tickStart() + public boolean shouldTick(float clock) { - if (isTicking) - { - isTicking = mod.doTickInGame(FMLCommonHandler.instance().getMinecraftInstance()); - } + return isTicking && ((!clockTicks || clock!=lastClock ) || () + return false; } @Override - public void tickEnd() + public void tickStart(float clock) + { + isTicking = mod.doTickInGame(clock, FMLCommonHandler.instance().getMinecraftInstance()); + } + @Override + public void tickEnd(float clock) { // NOOP for modloader } @@ -526,4 +532,28 @@ public class ModLoaderModContainer implements ModContainer { return mod; } + + /** + * @param useClock + */ + public void setClockTicks(boolean useClock) + { + this.clockTicks=useClock; + } + + /** + * @param enable + */ + public void setGUITicking(boolean enable) + { + this.guiTicks=enable; + } + + /** + * @param useClock + */ + public void setGUIClockTicks(boolean useClock) + { + this.guiClockTicks=useClock; + } } diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 3dcebf514..b202b19c9 100644 --- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -25,3 +25,19 @@ this.func_6250_c("Startup"); this.field_6286_O = new OpenGlCapsChecker(); this.field_6301_A.func_340_a(this.field_6304_y); +@@ -1340,6 +1344,7 @@ + this.func_28001_B(); + } + ++ FMLClientHandler.instance().onPreTick(); + Profiler.func_40663_a("stats"); + this.field_25001_G.func_27178_d(); + Profiler.func_40661_c("gui"); +@@ -1730,6 +1735,7 @@ + } + + Profiler.func_40662_b(); ++ FMLClientHandler.instance().onPostTick(); + this.field_6287_N = System.currentTimeMillis(); + } +