mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-06 03:28:12 +00:00
Don't wait for the chunk to be loaded when checking for monitors
There's a couple of alternative ways to solve this. Ideally we'd send our network messages at the same time as MC does (ChunkManager.playerLoadedChunk), but this'd require a mixin. Instead we just rely on the fact that if the chunk isn't loaded, monitors won't have done anything and so we don't need to send their contents! Fixes #1047, probably doesn't cause any regressions. I've not seen any issues on 1.16, but I also hadn't before so ¯\_(ツ)_/¯.
This commit is contained in:
parent
bcc7dd6991
commit
31ba17d085
@ -15,7 +15,6 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.ChunkStatus;
|
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.world.ChunkWatchEvent;
|
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||||
@ -47,8 +46,10 @@ public final class MonitorWatcher
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onWatch( ChunkWatchEvent.Watch event )
|
public static void onWatch( ChunkWatchEvent.Watch event )
|
||||||
{
|
{
|
||||||
|
// Get the current chunk if it has been loaded. This is safe as, if the chunk hasn't been loaded yet, then the
|
||||||
|
// monitor will have no contents, and so we won't need to send an update anyway.
|
||||||
ChunkPos chunkPos = event.getPos();
|
ChunkPos chunkPos = event.getPos();
|
||||||
Chunk chunk = (Chunk) event.getWorld().getChunk( chunkPos.x, chunkPos.z, ChunkStatus.FULL, false );
|
Chunk chunk = event.getWorld().getChunkSource().getChunkNow( chunkPos.x, chunkPos.z );
|
||||||
if( chunk == null ) return;
|
if( chunk == null ) return;
|
||||||
|
|
||||||
for( TileEntity te : chunk.getBlockEntities().values() )
|
for( TileEntity te : chunk.getBlockEntities().values() )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user