From d4243510102530684b860dbe927311bf47c488db Mon Sep 17 00:00:00 2001 From: Parker Hawke Date: Sat, 27 Jun 2020 11:09:01 +1000 Subject: [PATCH] SPIGOT-5853: DragonBattle#getEndPortalLocation() throws NPE on new world * Add method to generate the end portal --- nms-patches/EnderDragonBattle.patch | 33 +++++++++++++++++++ .../craftbukkit/boss/CraftDragonBattle.java | 14 ++++++++ 2 files changed, 47 insertions(+) create mode 100644 nms-patches/EnderDragonBattle.patch diff --git a/nms-patches/EnderDragonBattle.patch b/nms-patches/EnderDragonBattle.patch new file mode 100644 index 0000000000..da691e877b --- /dev/null +++ b/nms-patches/EnderDragonBattle.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/server/EnderDragonBattle.java ++++ b/net/minecraft/server/EnderDragonBattle.java +@@ -245,7 +245,7 @@ + } + + @Nullable +- private ShapeDetector.ShapeDetectorCollection j() { ++ public ShapeDetector.ShapeDetectorCollection j() { // PAIL private -> public, rename getExitPortalShape() + int i; + int j; + +@@ -376,10 +376,10 @@ + + private void a(BlockPosition blockposition) { + this.world.triggerEffect(3000, blockposition, 0); +- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a()).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), blockposition); ++ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a()).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error + } + +- private void a(boolean flag) { ++ public void a(boolean flag) { // PAIL private -> public, rename generateExitPortal() + WorldGenEndTrophy worldgenendtrophy = new WorldGenEndTrophy(flag); + + if (this.exitPortalLocation == null) { +@@ -388,7 +388,7 @@ + } + } + +- worldgenendtrophy.b((WorldGenFeatureConfiguration) WorldGenFeatureConfiguration.k).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), this.exitPortalLocation); ++ worldgenendtrophy.b(WorldGenFeatureConfiguration.k).a(this.world, this.world.getStructureManager(), this.world.getChunkProvider().getChunkGenerator(), new Random(), this.exitPortalLocation); // CraftBukkit - decompile error + } + + private EntityEnderDragon o() { diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java index 83a12e4776..dec7e8c600 100644 --- a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java +++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java @@ -30,9 +30,23 @@ public class CraftDragonBattle implements DragonBattle { @Override public Location getEndPortalLocation() { + if (handle.exitPortalLocation == null) { + return null; + } + return new Location(handle.world.getWorld(), handle.exitPortalLocation.getX(), handle.exitPortalLocation.getY(), handle.exitPortalLocation.getZ()); } + @Override + public boolean generateEndPortal(boolean withPortals) { + if (handle.exitPortalLocation != null || handle.j() != null) { + return false; + } + + this.handle.a(withPortals); + return true; + } + @Override public boolean hasBeenPreviouslyKilled() { return handle.isPreviouslyKilled();