diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorBlockEntity.java index 3f89c17cd..fbd451bf5 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorBlockEntity.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/MonitorBlockEntity.java @@ -349,13 +349,15 @@ public class MonitorBlockEntity extends BlockEntity { // Either delete the current monitor or sync a new one. if (needsTerminal) { if (serverMonitor == null) serverMonitor = new ServerMonitor(advanced, this); - } else { - serverMonitor = null; - } - // Update the terminal's width and height and rebuild it. This ensures the monitor - // is consistent when syncing it to other monitors. - if (serverMonitor != null) serverMonitor.rebuild(); + // Update the terminal's width and height and rebuild it. This ensures the monitor + // is consistent when syncing it to other monitors. + serverMonitor.rebuild(); + } else { + // Remove the terminal from the serverMonitor, but keep it around - this ensures that we sync + // the (now blank) monitor to the client. + if (serverMonitor != null) serverMonitor.reset(); + } // Update the other monitors, setting coordinates, dimensions and the server terminal var pos = getBlockPos(); diff --git a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java index 7de81be87..b7d43b8db 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/peripheral/monitor/ServerMonitor.java @@ -55,6 +55,12 @@ public class ServerMonitor { } } + synchronized void reset() { + if (terminal == null) return; + terminal = null; + markChanged(); + } + private void markChanged() { if (!changed.getAndSet(true)) TickScheduler.schedule(origin.tickToken); }