From 471da2192b46e9cbb995b06b8d27aab10eee2f4e Mon Sep 17 00:00:00 2001 From: Fabian Maurer Date: Sun, 20 Sep 2026 22:53:14 +0200 Subject: [PATCH] Handle subworlds --- .../multipart/handler/packethandlers.scala | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/scala/codechicken/multipart/handler/packethandlers.scala b/src/main/scala/codechicken/multipart/handler/packethandlers.scala index a9226b1..16c27b6 100644 --- a/src/main/scala/codechicken/multipart/handler/packethandlers.scala +++ b/src/main/scala/codechicken/multipart/handler/packethandlers.scala @@ -202,13 +202,27 @@ object MultipartSPH def onTickEnd() { PacketScheduler.sendScheduled() - for ((world, m) <- updateMap if !m.isEmpty) - sendUpdates( - world, - m, - world, - pos => new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4) - ) + for ((world, m) <- updateMap if !m.isEmpty) { + if (chunkWatchers.contains(world)) + sendUpdates( + world, + m, + world, + pos => new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4) + ) + else + // The world is not watched directly, it is embedded in a host world. + sendUpdates( + world, + m, + WorldContextRegistry.getHostWorld(world), + pos => + WorldContextRegistry.getHostChunk( + world, + new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4) + ) + ) + } updateMap.foreach(_._2.clear()) for ( @@ -218,6 +232,12 @@ object MultipartSPH ) { sendDescription(world, p, c) chunkWatchers.getOrElseUpdate(world, newWatchMap).addBinding(p, c) + // Chunks embedded in this one become visible with it. + for ( + (subWorld, subChunks) <- WorldContextRegistry + .getVisibleChunks(world, c); + sc <- subChunks + ) sendDescription(subWorld, p, sc) } newWatchers.clear() }