fix Cauldrons broken invalidation

This commit is contained in:
asiekierka 2015-05-07 10:48:00 +02:00
parent d6f603d635
commit d5be951092
3 changed files with 45 additions and 7 deletions

View file

@ -95,6 +95,7 @@ import buildcraft.core.lib.engines.TileEngineBase;
import buildcraft.core.lib.network.ChannelHandler;
import buildcraft.core.lib.utils.ColorUtils;
import buildcraft.core.lib.utils.NBTUtils;
import buildcraft.core.lib.utils.Utils;
import buildcraft.core.lib.utils.XorShift128Random;
import buildcraft.core.network.PacketHandlerCore;
import buildcraft.core.properties.WorldPropertyIsDirt;
@ -442,6 +443,28 @@ public class BuildCraftCore extends BuildCraftMod {
@Mod.EventHandler
public void serverStarting(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandBuildCraft());
if (Utils.CAULDRON_DETECTED) {
BCLog.logger.warn("############################################");
BCLog.logger.warn("# #");
BCLog.logger.warn("# Cauldron has been detected! Please keep #");
BCLog.logger.warn("# in mind that BuildCraft does NOT support #");
BCLog.logger.warn("# Cauldron and we do not promise to fix #");
BCLog.logger.warn("# bugs caused by its modifications to the #");
BCLog.logger.warn("# Minecraft engine. Please reconsider. #");
BCLog.logger.warn("# #");
BCLog.logger.warn("# Any lag caused by BuildCraft on top of #");
BCLog.logger.warn("# Cauldron likely arises from our fixes to #");
BCLog.logger.warn("# their bugs, so please don't report that #");
BCLog.logger.warn("# either. Thanks for your attention! ~BC #");
BCLog.logger.warn("# #");
BCLog.logger.warn("############################################");
// To people reading that code and thinking we're lying:
// Cauldron does not invalidate tile entities properly, causing
// issues with our tile entity cache. That is the bug and that
// is also the reason for the extra lag caused when using Cauldron.
}
}
@Mod.EventHandler

View file

@ -14,6 +14,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.core.lib.utils.BlockUtils;
import buildcraft.core.lib.utils.Utils;
public final class TileBuffer {
@ -56,11 +57,14 @@ public final class TileBuffer {
tracker.markTime(world);
}
public Block getBlock() {
if ((tile != null && tile.isInvalid()) || (tile == null && tracker.markTimeIfDelay(world))) {
private void tryRefresh() {
if (Utils.CAULDRON_DETECTED || (tile != null && tile.isInvalid()) || (tile == null && tracker.markTimeIfDelay(world))) {
refresh();
}
}
public Block getBlock() {
tryRefresh();
return block;
}
@ -70,11 +74,11 @@ public final class TileBuffer {
}
public TileEntity getTile(boolean forceUpdate) {
if (tile != null && !tile.isInvalid()) {
if (!Utils.CAULDRON_DETECTED && tile != null && !tile.isInvalid()) {
return tile;
}
if ((forceUpdate && tile != null && tile.isInvalid()) || tracker.markTimeIfDelay(world)) {
if (Utils.CAULDRON_DETECTED || (forceUpdate && tile != null && tile.isInvalid()) || tracker.markTimeIfDelay(world)) {
refresh();
if (tile != null && !tile.isInvalid()) {
@ -86,7 +90,7 @@ public final class TileBuffer {
}
public boolean exists() {
if (tile != null && !tile.isInvalid()) {
if (tile != null && !Utils.CAULDRON_DETECTED && !tile.isInvalid()) {
return true;
}

View file

@ -49,10 +49,21 @@ import buildcraft.core.lib.network.Packet;
import buildcraft.core.proxy.CoreProxy;
public final class Utils {
public static final boolean CAULDRON_DETECTED;
public static final XorShift128Random RANDOM = new XorShift128Random();
private static final List<ForgeDirection> directions = new ArrayList<ForgeDirection>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
static {
boolean cauldron = false;
try {
cauldron = Utils.class.getClassLoader().loadClass("org.spigotmc.SpigotConfig") != null;
} catch (ClassNotFoundException e) {
}
CAULDRON_DETECTED = cauldron;
}
/**
* Deactivate constructor
*/