SPIGOT-5472: Spurious warning when using clone command on tile entities

This commit is contained in:
md_5 2019-12-23 11:59:51 +11:00
parent 85106731bf
commit 75fac431cf
2 changed files with 24 additions and 9 deletions

View file

@ -334,15 +334,21 @@
}
}
}
@@ -604,6 +816,7 @@
}
}
@@ -606,12 +818,26 @@
+ public Map<BlockPosition, TileEntity> capturedTileEntities = Maps.newHashMap();
@Nullable
@Override
+ // CraftBukkit start
public TileEntity getTileEntity(BlockPosition blockposition) {
@@ -612,6 +825,12 @@
+ return getTileEntity(blockposition, true);
+ }
+ public Map<BlockPosition, TileEntity> 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_();

View file

@ -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;
+ }