mirror of
https://github.com/p2r3/bareiron.git
synced 2025-10-02 07:35:08 +02:00
send biome data to clients
This commit is contained in:
@@ -28,6 +28,6 @@ uint8_t getTerrainAt (int x, int y, int z, ChunkAnchor anchor);
|
|||||||
uint8_t getBlockAt (int x, int y, int z);
|
uint8_t getBlockAt (int x, int y, int z);
|
||||||
|
|
||||||
extern uint8_t chunk_section[4096];
|
extern uint8_t chunk_section[4096];
|
||||||
void buildChunkSection (int x, int y, int z);
|
uint8_t buildChunkSection (int cx, int cy, int cz);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -320,11 +320,11 @@ int sc_chunkDataAndUpdateLight (int client_fd, int _x, int _z) {
|
|||||||
// block palette as varint buffer
|
// block palette as varint buffer
|
||||||
send_all(client_fd, network_block_palette, sizeof(network_block_palette));
|
send_all(client_fd, network_block_palette, sizeof(network_block_palette));
|
||||||
// chunk section buffer
|
// chunk section buffer
|
||||||
buildChunkSection(x, y, z);
|
uint8_t biome = buildChunkSection(x, y, z);
|
||||||
send_all(client_fd, chunk_section, 4096);
|
send_all(client_fd, chunk_section, 4096);
|
||||||
// biome data
|
// biome data
|
||||||
writeByte(client_fd, 0); // bits per entry
|
writeByte(client_fd, 0); // bits per entry
|
||||||
writeByte(client_fd, W_plains); // biome palette
|
writeByte(client_fd, biome); // biome palette
|
||||||
// yield to idle task
|
// yield to idle task
|
||||||
task_yield();
|
task_yield();
|
||||||
}
|
}
|
||||||
|
@@ -326,7 +326,9 @@ uint8_t getBlockAt (int x, int y, int z) {
|
|||||||
uint8_t chunk_section[4096];
|
uint8_t chunk_section[4096];
|
||||||
ChunkAnchor chunk_anchors[256 / (CHUNK_SIZE * CHUNK_SIZE)];
|
ChunkAnchor chunk_anchors[256 / (CHUNK_SIZE * CHUNK_SIZE)];
|
||||||
|
|
||||||
void buildChunkSection (int cx, int cy, int cz) {
|
// Builds a 16x16x16 chunk of blocks and writes it to `chunk_section`
|
||||||
|
// Returns the biome at the origin corner of the chunk
|
||||||
|
uint8_t buildChunkSection (int cx, int cy, int cz) {
|
||||||
|
|
||||||
// Precompute the hashes and anchors for each minichunk
|
// Precompute the hashes and anchors for each minichunk
|
||||||
int anchor_index = 0;
|
int anchor_index = 0;
|
||||||
@@ -383,4 +385,6 @@ void buildChunkSection (int cx, int cy, int cz) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return chunk_anchors[0].biome;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user