SPIGOT-5710: POI data mismatch when cancelling BlockPlaceEvent for villager workstations

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2021-07-03 15:39:52 +10:00
parent a388fc3a6c
commit 917e89ed06
2 changed files with 27 additions and 20 deletions

View File

@@ -103,7 +103,7 @@
EntityHuman entityhuman = itemactioncontext.getEntity();
BlockPosition blockposition = itemactioncontext.getClickPosition();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
@@ -204,12 +256,153 @@
@@ -204,12 +256,155 @@
if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.b(itemactioncontext.getWorld().r(), shapedetectorblock)) {
return EnumInteractionResult.PASS;
} else {
@@ -175,9 +175,11 @@
+ // PAIL: Remove this when MC-99075 fixed
+ placeEvent.getPlayer().updateInventory();
+ // revert back all captured blocks
+ world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true, false);
+ }
+ world.preventPoiUpdated = false;
+
+ // Brute force all possible updates
+ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
@@ -258,7 +260,7 @@
return enuminteractionresult;
}
@@ -290,6 +483,21 @@
@@ -290,6 +485,21 @@
}
i -= k;
@@ -280,7 +282,7 @@
if (i <= 0) {
return false;
}
@@ -311,6 +519,11 @@
@@ -311,6 +521,11 @@
if (this.isDamaged(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
consumer.accept(t0);
Item item = this.getItem();
@@ -292,7 +294,7 @@
this.subtract(1);
if (t0 instanceof EntityHuman) {
@@ -466,6 +679,17 @@
@@ -466,6 +681,17 @@
return this.tag;
}
@@ -310,7 +312,7 @@
public NBTTagCompound getOrCreateTag() {
if (this.tag == null) {
this.setTag(new NBTTagCompound());
@@ -849,6 +1073,12 @@
@@ -849,6 +1075,12 @@
}
public void setRepairCost(int i) {
@@ -323,7 +325,7 @@
this.getOrCreateTag().setInt("RepairCost", i);
}
@@ -898,6 +1128,13 @@
@@ -898,6 +1130,13 @@
nbttaglist.add(nbttagcompound);
}