SPIGOT-6714: Don't fire PlayerBucketEvent when empty

By: Noah van der Aa <ndvdaa@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2021-08-18 17:06:40 +10:00
parent 3a23c54a91
commit 03aecfb428

View File

@ -23,6 +23,7 @@
IFluidSource ifluidsource = (IFluidSource) iblockdata.getBlock();
+ // CraftBukkit start
+ ItemStack dummyFluid = ifluidsource.removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
+ if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled.
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem());
+
+ if (event.isCancelled()) {