diff --git a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java index 539523975..d39ad764d 100644 --- a/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java +++ b/src/main/java/dan200/computercraft/client/proxy/ComputerCraftProxyClient.java @@ -23,7 +23,6 @@ import dan200.computercraft.shared.computer.inventory.ContainerComputerBase; import dan200.computercraft.shared.computer.inventory.ContainerViewComputer; import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive; import dan200.computercraft.shared.peripheral.monitor.ClientMonitor; -import dan200.computercraft.shared.peripheral.monitor.MonitorWatcher; import dan200.computercraft.shared.peripheral.printer.ContainerPrinter; import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; @@ -76,7 +75,6 @@ public final class ComputerCraftProxyClient implements ClientModInitializer public void onInitializeClient() { FrameInfo.init(); - MonitorWatcher.init(); registerContainers(); // While turtles themselves are not transparent, their upgrades may be. diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java index c8f35a5ec..99021a333 100644 --- a/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java +++ b/src/main/java/dan200/computercraft/fabric/mixin/MixinChunkMap.java @@ -5,7 +5,7 @@ */ package dan200.computercraft.fabric.mixin; -import dan200.computercraft.shared.peripheral.monitor.MonitorWatcher; +import dan200.computercraft.fabric.events.ComputerCraftCustomEvents; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; @@ -46,7 +46,7 @@ public class MixinChunkMap @Inject( method = "playerLoadedChunk", at = @At( value = "HEAD" ) ) private void playerLoadedChunk( ServerPlayer serverPlayer, MutableObject mutableObject, LevelChunk levelChunk, CallbackInfo ci ) { - MonitorWatcher.onWatch( serverPlayer, levelChunk.getPos() ); + ComputerCraftCustomEvents.SERVER_PLAYER_LOADED_CHUNK_EVENT.invoker().onServerPlayerLoadedChunk( serverPlayer, levelChunk.getPos() ); } } diff --git a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java index 4f082b0f6..be13b55d3 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/monitor/TileMonitor.java @@ -145,49 +145,24 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile width = nbt.getInt( NBT_WIDTH ); height = nbt.getInt( NBT_HEIGHT ); - if( oldXIndex != xIndex || oldYIndex != yIndex ) + if( level != null && level.isClientSide ) { - // If our index has changed then it's possible the origin monitor has changed. Thus - // we'll clear our cache. If we're the origin then we'll need to remove the glList as well. - if( oldXIndex == 0 && oldYIndex == 0 && clientMonitor != null ) clientMonitor.destroy(); - clientMonitor = null; - } + if( oldXIndex != xIndex || oldYIndex != yIndex ) + { + // If our index has changed then it's possible the origin monitor has changed. Thus + // we'll clear our cache. If we're the origin then we'll need to remove the glList as well. + if( oldXIndex == 0 && oldYIndex == 0 && clientMonitor != null ) clientMonitor.destroy(); + clientMonitor = null; + } - if( xIndex == 0 && yIndex == 0 ) - { - // If we're the origin terminal then create it. - if( clientMonitor == null ) clientMonitor = new ClientMonitor( advanced, this ); + if( xIndex == 0 && yIndex == 0 ) + { + // If we're the origin terminal then create it. + if( clientMonitor == null ) clientMonitor = new ClientMonitor( advanced, this ); + } } } - // @Override - // public final void handleUpdateTag( @Nonnull CompoundTag nbt ) - // { - // super.handleUpdateTag( nbt ); - // - // int oldXIndex = xIndex; - // int oldYIndex = yIndex; - // - // xIndex = nbt.getInt( NBT_X ); - // yIndex = nbt.getInt( NBT_Y ); - // width = nbt.getInt( NBT_WIDTH ); - // height = nbt.getInt( NBT_HEIGHT ); - // - // if( oldXIndex != xIndex || oldYIndex != yIndex ) - // { - // // If our index has changed then it's possible the origin monitor has changed. Thus - // // we'll clear our cache. If we're the origin then we'll need to remove the glList as well. - // if( oldXIndex == 0 && oldYIndex == 0 && clientMonitor != null ) clientMonitor.destroy(); - // clientMonitor = null; - // } - // - // if( xIndex == 0 && yIndex == 0 ) - // { - // // If we're the origin terminal then create it. - // if( clientMonitor == null ) clientMonitor = new ClientMonitor( advanced, this ); - // } - // } - @Override public void blockTick() { diff --git a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java index 5e875d045..53091c367 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/ComputerCraftProxyCommon.java @@ -27,6 +27,7 @@ import dan200.computercraft.shared.peripheral.commandblock.CommandBlockPeriphera import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods; import dan200.computercraft.shared.peripheral.modem.wired.BlockCable; import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; +import dan200.computercraft.shared.peripheral.monitor.MonitorWatcher; import dan200.computercraft.shared.turtle.FurnaceRefuelHandler; import dan200.computercraft.shared.util.Config; import dan200.computercraft.shared.util.TickScheduler; @@ -51,6 +52,7 @@ public final class ComputerCraftProxyCommon public static void init() { NetworkHandler.setup(); + MonitorWatcher.init(); registerProviders(); registerHandlers();