Fix NPE from using wrong ProtoChunk ctor (#6147)
This commit is contained in:
parent
d985976b3e
commit
a4880d832b
|
@ -33,23 +33,22 @@ index 6f5e1f7c23b19257c89b7c5a992ad76623bf4006..a2eecfaf54921423f803d759c06789e5
|
|||
};
|
||||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> ret = new CompletableFuture<>();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index 974ab04b08bbd3c27a394b37c1af112be5f28f43..c0075d226331f32e470dae5bf1ce8d79e8b263dc 100644
|
||||
index 974ab04b08bbd3c27a394b37c1af112be5f28f43..149ac5ec368b53a9a5e9208bd49a3c9453625d9c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -29,6 +29,18 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
||||
@@ -29,6 +29,17 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
||||
return GameEventDispatcher.NOOP;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ default boolean generateFlatBedrock() {
|
||||
+ if (this instanceof ProtoChunk) {
|
||||
+ return ((ProtoChunk)this).level.paperConfig.generateFlatBedrock;
|
||||
+ } else if (this instanceof LevelChunk) {
|
||||
+ return ((LevelChunk)this).level.paperConfig.generateFlatBedrock;
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ if (this.getLevel() != null) {
|
||||
+ return this.getLevel().paperConfig.generateFlatBedrock;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.Level getLevel();
|
||||
+ // Paper end
|
||||
+
|
||||
BlockState getType(final int x, final int y, final int z); // Paper
|
||||
|
@ -69,18 +68,31 @@ index 452b513e8b89d865a396066adaf4feb1140e1c62..8245c5834ec69beb8e3b95fb39006010
|
|||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
index 873fea54aecca411b6dee1ed3566f93c4fb9670f..64cb0658021866c3875d145cc4266896e57c081e 100644
|
||||
index 873fea54aecca411b6dee1ed3566f93c4fb9670f..7dc3d806a680150c6a2fffa1436fd63bbdc31eb3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
@@ -63,16 +63,24 @@ public class ProtoChunk implements ChunkAccess {
|
||||
@@ -63,16 +63,45 @@ public class ProtoChunk implements ChunkAccess {
|
||||
private long inhabitedTime;
|
||||
private final Map<GenerationStep.Carving, BitSet> carvingMasks = new Object2ObjectArrayMap<>();
|
||||
private volatile boolean isLightCorrect;
|
||||
+ final net.minecraft.world.level.Level level; // Paper - Add level
|
||||
+ // Paper start - Add level
|
||||
+ final net.minecraft.world.level.Level level;
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.Level getLevel() {
|
||||
+ return this.level;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ private static boolean PRINTED_OUTDATED_CTOR_MSG = false; // Paper - Add level
|
||||
|
||||
- public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor world) {
|
||||
+ // Paper start - add level
|
||||
+ @Deprecated public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor world) { this(pos, upgradeData, world, null); }
|
||||
+ @Deprecated // Paper start - add level
|
||||
public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor world) {
|
||||
+ // Paper start
|
||||
+ this(pos, upgradeData, world, null);
|
||||
+ if (!PRINTED_OUTDATED_CTOR_MSG) {
|
||||
+ new IllegalArgumentException("Must use ProtoChunk constructor with the ServerLevel parameter").printStackTrace();
|
||||
+ PRINTED_OUTDATED_CTOR_MSG = true;
|
||||
+ }
|
||||
+ }
|
||||
+ public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, LevelHeightAccessor world, net.minecraft.server.level.ServerLevel level) {
|
||||
+ // Paper end
|
||||
this(pos, upgradeData, (LevelChunkSection[])null, new ProtoTickList<>((block) -> {
|
||||
|
@ -91,9 +103,15 @@ index 873fea54aecca411b6dee1ed3566f93c4fb9670f..64cb0658021866c3875d145cc4266896
|
|||
+ }, pos, world), world, level); // Paper - add level
|
||||
}
|
||||
|
||||
- public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] levelChunkSections, ProtoTickList<Block> blockTickScheduler, ProtoTickList<Fluid> fluidTickScheduler, LevelHeightAccessor world) {
|
||||
+ // Paper start - add level
|
||||
+ @Deprecated public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] levelChunkSections, ProtoTickList<Block> blockTickScheduler, ProtoTickList<Fluid> fluidTickScheduler, LevelHeightAccessor world) { this(pos, upgradeData, levelChunkSections, blockTickScheduler, fluidTickScheduler, world, null); }
|
||||
+ @Deprecated // Paper start - add level
|
||||
public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] levelChunkSections, ProtoTickList<Block> blockTickScheduler, ProtoTickList<Fluid> fluidTickScheduler, LevelHeightAccessor world) {
|
||||
+ // Paper start
|
||||
+ this(pos, upgradeData, levelChunkSections, blockTickScheduler, fluidTickScheduler, world, null);
|
||||
+ if (!PRINTED_OUTDATED_CTOR_MSG) {
|
||||
+ new IllegalArgumentException("Must use ProtoChunk constructor with the ServerLevel parameter").printStackTrace();
|
||||
+ PRINTED_OUTDATED_CTOR_MSG = true;
|
||||
+ }
|
||||
+ }
|
||||
+ public ProtoChunk(ChunkPos pos, UpgradeData upgradeData, @Nullable LevelChunkSection[] levelChunkSections, ProtoTickList<Block> blockTickScheduler, ProtoTickList<Fluid> fluidTickScheduler, LevelHeightAccessor world, net.minecraft.server.level.ServerLevel level) {
|
||||
+ this.level = level;
|
||||
+ // Paper end
|
||||
|
|
|
@ -1178,10 +1178,10 @@ index fb6da4bccd33b9e079f4bcf84f8ff59ad24a5fe6..2007b0b04e7037e1444b5d1964638ccd
|
|||
if (iblockdata1 == null) {
|
||||
// CraftBukkit start - remove blockstate if failed (or the same)
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index c0075d226331f32e470dae5bf1ce8d79e8b263dc..ba409922a5274fbb9a02a897cf7fe490b02fd781 100644
|
||||
index 149ac5ec368b53a9a5e9208bd49a3c9453625d9c..12d11a249c759e99568a76c791cc0d65adfcfe94 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -75,12 +75,14 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
||||
@@ -74,7 +74,7 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
||||
default LevelChunkSection getOrCreateSection(int yIndex) {
|
||||
LevelChunkSection[] levelChunkSections = this.getSections();
|
||||
if (levelChunkSections[yIndex] == LevelChunk.EMPTY_SECTION) {
|
||||
|
@ -1190,13 +1190,6 @@ index c0075d226331f32e470dae5bf1ce8d79e8b263dc..ba409922a5274fbb9a02a897cf7fe490
|
|||
}
|
||||
|
||||
return levelChunkSections[yIndex];
|
||||
}
|
||||
|
||||
+ net.minecraft.world.level.Level getLevel(); // Paper - Anti-Xray - Add parameters
|
||||
+
|
||||
Collection<Entry<Heightmap.Types, Heightmap>> getHeightmaps();
|
||||
|
||||
default void setHeightmap(Heightmap.Types type, long[] heightmap) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||
index 69c2454533e6f21c70792b555ec02c6bc6d169b3..f9e0e109497d685a9d88d2fa8892287b9fa97443 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||
|
@ -1398,22 +1391,6 @@ index bb8fd88aebb550edec8c679622a02a595cbc6694..ac51089aae57a5f1d2411367ff177e05
|
|||
int j = data.length * 64 / 4096;
|
||||
if (this.palette == this.globalPalette) {
|
||||
Palette<T> palette = new HashMapPalette<>(this.registry, i, this.dummyPaletteResize, this.reader, this.writer);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
index 64cb0658021866c3875d145cc4266896e57c081e..78bd3274866fed3d627a3eda7b96b92716507d38 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
@@ -506,4 +506,11 @@ public class ProtoChunk implements ChunkAccess {
|
||||
public int getHeight() {
|
||||
return this.levelHeightAccessor.getHeight();
|
||||
}
|
||||
+
|
||||
+ // Paper start - Anti-Xray - Add parameters
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.Level getLevel() {
|
||||
+ return level;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
index 79a7221b0462931e94f31ccd7c6dc2720ddfb752..afbb42595afeb151208880dcf48b94d7c00a8733 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
|
|
|
@ -240,7 +240,7 @@ index a1529fef41543486d29271b1de62a6246d07d384..f518fc7a39a807bff2e141fd238ab1bf
|
|||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index d6cb161981d3cdef4669522ba51cb1db83f9e04c..aaeb50d7980a910ff21f9c1ea903acf994392ef8 100644
|
||||
index d8bf5a86a3eb0ae3fd6308e817a707ae98961479..ec0a9f46b50280324ae0d2eed208c8f332a5d88d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -671,6 +671,15 @@ public class ServerChunkCache extends ChunkSource {
|
||||
|
@ -302,7 +302,7 @@ index 8ebcd5947688a1f0a8216e934ac90da0e5a8540e..8cd2764e5d07975304b52ec5d995f4e7
|
|||
ServerChunkCache chunkproviderserver = this.getChunkSource();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index ba409922a5274fbb9a02a897cf7fe490b02fd781..63203172a127d812fd59cea0546b67e855ce3ad5 100644
|
||||
index 12d11a249c759e99568a76c791cc0d65adfcfe94..8393950a0b38ec7897d7643803d5accdb1f983f3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -29,6 +29,7 @@ public interface ChunkAccess extends BlockGetter, FeatureAccess {
|
||||
|
@ -312,7 +312,7 @@ index ba409922a5274fbb9a02a897cf7fe490b02fd781..63203172a127d812fd59cea0546b67e8
|
|||
+ default void setLastSaved(long ticks) {}
|
||||
// Paper start
|
||||
default boolean generateFlatBedrock() {
|
||||
if (this instanceof ProtoChunk) {
|
||||
if (this.getLevel() != null) {
|
||||
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 7d33ad1ec939de4527d0acb0915f05870c387565..cc02b577453fa251f0f1b508281ddea2513138a1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] Allow delegation to vanilla chunk gen
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 1d6fb9505fff146bae3ca25746e9533b765d2662..bf0f3d861ab7f185d9868e29ebe35216581f612e 100644
|
||||
index 49a907e0761cea917db3aa7cfbc6ed237acc59f6..f93b9a1d0f3600fa1c8b9a9881465c73a965862b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2038,6 +2038,32 @@ public final class CraftServer implements Server {
|
||||
|
@ -19,7 +19,7 @@ index 1d6fb9505fff146bae3ca25746e9533b765d2662..bf0f3d861ab7f185d9868e29ebe35216
|
|||
+ CraftChunkData data = (CraftChunkData) createChunkData(world);
|
||||
+ // do bunch of vanilla shit
|
||||
+ net.minecraft.server.level.ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
|
||||
+ net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(x, z), null, nmsWorld);
|
||||
+ net.minecraft.world.level.chunk.ProtoChunk protoChunk = new net.minecraft.world.level.chunk.ProtoChunk(new net.minecraft.world.level.ChunkPos(x, z), null, nmsWorld, nmsWorld);
|
||||
+ List<net.minecraft.world.level.chunk.ChunkAccess> list = new ArrayList<>();
|
||||
+ list.add(protoChunk);
|
||||
+ net.minecraft.server.level.WorldGenRegion genRegion = new net.minecraft.server.level.WorldGenRegion(nmsWorld, list, net.minecraft.world.level.chunk.ChunkStatus.EMPTY, -1);
|
||||
|
|
Loading…
Reference in New Issue