-
Notifications
You must be signed in to change notification settings - Fork 8
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
Fix container management #154
Fix container management #154
Conversation
ArtificialDriver
commented
Jun 26, 2023
- Adds specs for withdraw / deposit
- Completes the implementation of the shift click method to correctly send the changed slots
- Fixes the data types of the click_window packet
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.
On a high level note, getting rid of force_reset_hack
may pass the simple tests, but in the long run means that you'll have to implement each and every combination of click type and inventory state, including partial slots, NBT comparison, and "special" slots that can only receive certain item types (eg, furnace). Otherwise client-server inventory desync will be inevitable.
@@ -132,7 +132,6 @@ class Rosegold::Window | |||
|
|||
def click(slot_nr, right = false, shift = false, double = false) | |||
send_click ClickWindow.click self, slot_nr, right, shift, double | |||
force_reset_hack # TODO update slots | |||
end |
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 client must update the slots to the new states after the click.
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.
Can you explain to me how this hack exactly works? (I didn't observe it to be working so I removed it during test; probably shouldn't have committed this)
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 think a probably better solution is to implement the few basic things bots need to do (pretty much exclusively "quick swap" (shift click) and implement the slot management directly
Once we get to crafting we'll need a more robust API but for now I think something similar to this is fine
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.
Shift clicking is one of the more complex click modes to implement (see other comment); if you want something simple but useful you can start with "swap with hotbar".
The way the hack works is it sends an invalid variant of the click you want to execute, the server executes it as expected but notices that the client state is desynchronized and sends the entire inventory state again. As a result, the client only has to wait for the updated inventory state but doesn't need to implement the complex click logic itself.
# Find first empty slot in target container | ||
target_slot = find_empty_slot target |
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.
Shift clicking is also possible when there are no empty slots, but some matching target
slots are not entirely full. This also requires comparing NBT data.
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 agree; think this can be done as a separate issue though (I'll add a comment)
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.
Just don't close the other window if the server opens a new one
6e3d2e6
to
3095f73
Compare
This reverts commit e2bcc50.
Wait, shoot I wanted to turn on automerge |
Whelp, I fixed the main issues with this at least... |