diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java index 501571e5c..554a41cd7 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java @@ -116,7 +116,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { private CarriageSyncData getCarriageData() { return entityData.get(CARRIAGE_DATA); } - + public boolean hasSchedule() { return entityData.get(SCHEDULED); } @@ -175,7 +175,9 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { if (!level.isClientSide) { entityData.set(SCHEDULED, carriage.train.runtime.getSchedule() != null); - if (tickCount % getType().updateInterval() == 0 && carriageData.isDirty()) { + boolean shouldCarriageSyncThisTick = + carriage.train.shouldCarriageSyncThisTick(level.getGameTime(), getType().updateInterval()); + if (shouldCarriageSyncThisTick && carriageData.isDirty()) { entityData.set(CARRIAGE_DATA, null); entityData.set(CARRIAGE_DATA, carriageData); carriageData.setDirty(false); @@ -267,7 +269,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { Couple sides = Couple.create(false, false); if (!(contraption instanceof CarriageContraption cc)) return sides; - + sides.setFirst(cc.blazeBurnerConductors.getFirst()); sides.setSecond(cc.blazeBurnerConductors.getSecond()); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionInstance.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionInstance.java index 76079b4e0..844759931 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionInstance.java @@ -45,15 +45,16 @@ public class CarriageContraptionInstance extends EntityInstance carriages, List carriageSpacing, @@ -117,6 +118,7 @@ public class Train { manualSteer = SteerDirection.NONE; occupiedSignalBlocks = new HashMap<>(); reservedSignalBlocks = new HashSet<>(); + tickOffset = Create.RANDOM.nextInt(100); } public void earlyTick(Level level) { @@ -762,6 +764,10 @@ public class Train { }); } + + public boolean shouldCarriageSyncThisTick(long gameTicks, int updateInterval) { + return (gameTicks + tickOffset) % updateInterval == 0; + } public Couple> getEndpointEdges() { return Couple.create(carriages.get(0)