123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- #ifndef _CONTENT_H_
- #define _CONTENT_H_
- #include "common.h"
- #include "array.h"
- #include <stdint.h>
- #define CONTENT_MAX 0x0FFF
- #define CONTENT_ARRAY_SIZE 0x1000
- #define CONTENT_TYPE_MASK 0xF000
- #define CONTENT_TYPE_BLOCK 0x0000
- #define CONTENT_TYPE_CLOTHES 0x1000
- #define CONTENT_TYPE_MOB 0x2000
- #define CONTENT_TYPE_TOOL 0x4000
- #define CONTENT_TYPE_CRAFTITEM 0x8000
- #define CONTENT_INDEX_BLOCK 0x00
- #define CONTENT_INDEX_CLOTHES 0x01
- #define CONTENT_INDEX_MOB 0x02
- #define CONTENT_INDEX_TOOL 0x04
- #define CONTENT_INDEX_CRAFTITEM 0x08
- #define CONTENT_TYPE(x) (x&CONTENT_TYPE_MASK)
- #define CONTENT_IGNORE 0x007F
- #define CPT_NONE 0x00
- #define CPT_LIGHT 0x01
- #define CPT_MINERAL 0x02
- #define CPT_FACEDIR_SIMPLE 0x03
- #define CPT_FACEDIR_WALLMOUNT 0x04
- #define CPT_FACEDIR_MANUAL 0x05
- #define CPT_LIQUID 0x06
- #define CPT_PLANTGROWTH 0x07
- #define CPT_ENCHANTMENT 0x08
- #define CPT_DROP 0x09
- #define CPT_BLOCKDATA 0x0A
- #define CPT_SPECIAL 0x0B
- #define CMT_AIR 0x00
- #define CMT_WOOD 0x01
- #define CMT_TREE 0x02
- #define CMT_STONE 0x03
- #define CMT_LIQUID_SOURCE 0x04
- #define CMT_LIQUID 0x05
- #define CMT_PLANT 0x06
- #define CMT_DIRT 0x07
- #define CMT_GLASS 0x08
- #define CMT_FLESH 0x09
- #define CMT_BONE 0x0A
- #define CMT_COTTON 0x0B
- #define CMT_CANVAS 0x0C
- #define CMT_FUR 0x0D
- #define CMT_LEATHER 0x0E
- #define CMT_ARMOUR 0x0F
- #define CCT_NONE 0x00
- #define CCT_PANTS 0x01
- #define CCT_SHIRT 0x02
- #define CCT_HAT 0x03
- #define CCT_BOOTS 0x04
- #define CCT_JACKET 0x05
- #define CCT_BELT 0x06
- #define CCT_DECORATIVE 0x07
- #define CCT_MEDALLION 0x08
- #define CTT_NONE 0x00
- #define CTT_SPECIAL 0x01
- #define CTT_AXE 0x02
- #define CTT_PICK 0x03
- #define CTT_SHOVEL 0x04
- #define CTT_SHEAR 0x05
- #define CTT_BUCKET 0x06
- #define CTT_SWORD 0x07
- #define CTT_SPEAR 0x08
- #define CTT_CLUB 0x09
- #define CTT_HAMMER 0x0A
- #define CTT_SAW 0x0B
- #define CMF_NONE 0x00
- #define CMF_ROTATE 0x01
- #define CMF_TILED 0X02
- #define CCD_NONE 0x0000
- #define CCD_WALKABLE 0x0001
- #define CCD_SELECTABLE 0x0002
- #define CCD_TOOL_SELECTABLE 0x0004
- #define CCD_CLIMBABLE 0x0008
- #define CCD_REPLACEABLE 0x0010
- #define CCD_CRUSHABLE 0x0020
- #define CCD_DROPABLE 0x0040
- #define CCD_SOLID 0x0080
- #define CCD_CRUSHED 0x0100
- #define CCD_MOBSAFE 0x0200
- #define CCD_UNJUMPABLE 0x0400
- #define CDT_AIRLIKE 0x00
- #define CDT_CUBELIKE 0x01
- #define CDT_RAILLIKE 0x02
- #define CDT_PLANTLIKE 0x03
- #define CDT_PLANTLIKE_FERN 0x04
- #define CDT_MELONLIKE 0x05
- #define CDT_LIQUID 0x06
- #define CDT_LIQUID_SOURCE 0x07
- #define CDT_NODEBOX 0x08
- #define CDT_GLASSLIKE 0x09
- #define CDT_TORCHLIKE 0x0A
- #define CDT_FENCELIKE 0x0B
- #define CDT_FIRELIKE 0x0C
- #define CDT_WALLLIKE 0x0D
- #define CDT_ROOFLIKE 0x0E
- #define CDT_LEAFLIKE 0x0F
- #define CDT_NODEBOX_META 0x10
- #define CDT_WIRELIKE 0x11
- #define CDT_3DWIRELIKE 0x12
- #define CDT_STAIRLIKE 0x13
- #define CDT_SLABLIKE 0x14
- #define CDT_TRUNKLIKE 0x15
- #define CDT_DIRTLIKE 0x16
- #define CDT_FLAGLIKE 0x17
- #define CLM_BLOCKS 0x00
- #define CLM_BRIGHT 0x01
- #define CLM_CLEAR 0x02
- #define CLM_TRANSLUCENT 0x03
- #define CDE_UNDIGGABLE 0x00
- #define CDE_DIGGABLE 0x01
- #define CDE_IGNORE_BORDERSTONE 0x08
- #define CDE_GIVE_INVENTORY 0x10
- #define CDE_GIVE_INV_AON 0x20
- #define CET_NONE 0x00
- #define CET_CONDUCTIVE 0x01
- #define CET_SOURCE 0x02
- #define CET_SWITCH 0x03
- #define CET_GATE 0x04
- #define CET_SINK 0x05
- #define CT_TOP0 0x00
- #define CT_TOP1 0x01
- #define CT_TOP2 0x02
- #define CT_TOP3 0x03
- #define CT_BOTTOM0 0x10
- #define CT_BOTTOM1 0x11
- #define CT_BOTTOM2 0x12
- #define CT_BOTTOM3 0x13
- #define CT_RIGHT0 0x20
- #define CT_RIGHT1 0x21
- #define CT_RIGHT2 0x22
- #define CT_RIGHT3 0x23
- #define CT_LEFT0 0x30
- #define CT_LEFT1 0x31
- #define CT_LEFT2 0x32
- #define CT_LEFT3 0x33
- #define CT_BACK0 0x40
- #define CT_BACK1 0x41
- #define CT_BACK2 0x42
- #define CT_BACK3 0x43
- #define CT_FRONT0 0x50
- #define CT_FRONT1 0x51
- #define CT_FRONT2 0x52
- #define CT_FRONT3 0x53
- #define CT_SIDES0 0x60
- #define CT_SIDES1 0x61
- #define CT_SIDES2 0x62
- #define CT_SIDES3 0x63
- #define CT_BASE0 0x70
- #define CT_BASE1 0x71
- #define CT_BASE2 0x72
- #define CT_BASE3 0x73
- #define CT_META_TOP0 0x80
- #define CT_META_TOP1 0x81
- #define CT_META_TOP2 0x82
- #define CT_META_TOP3 0x83
- #define CT_META_BOTTOM0 0x90
- #define CT_META_BOTTOM1 0x91
- #define CT_META_BOTTOM2 0x92
- #define CT_META_BOTTOM3 0x93
- #define CT_META_RIGHT0 0xA0
- #define CT_META_RIGHT1 0xA1
- #define CT_META_RIGHT2 0xA2
- #define CT_META_RIGHT3 0xA3
- #define CT_META_LEFT0 0xB0
- #define CT_META_LEFT1 0xB1
- #define CT_META_LEFT2 0xB2
- #define CT_META_LEFT3 0xB3
- #define CT_META_BACK0 0xC0
- #define CT_META_BACK1 0xC1
- #define CT_META_BACK2 0xC2
- #define CT_META_BACK3 0xC3
- #define CT_META_FRONT0 0xD0
- #define CT_META_FRONT1 0xD1
- #define CT_META_FRONT2 0xD2
- #define CT_META_FRONT3 0xD3
- #define CT_META_SIDES0 0xE0
- #define CT_META_SIDES1 0xE1
- #define CT_META_SIDES2 0xE2
- #define CT_META_SIDES3 0xE3
- #define CT_META_BASE0 0xF0
- #define CT_META_BASE1 0xF1
- #define CT_META_BASE2 0xF2
- #define CT_META_BASE3 0xF3
- #define CT_INVENTORY 0x100
- #define CMD_NONE 0x00
- #define CMD_TEXTURE 0x01
- #define CMD_COLOUR 0x02
- #define CMI_NONE 0x00
- #define CMI_BFCULL 0x02
- #define CMI_UPNORMAL 0x04
- #define CMI_ALPHA_BLEND 0x08
- #define CMI_ADDITIVE_BLEND 0x10
- #define CMI_ALPHA_TEST 0x20
- #define CMI_SDF_ALPHA 0x40
- #define CFT_NONE 0x00
- #define CFT_INFO 0x01
- #define CFT_BOOKCONTENT 0x02
- #define CFT_OWNER 0x03
- #define CFT_INVOWNER 0x04
- #ifndef _HAVE_CONTENT_TYPE
- #define _HAVE_CONTENT_TYPE
- typedef uint16_t content_t;
- #endif
- #ifndef _HAVE_NODEBOX_TYPE
- #define _HAVE_NODEBOX_TYPE
- typedef struct nodebox_s {
- aabox_t box;
- v3_t angle;
- v3_t centre;
- } nodebox_t;
- #endif
- #ifndef _HAVE_ITEM_TYPE
- #define _HAVE_ITEM_TYPE
- typedef struct item_s {
- content_t content;
- uint16_t param1;
- uint16_t param2;
- } item_t;
- #endif
- #ifndef _HAVE_FACETEXT_TYPE
- #define _HAVE_FACETEXT_TYPE
- typedef struct facetext_s {
- uint16_t type;
- rectf_t pos;
- } facetext_t;
- #endif
- #ifndef _HAVE_BLOCKFEATURES_TYPE
- #define _HAVE_BLOCKFEATURES_TYPE
- typedef struct blockfeatures_s {
- uint8_t vertex_alpha;
- colour_t post_effect_colour;
-
- pos_t onact_also_affects;
-
- uint8_t home;
- facetext_t facetexts[6];
-
- uint8_t is_ground_content;
-
- uint8_t flammable;
-
- uint8_t air_equivalent;
-
- uint16_t digging_info;
-
- content_t metaid;
- struct {
- content_t wallmount;
- content_t floormount;
- content_t roofmount;
-
- content_t special;
-
- content_t lockstate;
-
- content_t powerstate;
- } alternate;
- struct {
-
- content_t source;
- content_t flowing;
-
- uint8_t viscosity;
- } liquid;
-
- struct {
- content_t block;
-
- content_t alternate;
- } ondrop;
-
- struct {
- uint8_t type;
- uint8_t drop;
- } energy;
- struct {
- content_t replace;
- content_t replace_requires;
-
- item_t special_drop;
- } ondig;
- struct {
- content_t replace;
- uint8_t borderstone;
- } onpunch;
- struct {
- uint16_t max_height;
-
- content_t small_drop;
-
- content_t large_drop;
-
- uint16_t large_count;
-
- uint8_t large_gives_small;
-
- content_t trellis_block;
-
- uint8_t fertilizer_affects;
- } plant;
- } blockfeatures_t;
- #endif
- #ifndef _HAVE_CLOTHESFEATURES_TYPE
- #define _HAVE_CLOTHESFEATURES_TYPE
- typedef struct clothesfeatures_s {
-
- uint8_t type;
-
- float armour;
-
- float warmth;
-
- float vacuum;
-
- float suffocate;
-
- uint8_t durability;
-
- float effect;
- } clothesfeatures_t;
- #endif
- #ifndef _HAVE_MOBFEATURES_TYPE
- #define _HAVE_MOBFEATURES_TYPE
- typedef struct mobfeatures_s {
- int stuff;
- } mobfeatures_t;
- #endif
- #ifndef _HAVE_TOOLFEATURES_TYPE
- #define _HAVE_TOOLFEATURES_TYPE
- typedef struct toolfeatures_s {
-
- uint8_t type;
-
- int16_t drop_count;
-
- uint8_t liquids_pointable;
-
- uint8_t damaging_nodes_diggable;
-
- uint8_t has_punch_effect;
-
- uint8_t has_unlock_effect;
-
- uint8_t has_rotate_effect;
-
- uint8_t has_fire_effect;
-
- float dig_time;
-
- uint8_t level;
-
- content_t thrown_item;
- } toolfeatures_t;
- #endif
- #ifndef _HAVE_CRAFTITEMFEATURES_TYPE
- #define _HAVE_CRAFTITEMFEATURES_TYPE
- typedef struct craftitemfeatures_s {
-
- uint8_t stackable;
-
- uint8_t consumable;
-
- int16_t hunger_effect;
-
- int16_t health_effect;
-
- int16_t cold_effect;
-
- int16_t energy_effect;
-
- int16_t drop_count;
-
- int8_t teleports;
-
- content_t drop_item;
-
- content_t thrown_item;
-
- content_t shot_item;
- } craftitemfeatures_t;
- #endif
- #ifndef _HAVE_CONTENTFEATURES_TYPE
- #define _HAVE_CONTENTFEATURES_TYPE
- typedef struct contentfeatures_s {
- content_t content;
- uint8_t param1_type;
- uint8_t param2_type;
-
- uint8_t material_type;
- float hardness;
- char* description;
-
- uint8_t draw_type;
- array_t materials;
- uint16_t materials_info;
- char* overlay;
-
- array_t collision_boxes;
- uint16_t collision_info;
-
- uint8_t light_data;
- uint8_t light_source;
-
- item_t dug_item;
- item_t extra_dug_item;
- int extra_dug_item_rarity;
- uint8_t extra_dug_item_min_level;
- uint8_t extra_dug_item_max_level;
- item_t cook_result;
- float fuel_time;
-
- item_t onuse_replace;
-
- content_t enchanted_item;
-
- struct {
- char* access;
- char* step;
- char* dig;
- char* place;
- char* punch;
- char* ambient;
- char* use;
- } sound;
-
- struct {
- uint8_t hard;
- uint8_t suffocation;
- uint8_t temperature;
- uint8_t pressure;
- } damage;
-
- union {
- blockfeatures_t block;
- clothesfeatures_t clothes;
- mobfeatures_t mob;
- toolfeatures_t tool;
- craftitemfeatures_t craftitem;
- } data;
- } contentfeatures_t;
- #endif
- #ifdef _CONTENT_LOCAL
- extern contentfeatures_t *contentfeatures[16];
- void content_defaults(contentfeatures_t *f);
- #endif
- contentfeatures_t *content_features(content_t id);
- item_t *content_item(item_t *i, content_t content, uint8_t param1, uint8_t param2);
- aabox_t *content_box(aabox_t *b, float min_x, float min_y, float min_z, float max_x, float max_y, float max_z);
- facetext_t *content_facetext(facetext_t *f, uint16_t type, float x, float y, float w, float h);
- int content_init(void);
- void content_exit(void);
- int content_block_init(void);
- int content_clothes_init(void);
- int content_craftitem_init(void);
- int content_mob_init(void);
- int content_tool_init(void);
- void content_meshgen_textures(contentfeatures_t *f,...);
- #endif
|