Update to Minecraft 1.19

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2022-06-08 02:00:00 +10:00
parent 91d9aa9a89
commit 25f3b50f6b
332 changed files with 3628 additions and 2559 deletions

View File

@@ -50,7 +50,7 @@
}
@Override
@@ -238,9 +254,16 @@
@@ -246,9 +262,16 @@
}
}
@@ -67,7 +67,7 @@
int i = blockposition.getY();
ChunkSection chunksection = this.getSection(this.getSectionIndex(i));
boolean flag1 = chunksection.hasOnlyAir();
@@ -279,7 +302,8 @@
@@ -287,7 +310,8 @@
if (!chunksection.getBlockState(j, k, l).is(block)) {
return null;
} else {
@@ -77,7 +77,7 @@
iblockdata.onPlace(this.level, blockposition, iblockdata1, flag);
}
@@ -324,7 +348,12 @@
@@ -332,7 +356,12 @@
@Nullable
public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
@@ -91,7 +91,7 @@
if (tileentity == null) {
NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition);
@@ -395,6 +424,13 @@
@@ -410,6 +439,13 @@
tileentity1.setRemoved();
}
@@ -105,7 +105,7 @@
}
}
@@ -424,6 +460,12 @@
@@ -439,6 +475,12 @@
if (this.isInLevel()) {
TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition);
@@ -116,9 +116,9 @@
+ // CraftBukkit end
+
if (tileentity != null) {
this.removeGameEventListener(tileentity);
tileentity.setRemoved();
@@ -471,6 +513,55 @@
World world = this.level;
@@ -491,6 +533,55 @@
}
@@ -174,7 +174,7 @@
public boolean isEmpty() {
return false;
}
@@ -659,7 +750,7 @@
@@ -684,7 +775,7 @@
private <T extends TileEntity> void updateBlockEntityTicker(T t0) {
IBlockData iblockdata = t0.getBlockState();
@@ -183,7 +183,7 @@
if (blockentityticker == null) {
this.removeBlockEntityTicker(t0.getBlockPos());
@@ -752,7 +843,7 @@
@@ -777,7 +868,7 @@
private boolean loggedInvalidBlockState;
a(TileEntity tileentity, BlockEntityTicker blockentityticker) {

View File

@@ -1,16 +1,7 @@
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -261,7 +261,7 @@
while (iterator.hasNext()) {
Holder<StructureFeature<?, ?>> holder = (Holder) iterator.next();
- Stream stream = set1.stream();
+ Stream<Holder<BiomeBase>> stream = set1.stream(); // CraftBukkit - decompile error
HolderSet holderset1 = ((StructureFeature) holder.value()).biomes();
Objects.requireNonNull(holderset1);
@@ -411,7 +411,7 @@
return null;
@@ -414,7 +414,7 @@
}
}
- public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) {
@@ -18,25 +9,25 @@
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) {
@@ -427,7 +427,7 @@
Set<BiomeBase> set = new ObjectArraySet();
@@ -436,7 +436,7 @@
if (this instanceof ChunkProviderFlat) {
- Stream stream = this.biomeSource.possibleBiomes().stream().map(Holder::value);
+ Stream<BiomeBase> stream = this.biomeSource.possibleBiomes().stream().map(Holder::value); // CraftBukkit - decompile error
for (int k = 0; k < j; ++k) {
ChunkSection chunksection = achunksection[k];
- PalettedContainerRO palettedcontainerro = chunksection.getBiomes();
+ PalettedContainerRO<Holder<BiomeBase>> palettedcontainerro = chunksection.getBiomes(); // CraftBukkit - decompile error
Objects.requireNonNull(set);
stream.forEach(set::add);
@@ -467,7 +467,7 @@
StructureFeature<?, ?> structurefeature = (StructureFeature) iterator.next();
Objects.requireNonNull(set);
palettedcontainerro.getAll(set::add);
@@ -462,7 +462,7 @@
Structure structure = (Structure) iterator.next();
seededrandom.setFeatureSeed(i, i1, l);
- Supplier supplier = () -> {
+ Supplier<String> supplier = () -> { // CraftBukkit - decompile error
Optional optional = iregistry.getResourceKey(structurefeature).map(Object::toString);
Optional optional = iregistry.getResourceKey(structure).map(Object::toString);
Objects.requireNonNull(structurefeature);
@@ -552,6 +552,33 @@
Objects.requireNonNull(structure);
@@ -547,6 +547,33 @@
}
}
@@ -59,7 +50,7 @@
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
+ SeededRandom seededrandom = new SeededRandom(new net.minecraft.world.level.levelgen.LegacyRandomSource(generatoraccessseed.getSeed()));
+ seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), x, z);
+ populator.populate(world, seededrandom, x, z, limitedRegion);
+ populator.populate(world, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
+ }
+ limitedRegion.saveEntities();
+ limitedRegion.breakLink();
@@ -67,6 +58,6 @@
+ // CraftBukkit end
+ }
+
public boolean hasFeatureChunkInRange(ResourceKey<StructureSet> resourcekey, long i, int j, int k, int l) {
StructureSet structureset = (StructureSet) this.structureSets.get(resourcekey);
public boolean hasStructureChunkInRange(Holder<StructureSet> holder, RandomState randomstate, long i, int j, int k, int l) {
StructureSet structureset = (StructureSet) holder.value();

View File

@@ -1,6 +1,20 @@
--- a/net/minecraft/world/level/chunk/ChunkSection.java
+++ b/net/minecraft/world/level/chunk/ChunkSection.java
@@ -190,6 +190,12 @@
@@ -25,9 +25,11 @@
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;
- public ChunkSection(int i, DataPaletteBlock<IBlockData> datapaletteblock, PalettedContainerRO<Holder<BiomeBase>> palettedcontainerro) {
+ public ChunkSection(int i, DataPaletteBlock<IBlockData> datapaletteblock, DataPaletteBlock<Holder<BiomeBase>> palettedcontainerro) {
+ // CraftBukkit end
this.bottomBlockY = getBottomBlockY(i);
this.states = datapaletteblock;
this.biomes = palettedcontainerro;
@@ -193,6 +195,12 @@
return (Holder) this.biomes.get(i, j, k);
}
@@ -11,5 +25,5 @@
+ // CraftBukkit end
+
public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j) {
DataPaletteBlock<Holder<BiomeBase>> datapaletteblock = this.getBiomes();
DataPaletteBlock<Holder<BiomeBase>> datapaletteblock = this.biomes.recreate();
int k = QuartPos.fromBlock(this.bottomBlockY());

View File

@@ -2,10 +2,10 @@
+++ b/net/minecraft/world/level/chunk/ChunkStatus.java
@@ -47,7 +47,7 @@
});
public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, definedstructuremanager, lightenginethreaded, function, list, ichunkaccess, flag) -> {
public static final ChunkStatus STRUCTURE_STARTS = register("structure_starts", ChunkStatus.EMPTY, 0, ChunkStatus.PRE_FEATURES, ChunkStatus.Type.PROTOCHUNK, (chunkstatus, executor, worldserver, chunkgenerator, structuretemplatemanager, lightenginethreaded, function, list, ichunkaccess, flag) -> {
if (!ichunkaccess.getStatus().isOrAfter(chunkstatus)) {
- if (worldserver.getServer().getWorldData().worldGenSettings().generateFeatures()) {
+ if (worldserver.serverLevelData.worldGenSettings().generateFeatures()) { // CraftBukkit
chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.structureFeatureManager(), ichunkaccess, definedstructuremanager, worldserver.getSeed());
- if (worldserver.getServer().getWorldData().worldGenSettings().generateStructures()) {
+ if (worldserver.serverLevelData.worldGenSettings().generateStructures()) { // CraftBukkit
chunkgenerator.createStructures(worldserver.registryAccess(), worldserver.getChunkSource().randomState(), worldserver.structureManager(), ichunkaccess, structuretemplatemanager, worldserver.getSeed());
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/IChunkAccess.java
+++ b/net/minecraft/world/level/chunk/IChunkAccess.java
@@ -80,6 +80,11 @@
@@ -77,6 +77,11 @@
protected final LevelHeightAccessor levelHeightAccessor;
protected final ChunkSection[] sections;
@@ -12,7 +12,7 @@
public IChunkAccess(ChunkCoordIntPair chunkcoordintpair, ChunkConverter chunkconverter, LevelHeightAccessor levelheightaccessor, IRegistry<BiomeBase> iregistry, long i, @Nullable ChunkSection[] achunksection, @Nullable BlendingData blendingdata) {
this.chunkPos = chunkcoordintpair;
this.upgradeData = chunkconverter;
@@ -97,7 +102,11 @@
@@ -94,7 +99,11 @@
}
replaceMissingSections(levelheightaccessor, iregistry, this.sections);
@@ -24,7 +24,7 @@
private static void replaceMissingSections(LevelHeightAccessor levelheightaccessor, IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) {
for (int i = 0; i < achunksection.length; ++i) {
@@ -259,10 +268,11 @@
@@ -256,10 +265,11 @@
public void setUnsaved(boolean flag) {
this.unsaved = flag;
@@ -37,7 +37,7 @@
}
public abstract ChunkStatus getStatus();
@@ -395,6 +405,27 @@
@@ -392,6 +402,27 @@
}
}
@@ -65,23 +65,3 @@
public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler) {
ChunkCoordIntPair chunkcoordintpair = this.getPos();
int i = QuartPos.fromBlock(chunkcoordintpair.getMinBlockX());
@@ -426,8 +457,10 @@
return this;
}
- public static record a(SerializableTickContainer<Block> a, SerializableTickContainer<FluidType> b) {
+ // CraftBukkit start - decompile error
+ public static record a(SerializableTickContainer<Block> blocks, SerializableTickContainer<FluidType> fluids) {
+ /*
private final SerializableTickContainer<Block> blocks;
private final SerializableTickContainer<FluidType> fluids;
@@ -443,5 +476,7 @@
public SerializableTickContainer<FluidType> fluids() {
return this.fluids;
}
+ */
+ // CraftBukkit end
}
}

View File

@@ -1,24 +1,45 @@
--- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
+++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
@@ -117,7 +117,7 @@
@@ -100,7 +100,7 @@
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
LightEngine lightengine = chunkproviderserver.getLightEngine();
IRegistry<BiomeBase> iregistry = worldserver.registryAccess().registryOrThrow(IRegistry.BIOME_REGISTRY);
- Codec<PalettedContainerRO<Holder<BiomeBase>>> codec = makeBiomeCodec(iregistry);
+ Codec<DataPaletteBlock<Holder<BiomeBase>>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write
boolean flag2 = false;
DataResult dataresult;
@@ -120,12 +120,12 @@
});
logger = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger);
- datapaletteblock = (DataPaletteBlock) dataresult.getOrThrow(false, logger::error);
+ datapaletteblock = (DataPaletteBlock) ((DataResult<DataPaletteBlock<IBlockData>>) dataresult).getOrThrow(false, logger::error); // CraftBukkit - decompile error
} else {
datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.e.SECTION_STATES);
datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES);
}
@@ -130,7 +130,7 @@
- Object object;
+ DataPaletteBlock object; // CraftBukkit - read/write
if (nbttagcompound1.contains("biomes", 10)) {
dataresult = codec.parse(DynamicOpsNBT.INSTANCE, nbttagcompound1.getCompound("biomes")).promotePartial((s) -> {
@@ -133,12 +133,12 @@
});
logger = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger);
- datapaletteblock1 = (DataPaletteBlock) dataresult.getOrThrow(false, logger::error);
+ datapaletteblock1 = (DataPaletteBlock) ((DataResult<DataPaletteBlock<Holder<BiomeBase>>>) dataresult).getOrThrow(false, logger::error); // CraftBukkit - decompile error
- object = (PalettedContainerRO) dataresult.getOrThrow(false, logger::error);
+ object = ((DataResult<DataPaletteBlock<Holder<BiomeBase>>>) dataresult).getOrThrow(false, logger::error); // CraftBukkit - decompile error
} else {
datapaletteblock1 = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.e.SECTION_BIOMES);
object = new DataPaletteBlock<>(iregistry.asHolderIdMap(), iregistry.getHolderOrThrow(Biomes.PLAINS), DataPaletteBlock.d.SECTION_BIOMES);
}
@@ -161,7 +161,7 @@
- ChunkSection chunksection = new ChunkSection(b0, datapaletteblock, (PalettedContainerRO) object);
+ ChunkSection chunksection = new ChunkSection(b0, datapaletteblock, (DataPaletteBlock) object); // CraftBukkit - read/write
achunksection[k] = chunksection;
villageplace.checkConsistencyWithBlocks(chunkcoordintpair, chunksection);
@@ -172,7 +172,7 @@
dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data")));
logger1 = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger1);
@@ -27,7 +48,7 @@
} else {
blendingdata = null;
}
@@ -192,7 +192,7 @@
@@ -203,7 +203,7 @@
dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen")));
logger1 = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger1);
@@ -36,21 +57,34 @@
Objects.requireNonNull(protochunk);
optional.ifPresent(protochunk::setBelowZeroRetrogen);
@@ -221,6 +221,13 @@
@@ -232,6 +232,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) object).persistentDataContainer.putAll((NBTTagCompound) persistentBase);
+ ((IChunkAccess) object1).persistentDataContainer.putAll((NBTTagCompound) persistentBase);
+ }
+ // CraftBukkit end
+
((IChunkAccess) object).setLightCorrect(flag);
((IChunkAccess) object1).setLightCorrect(flag);
NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps");
EnumSet<HeightMap.Type> enumset = EnumSet.noneOf(HeightMap.Type.class);
@@ -323,7 +330,7 @@
@@ -322,6 +329,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 = new NBTTagCompound();
@@ -334,7 +347,7 @@
nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime());
nbttagcompound.putString("Status", ichunkaccess.getStatus().getName());
BlendingData blendingdata = ichunkaccess.getBlendingData();
@@ -59,7 +93,7 @@
Logger logger;
if (blendingdata != null) {
@@ -370,7 +377,7 @@
@@ -381,7 +394,7 @@
if (flag1) {
ChunkSection chunksection = achunksection[j];
@@ -68,7 +102,7 @@
Logger logger1 = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger1);
@@ -454,6 +461,11 @@
@@ -465,6 +478,11 @@
nbttagcompound.put("Heightmaps", nbttagcompound3);
nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences()));

