-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Correct Interactive Block Behavior #388
Correct Interactive Block Behavior #388
Conversation
} | ||
} | ||
drop(open_containers); |
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.
not sure what's the need for manually managing memory as if it was C
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.
not sure what's the need for manually managing memory as if it was C
I think it's not necassary here but it's more like freeing the guard then managing the memory.
For example if you call an sub function that trys to lock the variable too you create an deadlock.
Which results in freezing
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 this is a draft and in progress :D I think I was trying to fix a different issue that I thought was from a deadlock. I will probably refactor this code
When opening a Chest, the server freezes and i get a timeout |
Fixed, tried to optimize code like this was C. |
Okay works now, But i found a bug. If you shift click a item from a chest into your inventory and reopen the chest the item will be in the chest again |
I checked comparing with master and it seems shift clicking is just not supported yet. Shift clicking into containers does the same thing. I believe that should be a separate PR since it would be modifying other interaction container code. |
Waiting for @Bryntet review, but for some reason crafting does not work anymore :c |
@Snowiiii IIRC crafting is currently broken on master too? or am I misremembering |
yep, its broken on master |
Merged! Thanks for your hard work on this, @OfficialKris ❤️ |
Description
Fixes #275 and many other interactive block issues:
player
removes a blockstandard
set of container functions to reduce code duplication for interactive blocksThis PR requires #384
Testing
Two clients
Internally, this change maintains the OpenContainer HashMap and a new AtomicU32 which tracks the current index for the generation of uuids. On large persistent servers, unique containers could be optimized to reduce memory usage. Every user who opens a unique container will generate and cache a new data structure (think 10,000 users opening a crafting table, enderchest, etc). Future work could include separating unique containers (crafting table) and persistent unique containers (ender chest) into separate data structures (ex. stacks instead of maps).
Also, another optimization could be made to client interactive block interactions. Currently, this requires that the server iterate through the entirety of the OpenContainer HashMap. It may be better to create a sort of registry which maps block position to OpenContainerID in the long term (again large server optimizations). Otherwise, the algorithm is randomized brute force with a time complexity of O(n + m).
Checklist
Things need to be done before this Pull Request can be merged.
cargo fmt
cargo clippy
cargo test