Skip to content
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

MOTION_BLOCKING heightmap #523

Merged
merged 13 commits into from
Sep 17, 2023
Merged

Conversation

tim-kt
Copy link
Contributor

@tim-kt tim-kt commented Sep 5, 2023

Objective

Aims to implement #104. This is a draft, I don't necessarily need a review yet.

Solution

The server needs to generate a heightmap when chunks are generated, update them when blocks are changed, and send it in the ChunkDataS2c packet.

I think the implementation should be done in the following order:

  • Encode (constant) heightmap and send it in the ChunkDataS2c packet
  • Build heightmap in write_init_packets
  • Find out which blocks are "motion-blocking"
  • Implement a blocks_motion function
  • Change weather.rs to test the functionalityWORLD_SURFACE
  • Find out why one needs to add 2 to the heightmap

Add `encode_heightmap` function to encode the heightmap into the necessary
format
@dyc3 dyc3 marked this pull request as draft September 5, 2023 21:04
@dyc3
Copy link
Collaborator

dyc3 commented Sep 5, 2023

I think it would be good to update the weather example to show this functionality.

Copy link
Member

@rj00a rj00a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I think we should handle this is by keeping the heightmaps completely contained in the write_init_packets function. We can rebuild the heightmaps there from scratch whenever the ChunkDataS2c packet cache needs to be created. This would avoid all the complexity involved in updating the heightmap whenever a block is modified.

We should also figure out which blocks exactly are considered "motion blocking" by the game and extract that information. And also figure out what WORLD_SURFACE is used for.

@tim-kt
Copy link
Contributor Author

tim-kt commented Sep 6, 2023

It seems like "motion-blocking" blocks are more or less solid and liquid blocks, waterlogged blocks included. One way to check this would be to examine the packets of the vanilla server in minecraft:debug and from this, generate a mapping from block state to motion-blocking or not. Has something like this been done before for Valence?

Helper functions: `world_surface` and `motion_blocking` (currently
producing the same heightmap)
Add stairway and sign to `weather.rs` example
@rj00a
Copy link
Member

rj00a commented Sep 7, 2023

You'll want to take a look at the extractor/ folder. That contains the fabric mod we are using to get information from the game.

So it seems like the main thing we're missing is an is_solid method for BlockState.

@tim-kt tim-kt marked this pull request as ready for review September 15, 2023 20:01
crates/valence_entity/extracted/entities.json Outdated Show resolved Hide resolved
crates/valence_server/src/layer/chunk/loaded.rs Outdated Show resolved Hide resolved
crates/valence_server/src/layer/chunk/loaded.rs Outdated Show resolved Hide resolved
crates/valence_server/src/layer/chunk/loaded.rs Outdated Show resolved Hide resolved
crates/valence_server/src/layer/chunk/loaded.rs Outdated Show resolved Hide resolved
Co-authored-by: Ryan Johnson <[email protected]>
@rj00a rj00a enabled auto-merge (squash) September 17, 2023 14:45
@rj00a rj00a merged commit e38ab81 into valence-rs:main Sep 17, 2023
10 checks passed
@tim-kt tim-kt mentioned this pull request Sep 17, 2023
1 task
@tim-kt tim-kt deleted the motion_blocking_heightmap branch September 17, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants