From 93ba2428a21929f980de05e65691deaa97d9d23c Mon Sep 17 00:00:00 2001 From: HenryLoenwind Date: Thu, 16 Apr 2015 20:40:33 +0200 Subject: [PATCH] New: Config value to disable upticking * Config value to have machines reject an update rate that is higher than the global tick rate. * Default is unchanged (allow). --- .../java/crazypants/enderio/TileEntityEio.java | 18 ++++++++++++------ .../java/crazypants/enderio/config/Config.java | 6 ++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/crazypants/enderio/TileEntityEio.java b/src/main/java/crazypants/enderio/TileEntityEio.java index dab44c05..f7ecd52d 100644 --- a/src/main/java/crazypants/enderio/TileEntityEio.java +++ b/src/main/java/crazypants/enderio/TileEntityEio.java @@ -5,6 +5,7 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import crazypants.enderio.config.Config; import crazypants.enderio.machine.PacketProgress; import crazypants.enderio.network.PacketHandler; import crazypants.util.BlockCoord; @@ -32,14 +33,19 @@ public abstract class TileEntityEio extends TileEntity { return true; } + private long lastUpdate = 0; + @Override public final void updateEntity() { - doUpdate(); - if(isProgressTile && !worldObj.isRemote) { - int curScaled = getProgressScaled(16); - if(++ticksSinceLastProgressUpdate >= getProgressUpdateFreq() || curScaled != lastProgressScaled) { - sendTaskProgressPacket(); - lastProgressScaled = curScaled; + if (Config.allowExternalTickSpeedup || worldObj.getTotalWorldTime() != lastUpdate) { + lastUpdate = worldObj.getTotalWorldTime(); + doUpdate(); + if (isProgressTile && !worldObj.isRemote) { + int curScaled = getProgressScaled(16); + if (++ticksSinceLastProgressUpdate >= getProgressUpdateFreq() || curScaled != lastProgressScaled) { + sendTaskProgressPacket(); + lastProgressScaled = curScaled; + } } } } diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 3bce15e0..5d279b0f 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -99,6 +99,7 @@ public final class Config { public static File configDirectory; public static boolean useHardRecipes = false; + public static boolean allowExternalTickSpeedup = true; public static boolean useSteelInChassi = false; @@ -567,6 +568,11 @@ public final class Config { transceiverUseEasyRecipe= config.get(sectionRecipe.name, "transceiverUseEasyRecipe", transceiverUseEasyRecipe, "When enabled the dim trans. will use a cheaper recipe") .getBoolean(useHardRecipes); + allowExternalTickSpeedup = config.get(sectionMisc.name, "allowExternalTickSpeedup", allowExternalTickSpeedup, + "Allows machines to run faster if another mod speeds up the tickrate. Running at higher tickrates is " + + "unsupported. Disable this if you run into any kind of problem.") + .getBoolean(allowExternalTickSpeedup); + enchanterBaseLevelCost = config.get(sectionRecipe.name, "enchanterBaseLevelCost", enchanterBaseLevelCost, "Base level cost added to all recipes in the enchanter.").getInt(enchanterBaseLevelCost);