Skip to content

Commit

Permalink
check if forcing actually worked
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Sep 3, 2024
1 parent 5913765 commit 348af9c
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down Expand Up @@ -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++;
}
Expand All @@ -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++;
}
}
Expand Down

0 comments on commit 348af9c

Please sign in to comment.