Add nearby players collision check when trying to place blocks #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Added a function in world/mod.rs that checks nearby players by a given point and a radius.
Using this function I switched the function that gets the nearby players to the new one and chose a radius of 20.
So every time a player tries to place a block it searches up players in the radius of 20 blocks and checks the collision with them.
If no collision was found it places the block. With that change I also fixed the bug that players could place blocks at their head height and start to swim.
Testing
Tried to place blocks beside or in myself and my 2. account. Both tries worked as expected. Feels like original vanilla minecraft.
I also tried to change the game modes and place from different angles.
Checklist
(Not needed) More testing with more than 2 players. [ ]
Code is well-formatted and adheres to project style guidelines:
cargo fmt
Code does not produce any clippy warnings
cargo clippy