-
-
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
Add nearby players collision check when trying to place blocks #293
Add nearby players collision check when trying to place blocks #293
Conversation
b9ee79b
to
afae3d0
Compare
pumpkin/src/client/player_packet.rs
Outdated
|
||
//Search in 20 block radius | ||
let mut intersects = false; | ||
for player in world.get_nearby_players(entity.pos.load(), 20).await { |
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.
Would't i make more sense to search in the players block range distance ?
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 would not say no, because the block should not intercept with other boundingboxes. I mean the position of the player is unimportant for the collision check. As you can see the radius is 20 blocks so the "placer" or player that places the block will automatically be in that range so players cannot place in themselfs. I hope I was able to make clear why used the block as the middle of the searching circle. But if you still want that to be changed I can do that.
and fix clippy
Overall looks good. |
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