mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-02 10:37:54 +00:00
Defer monitor tile update when placed by another TE
This commit is contained in:
@@ -9,6 +9,7 @@ package dan200.computercraft.shared.peripheral.monitor;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import dan200.computercraft.api.turtle.FakePlayer;
|
||||
import dan200.computercraft.shared.common.BlockGeneric;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -71,9 +72,14 @@ public class BlockMonitor extends BlockGeneric {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
if (entity instanceof TileMonitor && !world.isClient) {
|
||||
TileMonitor monitor = (TileMonitor) entity;
|
||||
monitor.contractNeighbours();
|
||||
monitor.contract();
|
||||
monitor.expand();
|
||||
// Defer the block update if we're being placed by another TE. See #691
|
||||
if ( livingEntity == null || livingEntity instanceof FakePlayer )
|
||||
{
|
||||
monitor.updateNeighborsDeferred();
|
||||
return;
|
||||
}
|
||||
|
||||
monitor.updateNeighbors();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -54,6 +54,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile {
|
||||
private ServerMonitor m_serverMonitor;
|
||||
private ClientMonitor m_clientMonitor;
|
||||
private MonitorPeripheral peripheral;
|
||||
private boolean needsUpdate = false;
|
||||
private boolean m_destroyed = false;
|
||||
private boolean visiting = false;
|
||||
private int m_width = 1;
|
||||
@@ -98,6 +99,12 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile {
|
||||
|
||||
@Override
|
||||
public void blockTick() {
|
||||
if ( needsUpdate )
|
||||
{
|
||||
needsUpdate = false;
|
||||
updateNeighbors();
|
||||
}
|
||||
|
||||
if (this.m_xIndex != 0 || this.m_yIndex != 0 || this.m_serverMonitor == null) {
|
||||
return;
|
||||
}
|
||||
@@ -530,6 +537,18 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile {
|
||||
return true;
|
||||
}
|
||||
|
||||
void updateNeighborsDeferred()
|
||||
{
|
||||
needsUpdate = true;
|
||||
}
|
||||
|
||||
void updateNeighbors()
|
||||
{
|
||||
contractNeighbours();
|
||||
contract();
|
||||
expand();
|
||||
}
|
||||
|
||||
@SuppressWarnings ("StatementWithEmptyBody")
|
||||
void expand() {
|
||||
while (this.mergeLeft() || this.mergeRight() || this.mergeUp() || this.mergeDown()) {
|
||||
|
Reference in New Issue
Block a user