Commits
Noah van der Aa authored and md_5 committed 3cad0316e04
16 16 | + |
17 17 | public class ItemBucket extends Item implements DispensibleContainerItem { |
18 18 | |
19 19 | public final FluidType content; |
20 20 | |
21 21 | iblockdata = world.getType(blockposition); |
22 22 | if (iblockdata.getBlock() instanceof IFluidSource) { |
23 23 | IFluidSource ifluidsource = (IFluidSource) iblockdata.getBlock(); |
24 24 | + // CraftBukkit start |
25 25 | + ItemStack dummyFluid = ifluidsource.removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); |
26 + | + if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled. |
26 27 | + PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem()); |
27 28 | + |
28 29 | + if (event.isCancelled()) { |
29 30 | + ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager) |
30 31 | + ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 |
31 32 | + return InteractionResultWrapper.fail(itemstack); |
32 33 | + } |
33 34 | + // CraftBukkit end |
34 35 | ItemStack itemstack1 = ifluidsource.removeFluid(world, blockposition, iblockdata); |
35 36 | |