Initialise default nibble arrays in ChunkAccess directly

When ChunkAccess was converted to an abstract class some versions
ago, the code to initialise nibble arrays should have been moved.
However, the code was not moved and so now mods constructing their
own implementations of ChunkAccess would not have the nibble arrays
initialised.

This is ported to Paper from Starlight to keep the code base in sync,
not because it fixes anything known.
This commit is contained in:
Spottedleaf 2023-10-16 18:57:45 -07:00
parent 00331d943e
commit 4b0bc74c90
10 changed files with 54 additions and 70 deletions

View file

@ -21314,7 +21314,7 @@ index 846ae3fd184a1d63b743aa25e045604576697c96..a907b79fd8291a0e92db138f37239d17
public int getIndex() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128d35b260a 100644
index f75d37091018d5544099861e2fe7d3fd04870750..9da26705d41931e77bff0e6a4d73bb9263e6989e 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -83,6 +83,7 @@ public class LevelChunk extends ChunkAccess {
@ -21325,7 +21325,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
public LevelChunk(Level world, ChunkPos pos) {
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
@@ -661,9 +662,26 @@ public class LevelChunk extends ChunkAccess {
@@ -657,9 +658,26 @@ public class LevelChunk extends ChunkAccess {
}
@ -21355,7 +21355,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
int chunkX = this.chunkPos.x;
int chunkZ = this.chunkPos.z;
net.minecraft.server.level.ServerChunkCache chunkProvider = this.level.getChunkSource();
@@ -678,10 +696,55 @@ public class LevelChunk extends ChunkAccess {
@@ -674,10 +692,55 @@ public class LevelChunk extends ChunkAccess {
}
}
this.setNeighbourLoaded(0, 0, this);
@ -21413,7 +21413,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
if (server != null) {
/*
* If it's a new world, the first few chunks are generated inside
@@ -690,6 +753,7 @@ public class LevelChunk extends ChunkAccess {
@@ -686,6 +749,7 @@ public class LevelChunk extends ChunkAccess {
*/
org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration));
@ -21421,7 +21421,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
if (this.needsDecoration) {
try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper
@@ -718,9 +782,11 @@ public class LevelChunk extends ChunkAccess {
@@ -714,9 +778,11 @@ public class LevelChunk extends ChunkAccess {
}
public void unloadCallback() {
@ -21434,7 +21434,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
server.getPluginManager().callEvent(unloadEvent);
// note: saving can be prevented, but not forced if no saving is actually required
this.mustNotSave = !unloadEvent.isSaveChunk();
@@ -742,9 +808,26 @@ public class LevelChunk extends ChunkAccess {
@@ -738,9 +804,26 @@ public class LevelChunk extends ChunkAccess {
// Paper end
}
@ -21462,7 +21462,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
}
// CraftBukkit end
@@ -813,7 +896,9 @@ public class LevelChunk extends ChunkAccess {
@@ -809,7 +892,9 @@ public class LevelChunk extends ChunkAccess {
return this.blockEntities;
}
@ -21472,7 +21472,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
ChunkPos chunkcoordintpair = this.getPos();
for (int i = 0; i < this.postProcessing.length; ++i) {
@@ -834,6 +919,7 @@ public class LevelChunk extends ChunkAccess {
@@ -830,6 +915,7 @@ public class LevelChunk extends ChunkAccess {
BlockState iblockdata1 = Block.updateFromNeighbourShapes(iblockdata, this.level, blockposition);
this.level.setBlock(blockposition, iblockdata1, 20);
@ -21480,7 +21480,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
}
}
@@ -851,6 +937,10 @@ public class LevelChunk extends ChunkAccess {
@@ -847,6 +933,10 @@ public class LevelChunk extends ChunkAccess {
this.pendingBlockEntities.clear();
this.upgradeData.upgrade(this);
@ -21491,7 +21491,7 @@ index f225a51d284a64d5a962256ab5d7b2d07544dc88..998ca8d123e8b373f0ce5c10f76ec128
}
@Nullable
@@ -900,7 +990,7 @@ public class LevelChunk extends ChunkAccess {
@@ -896,7 +986,7 @@ public class LevelChunk extends ChunkAccess {
}
public FullChunkStatus getFullStatus() {