Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
@@ -1,181 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/Chunk.java
|
||||
+++ b/net/minecraft/world/level/chunk/Chunk.java
|
||||
@@ -79,7 +79,7 @@
|
||||
};
|
||||
private final Map<BlockPosition, Chunk.d> tickersInLevel;
|
||||
public boolean loaded;
|
||||
- public final World level;
|
||||
+ public final WorldServer level; // CraftBukkit - type
|
||||
@Nullable
|
||||
private Supplier<FullChunkStatus> fullStatus;
|
||||
@Nullable
|
||||
@@ -98,7 +98,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;
|
||||
@@ -116,6 +116,11 @@
|
||||
this.fluidTicks = levelchunkticks1;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean mustNotSave;
|
||||
+ public boolean needsDecoration;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
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());
|
||||
if (!Collections.disjoint(protochunk.pendingBlockEntities.keySet(), protochunk.blockEntities.keySet())) {
|
||||
@@ -151,6 +156,10 @@
|
||||
this.skyLightSources = protochunk.skyLightSources;
|
||||
this.setLightCorrect(protochunk.isLightCorrect());
|
||||
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
|
||||
}
|
||||
|
||||
public void setUnsavedListener(Chunk.e chunk_e) {
|
||||
@@ -272,9 +281,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
@Override
|
||||
public IBlockData setBlockState(BlockPosition blockposition, IBlockData iblockdata, boolean flag) {
|
||||
+ return this.setBlockState(blockposition, iblockdata, flag, true);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public IBlockData setBlockState(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) {
|
||||
+ // CraftBukkit end
|
||||
int i = blockposition.getY();
|
||||
ChunkSection chunksection = this.getSection(this.getSectionIndex(i));
|
||||
boolean flag1 = chunksection.hasOnlyAir();
|
||||
@@ -324,7 +340,8 @@
|
||||
if (!chunksection.getBlockState(j, k, l).is(block)) {
|
||||
return null;
|
||||
} else {
|
||||
- if (!this.level.isClientSide) {
|
||||
+ // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
|
||||
+ if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BlockTileEntity)) {
|
||||
iblockdata.onPlace(this.level, blockposition, iblockdata1, flag);
|
||||
}
|
||||
|
||||
@@ -375,7 +392,12 @@
|
||||
|
||||
@Nullable
|
||||
public TileEntity getBlockEntity(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
|
||||
- TileEntity tileentity = (TileEntity) this.blockEntities.get(blockposition);
|
||||
+ // CraftBukkit start
|
||||
+ TileEntity tileentity = level.capturedTileEntities.get(blockposition);
|
||||
+ if (tileentity == null) {
|
||||
+ tileentity = (TileEntity) this.blockEntities.get(blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (tileentity == null) {
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) this.pendingBlockEntities.remove(blockposition);
|
||||
@@ -447,6 +469,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});
|
||||
+ new Exception().printStackTrace(); // CraftBukkit
|
||||
} else {
|
||||
IBlockData iblockdata1 = tileentity.getBlockState();
|
||||
|
||||
@@ -500,6 +523,12 @@
|
||||
if (this.isInLevel()) {
|
||||
TileEntity tileentity = (TileEntity) this.blockEntities.remove(blockposition);
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-5561: Also remove from pending map
|
||||
+ if (!pendingBlockEntities.isEmpty()) {
|
||||
+ pendingBlockEntities.remove(blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (tileentity != null) {
|
||||
World world = this.level;
|
||||
|
||||
@@ -553,6 +582,57 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void loadCallback() {
|
||||
+ org.bukkit.Server server = this.level.getCraftServer();
|
||||
+ if (server != null) {
|
||||
+ /*
|
||||
+ * If it's a new world, the first few chunks are generated inside
|
||||
+ * the World constructor. We can't reliably alter that, so we have
|
||||
+ * no way of creating a CraftWorld/CraftServer at that point.
|
||||
+ */
|
||||
+ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration));
|
||||
+
|
||||
+ if (this.needsDecoration) {
|
||||
+ this.needsDecoration = false;
|
||||
+ java.util.Random random = new java.util.Random();
|
||||
+ random.setSeed(level.getSeed());
|
||||
+ long xRand = random.nextLong() / 2L * 2L + 1L;
|
||||
+ long zRand = random.nextLong() / 2L * 2L + 1L;
|
||||
+ random.setSeed((long) this.chunkPos.x * xRand + (long) this.chunkPos.z * zRand ^ level.getSeed());
|
||||
+
|
||||
+ org.bukkit.World world = this.level.getWorld();
|
||||
+ if (world != null) {
|
||||
+ this.level.populating = true;
|
||||
+ try {
|
||||
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||
+ populator.populate(world, random, bukkitChunk);
|
||||
+ }
|
||||
+ } finally {
|
||||
+ this.level.populating = false;
|
||||
+ }
|
||||
+ }
|
||||
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void unloadCallback() {
|
||||
+ org.bukkit.Server server = this.level.getCraftServer();
|
||||
+ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(bukkitChunk, this.isUnsaved());
|
||||
+ server.getPluginManager().callEvent(unloadEvent);
|
||||
+ // note: saving can be prevented, but not forced if no saving is actually required
|
||||
+ this.mustNotSave = !unloadEvent.isSaveChunk();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isUnsaved() {
|
||||
+ return super.isUnsaved() && !this.mustNotSave;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
@@ -750,7 +830,7 @@
|
||||
|
||||
private <T extends TileEntity> void updateBlockEntityTicker(T t0) {
|
||||
IBlockData iblockdata = t0.getBlockState();
|
||||
- BlockEntityTicker<T> blockentityticker = iblockdata.getTicker(this.level, t0.getType());
|
||||
+ BlockEntityTicker<T> blockentityticker = iblockdata.getTicker(this.level, (TileEntityTypes<T>) t0.getType()); // CraftBukkit - decompile error
|
||||
|
||||
if (blockentityticker == null) {
|
||||
this.removeBlockEntityTicker(t0.getBlockPos());
|
||||
@@ -841,7 +921,7 @@
|
||||
private boolean loggedInvalidBlockState;
|
||||
|
||||
a(final TileEntity tileentity, final BlockEntityTicker blockentityticker) {
|
||||
- this.blockEntity = tileentity;
|
||||
+ this.blockEntity = (T) tileentity; // CraftBukkit - decompile error
|
||||
this.ticker = blockentityticker;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
--- a/net/minecraft/world/level/chunk/IChunkAccess.java
|
||||
+++ b/net/minecraft/world/level/chunk/IChunkAccess.java
|
||||
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -85,6 +85,11 @@
|
||||
protected final LevelHeightAccessor levelHeightAccessor;
|
||||
protected final ChunkSection[] sections;
|
||||
protected final LevelChunkSection[] sections;
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6814: move to IChunkAccess to account for 1.17 to 1.18 chunk upgrading.
|
||||
+ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry();
|
||||
+ public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||
+ public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
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;
|
||||
public ChunkAccess(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor heightLimitView, Registry<Biome> biomeRegistry, long inhabitedTime, @Nullable LevelChunkSection[] sectionArray, @Nullable BlendingData blendingData) {
|
||||
this.chunkPos = pos;
|
||||
this.upgradeData = upgradeData;
|
||||
@@ -103,7 +108,11 @@
|
||||
}
|
||||
|
||||
replaceMissingSections(iregistry, this.sections);
|
||||
ChunkAccess.replaceMissingSections(biomeRegistry, this.sections);
|
||||
+ // CraftBukkit start
|
||||
+ this.biomeRegistry = iregistry;
|
||||
+ this.biomeRegistry = biomeRegistry;
|
||||
}
|
||||
+ public final IRegistry<BiomeBase> biomeRegistry;
|
||||
+ public final Registry<Biome> biomeRegistry;
|
||||
+ // CraftBukkit end
|
||||
|
||||
private static void replaceMissingSections(IRegistry<BiomeBase> iregistry, ChunkSection[] achunksection) {
|
||||
for (int i = 0; i < achunksection.length; ++i) {
|
||||
private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sectionArray) {
|
||||
for (int i = 0; i < sectionArray.length; ++i) {
|
||||
@@ -275,6 +284,7 @@
|
||||
public boolean tryMarkSaved() {
|
||||
if (this.unsaved) {
|
||||
@@ -46,26 +46,26 @@
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setBiome(int i, int j, int k, Holder<BiomeBase> biome) {
|
||||
+ public void setBiome(int i, int j, int k, Holder<Biome> biome) {
|
||||
+ try {
|
||||
+ int l = QuartPos.fromBlock(this.getMinY());
|
||||
+ int i1 = l + QuartPos.fromBlock(this.getHeight()) - 1;
|
||||
+ int j1 = MathHelper.clamp(j, l, i1);
|
||||
+ int j1 = Mth.clamp(j, l, i1);
|
||||
+ int k1 = this.getSectionIndex(QuartPos.toBlock(j1));
|
||||
+
|
||||
+ this.sections[k1].setBiome(i & 3, j1 & 3, k & 3, biome);
|
||||
+ } catch (Throwable throwable) {
|
||||
+ CrashReport crashreport = CrashReport.forThrowable(throwable, "Setting biome");
|
||||
+ CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Biome being set");
|
||||
+ CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Biome being set");
|
||||
+
|
||||
+ crashreportsystemdetails.setDetail("Location", () -> {
|
||||
+ return CrashReportSystemDetails.formatLocation(this, i, j, k);
|
||||
+ return CrashReportCategory.formatLocation(this, i, j, k);
|
||||
+ });
|
||||
+ throw new ReportedException(crashreport);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler) {
|
||||
ChunkCoordIntPair chunkcoordintpair = this.getPos();
|
||||
public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler) {
|
||||
ChunkPos chunkcoordintpair = this.getPos();
|
||||
int i = QuartPos.fromBlock(chunkcoordintpair.getMinBlockX());
|
||||
@@ -0,0 +1,139 @@
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -312,29 +312,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public void applyBiomeDecoration(WorldGenLevel world, ChunkAccess chunk, StructureManager structureAccessor) {
|
||||
- ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
+ public void addVanillaDecorations(WorldGenLevel generatoraccessseed, ChunkAccess ichunkaccess, StructureManager structuremanager) { // CraftBukkit
|
||||
+ ChunkPos chunkcoordintpair = ichunkaccess.getPos();
|
||||
|
||||
if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) {
|
||||
- SectionPos sectionposition = SectionPos.of(chunkcoordintpair, world.getMinSectionY());
|
||||
+ SectionPos sectionposition = SectionPos.of(chunkcoordintpair, generatoraccessseed.getMinSectionY());
|
||||
BlockPos blockposition = sectionposition.origin();
|
||||
- Registry<Structure> iregistry = world.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
+ Registry<Structure> iregistry = generatoraccessseed.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
Map<Integer, List<Structure>> map = (Map) iregistry.stream().collect(Collectors.groupingBy((structure) -> {
|
||||
return structure.step().ordinal();
|
||||
}));
|
||||
List<FeatureSorter.StepFeatureData> list = (List) this.featuresPerStep.get();
|
||||
WorldgenRandom seededrandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
- long i = seededrandom.setDecorationSeed(world.getSeed(), blockposition.getX(), blockposition.getZ());
|
||||
+ long i = seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), blockposition.getX(), blockposition.getZ());
|
||||
Set<Holder<Biome>> set = new ObjectArraySet();
|
||||
|
||||
ChunkPos.rangeClosed(sectionposition.chunk(), 1).forEach((chunkcoordintpair1) -> {
|
||||
- ChunkAccess ichunkaccess1 = world.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z);
|
||||
+ ChunkAccess ichunkaccess1 = generatoraccessseed.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z);
|
||||
LevelChunkSection[] achunksection = ichunkaccess1.getSections();
|
||||
int j = achunksection.length;
|
||||
|
||||
for (int k = 0; k < j; ++k) {
|
||||
LevelChunkSection chunksection = achunksection[k];
|
||||
- PalettedContainerRO palettedcontainerro = chunksection.getBiomes();
|
||||
+ PalettedContainerRO<Holder<Biome>> palettedcontainerro = chunksection.getBiomes(); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(set);
|
||||
palettedcontainerro.getAll(set::add);
|
||||
@@ -345,7 +345,7 @@
|
||||
int j = list.size();
|
||||
|
||||
try {
|
||||
- Registry<PlacedFeature> iregistry1 = world.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE);
|
||||
+ Registry<PlacedFeature> iregistry1 = generatoraccessseed.registryAccess().lookupOrThrow(Registries.PLACED_FEATURE);
|
||||
int k = Math.max(GenerationStep.Decoration.values().length, j);
|
||||
|
||||
for (int l = 0; l < k; ++l) {
|
||||
@@ -353,7 +353,7 @@
|
||||
Iterator iterator;
|
||||
CrashReportCategory crashreportsystemdetails;
|
||||
|
||||
- if (structureAccessor.shouldGenerateStructures()) {
|
||||
+ if (structuremanager.shouldGenerateStructures()) {
|
||||
List<Structure> list1 = (List) map.getOrDefault(l, Collections.emptyList());
|
||||
|
||||
for (iterator = list1.iterator(); iterator.hasNext(); ++i1) {
|
||||
@@ -368,9 +368,9 @@
|
||||
};
|
||||
|
||||
try {
|
||||
- world.setCurrentlyGenerating(supplier);
|
||||
- structureAccessor.startsForStructure(sectionposition, structure).forEach((structurestart) -> {
|
||||
- structurestart.placeInChunk(world, structureAccessor, this, seededrandom, ChunkGenerator.getWritableArea(chunk), chunkcoordintpair);
|
||||
+ generatoraccessseed.setCurrentlyGenerating(supplier);
|
||||
+ structuremanager.startsForStructure(sectionposition, structure).forEach((structurestart) -> {
|
||||
+ structurestart.placeInChunk(generatoraccessseed, structuremanager, this, seededrandom, ChunkGenerator.getWritableArea(ichunkaccess), chunkcoordintpair);
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(exception, "Feature placement");
|
||||
@@ -421,8 +421,8 @@
|
||||
seededrandom.setFeatureSeed(i, l1, l);
|
||||
|
||||
try {
|
||||
- world.setCurrentlyGenerating(supplier1);
|
||||
- placedfeature.placeWithBiomeCheck(world, this, seededrandom, blockposition);
|
||||
+ generatoraccessseed.setCurrentlyGenerating(supplier1);
|
||||
+ placedfeature.placeWithBiomeCheck(generatoraccessseed, this, seededrandom, blockposition);
|
||||
} catch (Exception exception1) {
|
||||
CrashReport crashreport1 = CrashReport.forThrowable(exception1, "Feature placement");
|
||||
|
||||
@@ -435,7 +435,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- world.setCurrentlyGenerating((Supplier) null);
|
||||
+ generatoraccessseed.setCurrentlyGenerating((Supplier) null);
|
||||
} catch (Exception exception2) {
|
||||
CrashReport crashreport2 = CrashReport.forThrowable(exception2, "Biome decoration");
|
||||
|
||||
@@ -445,6 +445,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void applyBiomeDecoration(WorldGenLevel world, ChunkAccess chunk, StructureManager structureAccessor) {
|
||||
+ this.applyBiomeDecoration(world, chunk, structureAccessor, true);
|
||||
+ }
|
||||
+
|
||||
+ public void applyBiomeDecoration(WorldGenLevel generatoraccessseed, ChunkAccess ichunkaccess, StructureManager structuremanager, boolean vanilla) {
|
||||
+ if (vanilla) {
|
||||
+ this.addVanillaDecorations(generatoraccessseed, ichunkaccess, structuremanager);
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.World world = generatoraccessseed.getMinecraftWorld().getWorld();
|
||||
+ // only call when a populator is present (prevents unnecessary entity conversion)
|
||||
+ if (!world.getPopulators().isEmpty()) {
|
||||
+ org.bukkit.craftbukkit.generator.CraftLimitedRegion limitedRegion = new org.bukkit.craftbukkit.generator.CraftLimitedRegion(generatoraccessseed, ichunkaccess.getPos());
|
||||
+ int x = ichunkaccess.getPos().x;
|
||||
+ int z = ichunkaccess.getPos().z;
|
||||
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||
+ WorldgenRandom seededrandom = new WorldgenRandom(new net.minecraft.world.level.levelgen.LegacyRandomSource(generatoraccessseed.getSeed()));
|
||||
+ seededrandom.setDecorationSeed(generatoraccessseed.getSeed(), x, z);
|
||||
+ populator.populate(world, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
|
||||
+ }
|
||||
+ limitedRegion.saveEntities();
|
||||
+ limitedRegion.breakLink();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private static BoundingBox getWritableArea(ChunkAccess chunk) {
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
int i = chunkcoordintpair.getMinBlockX();
|
||||
@@ -582,6 +609,14 @@
|
||||
StructureStart structurestart = structure.generate(weightedEntry.structure(), dimension, dynamicRegistryManager, this, this.biomeSource, noiseConfig, structureManager, seed, pos, j, chunk, predicate);
|
||||
|
||||
if (structurestart.isValid()) {
|
||||
+ // CraftBukkit start
|
||||
+ BoundingBox box = structurestart.getBoundingBox();
|
||||
+ org.bukkit.event.world.AsyncStructureSpawnEvent event = new org.bukkit.event.world.AsyncStructureSpawnEvent(structureAccessor.level.getMinecraftWorld().getWorld(), org.bukkit.craftbukkit.generator.structure.CraftStructure.minecraftToBukkit(structure), new org.bukkit.util.BoundingBox(box.minX(), box.minY(), box.minZ(), box.maxX(), box.maxY(), box.maxZ()), pos.x, pos.z);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
structureAccessor.setStartForStructure(sectionPos, structure, structurestart, chunk);
|
||||
return true;
|
||||
} else {
|
||||
@@ -1,69 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -312,7 +312,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) {
|
||||
+ public void addVanillaDecorations(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) { // CraftBukkit
|
||||
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||
|
||||
if (!SharedConstants.debugVoidTerrain(chunkcoordintpair)) {
|
||||
@@ -334,7 +334,7 @@
|
||||
|
||||
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);
|
||||
palettedcontainerro.getAll(set::add);
|
||||
@@ -445,6 +445,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager) {
|
||||
+ applyBiomeDecoration(generatoraccessseed, ichunkaccess, structuremanager, true);
|
||||
+ }
|
||||
+
|
||||
+ public void applyBiomeDecoration(GeneratorAccessSeed generatoraccessseed, IChunkAccess ichunkaccess, StructureManager structuremanager, boolean vanilla) {
|
||||
+ if (vanilla) {
|
||||
+ addVanillaDecorations(generatoraccessseed, ichunkaccess, structuremanager);
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.World world = generatoraccessseed.getMinecraftWorld().getWorld();
|
||||
+ // only call when a populator is present (prevents unnecessary entity conversion)
|
||||
+ if (!world.getPopulators().isEmpty()) {
|
||||
+ org.bukkit.craftbukkit.generator.CraftLimitedRegion limitedRegion = new org.bukkit.craftbukkit.generator.CraftLimitedRegion(generatoraccessseed, ichunkaccess.getPos());
|
||||
+ int x = ichunkaccess.getPos().x;
|
||||
+ int z = ichunkaccess.getPos().z;
|
||||
+ 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, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
|
||||
+ }
|
||||
+ limitedRegion.saveEntities();
|
||||
+ limitedRegion.breakLink();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private static StructureBoundingBox getWritableArea(IChunkAccess ichunkaccess) {
|
||||
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
|
||||
int i = chunkcoordintpair.getMinBlockX();
|
||||
@@ -582,6 +609,14 @@
|
||||
StructureStart structurestart = structure.generate(structureset_a.structure(), resourcekey, iregistrycustom, this, this.biomeSource, randomstate, structuretemplatemanager, i, chunkcoordintpair, j, ichunkaccess, predicate);
|
||||
|
||||
if (structurestart.isValid()) {
|
||||
+ // CraftBukkit start
|
||||
+ StructureBoundingBox box = structurestart.getBoundingBox();
|
||||
+ org.bukkit.event.world.AsyncStructureSpawnEvent event = new org.bukkit.event.world.AsyncStructureSpawnEvent(structuremanager.level.getMinecraftWorld().getWorld(), org.bukkit.craftbukkit.generator.structure.CraftStructure.minecraftToBukkit(structure), new org.bukkit.util.BoundingBox(box.minX(), box.minY(), box.minZ(), box.maxX(), box.maxY(), box.maxZ()), chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
structuremanager.setStartForStructure(sectionposition, structure, structurestart, ichunkaccess);
|
||||
return true;
|
||||
} else {
|
||||
@@ -1,33 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/ChunkSection.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkSection.java
|
||||
@@ -23,7 +23,7 @@
|
||||
private short tickingBlockCount;
|
||||
private short tickingFluidCount;
|
||||
private final DataPaletteBlock<IBlockData> states;
|
||||
- private PalettedContainerRO<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 - read/write
|
||||
this.states = datapaletteblock;
|
||||
this.biomes = palettedcontainerro;
|
||||
this.recalcBlockCounts();
|
||||
@@ -196,6 +196,12 @@
|
||||
return (Holder) this.biomes.get(i, j, k);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setBiome(int i, int j, int k, Holder<BiomeBase> biome) {
|
||||
+ this.biomes.set(i, j, k, biome);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void fillBiomesFromNoise(BiomeResolver biomeresolver, Climate.Sampler climate_sampler, int i, int j, int k) {
|
||||
DataPaletteBlock<Holder<BiomeBase>> datapaletteblock = this.biomes.recreate();
|
||||
boolean flag = true;
|
||||
@@ -0,0 +1,7 @@
|
||||
--- a/net/minecraft/world/level/chunk/DataLayer.java
|
||||
+++ b/net/minecraft/world/level/chunk/DataLayer.java
|
||||
@@ -1,3 +1,4 @@
|
||||
+// mc-dev import
|
||||
package net.minecraft.world.level.chunk;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -0,0 +1,266 @@
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -79,7 +79,7 @@
|
||||
};
|
||||
private final Map<BlockPos, LevelChunk.RebindableTickingBlockEntityWrapper> tickersInLevel;
|
||||
public boolean loaded;
|
||||
- public final Level level;
|
||||
+ public final ServerLevel level; // CraftBukkit - type
|
||||
@Nullable
|
||||
private Supplier<FullChunkStatus> fullStatus;
|
||||
@Nullable
|
||||
@@ -98,7 +98,7 @@
|
||||
this.tickersInLevel = Maps.newHashMap();
|
||||
this.unsavedListener = (chunkcoordintpair1) -> {
|
||||
};
|
||||
- this.level = world;
|
||||
+ this.level = (ServerLevel) world; // CraftBukkit - type
|
||||
this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap();
|
||||
Heightmap.Types[] aheightmap_type = Heightmap.Types.values();
|
||||
int j = aheightmap_type.length;
|
||||
@@ -116,6 +116,11 @@
|
||||
this.fluidTicks = fluidTickScheduler;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean mustNotSave;
|
||||
+ public boolean needsDecoration;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public LevelChunk(ServerLevel world, ProtoChunk protoChunk, @Nullable LevelChunk.PostLoadProcessor entityLoader) {
|
||||
this(world, protoChunk.getPos(), protoChunk.getUpgradeData(), protoChunk.unpackBlockTicks(), protoChunk.unpackFluidTicks(), protoChunk.getInhabitedTime(), protoChunk.getSections(), entityLoader, protoChunk.getBlendingData());
|
||||
if (!Collections.disjoint(protoChunk.pendingBlockEntities.keySet(), protoChunk.blockEntities.keySet())) {
|
||||
@@ -151,6 +156,10 @@
|
||||
this.skyLightSources = protoChunk.skyLightSources;
|
||||
this.setLightCorrect(protoChunk.isLightCorrect());
|
||||
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
|
||||
}
|
||||
|
||||
public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) {
|
||||
@@ -272,78 +281,86 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState setBlockState(BlockPos pos, BlockState state, boolean moved) {
|
||||
- int i = pos.getY();
|
||||
+ return this.setBlockState(pos, state, moved, true);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public BlockState setBlockState(BlockPos blockposition, BlockState iblockdata, boolean flag, boolean doPlace) {
|
||||
+ // CraftBukkit end
|
||||
+ int i = blockposition.getY();
|
||||
LevelChunkSection chunksection = this.getSection(this.getSectionIndex(i));
|
||||
boolean flag1 = chunksection.hasOnlyAir();
|
||||
|
||||
- if (flag1 && state.isAir()) {
|
||||
+ if (flag1 && iblockdata.isAir()) {
|
||||
return null;
|
||||
} else {
|
||||
- int j = pos.getX() & 15;
|
||||
+ int j = blockposition.getX() & 15;
|
||||
int k = i & 15;
|
||||
- int l = pos.getZ() & 15;
|
||||
- BlockState iblockdata1 = chunksection.setBlockState(j, k, l, state);
|
||||
+ int l = blockposition.getZ() & 15;
|
||||
+ BlockState iblockdata1 = chunksection.setBlockState(j, k, l, iblockdata);
|
||||
|
||||
- if (iblockdata1 == state) {
|
||||
+ if (iblockdata1 == iblockdata) {
|
||||
return null;
|
||||
} else {
|
||||
- Block block = state.getBlock();
|
||||
+ Block block = iblockdata.getBlock();
|
||||
|
||||
- ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING)).update(j, i, l, state);
|
||||
- ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES)).update(j, i, l, state);
|
||||
- ((Heightmap) this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR)).update(j, i, l, state);
|
||||
- ((Heightmap) this.heightmaps.get(Heightmap.Types.WORLD_SURFACE)).update(j, i, l, state);
|
||||
+ ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING)).update(j, i, l, iblockdata);
|
||||
+ ((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES)).update(j, i, l, iblockdata);
|
||||
+ ((Heightmap) this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR)).update(j, i, l, iblockdata);
|
||||
+ ((Heightmap) this.heightmaps.get(Heightmap.Types.WORLD_SURFACE)).update(j, i, l, iblockdata);
|
||||
boolean flag2 = chunksection.hasOnlyAir();
|
||||
|
||||
if (flag1 != flag2) {
|
||||
- this.level.getChunkSource().getLightEngine().updateSectionStatus(pos, flag2);
|
||||
+ this.level.getChunkSource().getLightEngine().updateSectionStatus(blockposition, flag2);
|
||||
this.level.getChunkSource().onSectionEmptinessChanged(this.chunkPos.x, SectionPos.blockToSectionCoord(i), this.chunkPos.z, flag2);
|
||||
}
|
||||
|
||||
- if (LightEngine.hasDifferentLightProperties(iblockdata1, state)) {
|
||||
+ if (LightEngine.hasDifferentLightProperties(iblockdata1, iblockdata)) {
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("updateSkyLightSources");
|
||||
this.skyLightSources.update(this, j, i, l);
|
||||
gameprofilerfiller.popPush("queueCheckLight");
|
||||
- this.level.getChunkSource().getLightEngine().checkBlock(pos);
|
||||
+ this.level.getChunkSource().getLightEngine().checkBlock(blockposition);
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
|
||||
boolean flag3 = iblockdata1.hasBlockEntity();
|
||||
|
||||
if (!this.level.isClientSide) {
|
||||
- iblockdata1.onRemove(this.level, pos, state, moved);
|
||||
+ iblockdata1.onRemove(this.level, blockposition, iblockdata, flag);
|
||||
} else if (!iblockdata1.is(block) && flag3) {
|
||||
- this.removeBlockEntity(pos);
|
||||
+ this.removeBlockEntity(blockposition);
|
||||
}
|
||||
|
||||
if (!chunksection.getBlockState(j, k, l).is(block)) {
|
||||
return null;
|
||||
} else {
|
||||
- if (!this.level.isClientSide) {
|
||||
- state.onPlace(this.level, pos, iblockdata1, moved);
|
||||
+ // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
|
||||
+ if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) {
|
||||
+ iblockdata.onPlace(this.level, blockposition, iblockdata1, flag);
|
||||
}
|
||||
|
||||
- if (state.hasBlockEntity()) {
|
||||
- BlockEntity tileentity = this.getBlockEntity(pos, LevelChunk.EntityCreationType.CHECK);
|
||||
+ if (iblockdata.hasBlockEntity()) {
|
||||
+ BlockEntity tileentity = this.getBlockEntity(blockposition, LevelChunk.EntityCreationType.CHECK);
|
||||
|
||||
- if (tileentity != null && !tileentity.isValidBlockState(state)) {
|
||||
- LevelChunk.LOGGER.warn("Found mismatched block entity @ {}: type = {}, state = {}", new Object[]{pos, tileentity.getType().builtInRegistryHolder().key().location(), state});
|
||||
- this.removeBlockEntity(pos);
|
||||
+ if (tileentity != null && !tileentity.isValidBlockState(iblockdata)) {
|
||||
+ LevelChunk.LOGGER.warn("Found mismatched block entity @ {}: type = {}, state = {}", new Object[]{blockposition, tileentity.getType().builtInRegistryHolder().key().location(), iblockdata});
|
||||
+ this.removeBlockEntity(blockposition);
|
||||
tileentity = null;
|
||||
}
|
||||
|
||||
if (tileentity == null) {
|
||||
- tileentity = ((EntityBlock) block).newBlockEntity(pos, state);
|
||||
+ tileentity = ((EntityBlock) block).newBlockEntity(blockposition, iblockdata);
|
||||
if (tileentity != null) {
|
||||
this.addAndRegisterBlockEntity(tileentity);
|
||||
}
|
||||
} else {
|
||||
- tileentity.setBlockState(state);
|
||||
+ tileentity.setBlockState(iblockdata);
|
||||
this.updateBlockEntityTicker(tileentity);
|
||||
}
|
||||
}
|
||||
@@ -375,7 +392,12 @@
|
||||
|
||||
@Nullable
|
||||
public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) {
|
||||
- BlockEntity tileentity = (BlockEntity) this.blockEntities.get(pos);
|
||||
+ // CraftBukkit start
|
||||
+ BlockEntity tileentity = this.level.capturedTileEntities.get(pos);
|
||||
+ if (tileentity == null) {
|
||||
+ tileentity = (BlockEntity) this.blockEntities.get(pos);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (tileentity == null) {
|
||||
CompoundTag nbttagcompound = (CompoundTag) this.pendingBlockEntities.remove(pos);
|
||||
@@ -447,6 +469,7 @@
|
||||
|
||||
if (!iblockdata.hasBlockEntity()) {
|
||||
LevelChunk.LOGGER.warn("Trying to set block entity {} at position {}, but state {} does not allow it", new Object[]{blockEntity, blockposition, iblockdata});
|
||||
+ new Exception().printStackTrace(); // CraftBukkit
|
||||
} else {
|
||||
BlockState iblockdata1 = blockEntity.getBlockState();
|
||||
|
||||
@@ -500,6 +523,12 @@
|
||||
if (this.isInLevel()) {
|
||||
BlockEntity tileentity = (BlockEntity) this.blockEntities.remove(pos);
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-5561: Also remove from pending map
|
||||
+ if (!this.pendingBlockEntities.isEmpty()) {
|
||||
+ this.pendingBlockEntities.remove(pos);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (tileentity != null) {
|
||||
Level world = this.level;
|
||||
|
||||
@@ -553,6 +582,57 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void loadCallback() {
|
||||
+ org.bukkit.Server server = this.level.getCraftServer();
|
||||
+ if (server != null) {
|
||||
+ /*
|
||||
+ * If it's a new world, the first few chunks are generated inside
|
||||
+ * the World constructor. We can't reliably alter that, so we have
|
||||
+ * no way of creating a CraftWorld/CraftServer at that point.
|
||||
+ */
|
||||
+ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration));
|
||||
+
|
||||
+ if (this.needsDecoration) {
|
||||
+ this.needsDecoration = false;
|
||||
+ java.util.Random random = new java.util.Random();
|
||||
+ random.setSeed(this.level.getSeed());
|
||||
+ long xRand = random.nextLong() / 2L * 2L + 1L;
|
||||
+ long zRand = random.nextLong() / 2L * 2L + 1L;
|
||||
+ random.setSeed((long) this.chunkPos.x * xRand + (long) this.chunkPos.z * zRand ^ this.level.getSeed());
|
||||
+
|
||||
+ org.bukkit.World world = this.level.getWorld();
|
||||
+ if (world != null) {
|
||||
+ this.level.populating = true;
|
||||
+ try {
|
||||
+ for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||
+ populator.populate(world, random, bukkitChunk);
|
||||
+ }
|
||||
+ } finally {
|
||||
+ this.level.populating = false;
|
||||
+ }
|
||||
+ }
|
||||
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(bukkitChunk));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void unloadCallback() {
|
||||
+ org.bukkit.Server server = this.level.getCraftServer();
|
||||
+ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(bukkitChunk, this.isUnsaved());
|
||||
+ server.getPluginManager().callEvent(unloadEvent);
|
||||
+ // note: saving can be prevented, but not forced if no saving is actually required
|
||||
+ this.mustNotSave = !unloadEvent.isSaveChunk();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isUnsaved() {
|
||||
+ return super.isUnsaved() && !this.mustNotSave;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
@@ -750,7 +830,7 @@
|
||||
|
||||
private <T extends BlockEntity> void updateBlockEntityTicker(T blockEntity) {
|
||||
BlockState iblockdata = blockEntity.getBlockState();
|
||||
- BlockEntityTicker<T> blockentityticker = iblockdata.getTicker(this.level, blockEntity.getType());
|
||||
+ BlockEntityTicker<T> blockentityticker = iblockdata.getTicker(this.level, (BlockEntityType<T>) blockEntity.getType()); // CraftBukkit - decompile error
|
||||
|
||||
if (blockentityticker == null) {
|
||||
this.removeBlockEntityTicker(blockEntity.getBlockPos());
|
||||
@@ -841,7 +921,7 @@
|
||||
private boolean loggedInvalidBlockState;
|
||||
|
||||
BoundTickingBlockEntity(final BlockEntity tileentity, final BlockEntityTicker blockentityticker) {
|
||||
- this.blockEntity = tileentity;
|
||||
+ this.blockEntity = (T) tileentity; // CraftBukkit - decompile error
|
||||
this.ticker = blockentityticker;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -23,7 +23,7 @@
|
||||
private short tickingBlockCount;
|
||||
private short tickingFluidCount;
|
||||
public final PalettedContainer<BlockState> states;
|
||||
- private PalettedContainerRO<Holder<Biome>> biomes;
|
||||
+ private PalettedContainer<Holder<Biome>> biomes; // CraftBukkit - read/write
|
||||
|
||||
private LevelChunkSection(LevelChunkSection section) {
|
||||
this.nonEmptyBlockCount = section.nonEmptyBlockCount;
|
||||
@@ -33,9 +33,9 @@
|
||||
this.biomes = section.biomes.copy();
|
||||
}
|
||||
|
||||
- public LevelChunkSection(PalettedContainer<BlockState> blockStateContainer, PalettedContainerRO<Holder<Biome>> biomeContainer) {
|
||||
- this.states = blockStateContainer;
|
||||
- this.biomes = biomeContainer;
|
||||
+ public LevelChunkSection(PalettedContainer<BlockState> datapaletteblock, PalettedContainer<Holder<Biome>> palettedcontainerro) { // CraftBukkit - read/write
|
||||
+ this.states = datapaletteblock;
|
||||
+ this.biomes = palettedcontainerro;
|
||||
this.recalcBlockCounts();
|
||||
}
|
||||
|
||||
@@ -196,6 +196,12 @@
|
||||
return (Holder) this.biomes.get(x, y, z);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setBiome(int i, int j, int k, Holder<Biome> biome) {
|
||||
+ this.biomes.set(i, j, k, biome);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler, int x, int y, int z) {
|
||||
PalettedContainer<Holder<Biome>> datapaletteblock = this.biomes.recreate();
|
||||
boolean flag = true;
|
||||
@@ -1,7 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/NibbleArray.java
|
||||
+++ b/net/minecraft/world/level/chunk/NibbleArray.java
|
||||
@@ -1,3 +1,4 @@
|
||||
+// mc-dev import
|
||||
package net.minecraft.world.level.chunk;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
|
||||
+++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
|
||||
@@ -36,7 +36,7 @@
|
||||
static CompletableFuture<ChunkAccess> generateStructureStarts(WorldGenContext context, ChunkStep step, StaticCache2D<GenerationChunkHolder> chunks, ChunkAccess chunk) {
|
||||
ServerLevel worldserver = context.level();
|
||||
|
||||
- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) {
|
||||
+ if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit
|
||||
context.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), chunk, context.structureManager(), worldserver.dimension());
|
||||
}
|
||||
|
||||
@@ -170,7 +170,17 @@
|
||||
|
||||
private static void postLoadProtoChunk(ServerLevel world, List<CompoundTag> entities) {
|
||||
if (!entities.isEmpty()) {
|
||||
- world.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entities, world, 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
|
||||
+ world.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entities, world, EntitySpawnReason.LOAD).filter((entity) -> {
|
||||
+ boolean needsRemoval = false;
|
||||
+ net.minecraft.server.dedicated.DedicatedServer server = world.getCraftServer().getServer();
|
||||
+ if (!world.getChunkSource().spawnFriendlies && (entity instanceof net.minecraft.world.entity.animal.Animal || entity instanceof net.minecraft.world.entity.animal.WaterAnimal)) {
|
||||
+ entity.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ return !needsRemoval;
|
||||
+ }));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
|
||||
+++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java
|
||||
@@ -36,7 +36,7 @@
|
||||
static CompletableFuture<IChunkAccess> generateStructureStarts(WorldGenContext worldgencontext, ChunkStep chunkstep, StaticCache2D<GenerationChunkHolder> staticcache2d, IChunkAccess ichunkaccess) {
|
||||
WorldServer worldserver = worldgencontext.level();
|
||||
|
||||
- if (worldserver.getServer().getWorldData().worldGenOptions().generateStructures()) {
|
||||
+ if (worldserver.serverLevelData.worldGenOptions().generateStructures()) { // CraftBukkit
|
||||
worldgencontext.generator().createStructures(worldserver.registryAccess(), worldserver.getChunkSource().getGeneratorState(), worldserver.structureManager(), ichunkaccess, worldgencontext.structureManager(), worldserver.dimension());
|
||||
}
|
||||
|
||||
@@ -170,7 +170,17 @@
|
||||
|
||||
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
|
||||
if (!list.isEmpty()) {
|
||||
- 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, EntitySpawnReason.LOAD).filter((entity) -> {
|
||||
+ boolean needsRemoval = false;
|
||||
+ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getCraftServer().getServer();
|
||||
+ 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;
|
||||
+ }
|
||||
+ return !needsRemoval;
|
||||
+ }));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
--- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java
|
||||
@@ -15,10 +15,16 @@
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.server.level.ServerChunkCache;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.datafix.DataFixTypes;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
-import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
+// CraftBukkit start
|
||||
+import java.util.concurrent.ExecutionException;
|
||||
+import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
+import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.structure.LegacyStructureDataHandler;
|
||||
import net.minecraft.world.level.storage.DimensionDataStorage;
|
||||
|
||||
@@ -39,27 +45,71 @@
|
||||
return this.worker.isOldChunkAround(chunkPos, checkRadius);
|
||||
}
|
||||
|
||||
- public CompoundTag upgradeChunkTag(ResourceKey<Level> worldKey, Supplier<DimensionDataStorage> persistentStateManagerFactory, CompoundTag nbt, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> generatorCodecKey) {
|
||||
- int i = ChunkStorage.getVersion(nbt);
|
||||
+ // CraftBukkit start
|
||||
+ private boolean check(ServerChunkCache cps, int x, int z) {
|
||||
+ ChunkPos pos = new ChunkPos(x, z);
|
||||
+ if (cps != null) {
|
||||
+ com.google.common.base.Preconditions.checkState(org.bukkit.Bukkit.isPrimaryThread(), "primary thread");
|
||||
+ if (cps.hasChunk(x, z)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+ CompoundTag nbt;
|
||||
+ try {
|
||||
+ nbt = this.read(pos).get().orElse(null);
|
||||
+ } catch (InterruptedException | ExecutionException ex) {
|
||||
+ throw new RuntimeException(ex);
|
||||
+ }
|
||||
+ if (nbt != null) {
|
||||
+ CompoundTag level = nbt.getCompound("Level");
|
||||
+ if (level.getBoolean("TerrainPopulated")) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ ChunkStatus status = ChunkStatus.byName(level.getString("Status"));
|
||||
+ if (status != null && status.isOrAfter(ChunkStatus.FEATURES)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public CompoundTag upgradeChunkTag(ResourceKey<LevelStem> resourcekey, Supplier<DimensionDataStorage> supplier, CompoundTag nbttagcompound, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> optional, ChunkPos pos, @Nullable LevelAccessor generatoraccess) {
|
||||
+ // CraftBukkit end
|
||||
+ int i = ChunkStorage.getVersion(nbttagcompound);
|
||||
+
|
||||
if (i == SharedConstants.getCurrentVersion().getDataVersion().getVersion()) {
|
||||
- return nbt;
|
||||
+ return nbttagcompound;
|
||||
} else {
|
||||
try {
|
||||
+ // CraftBukkit start
|
||||
+ if (i < 1466) {
|
||||
+ CompoundTag level = nbttagcompound.getCompound("Level");
|
||||
+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) {
|
||||
+ ServerChunkCache cps = (generatoraccess == null) ? null : ((ServerLevel) generatoraccess).getChunkSource();
|
||||
+ if (this.check(cps, pos.x - 1, pos.z) && this.check(cps, pos.x - 1, pos.z - 1) && this.check(cps, pos.x, pos.z - 1)) {
|
||||
+ level.putBoolean("LightPopulated", true);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (i < 1493) {
|
||||
- nbt = DataFixTypes.CHUNK.update(this.fixerUpper, nbt, i, 1493);
|
||||
- if (nbt.getCompound("Level").getBoolean("hasLegacyStructureData")) {
|
||||
- LegacyStructureDataHandler persistentstructurelegacy = this.getLegacyStructureHandler(worldKey, persistentStateManagerFactory);
|
||||
+ nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493);
|
||||
+ if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {
|
||||
+ LegacyStructureDataHandler persistentstructurelegacy = this.getLegacyStructureHandler(resourcekey, supplier);
|
||||
|
||||
- nbt = persistentstructurelegacy.updateFromLegacy(nbt);
|
||||
+ nbttagcompound = persistentstructurelegacy.updateFromLegacy(nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
- ChunkStorage.injectDatafixingContext(nbt, worldKey, generatorCodecKey);
|
||||
- nbt = DataFixTypes.CHUNK.updateToCurrentVersion(this.fixerUpper, nbt, Math.max(1493, i));
|
||||
- ChunkStorage.removeDatafixingContext(nbt);
|
||||
- NbtUtils.addCurrentDataVersion(nbt);
|
||||
- return nbt;
|
||||
+ ChunkStorage.injectDatafixingContext(nbttagcompound, resourcekey, optional);
|
||||
+ nbttagcompound = DataFixTypes.CHUNK.updateToCurrentVersion(this.fixerUpper, nbttagcompound, Math.max(1493, i));
|
||||
+ ChunkStorage.removeDatafixingContext(nbttagcompound);
|
||||
+ NbtUtils.addCurrentDataVersion(nbttagcompound);
|
||||
+ return nbttagcompound;
|
||||
} catch (Exception exception) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(exception, "Updated chunk");
|
||||
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Updated chunk details");
|
||||
@@ -70,7 +120,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey<Level> worldKey, Supplier<DimensionDataStorage> stateManagerGetter) {
|
||||
+ private LegacyStructureDataHandler getLegacyStructureHandler(ResourceKey<LevelStem> worldKey, Supplier<DimensionDataStorage> stateManagerGetter) { // CraftBukkit
|
||||
LegacyStructureDataHandler persistentstructurelegacy = this.legacyStructureHandler;
|
||||
|
||||
if (persistentstructurelegacy == null) {
|
||||
@@ -85,7 +135,7 @@
|
||||
return persistentstructurelegacy;
|
||||
}
|
||||
|
||||
- public static void injectDatafixingContext(CompoundTag nbt, ResourceKey<Level> worldKey, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> generatorCodecKey) {
|
||||
+ public static void injectDatafixingContext(CompoundTag nbt, ResourceKey<LevelStem> worldKey, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> generatorCodecKey) { // CraftBukkit
|
||||
CompoundTag nbttagcompound1 = new CompoundTag();
|
||||
|
||||
nbttagcompound1.putString("dimension", worldKey.location().toString());
|
||||
@@ -1,95 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/storage/IChunkLoader.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/IChunkLoader.java
|
||||
@@ -22,6 +22,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;
|
||||
+import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
+import net.minecraft.world.level.dimension.WorldDimension;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class IChunkLoader implements AutoCloseable {
|
||||
|
||||
public static final int LAST_MONOLYTH_STRUCTURE_DATA_VERSION = 1493;
|
||||
@@ -39,13 +48,57 @@
|
||||
return this.worker.isOldChunkAround(chunkcoordintpair, i);
|
||||
}
|
||||
|
||||
- public NBTTagCompound upgradeChunkTag(ResourceKey<World> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> optional) {
|
||||
+ // CraftBukkit start
|
||||
+ 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");
|
||||
+ if (cps.hasChunk(x, z)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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")) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ ChunkStatus status = ChunkStatus.byName(level.getString("Status"));
|
||||
+ if (status != null && status.isOrAfter(ChunkStatus.FEATURES)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ public NBTTagCompound upgradeChunkTag(ResourceKey<WorldDimension> resourcekey, Supplier<WorldPersistentData> supplier, NBTTagCompound nbttagcompound, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> optional, ChunkCoordIntPair pos, @Nullable GeneratorAccess generatoraccess) {
|
||||
+ // CraftBukkit end
|
||||
int i = getVersion(nbttagcompound);
|
||||
|
||||
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
|
||||
+
|
||||
if (i < 1493) {
|
||||
nbttagcompound = DataFixTypes.CHUNK.update(this.fixerUpper, nbttagcompound, i, 1493);
|
||||
if (nbttagcompound.getCompound("Level").getBoolean("hasLegacyStructureData")) {
|
||||
@@ -70,7 +123,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- 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) {
|
||||
@@ -85,7 +138,7 @@
|
||||
return persistentstructurelegacy;
|
||||
}
|
||||
|
||||
- public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<World> resourcekey, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> optional) {
|
||||
+ public static void injectDatafixingContext(NBTTagCompound nbttagcompound, ResourceKey<WorldDimension> resourcekey, Optional<ResourceKey<MapCodec<? extends ChunkGenerator>>> optional) { // CraftBukkit
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
|
||||
nbttagcompound1.putString("dimension", resourcekey.location().toString());
|
||||
@@ -7,14 +7,14 @@
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@@ -63,8 +64,8 @@
|
||||
} else {
|
||||
this.externalFileDir = path1;
|
||||
this.externalFileDir = directory;
|
||||
this.offsets = this.header.asIntBuffer();
|
||||
- this.offsets.limit(1024);
|
||||
- this.header.position(4096);
|
||||
+ ((java.nio.Buffer) this.offsets).limit(1024); // CraftBukkit - decompile error
|
||||
+ ((java.nio.Buffer) this.header).position(4096); // CraftBukkit - decompile error
|
||||
this.timestamps = this.header.asIntBuffer();
|
||||
if (flag) {
|
||||
if (dsync) {
|
||||
this.file = FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.READ, StandardOpenOption.WRITE, StandardOpenOption.DSYNC);
|
||||
@@ -73,7 +74,7 @@
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
- bytebuffer.flip();
|
||||
+ ((java.nio.Buffer) bytebuffer).flip(); // CraftBukkit - decompile error
|
||||
if (bytebuffer.remaining() < 5) {
|
||||
RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", new Object[]{chunkcoordintpair, l, bytebuffer.remaining()});
|
||||
RegionFile.LOGGER.error("Chunk {} header is truncated: expected {} but read {}", new Object[]{pos, l, bytebuffer.remaining()});
|
||||
return null;
|
||||
@@ -246,7 +247,7 @@
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
FileChannel filechannel = FileChannel.open(path1, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
|
||||
|
||||
try {
|
||||
- bytebuffer.position(5);
|
||||
+ ((java.nio.Buffer) bytebuffer).position(5); // CraftBukkit - decompile error
|
||||
filechannel.write(bytebuffer);
|
||||
- buf.position(5);
|
||||
+ ((java.nio.Buffer) buf).position(5); // CraftBukkit - decompile error
|
||||
filechannel.write(buf);
|
||||
} catch (Throwable throwable) {
|
||||
if (filechannel != null) {
|
||||
@@ -382,7 +383,7 @@
|
||||
@@ -1,56 +0,0 @@
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileCache.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFileCache.java
|
||||
@@ -32,7 +32,7 @@
|
||||
this.info = regionstorageinfo;
|
||||
}
|
||||
|
||||
- private RegionFile getRegionFile(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
+ private RegionFile getRegionFile(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
|
||||
long i = ChunkCoordIntPair.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
|
||||
RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
Path path = this.folder;
|
||||
int j = chunkcoordintpair.getRegionX();
|
||||
Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
|
||||
RegionFile regionfile1 = new RegionFile(this.info, path1, this.folder, this.sync);
|
||||
|
||||
this.regionCache.putAndMoveToFirst(i, regionfile1);
|
||||
@@ -56,7 +57,12 @@
|
||||
|
||||
@Nullable
|
||||
public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
- RegionFile regionfile = this.getRegionFile(chunkcoordintpair);
|
||||
+ // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
+ RegionFile regionfile = this.getRegionFile(chunkcoordintpair, true);
|
||||
+ if (regionfile == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair);
|
||||
|
||||
NBTTagCompound nbttagcompound;
|
||||
@@ -96,7 +102,12 @@
|
||||
}
|
||||
|
||||
public void scanChunk(ChunkCoordIntPair chunkcoordintpair, StreamTagVisitor streamtagvisitor) throws IOException {
|
||||
- RegionFile regionfile = this.getRegionFile(chunkcoordintpair);
|
||||
+ // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
+ RegionFile regionfile = this.getRegionFile(chunkcoordintpair, true);
|
||||
+ if (regionfile == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkcoordintpair);
|
||||
|
||||
try {
|
||||
@@ -122,7 +133,7 @@
|
||||
}
|
||||
|
||||
protected void write(ChunkCoordIntPair chunkcoordintpair, @Nullable NBTTagCompound nbttagcompound) throws IOException {
|
||||
- RegionFile regionfile = this.getRegionFile(chunkcoordintpair);
|
||||
+ RegionFile regionfile = this.getRegionFile(chunkcoordintpair, false); // CraftBukkit
|
||||
|
||||
if (nbttagcompound == null) {
|
||||
regionfile.clear(chunkcoordintpair);
|
||||
@@ -0,0 +1,62 @@
|
||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -32,8 +32,8 @@
|
||||
this.info = storageKey;
|
||||
}
|
||||
|
||||
- private RegionFile getRegionFile(ChunkPos pos) throws IOException {
|
||||
- long i = ChunkPos.asLong(pos.getRegionX(), pos.getRegionZ());
|
||||
+ private RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
|
||||
+ long i = ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
|
||||
RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i);
|
||||
|
||||
if (regionfile != null) {
|
||||
@@ -45,8 +45,9 @@
|
||||
|
||||
FileUtil.createDirectoriesSafe(this.folder);
|
||||
Path path = this.folder;
|
||||
- int j = pos.getRegionX();
|
||||
- Path path1 = path.resolve("r." + j + "." + pos.getRegionZ() + ".mca");
|
||||
+ int j = chunkcoordintpair.getRegionX();
|
||||
+ Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca");
|
||||
+ if (existingOnly && !java.nio.file.Files.exists(path1)) return null; // CraftBukkit
|
||||
RegionFile regionfile1 = new RegionFile(this.info, path1, this.folder, this.sync);
|
||||
|
||||
this.regionCache.putAndMoveToFirst(i, regionfile1);
|
||||
@@ -56,7 +57,12 @@
|
||||
|
||||
@Nullable
|
||||
public CompoundTag read(ChunkPos pos) throws IOException {
|
||||
- RegionFile regionfile = this.getRegionFile(pos);
|
||||
+ // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
+ RegionFile regionfile = this.getRegionFile(pos, true);
|
||||
+ if (regionfile == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos);
|
||||
|
||||
CompoundTag nbttagcompound;
|
||||
@@ -96,7 +102,12 @@
|
||||
}
|
||||
|
||||
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException {
|
||||
- RegionFile regionfile = this.getRegionFile(chunkPos);
|
||||
+ // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
|
||||
+ RegionFile regionfile = this.getRegionFile(chunkPos, true);
|
||||
+ if (regionfile == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkPos);
|
||||
|
||||
try {
|
||||
@@ -122,7 +133,7 @@
|
||||
}
|
||||
|
||||
protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
|
||||
- RegionFile regionfile = this.getRegionFile(pos);
|
||||
+ RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit
|
||||
|
||||
if (nbt == null) {
|
||||
regionfile.clear(pos);
|
||||
@@ -0,0 +1,147 @@
|
||||
--- 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.SavedTick;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
-public record SerializableChunkData(Registry<Biome> biomeRegistry, ChunkPos chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.Packed blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, UpgradeData upgradeData, @Nullable long[] carvingMask, Map<Heightmap.Types, long[]> heightmaps, ChunkAccess.PackedTicks packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List<SerializableChunkData.SectionData> sectionData, List<CompoundTag> entities, List<CompoundTag> blockEntities, CompoundTag structureData) {
|
||||
+// CraftBukkit - persistentDataContainer
|
||||
+public record SerializableChunkData(Registry<Biome> biomeRegistry, ChunkPos chunkPos, int minSectionY, long lastUpdateTime, long inhabitedTime, ChunkStatus chunkStatus, @Nullable BlendingData.Packed blendingData, @Nullable BelowZeroRetrogen belowZeroRetrogen, UpgradeData upgradeData, @Nullable long[] carvingMask, Map<Heightmap.Types, long[]> heightmaps, ChunkAccess.PackedTicks packedTicks, ShortList[] postProcessingSections, boolean lightCorrect, List<SerializableChunkData.SectionData> sectionData, List<CompoundTag> entities, List<CompoundTag> blockEntities, CompoundTag structureData, @Nullable Tag persistentDataContainer) {
|
||||
|
||||
public static final Codec<PalettedContainer<BlockState>> BLOCK_STATE_CODEC = PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState());
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -110,7 +111,7 @@
|
||||
dataresult = BlendingData.Packed.CODEC.parse(NbtOps.INSTANCE, nbt.getCompound("blending_data"));
|
||||
logger = SerializableChunkData.LOGGER;
|
||||
Objects.requireNonNull(logger);
|
||||
- blendingdata_d = (BlendingData.Packed) dataresult.resultOrPartial(logger::error).orElse((Object) null);
|
||||
+ blendingdata_d = (BlendingData.Packed) ((DataResult<BlendingData.Packed>) dataresult).resultOrPartial(logger::error).orElse(null); // CraftBukkit - decompile error
|
||||
} else {
|
||||
blendingdata_d = null;
|
||||
}
|
||||
@@ -121,7 +122,7 @@
|
||||
dataresult = BelowZeroRetrogen.CODEC.parse(NbtOps.INSTANCE, nbt.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 @@
|
||||
ListTag nbttaglist2 = nbt.getList("sections", 10);
|
||||
List<SerializableChunkData.SectionData> list4 = new ArrayList(nbttaglist2.size());
|
||||
Registry<Biome> iregistry = registryManager.lookupOrThrow(Registries.BIOME);
|
||||
- Codec<PalettedContainerRO<Holder<Biome>>> codec = makeBiomeCodec(iregistry);
|
||||
+ Codec<PalettedContainer<Holder<Biome>>> codec = makeBiomeCodecRW(iregistry); // CraftBukkit - read/write
|
||||
|
||||
for (int i1 = 0; i1 < nbttaglist2.size(); ++i1) {
|
||||
CompoundTag nbttagcompound3 = nbttaglist2.getCompound(i1);
|
||||
@@ -196,17 +197,17 @@
|
||||
datapaletteblock = new PalettedContainer<>(Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
|
||||
}
|
||||
|
||||
- Object object;
|
||||
+ PalettedContainer object; // CraftBukkit - read/write
|
||||
|
||||
if (nbttagcompound3.contains("biomes", 10)) {
|
||||
- object = (PalettedContainerRO) codec.parse(NbtOps.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> {
|
||||
+ object = codec.parse(NbtOps.INSTANCE, nbttagcompound3.getCompound("biomes")).promotePartial((s1) -> { // CraftBukkit - read/write
|
||||
logErrors(chunkcoordintpair, b0, s1);
|
||||
}).getOrThrow(SerializableChunkData.ChunkReadException::new);
|
||||
} else {
|
||||
object = new PalettedContainer<>(iregistry.asHolderIdMap(), iregistry.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES);
|
||||
}
|
||||
|
||||
- chunksection = new LevelChunkSection(datapaletteblock, (PalettedContainerRO) object);
|
||||
+ chunksection = new LevelChunkSection(datapaletteblock, (PalettedContainer) object); // CraftBukkit - read/write
|
||||
} else {
|
||||
chunksection = null;
|
||||
}
|
||||
@@ -217,7 +218,8 @@
|
||||
list4.add(new SerializableChunkData.SectionData(b0, chunksection, nibblearray, nibblearray1));
|
||||
}
|
||||
|
||||
- return new SerializableChunkData(iregistry, chunkcoordintpair, world.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, world.getMinSectionY(), i, j, chunkstatus, blendingdata_d, belowzeroretrogen, chunkconverter, along, map, ichunkaccess_a, ashortlist, flag, list4, list2, list3, nbttagcompound2, nbt.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 (this.persistentDataContainer instanceof CompoundTag) {
|
||||
+ ((ChunkAccess) object).persistentDataContainer.putAll((CompoundTag) this.persistentDataContainer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
((ChunkAccess) object).setLightCorrect(this.lightCorrect);
|
||||
EnumSet<Heightmap.Types> enumset = EnumSet.noneOf(Heightmap.Types.class);
|
||||
Iterator iterator1 = ((ChunkAccess) object).getPersistedStatus().heightmapsAfter().iterator();
|
||||
@@ -346,7 +354,13 @@
|
||||
|
||||
private static Codec<PalettedContainerRO<Holder<Biome>>> makeBiomeCodec(Registry<Biome> biomeRegistry) {
|
||||
return PalettedContainer.codecRO(biomeRegistry.asHolderIdMap(), biomeRegistry.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomeRegistry.getOrThrow(Biomes.PLAINS));
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - read/write
|
||||
+ private static Codec<PalettedContainer<Holder<Biome>>> makeBiomeCodecRW(Registry<Biome> iregistry) {
|
||||
+ return PalettedContainer.codecRW(iregistry.asHolderIdMap(), iregistry.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, iregistry.getOrThrow(Biomes.PLAINS));
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static SerializableChunkData copyOf(ServerLevel world, ChunkAccess chunk) {
|
||||
if (!chunk.canBeSerialized()) {
|
||||
@@ -419,7 +433,14 @@
|
||||
});
|
||||
CompoundTag nbttagcompound1 = packStructureData(StructurePieceSerializationContext.fromLevel(world), chunkcoordintpair, chunk.getAllStarts(), chunk.getAllReferences());
|
||||
|
||||
- return new SerializableChunkData(world.registryAccess().lookupOrThrow(Registries.BIOME), chunkcoordintpair, chunk.getMinSectionY(), world.getGameTime(), chunk.getInhabitedTime(), chunk.getPersistedStatus(), (BlendingData.Packed) Optionull.map(chunk.getBlendingData(), BlendingData::pack), chunk.getBelowZeroRetrogen(), chunk.getUpgradeData().copy(), along, map, ichunkaccess_a, ashortlist, chunk.isLightCorrect(), list, list2, list1, nbttagcompound1);
|
||||
+ // CraftBukkit start - store chunk persistent data in nbt
|
||||
+ CompoundTag persistentDataContainer = null;
|
||||
+ if (!chunk.persistentDataContainer.isEmpty()) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading.
|
||||
+ persistentDataContainer = chunk.persistentDataContainer.toTagCompound();
|
||||
+ }
|
||||
+
|
||||
+ return new SerializableChunkData(world.registryAccess().lookupOrThrow(Registries.BIOME), chunkcoordintpair, chunk.getMinSectionY(), world.getGameTime(), chunk.getInhabitedTime(), chunk.getPersistedStatus(), (BlendingData.Packed) Optionull.map(chunk.getBlendingData(), BlendingData::pack), chunk.getBelowZeroRetrogen(), chunk.getUpgradeData().copy(), along, map, ichunkaccess_a, ashortlist, chunk.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<Tag> 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 (this.persistentDataContainer != null) { // SPIGOT-6814: Always save PDC to account for 1.17 to 1.18 chunk upgrading.
|
||||
+ nbttagcompound.put("ChunkBukkitValues", this.persistentDataContainer);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@@ -623,6 +649,12 @@
|
||||
StructureStart structurestart = StructureStart.loadStaticStart(context, nbttagcompound1.getCompound(s), worldSeed);
|
||||
|
||||
if (structurestart != null) {
|
||||
+ // CraftBukkit start - load persistent data for structure start
|
||||
+ net.minecraft.nbt.Tag persistentBase = nbttagcompound1.getCompound(s).get("StructureBukkitValues");
|
||||
+ if (persistentBase instanceof CompoundTag) {
|
||||
+ structurestart.persistentDataContainer.putAll((CompoundTag) persistentBase);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
map.put(structure, structurestart);
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
--- 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user