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

重置后标记未保存

This commit is contained in:
XiaoMoMi
2025-04-29 17:48:51 +08:00
parent 646d7a9025
commit 26dfb82f80
2 changed files with 15 additions and 9 deletions

View File

@@ -273,6 +273,7 @@ public class BukkitWorldManager implements WorldManager, Listener {
}
}
if (Config.restoreVanillaBlocks()) {
boolean unsaved = false;
CESection[] ceSections = ceChunk.sections();
Object worldServer = FastNMS.INSTANCE.field$CraftChunk$worldServer(chunk);
Object chunkSource = FastNMS.INSTANCE.method$ServerLevel$getChunkSource(worldServer);
@@ -282,18 +283,23 @@ public class BukkitWorldManager implements WorldManager, Listener {
CESection ceSection = ceSections[i];
Object section = sections[i];
BukkitInjector.uninjectLevelChunkSection(section);
if (ceSection.statesContainer().isEmpty()) continue;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 16; y++) {
ImmutableBlockState customState = ceSection.getBlockState(x, y, z);
if (!customState.isEmpty() && customState.vanillaBlockState() != null) {
FastNMS.INSTANCE.method$LevelChunkSection$setBlockState(section, x, y, z, customState.vanillaBlockState().handle(), false);
if (!ceSection.statesContainer().isEmpty()) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 16; y++) {
ImmutableBlockState customState = ceSection.getBlockState(x, y, z);
if (!customState.isEmpty() && customState.vanillaBlockState() != null) {
FastNMS.INSTANCE.method$LevelChunkSection$setBlockState(section, x, y, z, customState.vanillaBlockState().handle(), false);
unsaved = true;
}
}
}
}
}
}
if (unsaved && !FastNMS.INSTANCE.method$LevelChunk$isUnsaved(levelChunk)) {
FastNMS.INSTANCE.method$LevelChunk$markUnsaved(levelChunk);
}
}
ceChunk.unload();
}