Update to Minecraft 1.21.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-10-23 02:15:00 +11:00
parent 2c4beb962b
commit d3a23f42c3
522 changed files with 8501 additions and 6477 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/Chunk.java
+++ b/net/minecraft/world/level/chunk/Chunk.java
@@ -77,7 +77,7 @@
@@ -78,7 +78,7 @@
};
private final Map<BlockPosition, Chunk.d> tickersInLevel;
public boolean loaded;
@@ -9,16 +9,16 @@
@Nullable
private Supplier<FullChunkStatus> fullStatus;
@Nullable
@@ -93,7 +93,7 @@
public Chunk(World world, ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelChunkTicks<Block> levelchunkticks, LevelChunkTicks<FluidType> levelchunkticks1, long i, @Nullable ChunkSection[] achunksection, @Nullable Chunk.c chunk_c, @Nullable BlendingData blendingdata) {
super(chunkcoordintpair, chunkconverter, world, world.registryAccess().registryOrThrow(Registries.BIOME), i, achunksection, blendingdata);
@@ -97,7 +97,7 @@
this.tickersInLevel = Maps.newHashMap();
this.unsavedListener = (chunkcoordintpair1) -> {
};
- this.level = world;
+ this.level = (WorldServer) world; // CraftBukkit - type
this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap();
HeightMap.Type[] aheightmap_type = HeightMap.Type.values();
int j = aheightmap_type.length;
@@ -111,6 +111,11 @@
@@ -115,6 +115,11 @@
this.fluidTicks = levelchunkticks1;
}
@@ -30,18 +30,18 @@
public Chunk(WorldServer worldserver, ProtoChunk protochunk, @Nullable Chunk.c chunk_c) {
this(worldserver, protochunk.getPos(), protochunk.getUpgradeData(), protochunk.unpackBlockTicks(), protochunk.unpackFluidTicks(), protochunk.getInhabitedTime(), protochunk.getSections(), chunk_c, protochunk.getBlendingData());
Iterator iterator = protochunk.getBlockEntities().values().iterator();
@@ -142,6 +147,10 @@
@@ -146,6 +151,10 @@
this.skyLightSources = protochunk.skyLightSources;
this.setLightCorrect(protochunk.isLightCorrect());
this.unsaved = true;
this.markUnsaved();
+ this.needsDecoration = true; // CraftBukkit
+ // CraftBukkit start
+ this.persistentDataContainer = protochunk.persistentDataContainer; // SPIGOT-6814: copy PDC to account for 1.17 to 1.18 chunk upgrading.
+ // CraftBukkit end
}
@Override
@@ -244,9 +253,16 @@
public void setUnsavedListener(Chunk.e chunk_e) {
@@ -267,9 +276,16 @@
}
}
@@ -58,7 +58,7 @@
int i = blockposition.getY();
ChunkSection chunksection = this.getSection(this.getSectionIndex(i));
boolean flag1 = chunksection.hasOnlyAir();
@@ -295,7 +311,8 @@
@@ -319,7 +335,8 @@
if (!chunksection.getBlockState(j, k, l).is(block)) {
return null;
} else {
@@ -68,7 +68,7 @@
iblockdata.onPlace(this.level, blockposition, iblockdata1, flag);
}
@@ -345,7 +362,12 @@
@@ -370,7 +387,12 @@
@Nullable
public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@@ -82,7 +82,7 @@
if (tileentity == null) {
NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition);
@@ -417,6 +439,7 @@
@@ -442,6 +464,7 @@
if (!iblockdata.hasBlockEntity()) {
Chunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{tileentity, blockposition, iblockdata});
@@ -90,7 +90,7 @@
} else {
IBlockData iblockdata1 = tileentity.getBlockState();
@@ -470,6 +493,12 @@
@@ -495,6 +518,12 @@
if (this.isInLevel()) {
TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition);
@@ -103,7 +103,7 @@
if (tileentity != null) {
World world = this.level;
@@ -523,6 +552,57 @@
@@ -548,6 +577,57 @@
}
@@ -161,7 +161,7 @@
public boolean isEmpty() {
return false;
}
@@ -718,7 +798,7 @@
@@ -745,7 +825,7 @@
private <T extends TileEntity> void updateBlockEntityTicker(T t0) {
IBlockData iblockdata = t0.getBlockState();
@@ -170,7 +170,7 @@
if (blockentityticker == null) {
this.removeBlockEntityTicker(t0.getBlockPos());
@@ -803,7 +883,7 @@
@@ -836,7 +916,7 @@
private boolean loggedInvalidBlockState;
a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) {

View File

@@ -1,20 +1,24 @@
--- a/net/minecraft/world/level/chunk/ChunkSection.java
+++ b/net/minecraft/world/level/chunk/ChunkSection.java
@@ -23,9 +23,11 @@
@@ -23,7 +23,7 @@
private short tickingBlockCount;
private short tickingFluidCount;
private final DataPaletteBlock<IBlockData> states;
- private PalettedContainerRO<Holder<BiomeBase>> biomes;
+ // CraftBukkit start - read/write
+ private DataPaletteBlock<Holder<BiomeBase>> biomes;
+ private DataPaletteBlock<Holder<BiomeBase>> biomes; // CraftBukkit - read/write
private ChunkSection(ChunkSection chunksection) {
this.nonEmptyBlockCount = chunksection.nonEmptyBlockCount;
@@ -33,7 +33,7 @@
this.biomes = chunksection.biomes.copy();
}
- public ChunkSection(DataPaletteBlock<IBlockData> datapaletteblock, PalettedContainerRO<Holder<BiomeBase>> palettedcontainerro) {
+ public ChunkSection(DataPaletteBlock<IBlockData> datapaletteblock, DataPaletteBlock<Holder<BiomeBase>> palettedcontainerro) {
+ // CraftBukkit end
+ public ChunkSection(DataPaletteBlock<IBlockData> datapaletteblock, DataPaletteBlock<Holder<BiomeBase>> palettedcontainerro) { // CraftBukkit - read/write
this.states = datapaletteblock;
this.biomes = palettedcontainerro;
this.recalcBlockCounts();
@@ -188,6 +190,12 @@
@@ -196,6 +196,12 @@
return (Holder) this.biomes.get(i, j, k);
}

View File

@@ -24,11 +24,15 @@
private static void replaceMissingSections(IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) {
for (int i = 0; i < achunksection.length; ++i) {
@@ -270,10 +279,11 @@
public void setUnsaved(boolean flag) {
this.unsaved = flag;
+ if (!flag) this.persistentDataContainer.dirty(false); // CraftBukkit - SPIGOT-6814: chunk was saved, pdc is no longer dirty
@@ -275,6 +284,7 @@
public boolean tryMarkSaved() {
if (this.unsaved) {
this.unsaved = false;
+ this.persistentDataContainer.dirty(false); // CraftBukkit - SPIGOT-6814: chunk was saved, pdc is no longer dirty
return true;
} else {
return false;
@@ -282,7 +292,7 @@
}
public boolean isUnsaved() {
@@ -37,14 +41,14 @@
}
public abstract ChunkStatus getPersistedStatus();
@@ -449,6 +459,27 @@
@@ -458,6 +468,27 @@
}
}
+ // CraftBukkit start
+ public void setBiome(int i, int j, int k, Holder<BiomeBase> biome) {
+ try {
+ int l = QuartPos.fromBlock(this.getMinBuildHeight());
+ int l = QuartPos.fromBlock(this.getMinY());
+ int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1;
+ int j1 = MathHelper.clamp(j, l, i1);
+ int k1 = this.getSectionIndex(QuartPos.toBlock(j1));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
+++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
@@ -38,7 +38,7 @@
@@ -36,7 +36,7 @@
static CompletableFuture<IChunkAccess> generateStructureStarts(WorldGenContext worldgencontext, ChunkStep chunkstep, StaticCache2D<GenerationChunkHolder> staticcache2d, IChunkAccess ichunkaccess) {
WorldServer worldserver = worldgencontext.level();
@@ -9,20 +9,16 @@
worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager());
}
@@ -177,7 +177,21 @@
@@ -170,7 +170,17 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver));
- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver, EntitySpawnReason.LOAD));
+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
+ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver).filter((entity) -> {
+ worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver, EntitySpawnReason.LOAD).filter((entity) -> {
+ boolean needsRemoval = false;
+ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer();
+ if (!server.areNpcsEnabled() && entity instanceof net.minecraft.world.entity.npc.NPC) {
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
+ needsRemoval = true;
+ }
+ if (!server.isSpawningAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
+ if (!worldserver.getChunkSource().spawnFriendlies && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
+ needsRemoval = true;
+ }

View File

@@ -1,111 +0,0 @@
--- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
+++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
@@ -105,7 +105,7 @@
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
LevelLightEngine levellightengine = chunkproviderserver.getLightEngine();
IRegistry<BiomeBase> iregistry = worldserver.registryAccess().registryOrThrow(Registries.BIOME);
- Codec<PalettedContainerRO<Holder<BiomeBase>>> codec = makeBiomeCodec(iregistry);
+ Codec<DataPaletteBlock<Holder<BiomeBase>>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write
boolean flag2 = false;
for (int j = 0; j < nbttaglist.size(); ++j) {
@@ -124,17 +124,17 @@
datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES);
}
- Object object;
+ DataPaletteBlock object; // CraftBukkit - read/write
if (nbttagcompound1.contains("biomes", 10)) {
- object = (PalettedContainerRO) codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound1.getCompound("biomes")).promotePartial((s) -> {
+ object = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound1.getCompound("biomes")).promotePartial((s) -> { // CraftBukkit - decompile error
logErrors(chunkcoordintpair, b0, s);
}).getOrThrow(ChunkRegionLoader.a::new);
} else {
object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES);
}
- ChunkSection chunksection = new ChunkSection(datapaletteblock, (PalettedContainerRO) object);
+ ChunkSection chunksection = new ChunkSection(datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write
achunksection[k] = chunksection;
SectionPosition sectionposition = SectionPosition.of(chunkcoordintpair, b0);
@@ -171,7 +171,7 @@
dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data")));
logger = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger);
- blendingdata = (BlendingData) dataresult.resultOrPartial(logger::error).orElse((Object) null);
+ blendingdata = (BlendingData) ((DataResult<BlendingData>) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error
} else {
blendingdata = null;
}
@@ -202,7 +202,7 @@
dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen")));
logger = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger);
- Optional optional = dataresult.resultOrPartial(logger::error);
+ Optional<BelowZeroRetrogen> optional = ((DataResult<BelowZeroRetrogen>) dataresult).resultOrPartial(logger::error); // CraftBukkit - decompile error
Objects.requireNonNull(protochunk);
optional.ifPresent(protochunk::setBelowZeroRetrogen);
@@ -216,6 +216,13 @@
}
}
+ // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading.
+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound.get("ChunkBukkitValues");
+ if (persistentBase instanceof NBTTagCompound) {
+ ((IChunkAccess) object1).persistentDataContainer.putAll((NBTTagCompound) persistentBase);
+ }
+ // CraftBukkit end
+
((IChunkAccess) object1).setLightCorrect(flag);
NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps");
EnumSet<HeightMap.Type> enumset = EnumSet.noneOf(HeightMap.Type.class);
@@ -295,6 +302,12 @@
return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
}
+ // CraftBukkit start - read/write
+ private static Codec<DataPaletteBlock<Holder<BiomeBase>>> makeBiomeCodecRW(IRegistry<BiomeBase> iregistry) {
+ return DataPaletteBlock.codecRW(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
+ }
+ // CraftBukkit end
+
public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) {
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
NBTTagCompound nbttagcompound = GameProfileSerializer.addCurrentDataVersion(new NBTTagCompound());
@@ -306,7 +319,7 @@
nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime());
nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(ichunkaccess.getPersistedStatus()).toString());
BlendingData blendingdata = ichunkaccess.getBlendingData();
- DataResult dataresult;
+ DataResult<NBTBase> dataresult; // CraftBukkit - decompile error
Logger logger;
if (blendingdata != null) {
@@ -430,6 +443,11 @@
nbttagcompound.put("Heightmaps", nbttagcompound3);
nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences()));
+ // CraftBukkit start - store chunk persistent data in nbt
+ if (!ichunkaccess.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading.
+ nbttagcompound.put("ChunkBukkitValues", ichunkaccess.persistentDataContainer.toTagCompound());
+ }
+ // CraftBukkit end
return nbttagcompound;
}
@@ -534,6 +552,12 @@
StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i);
if (structurestart != null) {
+ // CraftBukkit start - load persistent data for structure start
+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues");
+ if (persistentBase instanceof NBTTagCompound) {
+ structurestart.persistentDataContainer.putAll((NBTTagCompound) persistentBase);
+ }
+ // CraftBukkit end
map.put(structure, structurestart);
}
}

