Skip to content

Commit 591549d

Browse files
committed
Improve loop detection(?)
Might help with #382
1 parent 3ae52b8 commit 591549d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/org/dave/compactmachines3/block/BlockMachine.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,15 @@ public void neighborChanged(IBlockState state, World world, BlockPos pos, Block
130130
// Make sure we don't stack overflow when we get in a notifyBlockChange loop.
131131
// Just ensure only a single notification happens per tick.
132132
TileEntityMachine te = (TileEntityMachine) world.getTileEntity(pos);
133-
if(te.isInsideItself()) {
133+
if(te.isInsideItself() || te.alreadyNotifiedOnTick) {
134134
return;
135135
}
136136

137137
WorldServer machineWorld = DimensionTools.getServerMachineWorld();
138138
BlockPos neighborPos = te.getTunnelForSide(facing);
139139
if(neighborPos != null && machineWorld.getTileEntity(neighborPos) instanceof TileEntityTunnel) {
140-
if(te.lastNeighborUpdateTick != world.getTotalWorldTime()) {
141-
machineWorld.notifyNeighborsOfStateChange(neighborPos, Blockss.tunnel, false);
142-
te.lastNeighborUpdateTick = world.getTotalWorldTime();
143-
}
140+
machineWorld.notifyNeighborsOfStateChange(neighborPos, Blockss.tunnel, false);
141+
te.alreadyNotifiedOnTick = true;
144142
}
145143

146144

src/main/java/org/dave/compactmachines3/tile/TileEntityMachine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
public class TileEntityMachine extends TileEntity implements ICapabilityProvider, ITickable {
4242
public int coords = -1;
4343
private boolean initialized = false;
44-
public long lastNeighborUpdateTick = 0;
44+
public boolean alreadyNotifiedOnTick = false;
4545
public long nextSpawnTick = 0;
4646

4747
protected String customName = "";
@@ -300,6 +300,8 @@ public void update() {
300300
this.initialized = true;
301301
}
302302

303+
this.alreadyNotifiedOnTick = false;
304+
303305
if(nextSpawnTick == 0) {
304306
nextSpawnTick = this.getWorld().getTotalWorldTime() + ConfigurationHandler.MachineSettings.spawnRate;
305307
}

0 commit comments

Comments
 (0)