From 2349feb8495c2064c0f987e5fd93dcc7dd6abcc9 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 13 Jul 2019 12:07:15 +1000 Subject: [PATCH] SPIGOT-5163: Cancelling PlayerBucketFillEvent visually removes the targeted block --- nms-patches/ItemBucket.patch | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nms-patches/ItemBucket.patch b/nms-patches/ItemBucket.patch index 0e1a0aef3e..ae71331b8d 100644 --- a/nms-patches/ItemBucket.patch +++ b/nms-patches/ItemBucket.patch @@ -14,7 +14,7 @@ public class ItemBucket extends Item { -@@ -30,12 +37,21 @@ +@@ -30,12 +37,22 @@ if (this.fluidType == FluidTypes.EMPTY) { 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).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 + return new InteractionResultWrapper(EnumInteractionResult.FAIL, itemstack); + } @@ -37,7 +38,7 @@ if (!world.isClientSide) { CriterionTriggers.j.a((EntityPlayer) entityhuman, new ItemStack(fluidtype.b())); -@@ -50,7 +66,7 @@ +@@ -50,7 +67,7 @@ iblockdata = world.getType(blockposition); BlockPosition blockposition1 = iblockdata.getBlock() instanceof IFluidContainer && this.fluidType == FluidTypes.WATER ? blockposition : movingobjectpositionblock.getBlockPosition().shift(movingobjectpositionblock.getDirection()); @@ -46,7 +47,7 @@ this.a(world, itemstack, blockposition1); if (entityhuman instanceof EntityPlayer) { CriterionTriggers.y.a((EntityPlayer) entityhuman, blockposition1, itemstack); -@@ -74,16 +90,19 @@ +@@ -74,16 +91,19 @@ public void a(World world, ItemStack itemstack, BlockPosition blockposition) {} @@ -70,7 +71,7 @@ } return itemstack; -@@ -91,7 +110,13 @@ +@@ -91,7 +111,13 @@ } } @@ -84,7 +85,7 @@ if (!(this.fluidType instanceof FluidTypeFlowing)) { return false; } else { -@@ -101,8 +126,18 @@ +@@ -101,8 +127,18 @@ boolean flag1 = material.isReplaceable(); if (!world.isEmpty(blockposition) && !flag && !flag1 && (!(iblockdata.getBlock() instanceof IFluidContainer) || !((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, this.fluidType))) {