3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 02:50:09 +01:00

SPIGOT-4541: Cancelled bucket events require inventory update

Dieser Commit ist enthalten in:
md_5 2018-12-22 10:12:16 +11:00
Ursprung 1b982fd67e
Commit 6ff5a64c25

Datei anzeigen

@ -14,7 +14,7 @@
public class ItemBucket extends Item {
@@ -26,12 +33,20 @@
@@ -26,12 +33,21 @@
if (this.fluidType == FluidTypes.a) {
iblockdata = world.getType(blockposition);
if (iblockdata.getBlock() instanceof IFluidSource) {
@ -23,6 +23,7 @@
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, blockposition.getX(), blockposition.getY(), blockposition.getZ(), null, itemstack, dummyFluid.b());
+
+ if (event.isCancelled()) {
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
+ return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack);
+ }
+ // CraftBukkit end
@ -36,7 +37,7 @@
if (!world.isClientSide) {
CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.b()));
@@ -46,7 +61,7 @@
@@ -46,7 +62,7 @@
iblockdata = world.getType(blockposition);
BlockPosition blockposition1 = this.a(iblockdata, blockposition, movingobjectposition);
@ -45,7 +46,7 @@
this.a(world, itemstack, blockposition1);
if (entityhuman instanceof EntityPlayer) {
CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack);
@@ -76,16 +91,19 @@
@@ -76,16 +92,19 @@
public void a(World world, ItemStack itemstack, BlockPosition blockposition) {}
@ -69,7 +70,7 @@
}
return itemstack;
@@ -93,7 +111,13 @@
@@ -93,7 +112,13 @@
}
}
@ -83,7 +84,7 @@
if (!(this.fluidType instanceof FluidTypeFlowing)) {
return false;
} else {
@@ -103,8 +127,18 @@
@@ -103,8 +128,18 @@
boolean flag1 = material.isReplaceable();
if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, this.fluidType))) {
@ -95,7 +96,7 @@
+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent(entityhuman, clicked.getX(), clicked.getY(), clicked.getZ(), enumdirection, itemstack);
+ if (event.isCancelled()) {
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
+ // TODO: inventory not updated
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
+ return false;
+ }
+ }