Use result of setItemStack in PlayerBucketEmptyEvent (#2651)#2857
Use result of setItemStack in PlayerBucketEmptyEvent (#2651)#2857Draycia wants to merge 6 commits into
Conversation
|
Seems this inadvertently causes creative player buckets to empty when they wouldn't otherwise without the patch |
|
Tested the latest change, creative players no longer have their buckets mutated on use (as is the case without the patch) and survival player buckets are properly mutated as well. |
|
|
||
| public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(World world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, EnumHand enumHand) { | ||
| - return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, world, who, changed, clicked, clickedFace, itemstack, Items.BUCKET, enumHand); | ||
| + return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, world, who, changed, clicked, clickedFace, itemstack, itemstack.getItem(), enumHand); // Paper - don't forcefully set to bucket |
There was a problem hiding this comment.
fixes the creative case but breaks survival - only use the item in hand Item if the player is creative, else Bucket will do
There was a problem hiding this comment.
should be fixed in latest commit
|
|
| ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541 | ||
| return false; | ||
| } | ||
| + entityhuman.setItemInHand(enumhand, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack())); // Paper - 2651: set item in hand if event isn't cancelled |
There was a problem hiding this comment.
this needs to be passed to the caller so it can set the item result in the interact wrapper - the wrapper is the proper way to handle changes to the item
|
I'm too retarded to continue atm, and I'm busy with other things. Maybe in the future if @Spottedleaf doesn't snag it |
Resolves the weird behaviour where modifications to itemStack in PlayerBucketEmptyEvent (through setItemStack in PlayerBucketEvent) are ignored.
Tested with #2651's code snippet and it seems to be functional with this change, things seem fine with the plugin omitted as well.