#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "nbt.h"
Go to the source code of this file.
|
regionfile * | open_regionfile (char *filename) |
|
void | free_region (regionfile *region) |
|
size_t | count_chunks (regionfile *region) |
|
void | for_each_chunk_raw (regionfile *region, raw_chunk_func function, void *context) |
|
void | for_each_chunk (regionfile *region, chunk_func function, void *context) |
|
int | region_contains_chunk (regionfile *region, int32_t cx, int32_t cz) |
|
uint8_t | region_chunk_sector_count (regionfile *region, int32_t cx, int32_t cz) |
|
nbt_node * | get_raw_chunk (regionfile *region, int32_t cx, int32_t cz) |
|
chunk * | nbt_to_chunk (nbt_node *node, uint16_t flags) |
|
size_t | determine_region_file (char *buf, size_t len, int32_t cx, int32_t cz) |
|
int | write_chunk (regionfile *region, int32_t cx, int32_t cz, chunk *c) |
|
void | initblockdb () |
|
char * | get_block_name (uint8_t block_id, uint8_t data) |
|
void | initbiomedb () |
|
char * | get_biome_name (uint8_t biome_id) |
|
chunk * | get_chunk (regionfile *region, int32_t cx, int32_t cz, uint16_t flags) |
|
void | free_chunk (chunk *c) |
|
level * | open_level (char *filename) |
|
int | write_level (level *lvl, char *into) |
|
void | free_level (level *lvl) |
|
#define chunk_from_coord |
( |
|
i | ) |
(i/16) |
Calculate in which chunk this coordinate is
Definition at line 132 of file mcchunk.h.
#define SECTOR_BYTES 4096 |
typedef void(* chunk_func)(chunk *c, void *context) |
typedef void(* raw_chunk_func)(nbt_node *node, void *context) |
Enumerator |
---|
GET_TILE_ENTITIES |
|
GET_ENTITIES |
|
Definition at line 63 of file mcchunk.h.
Count the amount of chunks available in this region structure
size_t determine_region_file |
( |
char * |
buf, |
|
|
size_t |
len, |
|
|
int32_t |
cx, |
|
|
int32_t |
cz |
|
) |
| |
Loop through all the available chunks in our regionfile don't do some odd for loop yourself calling get_chunk as this function is simply more efficient, it keeps the file open for example. (And it's just easier..) Don't keep the chunk around, as it is freed automatically
Similar to for_each_chunk but gives you access to the raw nbt_node* instead.
void free_chunk |
( |
chunk * |
c | ) |
|
Free function for the chunk structure
void free_level |
( |
level * |
lvl | ) |
|
Free function for the level structure
Used to free the region structure
char* get_biome_name |
( |
uint8_t |
biome_id | ) |
|
Get the human readable name for biome_id if this biome_id simply doesn't exist it'll return NULL (-1 isn't even handled)
- See Also
- initbiomedb
char* get_block_name |
( |
uint8_t |
block_id, |
|
|
uint8_t |
data |
|
) |
| |
Get the human readable name for block_id with data if the block simply doesn't exist it'll return NULL
- See Also
- initblockdb
chunk* get_chunk |
( |
regionfile * |
region, |
|
|
int32_t |
cx, |
|
|
int32_t |
cz, |
|
|
uint16_t |
flags |
|
) |
| |
Get a chunk structure for the chunk located at cx, cz in region. Blocks in this structure are accessed using the blocks and data arrays, it would look like the following: c->blocks[y][z][x];
Initialize the biome name database you must call this before using
- See Also
- get_biome_name
Initialize the block names database you must call this once before using
- See Also
- get_block_name
Convert a raw nbt_node* to a chunk structure instead will return NULL upon failure.
level* open_level |
( |
char * |
filename | ) |
|
Used to open a region file simply pass the filename into it
uint8_t region_chunk_sector_count |
( |
regionfile * |
region, |
|
|
int32_t |
cx, |
|
|
int32_t |
cz |
|
) |
| |
Return the amount of internal sectors this chunk consists of, will return 0 on error.
int region_contains_chunk |
( |
regionfile * |
region, |
|
|
int32_t |
cx, |
|
|
int32_t |
cz |
|
) |
| |
Check if this region structure contains the chunk located at x: cx y: cy returns 1 if it is in the region structure, 0 otherwise ingame you can get the chunk coordinates from the debug screen (F3). It'll look something like this: x: -20.64464 (-21) // c: -2 (11) y: 120.500 (feet pos, 122.120 eyes pos) z: 36.39552 (36) // c: 2 (4)
The x, y & z coordinates here are your players location the number just behind "c:" is the chunk number. So in this case it would be x: -2, z: 2.
Writes the chunk to the regionfile at position cx, cz
int write_level |
( |
level * |
lvl, |
|
|
char * |
into |
|
) |
| |
Write our level structure into a file
- Parameters
-
into | the filepath to write into, must exist. If NULL it'll be written into the original path. |