SPIGOT-4975: NPE on WorldGenStronghold When Using Multiple Worlds

This commit is contained in:
md_5 2019-07-22 16:03:02 +10:00
parent 65ea162ce2
commit c03b2befb2
2 changed files with 33 additions and 0 deletions

View file

@ -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());

View file

@ -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<? extends GeneratorSettingsDefault> chunkgenerator, BlockPosition blockposition, int i, boolean flag) {
+ public synchronized BlockPosition getNearestGeneratedFeature(World world, ChunkGenerator<? extends GeneratorSettingsDefault> chunkgenerator, BlockPosition blockposition, int i, boolean flag) { // CraftBukkit - synchronized
if (!chunkgenerator.getWorldChunkManager().a(this)) {
return null;
} else {