SPIGOT-2833: Tile entities occasionally wiped after placement

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2016-11-24 09:30:01 +11:00
parent 874e784b8a
commit 5a3215856c

View File

@ -75,7 +75,7 @@
this.F(); this.F();
} }
@@ -94,11 +128,137 @@ @@ -94,11 +128,138 @@
} }
public EnumInteractionResult placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) { public EnumInteractionResult placeItem(EntityHuman entityhuman, World world, BlockPosition blockposition, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
@ -152,6 +152,11 @@
+ this.setData(newData); + this.setData(newData);
+ this.setCount(newCount); + this.setCount(newCount);
+ } + }
+
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
+ world.setTileEntity(e.getKey(), e.getValue());
+ }
+
+ for (BlockState blockstate : blocks) { + for (BlockState blockstate : blocks) {
+ int x = blockstate.getX(); + int x = blockstate.getX();
+ int y = blockstate.getY(); + int y = blockstate.getY();
@ -169,10 +174,6 @@
+ world.notifyAndUpdatePhysics(newblockposition, null, oldBlock.getBlockData(), block, updateFlag); // send null chunk as chunk.k() returns false by this point + world.notifyAndUpdatePhysics(newblockposition, null, oldBlock.getBlockData(), block, updateFlag); // send null chunk as chunk.k() returns false by this point
+ } + }
+ +
+ for (Map.Entry<BlockPosition, TileEntity> e : world.capturedTileEntities.entrySet()) {
+ world.setTileEntity(e.getKey(), e.getValue());
+ }
+
+ // Special case juke boxes as they update their tile entity. Copied from ItemRecord. + // Special case juke boxes as they update their tile entity. Copied from ItemRecord.
+ // PAIL: checkme on updates. + // PAIL: checkme on updates.
+ if (this.item instanceof ItemRecord) { + if (this.item instanceof ItemRecord) {
@ -214,7 +215,7 @@
return enuminteractionresult; return enuminteractionresult;
} }
@@ -122,7 +282,7 @@ @@ -122,7 +283,7 @@
nbttagcompound.setByte("Count", (byte) this.count); nbttagcompound.setByte("Count", (byte) this.count);
nbttagcompound.setShort("Damage", (short) this.damage); nbttagcompound.setShort("Damage", (short) this.damage);
if (this.tag != null) { if (this.tag != null) {
@ -223,7 +224,7 @@
} }
return nbttagcompound; return nbttagcompound;
@@ -157,11 +317,30 @@ @@ -157,11 +318,30 @@
} }
public void setData(int i) { public void setData(int i) {
@ -256,7 +257,7 @@
} }
public int k() { public int k() {
@@ -205,6 +384,11 @@ @@ -205,6 +385,11 @@
entityhuman.b(StatisticList.c(this.item)); entityhuman.b(StatisticList.c(this.item));
} }
@ -268,7 +269,7 @@
this.damage = 0; this.damage = 0;
} }
@@ -509,6 +693,12 @@ @@ -509,6 +694,12 @@
nbttaglist.add(nbttagcompound); nbttaglist.add(nbttagcompound);
} }