Support for result ItemStack in CraftItemEvent#8443
Conversation
Ohhh i forget this... |
2988cfc to
5c0dd5c
Compare
|
Okay i make a few changes...
a little example added. |
| + int itemResultCount = baseResult.getAmount(); | ||
| + if (packet.getClickType() == net.minecraft.world.inventory.ClickType.QUICK_MOVE && action == InventoryAction.MOVE_TO_OTHER_INVENTORY) { | ||
| + for (itemstack = this.player.containerMenu.quickMoveStack(this.player, packet.getSlotNum()); !itemstack.isEmpty() && ItemStack.isSame(this.player.containerMenu.slots.get(packet.getSlotNum()).getItem(), itemstack); itemstack = this.player.containerMenu.quickMoveStack(player, packet.getSlotNum())) { | ||
| + if (this.player.containerMenu.slots.get(packet.getSlotNum()).mayPickup(this.player) && (this.player.getInventory().getSlotWithRemainingSpace(this.player.containerMenu.slots.get(packet.getSlotNum()).getItem()) != -1 || this.player.getInventory().getFreeSlot() != -1)) { |
There was a problem hiding this comment.
This is not needed the quick move stack already check that see the boolean result of #moveItemStackTo
There was a problem hiding this comment.
i use quickmove based in how NMS handle this calling the same method.
There was a problem hiding this comment.
Oh nvm i have missed this nms logic my bad
5c0dd5c to
19b7277
Compare
Machine-Maker
left a comment
There was a problem hiding this comment.
I don't really like shoving all that logic into the packet listener class. Also, this issue applies to all the "crafts" in the game. I feel like we need a new system of events listening to "recipe results" for all the recipe types that takes into account shift clicks and everything instead of relying on the inventory click event.
But then is not correct add tbe correct result in CraftItemEvent? About the code in packet maybe move this to the CraftEvent or dont remember the class with many methods to call event? |
|
The So this is the wrong event to use to get this. A different event(s) should be added to handle "recipe use" in a general sense easily applies to all recipe types, not just 1. This should be done without mangling the vanilla logic for handling shift clicks. |
Then you mean...
|
|
The event should probably function like shift clicking multiple stacks. Instead of trying to aggregate all the stacks crafted, just call the event once per craft. So maybe it'll be called 64 times, but that similar behavior already exists with the inventory click event. |
|
This is smth along the lines of what I had in mind. https://github.com/Machine-Maker/Paper/tree/feature/RecipeCraftEvent. Not 100% satisfied, its just a mockup pretty much. And it only handles quickmoves atm, not other types of clicks |
|
What's the status on this? |
Not working in 2×2 crafting (InventoryMenu) |
|
Hi, any update on this? I'm currently running roughly the same logic as in this PR in my code to compute the number of crafted items, but having to implement it myself can lead to errors (I already had to fix my code twice...), and I would love to see it implemented officially by Paper instead! Thx |
This PR close #8439 and #7383 adding a few changes for possible list result item from craft event, this based in the quick move generated when a player use Shift+Click for get all the possible items crafted.
A little example with.