SPIGOT-4221: Update surrounding blocks for cancelled break/place

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2018-08-03 11:34:26 +10:00
commit 33f46cbebf
3 changed files with 32 additions and 20 deletions

View file

@ -85,7 +85,7 @@
EntityHuman entityhuman = itemactioncontext.getEntity();
BlockPosition blockposition = itemactioncontext.getClickPosition();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
@@ -106,12 +146,136 @@
@@ -106,12 +146,142 @@
if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().E(), shapedetectorblock)) {
return EnumInteractionResult.PASS;
} else {
@ -156,6 +156,12 @@
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true, false);
+ }
+
+ // Brute force all possible updates
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
+ for (EnumDirection dir : EnumDirection.values()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir)));
+ }
+ } else {
+ // Change the stack to its new contents if it hasn't been tampered with.
+ if (this.getCount() == oldCount) {
@ -223,7 +229,7 @@
return enuminteractionresult;
}
@@ -135,7 +299,7 @@
@@ -135,7 +305,7 @@
nbttagcompound.setString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
nbttagcompound.setByte("Count", (byte) this.count);
if (this.tag != null) {
@ -232,7 +238,7 @@
}
return nbttagcompound;
@@ -213,6 +377,11 @@
@@ -213,6 +383,11 @@
if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) {
entityliving.c(this);
Item item = this.getItem();
@ -244,7 +250,7 @@
this.subtract(1);
if (entityliving instanceof EntityHuman) {
@@ -480,6 +649,14 @@
@@ -480,6 +655,14 @@
}
public void setRepairCost(int i) {
@ -259,7 +265,7 @@
this.getOrCreateTag().setInt("RepairCost", i);
}
@@ -522,6 +699,13 @@
@@ -522,6 +705,13 @@
nbttaglist.add((NBTBase) nbttagcompound);
}