Skip to content

Improve how the inventory is synchronized with the server #643

@IntegratedQuantum

Description

@IntegratedQuantum

The current approach, where the client just does whatever it wants and sends the full inventory info to the server doesn't work when there are conflicts with other players, such as when collecting item drops or using a chest.

So I think the client should send all attempted inventory moves to the server, and the server then ensures that the correct items get moved.
Of course this would also need client-side prediction.
Without this items from chests could be duplicated or destroyed when two players try to access the same slot at the same time.

Current plan:

  • Refactor all inventory operations through one common interface
  • Implement undo operations
  • Add operations for opening and closing inventories
  • Make sure resources are cleaned without any leaks and use-after frees, specifically dropping of tools
  • Add an id to each inventory so it can be communicated to the server
  • Send the data to the server
  • Send confirmation to the client
  • Send inventory operations to other clients that have this inventory open (note: not all inventories are visible to every client)
  • React to server-side events (like e.g. collecting into a slot) by undoing the stack and redoing every command
  • Remove drop item stack from the genericUpdate protocol now that drop events are sent through inventory operations
  • fix inventory crafting (either by sending the player inventory with it, or by using all normal inventories currently opened by the player) Cant craft #752
  • Add data for the source of the inventory when opening (is it a player inventory? is it a block inventory?)
  • figure out block placement/breaking operations Moved to Improve how block placing/breaking is synchronized with the server #751.

Metadata

Metadata

Labels

engineenhancementa new feature or improvementexperimentala feature or idea that will require lots of experimentation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions