Skip to content

[1.21] InvWrapper.extractItem doesn't take Container.canTakeItem into account #2081

Open
@GizmoTheMoonPig

Description

@GizmoTheMoonPig

Minecraft Version: 1.21.1

NeoForge Version: 21.1.141

Logs: N/A

Steps to Reproduce:

  1. Create a block entity that implements Container
  2. Override canTakeItem and set up some sort of logic in it (or just make it return false)
  3. Launch game, put items in the block and throw a hopper under it
  4. Observe as items are still removed from the block

Description of issue:
I assume this method is decently new, as only chiseled bookshelves and jukeboxes use it, but Container.canTakeItem is not checked before doing any item extraction in InvWrapper.extractItem. Both uses in vanilla code are fairly useless as it just checks that the target container has an available slot so I can see how this may have been missed. In my case, however, I don't want items to be extracted if a certain boolean property on the blockstate is set to true. I'm aware I could get around this by writing my own item hander instead of just using InvWrapper, but I would honestly just rather use what's already provided :P

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNeeds triaging and confirmation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions