Update to Minecraft 1.21

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-06-14 01:05:00 +10:00
parent 7c6204e1a9
commit eed041d629
255 changed files with 3585 additions and 3261 deletions

View File

@@ -82,21 +82,15 @@
if (tileentity == null) {
NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition);
@@ -418,6 +440,13 @@
tileentity1.setRemoved();
}
@@ -412,6 +434,7 @@
+ // CraftBukkit start
+ } else {
+ System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.getBlockPos().getX() + "," + tileentity.getBlockPos().getY() + "," + tileentity.getBlockPos().getZ()
+ + " (" + getBlockState(blockposition) + ") where there was no entity tile!");
+ System.out.println("Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16));
+ new Exception().printStackTrace();
+ // CraftBukkit end
}
}
if (!iblockdata.hasBlockEntity()) {
Chunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{tileentity, blockposition, iblockdata});
+ new Exception().printStackTrace(); // CraftBukkit
} else {
IBlockData iblockdata1 = tileentity.getBlockState();
@@ -447,6 +476,12 @@
@@ -465,6 +488,12 @@
if (this.isInLevel()) {
TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition);
@@ -109,7 +103,7 @@
if (tileentity != null) {
World world = this.level;
@@ -500,6 +535,57 @@
@@ -518,6 +547,57 @@
}
@@ -167,7 +161,7 @@
public boolean isEmpty() {
return false;
}
@@ -695,7 +781,7 @@
@@ -713,7 +793,7 @@
private <T extends TileEntity> void updateBlockEntityTicker(T t0) {
IBlockData iblockdata = t0.getBlockState();
@@ -176,7 +170,7 @@
if (blockentityticker == null) {
this.removeBlockEntityTicker(t0.getBlockPos());
@@ -780,7 +866,7 @@
@@ -798,7 +878,7 @@
private boolean loggedInvalidBlockState;
a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -312,7 +312,7 @@
@@ -311,7 +311,7 @@
}
}
@@ -9,7 +9,7 @@
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) {
@@ -334,7 +334,7 @@
@@ -333,7 +333,7 @@
for (int k = 0; k < j; ++k) {
ChunkSection chunksection = achunksection[k];
@@ -18,7 +18,7 @@
Objects.requireNonNull(set);
palettedcontainerro.getAll(set::add);
@@ -445,6 +445,33 @@
@@ -444,6 +444,33 @@
}
}
@@ -52,7 +52,7 @@
private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) {
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
int i = chunkcoordintpair.getMinBlockX();
@@ -582,6 +609,14 @@
@@ -581,6 +608,14 @@
StructureStart structurestart = structure.generate(iregistrycustom, this, this.biomeSource, randomstate, structuretemplatemanager, i, chunkcoordintpair, j, ichunkaccess, predicate);
if (structurestart.isValid()) {

View File

@@ -24,7 +24,7 @@
private static void replaceMissingSections(IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) {
for (int i = 0; i < achunksection.length; ++i) {
@@ -266,10 +275,11 @@
@@ -270,10 +279,11 @@
public void setUnsaved(boolean flag) {
this.unsaved = flag;
@@ -36,8 +36,8 @@
+ return this.unsaved || this.persistentDataContainer.dirty(); // CraftBukkit - SPIGOT-6814: chunk is unsaved if pdc was mutated
}
public abstract ChunkStatus getStatus();
@@ -445,6 +455,27 @@
public abstract ChunkStatus getPersistedStatus();
@@ -449,6 +459,27 @@
}
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
+++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
@@ -33,7 +33,7 @@
static CompletableFuture<IChunkAccess> generateStructureStarts(WorldGenContext worldgencontext, ChunkStatus chunkstatus, Executor executor, ToFullChunk tofullchunk, List<IChunkAccess> list, IChunkAccess ichunkaccess) {
@@ -38,7 +38,7 @@
static CompletableFuture<IChunkAccess> generateStructureStarts(WorldGenContext worldgencontext, ChunkStep chunkstep, StaticCache2D<GenerationChunkHolder> staticcache2d, IChunkAccess ichunkaccess) {
WorldServer worldserver = worldgencontext.level();
- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) {
@@ -9,3 +9,26 @@
worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager());
}
@@ -177,7 +177,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
- worldserver.addWorldGenChunkEntities(EntityTypes.loadEntitiesRecursive(list, worldserver));
+ // 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) -> {
+ 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)) {
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
+ needsRemoval = true;
+ }
+ return !needsRemoval;
+ }));
+ // CraftBukkit end
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
+++ b/net/minecraft/world/level/chunk/storage/ChunkRegionLoader.java
@@ -104,7 +104,7 @@
@@ -105,7 +105,7 @@
ChunkProviderServer chunkproviderserver = worldserver.getChunkSource();
LevelLightEngine levellightengine = chunkproviderserver.getLightEngine();
IRegistry<BiomeBase> iregistry = worldserver.registryAccess().registryOrThrow(Registries.BIOME);
@@ -9,7 +9,7 @@
boolean flag2 = false;
for (int j = 0; j < nbttaglist.size(); ++j) {
@@ -123,17 +123,17 @@
@@ -124,17 +124,17 @@
datapaletteblock = new DataPaletteBlock<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), DataPaletteBlock.d.SECTION_STATES);
}
@@ -30,7 +30,7 @@
achunksection[k] = chunksection;
SectionPosition sectionposition = SectionPosition.of(chunkcoordintpair, b0);
@@ -170,7 +170,7 @@
@@ -171,7 +171,7 @@
dataresult = BlendingData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("blending_data")));
logger = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger);
@@ -39,7 +39,7 @@
} else {
blendingdata = null;
}
@@ -201,7 +201,7 @@
@@ -202,7 +202,7 @@
dataresult = BelowZeroRetrogen.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("below_zero_retrogen")));
logger = ChunkRegionLoader.LOGGER;
Objects.requireNonNull(logger);
@@ -48,7 +48,7 @@
Objects.requireNonNull(protochunk);
optional.ifPresent(protochunk::setBelowZeroRetrogen);
@@ -215,6 +215,13 @@
@@ -216,6 +216,13 @@
}
}
@@ -62,7 +62,7 @@
((IChunkAccess) object1).setLightCorrect(flag);
NBTTagCompound nbttagcompound2 = nbttagcompound.getCompound("Heightmaps");
EnumSet<HeightMap.Type> enumset = EnumSet.noneOf(HeightMap.Type.class);
@@ -294,6 +301,12 @@
@@ -295,6 +302,12 @@
return DataPaletteBlock.codecRO(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), DataPaletteBlock.d.SECTION_BIOMES, iregistry.getHolderOrThrow(Biomes.PLAINS));
}
@@ -75,16 +75,16 @@
public static NBTTagCompound write(WorldServer worldserver, IChunkAccess ichunkaccess) {
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
NBTTagCompound nbttagcompound = GameProfileSerializer.addCurrentDataVersion(new NBTTagCompound());
@@ -305,7 +318,7 @@
@@ -306,7 +319,7 @@
nbttagcompound.putLong("InhabitedTime", ichunkaccess.getInhabitedTime());
nbttagcompound.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(ichunkaccess.getStatus()).toString());
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) {
@@ -429,6 +442,11 @@
@@ -430,6 +443,11 @@
nbttagcompound.put("Heightmaps", nbttagcompound3);
nbttagcompound.put("structures", packStructureData(StructurePieceSerializationContext.fromLevel(worldserver), chunkcoordintpair, ichunkaccess.getAllStarts(), ichunkaccess.getAllReferences()));
@@ -96,7 +96,7 @@
return nbttagcompound;
}
@@ -533,6 +551,12 @@
@@ -534,6 +552,12 @@
StructureStart structurestart = StructureStart.loadStaticStart(structurepieceserializationcontext, nbttagcompound1.getCompound(s), i);
if (structurestart != null) {

View File

@@ -16,7 +16,7 @@
public class IChunkLoader implements AutoCloseable {
public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493;
@@ -39,10 +48,54 @@
@@ -39,13 +48,57 @@
return this.worker.isOldChunkAround(chunkcoordintpair, i);
}
@@ -56,23 +56,26 @@
+ // CraftBukkit end
int i = getVersion(nbttagcompound);
try {
+ // CraftBukkit start
+ if (i < 1466) {
+ NBTTagCompound level = nbttagcompound.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) {
+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkSource();
+ if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) {
+ level.putBoolean("LightPopulated", true);
if (i == SharedConstants.getCurrentVersion().getDataVersion().getVersion()) {
return nbttagcompound;
} else {
try {
+ // CraftBukkit start
+ if (i < 1466) {
+ NBTTagCompound level = nbttagcompound.getCompound("Level");
+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) {
+ ChunkProviderServer cps = (generatoraccess == null) ? null : ((WorldServer) generatoraccess).getChunkSource();
+ if (check(cps, pos.x - 1, pos.z) && check(cps, pos.x - 1, pos.z - 1) && check(cps, pos.x, pos.z - 1)) {
+ level.putBoolean("LightPopulated", true);
+ }
+ }
+ }
+ }
+ // CraftBukkit end
+ // CraftBukkit end
+
if (i < 1493) {
nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493);
if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {
@@ -69,7 +122,7 @@
if (i < 1493) {
nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493);
if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {
@@ -70,7 +123,7 @@
}
}
@@ -81,7 +84,7 @@
PersistentStructureLegacy persistentstructurelegacy = this.legacyStructureHandler;
if (persistentstructurelegacy == null) {
@@ -84,7 +137,7 @@
@@ -85,7 +138,7 @@
return persistentstructurelegacy;
}