SPIGOT-4541: Cancelled bucket events require inventory update

This commit is contained in:
md_5 2018-12-22 10:12:16 +11:00
parent 1b982fd67e
commit 6ff5a64c25

View File

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