View File

@@ -1,10 +1,11 @@
--- a/net/minecraft/world/level/chunk/storage/IChunkLoader.java
+++ b/net/minecraft/world/level/chunk/storage/IChunkLoader.java
@@ -18,6 +18,14 @@
@@ -19,6 +19,15 @@
import net.minecraft.world.level.levelgen.structure.PersistentStructureLegacy;
import net.minecraft.world.level.storage.WorldPersistentData;
+// CraftBukkit start
+import java.util.concurrent.ExecutionException;
+import net.minecraft.server.level.ChunkProviderServer;
+import net.minecraft.server.level.WorldServer;
+import net.minecraft.world.level.GeneratorAccess;
@@ -15,13 +16,13 @@
public class IChunkLoader implements AutoCloseable {
public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493;
@@ -31,9 +39,48 @@
this.worker = new IOWorker(path, flag, "chunk");
@@ -36,9 +45,53 @@
return this.worker.isOldChunkAround(chunkcoordintpair, i);
}
- public NBTTagCompound upgradeChunkTag(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) {
+ // CraftBukkit start
+ private boolean check(ChunkProviderServer cps, int x, int z) throws IOException {
+ private boolean check(ChunkProviderServer cps, int x, int z) {
+ ChunkCoordIntPair pos = new ChunkCoordIntPair(x, z);
+ if (cps != null) {
+ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread");
@@ -30,7 +31,12 @@
+ }
+ }
+
+ NBTTagCompound nbt = read(pos);
+ NBTTagCompound nbt;
+ try {
+ nbt = read(pos).get().orElse(null);
+ } catch (InterruptedException | ExecutionException ex) {
+ throw new RuntimeException(ex);
+ }
+ if (nbt != null) {
+ NBTTagCompound level = nbt.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated")) {
@@ -46,7 +52,7 @@
+ return false;
+ }
+
+ public NBTTagCompound upgradeChunkTag(ResourceKey<WorldDimension> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) throws IOException {
+ public NBTTagCompound upgradeChunkTag(ResourceKey<WorldDimension> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) {
+ // CraftBukkit end
int i = getVersion(nbttagcompound);
@@ -65,10 +71,19 @@
if (i < 1493) {
nbttagcompound = GameProfileSerializer.update(this.fixerUpper, DataFixTypes.CHUNK, nbttagcompound, i, 1493);
if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {
@@ -55,7 +102,7 @@
@@ -58,7 +111,7 @@
return nbttagcompound;
}
- private PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier) {
+ private PersistentStructureLegacy getLegacyStructureHandler(ResourceKey<WorldDimension> resourcekey, Supplier<WorldPersistentData> supplier) { // CraftBukkit
PersistentStructureLegacy persistentstructurelegacy = this.legacyStructureHandler;
if (persistentstructurelegacy == null) {
@@ -73,7 +126,7 @@
return persistentstructurelegacy;
}
- public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<World> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) {
+ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<WorldDimension> resourcekey, Optional<ResourceKey<Codec<? extends ChunkGenerator>>> optional) { // CraftBukkit
NBTTagCompound nbttagcompound1 = new NBTTagCompound();