9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-24 09:29:33 +00:00

perf(bukkit): 优化 chunks 加载逻辑

This commit is contained in:
jhqwqmc
2025-05-02 00:57:00 +08:00
parent bdaf9d759f
commit 7266a0eee2

View File

@@ -74,10 +74,8 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent {
int oldStateId = BlockStateUtils.blockDataToId(Bukkit.createBlockData(oldBlockState.getAsString()));
if (BlockStateUtils.isVanillaBlock(stateId) && BlockStateUtils.isVanillaBlock(oldStateId)) continue;
var ceChunk = ceWorld.getChunkAtIfLoaded(chunkX, chunkZ);
boolean needSave = false;
if (ceChunk == null) {
ceChunk = ceWorld.worldDataStorage().readChunkAt(ceWorld, new ChunkPos(chunkX, chunkZ));
needSave = true;
}
var immutableBlockState = BukkitBlockManager.instance().getImmutableBlockState(stateId);
if (immutableBlockState == null) {
@@ -85,7 +83,7 @@ public class FastAsyncWorldEditDelegate extends AbstractDelegateExtent {
} else {
ceChunk.setBlockState(blockX, blockY, blockZ, immutableBlockState);
}
if (needSave) needSaveChunks.add(ceChunk);
needSaveChunks.add(ceChunk);
}
for (CEChunk ceChunk : needSaveChunks) {
ceWorld.worldDataStorage().writeChunkAt(ceChunk.chunkPos(), ceChunk, true);