This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminecraft.h
89 lines (72 loc) · 2.28 KB
/
minecraft.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
minecraft.h
Extension module header file
*/
#ifndef PARAMETERS
#define PARAMETERS
// Buffer sizes
#define SMALL_DEFLATE_MAX 10000;
#define SMALL_INFLATE_MAX 20000;
#define CHUNK_DEFLATE_MAX 1000000;
#define CHUNK_INFLATE_MAX 1000000;
#define MAX_CHUNKS 101
#define MAX_REGIONS 8
#define NEW_REGION_BUFFER_SIZE 2000000
#define REGION_BUFFER_PADDING 10000
#endif
// structs
typedef struct TagType{
char *name;
int id;
bool empty_byte_list;
unsigned char sub_tag_id; // Optional, for List tag
} TagType;
typedef struct {
PyObject_HEAD
unsigned short id;
unsigned char data, blocklight, skylight;
} Block;
typedef struct {
PyObject_HEAD
PyObject *world, *dict;
int x, z;
} Chunk;
typedef struct {
unsigned char *buffer;
int x, z, buffer_size, current_size;
struct Region *next; // Meant to function as a linked list, as part of the World
} Region;
typedef struct {
PyObject_HEAD
PyObject *level; // level.dat dictionary
char *path; // path to the world
Region *regions;
// Chunk holding code, probably will be moved
PyObject **chunks;
} World;
// block.c
PyTypeObject minecraft_BlockType;
int Block_init( Block *self, PyObject *args, PyObject *kwds );
// chunk.c
PyTypeObject minecraft_ChunkType;
int Chunk_init( Chunk *self, PyObject *args, PyObject *kwds );
PyObject *Chunk_get_block( Chunk *self, PyObject *args );
PyObject *Chunk_put_block( Chunk *self, PyObject *args );
// generator.c
PyTypeObject minecraft_GeneratorType;
// nbt.c
long swap_endianness( unsigned char *buffer, int bytes );
void swap_endianness_in_memory( unsigned char *buffer, int bytes );
void dump_buffer( unsigned char *buffer, int count );
int inf( unsigned char *dst, unsigned char *src, int bytes, int mode );
int def( unsigned char *dst, unsigned char *src, int bytes, int mode, int *size );
PyObject *get_tag( unsigned char *tag, char tag_id, int *moved );
int write_tags( unsigned char *dst, PyObject *dict, TagType tags[] );
// region.c
int update_region( Region *region, Chunk *chunk );
int save_region( Region *region, char *path );
int unload_region( Region *region, char *path );
void print_region_info( Region *region );
// world.c
PyTypeObject minecraft_WorldType;
Region *load_region( World *self, int x, int z );