From 75fac431cfc807ccf05629ce4796db958ee112e6 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 23 Dec 2019 11:59:51 +1100 Subject: [PATCH] SPIGOT-5472: Spurious warning when using clone command on tile entities --- nms-patches/World.patch | 27 +++++++++++++++++++++------ nms-patches/WorldServer.patch | 6 +++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/nms-patches/World.patch b/nms-patches/World.patch index 481df1e926..a0fe2c98ce 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -334,15 +334,21 @@ } } } -@@ -604,6 +816,7 @@ - } - } +@@ -606,12 +818,26 @@ -+ public Map capturedTileEntities = Maps.newHashMap(); @Nullable @Override ++ // CraftBukkit start public TileEntity getTileEntity(BlockPosition blockposition) { -@@ -612,6 +825,12 @@ ++ return getTileEntity(blockposition, true); ++ } ++ public Map capturedTileEntities = Maps.newHashMap(); ++ ++ @Nullable ++ protected TileEntity getTileEntity(BlockPosition blockposition, boolean validate) { ++ // CraftBukkit end + if (isOutsideWorld(blockposition)) { + return null; } else if (!this.isClientSide && Thread.currentThread() != this.serverThread) { return null; } else { @@ -355,7 +361,7 @@ TileEntity tileentity = null; if (this.tickingTileEntities) { -@@ -646,6 +865,13 @@ +@@ -646,6 +872,13 @@ public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { if (!isOutsideWorld(blockposition)) { if (tileentity != null && !tileentity.isRemoved()) { @@ -369,3 +375,12 @@ if (this.tickingTileEntities) { tileentity.setLocation(this, blockposition); Iterator iterator = this.tileEntityListPending.iterator(); +@@ -670,7 +903,7 @@ + } + + public void removeTileEntity(BlockPosition blockposition) { +- TileEntity tileentity = this.getTileEntity(blockposition); ++ TileEntity tileentity = this.getTileEntity(blockposition, false); // CraftBukkit + + if (tileentity != null && this.tickingTileEntities) { + tileentity.ab_(); diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index 828421181a..8334d76e04 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -62,9 +62,9 @@ + + // CraftBukkit start + @Override -+ public TileEntity getTileEntity(BlockPosition pos) { -+ TileEntity result = super.getTileEntity(pos); -+ if (Thread.currentThread() != this.serverThread) { ++ protected TileEntity getTileEntity(BlockPosition pos, boolean validate) { ++ TileEntity result = super.getTileEntity(pos, validate); ++ if (!validate || Thread.currentThread() != this.serverThread) { + // SPIGOT-5378: avoid deadlock, this can be called in loading logic (i.e lighting) but getType() will block on chunk load + return result; + }