Skip to content

Implement a new inventory API - #221

Merged
caelunshun merged 6 commits into
developfrom
inventory-refactor
May 18, 2020
Merged

caelunshun merged 6 commits into
developfrom
inventory-refactor

Conversation

@caelunshun

Copy link
Copy Markdown
Member

The old inventory design had a key problem: It could not correctly handle slot indexing in different contexts. As per this page, indices in the protocol take different forms depending on the current window. The old API used raw indices based on those used for the main inventory context, but this cannot be extended to work with other windows, such as crafting tables, chests, etc.

The new design hopes to solve the above.

Resolves #79.

@caelunshun caelunshun added this to the 0.7 milestone May 12, 2020
@Defman

Defman commented May 12, 2020 •

Copy link
Copy Markdown
Member

How are we going to handle serialization? I suspect that we want to serialize directly to NBT format? But are inventory serialization handle separately for tile entities compared to players?

@Defman

Defman commented May 12, 2020

Copy link
Copy Markdown
Member

Also, which kinds of operations do we expect users to have a need for?
The ability to subtract and add a number of items based on attributes? Ie, type, tags, durability, and etc?

Would these operations be carried out on the entire inventory or a subset, ie hotbar and armor?

@caelunshun
caelunshun marked this pull request as ready for review May 18, 2020 17:53
@caelunshun

Copy link
Copy Markdown
Member Author

@Defman for querying, here's some use cases I can think of:

  • Querying for an empty slot, or a slot with a certain item, with configurable order. For example, the collect_item function currently does this.
  • Querying for some quantity of an item of a set of types—the arrow shooting system currently does this to remove shot arrows from the inventory.

@caelunshun
caelunshun merged commit 615ded0 into develop May 18, 2020
@caelunshun
caelunshun deleted the inventory-refactor branch May 18, 2020 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correctly handle inventory indexing

3 participants