Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inventory#all doesn't scan the entire inventory #10695

Open
NonSwag opened this issue May 11, 2024 · 2 comments
Open

Inventory#all doesn't scan the entire inventory #10695

NonSwag opened this issue May 11, 2024 · 2 comments
Labels
resolution: awaiting response Additional information is required from the issue reporter type: bug Something doesn't work as it was intended to. version: 1.20.6 Game version 1.20.6

Comments

@NonSwag
Copy link
Contributor

NonSwag commented May 11, 2024

Expected behavior

Suggested by the docs of the method, it should look up all slots in the entire inventory

Observed/Actual behavior

It only looks up the storage content

Steps/models to reproduce

Well... it's just an inconsistency... soo...

Plugin and Datapack List

unimportent

Paper version

1.20.6-R0.1-SNAPSHOT

Other

docs:
image
implementation:
image

@NonSwag NonSwag added status: needs triage type: bug Something doesn't work as it was intended to. labels May 11, 2024
@kashike kashike added the version: 1.20.6 Game version 1.20.6 label May 11, 2024
@Machine-Maker
Copy link
Member

I think this is "works as intended" due to the documentation on Inventory#getStorageContents. The javadocs for that method say

In most cases this will represent the entire inventory, but in some cases it may exclude armor or result slots.

and continues

It is these contents which will be used for add / contains / remove methods which look for a specific stack

I think that second part includes the #all method you mention here, as its looking for a specific stack. And it's right, all the other methods only operate on the "storage contents".

@Machine-Maker
Copy link
Member

It looks like previously, Paper has added specific API to cover "all slots". There is a Inventory#removeItemAnySlot method to account for the other Inventory#removeItem only removing from the "storage" contents. I think that is the better solution here, adding an "any slot" variant of all the methods that have "storage-specific" versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: awaiting response Additional information is required from the issue reporter type: bug Something doesn't work as it was intended to. version: 1.20.6 Game version 1.20.6
Projects
Status: ⌛ Awaiting Response
Development

No branches or pull requests

3 participants