View File

@@ -0,0 +1,146 @@
--- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
+++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java
@@ -76,7 +76,8 @@
import net.minecraft.world.ticks.TickListChunk;
import org.slf4j.Logger;
-public record SerializableChunkData(IRegistry<BiomeBase> biomeRegistry, ChunkCoordIntPair chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.d blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, ChunkConverter upgradeData, @Nullable long[] carvingMask, Map<HeightMap.Type, long[]> heightmaps, IChunkAccess.a packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List<SerializableChunkData.b> sectionData, List<NBTTagCompound> entities, List<NBTTagCompound> blockEntities, NBTTagCompound structureData) {
+// CraftBukkit - persistentDataContainer
+public record SerializableChunkData(IRegistry<BiomeBase> biomeRegistry, ChunkCoordIntPair chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.d blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, ChunkConverter upgradeData, @Nullable long[] carvingMask, Map<HeightMap.Type, long[]> heightmaps, IChunkAccess.a packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List<SerializableChunkData.b> sectionData, List<NBTTagCompound> entities, List<NBTTagCompound> blockEntities, NBTTagCompound structureData, @Nullable NBTBase persistentDataContainer) {
public static final Codec<DataPaletteBlock<IBlockData>> BLOCK_STATE_CODEC = DataPaletteBlock.codecRW(Block.BLOCK_STATE_REGISTRY, IBlockData.CODEC, DataPaletteBlock.d.SECTION_STATES, Blocks.AIR.defaultBlockState());
private static final Logger LOGGER = LogUtils.getLogger();
@@ -110,7 +111,7 @@
dataresult = BlendingData.d.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data"));
logger = SerializableChunkData.LOGGER;
Objects.requireNonNull(logger);
- blendingdata_d = (BlendingData.d) dataresult.resultOrPartial(logger::error).orElse((Object) null);
+ blendingdata_d = (BlendingData.d) ((DataResult<BlendingData.d>) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error
} else {
blendingdata_d = null;
}
@@ -121,7 +122,7 @@
dataresult = BelowZeroRetrogen.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen"));
logger = SerializableChunkData.LOGGER;
Objects.requireNonNull(logger);
- belowzeroretrogen = (BelowZeroRetrogen) dataresult.resultOrPartial(logger::error).orElse((Object) null);
+ belowzeroretrogen = (BelowZeroRetrogen) ((DataResult<BelowZeroRetrogen>) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error
} else {
belowzeroretrogen = null;
}
@@ -178,7 +179,7 @@
NBTTagList nbttaglist2 = nbttagcompound.getList("sections", 10);
List<SerializableChunkData.b> list4 = new ArrayList(nbttaglist2.size());
IRegistry<BiomeBase> iregistry = iregistrycustom.lookupOrThrow(Registries.BIOME);
- Codec<PalettedContainerRO<Holder<BiomeBase>>> codec = makeBiomeCodec(iregistry);
+ Codec<DataPaletteBlock<Holder<BiomeBase>>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write
for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) {
NBTTagCompound nbttagcompound3 = nbttaglist2.getCompound(i1);
@@ -196,17 +197,17 @@
datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES);
}
- Object object;
+ DataPaletteBlock object; // CraftBukkit - read/write
if (nbttagcompound3.contains("biomes", 10)) {
- object = (PalettedContainerRO) codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> {
+ object = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> { // CraftBukkit - read/write
logErrors(chunkcoordintpair, b0, s1);
}).getOrThrow(SerializableChunkData.a::new);
} else {
object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES);
}
- chunksection = new ChunkSection(datapaletteblock, (PalettedContainerRO) object);
+ chunksection = new ChunkSection(datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write
} else {
chunksection = null;
}
@@ -217,7 +218,8 @@
list4.add(new SerializableChunkData.b(b0, chunksection, nibblearray, nibblearray1));
}
- return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2);
+ // CraftBukkit - ChunkBukkitValues
+ return new SerializableChunkData(iregistry, chunkcoordintpair, levelheightaccessor.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2, nbttagcompound.get("ChunkBukkitValues"));
}
}
@@ -289,6 +291,12 @@
}
}
+ // CraftBukkit start - load chunk persistent data from nbt - SPIGOT-6814: Already load PDC here to account for 1.17 to 1.18 chunk upgrading.
+ if (persistentDataContainer instanceof NBTTagCompound) {
+ ((IChunkAccess) object).persistentDataContainer.putAll((NBTTagCompound) persistentDataContainer);
+ }
+ // CraftBukkit end
+
((IChunkAccess) object).setLightCorrect(this.lightCorrect);
EnumSet<HeightMap.Type> enumset = EnumSet.noneOf(HeightMap.Type.class);
Iterator iterator1 = ((IChunkAccess) object).getPersistedStatus().heightmapsAfter().iterator();
@@ -348,6 +356,12 @@
return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS));
}
+ // CraftBukkit start - read/write
+ private static Codec<DataPaletteBlock<Holder<BiomeBase>>> makeBiomeCodecRW(IRegistry<BiomeBase> iregistry) {
+ return DataPaletteBlock.codecRW(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS));
+ }
+ // CraftBukkit end
+
public static SerializableChunkData copyOf(WorldServer worldserver, IChunkAccess ichunkaccess) {
if (!ichunkaccess.canBeSerialized()) {
throw new IllegalArgumentException("Chunk can't be serialized: " + String.valueOf(ichunkaccess));
@@ -419,7 +433,14 @@
});
NBTTagCompound nbttagcompound1 = packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences());
- return new SerializableChunkData(worldserver.registryAccess().lookupOrThrow(Registries.BIOME), chunkcoordintpair, ichunkaccess.getMinSectionY(), worldserver.getGameTime(), ichunkaccess.getInhabitedTime(), ichunkaccess.getPersistedStatus(), (BlendingData.d) Optionull.map(ichunkaccess.getBlendingData(), BlendingData::pack), ichunkaccess.getBelowZeroRetrogen(), ichunkaccess.getUpgradeData().copy(), along, map, ichunkaccess_a, ashortlist, ichunkaccess.isLightCorrect(), list, list2, list1, nbttagcompound1);
+ // CraftBukkit start - store chunk persistent data in nbt
+ NBTTagCompound persistentDataContainer = null;
+ if (!ichunkaccess.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading.
+ persistentDataContainer = ichunkaccess.persistentDataContainer.toTagCompound();
+ }
+
+ return new SerializableChunkData(worldserver.registryAccess().lookupOrThrow(Registries.BIOME), chunkcoordintpair, ichunkaccess.getMinSectionY(), worldserver.getGameTime(), ichunkaccess.getInhabitedTime(), ichunkaccess.getPersistedStatus(), (BlendingData.d) Optionull.map(ichunkaccess.getBlendingData(), BlendingData::pack), ichunkaccess.getBelowZeroRetrogen(), ichunkaccess.getUpgradeData().copy(), along, map, ichunkaccess_a, ashortlist, ichunkaccess.isLightCorrect(), list, list2, list1, nbttagcompound1, persistentDataContainer);
+ // CraftBukkit end
}
}
@@ -432,7 +453,7 @@
nbttagcompound.putLong("LastUpdate", this.lastUpdateTime);
nbttagcompound.putLong("InhabitedTime", this.inhabitedTime);
nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(this.chunkStatus).toString());
- DataResult dataresult;
+ DataResult<NBTBase> dataresult; // CraftBukkit - decompile error
Logger logger;
if (this.blendingData != null) {
@@ -513,6 +534,11 @@
});
nbttagcompound.put("Heightmaps", nbttagcompound2);
nbttagcompound.put("structures", this.structureData);
+ // CraftBukkit start - store chunk persistent data in nbt
+ if (persistentDataContainer != null) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading.
+ nbttagcompound.put("ChunkBukkitValues", persistentDataContainer);
+ }
+ // CraftBukkit end
return nbttagcompound;
}
@@ -623,6 +649,12 @@
StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i);
if (structurestart != null) {
+ // CraftBukkit start - load persistent data for structure start
+ net.minecraft.nbt.NBTBase persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues");
+ if (persistentBase instanceof NBTTagCompound) {
+ structurestart.persistentDataContainer.putAll((NBTTagCompound) persistentBase);
+ }
+ // CraftBukkit end
map.put(structure, structurestart);
}
}