From 348af9c8e2a88037e264647d3236aa93eabf2fe5 Mon Sep 17 00:00:00 2001 From: Thiakil Date: Tue, 3 Sep 2024 10:20:19 +0800 Subject: [PATCH] check if forcing actually worked --- .../component/TileComponentChunkLoader.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java b/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java index 7dad77dbb77..90a6f4f413e 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentChunkLoader.java @@ -67,7 +67,10 @@ private void releaseChunkTickets(@NotNull ServerLevel world, @NotNull BlockPos p LOGGER.debug("Attempting to remove {} chunk tickets. Pos: {} World: {}", tickets, pos, world.dimension().location()); if (tickets > 0) { for (long chunkPos : chunkSet) { - TICKET_CONTROLLER.forceChunk(world, pos, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos), false, forceTicks); + boolean success = TICKET_CONTROLLER.forceChunk(world, pos, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos), false, forceTicks); + if (!success) { + LOGGER.warn("Failed to release chunk ticket for {}", chunkPos); + } } chunkSet.clear(); markDirty(); @@ -84,8 +87,11 @@ private void registerChunkTickets(@NotNull ServerLevel world) { LOGGER.debug("Attempting to add {} chunk tickets. Pos: {} World: {}", tickets, prevPos, world.dimension().location()); if (tickets > 0) { for (ChunkPos chunkPos : chunks) { - TICKET_CONTROLLER.forceChunk(world, prevPos, chunkPos.x, chunkPos.z, true, forceTicks); + boolean success = TICKET_CONTROLLER.forceChunk(world, prevPos, chunkPos.x, chunkPos.z, true, forceTicks); chunkSet.add(chunkPos.toLong()); + if (!success) { + LOGGER.error("Failed to force chunk during registration {}", chunkPos); + } } markDirty(); } @@ -147,7 +153,10 @@ private void refreshChunkTickets(@NotNull ServerLevel world, @NotNull BlockPos p if (!newChunks.contains(chunkPos)) { //If the chunk is no longer in our chunks we want loaded // then we need to unforce the chunk and remove it - TICKET_CONTROLLER.forceChunk(world, pos, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos), false, forceTicks); + boolean success = TICKET_CONTROLLER.forceChunk(world, pos, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos), false, forceTicks); + if (!success) { + LOGGER.warn("Failed to remove forced chunk {}", chunkPos); + } chunkIt.remove(); removed++; } @@ -157,7 +166,10 @@ private void refreshChunkTickets(@NotNull ServerLevel world, @NotNull BlockPos p if (chunkSet.add(chunkPos)) { //If we didn't already have it in our chunk set and added actually added it as it is new // then we also need to force the chunk - TICKET_CONTROLLER.forceChunk(world, pos, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos), true, forceTicks); + boolean success = TICKET_CONTROLLER.forceChunk(world, pos, ChunkPos.getX(chunkPos), ChunkPos.getZ(chunkPos), true, forceTicks); + if (!success) { + LOGGER.error("Failed to force chunk during refresh {}", chunkPos); + } added++; } }