From c03b2befb25ee6813f5f426ce7e4c2e6d13a837f Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 22 Jul 2019 16:03:02 +1000 Subject: [PATCH] SPIGOT-4975: NPE on WorldGenStronghold When Using Multiple Worlds --- nms-patches/ChunkGenerator.patch | 22 ++++++++++++++++++++++ nms-patches/WorldGenStronghold.patch | 11 +++++++++++ 2 files changed, 33 insertions(+) create mode 100644 nms-patches/ChunkGenerator.patch create mode 100644 nms-patches/WorldGenStronghold.patch diff --git a/nms-patches/ChunkGenerator.patch b/nms-patches/ChunkGenerator.patch new file mode 100644 index 0000000000..4655ec35e7 --- /dev/null +++ b/nms-patches/ChunkGenerator.patch @@ -0,0 +1,22 @@ +--- a/net/minecraft/server/ChunkGenerator.java ++++ b/net/minecraft/server/ChunkGenerator.java +@@ -148,6 +148,19 @@ + ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos(); + StructureStart structurestart = StructureStart.a; + ++ // CraftBukkit start ++ if (structuregenerator == WorldGenerator.STRONGHOLD) { ++ synchronized (structuregenerator) { ++ if (structuregenerator.a(chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z)) { ++ BiomeBase biomebase = this.getWorldChunkManager().getBiome(new BlockPosition(chunkcoordintpair.d() + 9, 0, chunkcoordintpair.e() + 9)); ++ StructureStart structurestart1 = structuregenerator.a().create(structuregenerator, chunkcoordintpair.x, chunkcoordintpair.z, biomebase, StructureBoundingBox.a(), 0, chunkgenerator.getSeed()); ++ ++ structurestart1.a(this, definedstructuremanager, chunkcoordintpair.x, chunkcoordintpair.z, biomebase); ++ structurestart = structurestart1.e() ? structurestart1 : StructureStart.a; ++ } ++ } ++ } else ++ // CraftBukkit end + if (structuregenerator.a(chunkgenerator, seededrandom, chunkcoordintpair.x, chunkcoordintpair.z)) { + BiomeBase biomebase = this.getWorldChunkManager().getBiome(new BlockPosition(chunkcoordintpair.d() + 9, 0, chunkcoordintpair.e() + 9)); + StructureStart structurestart1 = structuregenerator.a().create(structuregenerator, chunkcoordintpair.x, chunkcoordintpair.z, biomebase, StructureBoundingBox.a(), 0, chunkgenerator.getSeed()); diff --git a/nms-patches/WorldGenStronghold.patch b/nms-patches/WorldGenStronghold.patch new file mode 100644 index 0000000000..3c29071576 --- /dev/null +++ b/nms-patches/WorldGenStronghold.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/server/WorldGenStronghold.java ++++ b/net/minecraft/server/WorldGenStronghold.java +@@ -67,7 +67,7 @@ + + @Nullable + @Override +- public BlockPosition getNearestGeneratedFeature(World world, ChunkGenerator chunkgenerator, BlockPosition blockposition, int i, boolean flag) { ++ public synchronized BlockPosition getNearestGeneratedFeature(World world, ChunkGenerator chunkgenerator, BlockPosition blockposition, int i, boolean flag) { // CraftBukkit - synchronized + if (!chunkgenerator.getWorldChunkManager().a(this)) { + return null; + } else {