-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
[ECS] Inventory interactions #189
Conversation
… are built and sent
… `update_player_inventories`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. It's exciting to see this coming together.
Some issues:
-
Opening an inventory for the first time, the client is sent the
SetContainerSlot
packet for every occupied slot in addition to the initialSetContainerContent
packet. This happens because the modified bits are only cleared when the inventory is open. This can be fixed by clearing the modified bits of all inventories unconditionally in a separate system that runs afterupdate_open_inventories
However, this wouldn't fix the problem if the inventory happens to be modified on the same tick it's opened. I could see this being a problem with code that wants to create and open an inventory at the same time. Solution: Don't run
update_open_inventories
on clients with newly addedOpenInventory
components by usingChangeTrackers
? Or maybe combineupdate_client_on_open_inventory
andupdate_open_inventories
into one system?"Don't initialize and update on the same tick" seems to be a recurring pattern I'm noticing.
-
SetContainerSlot
packets are sent for slots that the client itself modified, even though this is not necessary. I think this can be fixed by storing slot modifications inClient
and filteringSetContainerSlot
writes based on this information. -
When validation is implemented, should we validate the
ClickContainer
event before it's sent so users don't need to worry about illegal events?
I don't think so, it might be useful to be able to read all of the events regardless of validity. Instead, maybe we could validate and then emit other events based on that? We are going to need to emit drop item events anyway. |
…kets based on if the state update is actually needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In creative, move an item from the creative menu into your hotbar. Then switch to survival and try to click on it. You'll be sent a
SetContainerContent
packet. - Open an inventory and move an item from your inventory into the open inventory. Without closing the window, move the item back to your inventory in a different spot than where it was originally. Once the window is closed, you will be sent a
SetContainerSlot
packet.
effectively reverts 5cbc917
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still getting Client state id mismatch, resyncing
while switching between creative and survival. At one point, every interaction with the inventory in survival mode caused a Client state id mismatch, resyncing
to be printed.
I'm not able to reproduce the state id mismatch you're talking about. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The player inventory is missing a slot for index 45 (the offhand). Need to increase the size from 45 to 46.
- Shift-clicking the "Destroy Item" box in creative doesn't function correctly. The client is sending
SetCreativeModeSlot
packets to remove the items, but it's not actually clearing the items locally. After some testing with vanilla, it appears that we need to send all slot changes back to the client but only while the client is in creative mode. Mojang why?? - Regarding "At one point, every interaction with the inventory in survival mode caused a
Client state id mismatch, resyncing
to be printed.", basically what happened is that theevent.state_id
was always0
whileclient.inventory_state_id
kept going up. I haven't reproduced the issue since fixing thea ^ b
thing, so it might've been a consequence of that.
27068bf
to
5e150c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am starting to lose my sanity.
We really need to be able to do automated e2e tests on this, because this is ridiculous. |
ff3e307
to
8bb95dd
Compare
Still seeing some issues but yeah let's not drag this out forever. |
Motivation: There are a lot of edge cases we have to handle, and every new line of code we write increases the risk of regressions. Regressions slow down dev time: a perfect example of this is what happened in #189. Unsolved issues: - [x] `test_client_position` is flakey ### Test plan ``` cargo test -p valence_new ``` --------- Co-authored-by: Ryan <[email protected]>
Client
componentupdate_player_inventories
Test plan
inventory_test
example