9 #define CONTENT_MAX 0x0FFF
10 #define CONTENT_ARRAY_SIZE 0x1000
12 /* the top nibble of content_t is a type identifier
13 * this allows for 16 possible content types */
14 #define CONTENT_TYPE_MASK 0xF000
15 #define CONTENT_TYPE_BLOCK 0x0000
16 #define CONTENT_TYPE_CLOTHES 0x1000
17 #define CONTENT_TYPE_MOB 0x2000
18 #define CONTENT_TYPE_TOOL 0x4000
19 #define CONTENT_TYPE_CRAFTITEM 0x8000
21 #define CONTENT_INDEX_BLOCK 0x00
22 #define CONTENT_INDEX_CLOTHES 0x01
23 #define CONTENT_INDEX_MOB 0x02
24 #define CONTENT_INDEX_TOOL 0x04
25 #define CONTENT_INDEX_CRAFTITEM 0x08
27 #define CONTENT_TYPE(x) (x&CONTENT_TYPE_MASK)
29 /* the universal "nothing" value */
30 #define CONTENT_IGNORE 0x007F
34 #define CPT_LIGHT 0x01
35 #define CPT_MINERAL 0x02
36 #define CPT_FACEDIR_SIMPLE 0x03 /* chests and such */
37 #define CPT_FACEDIR_WALLMOUNT 0x04 /* signs and such */
38 #define CPT_FACEDIR_MANUAL 0x05 /* planks and such */
39 #define CPT_LIQUID 0x06
40 #define CPT_PLANTGROWTH 0x07
41 #define CPT_ENCHANTMENT 0x08
43 #define CPT_BLOCKDATA 0x0A
44 #define CPT_SPECIAL 0x0B
50 #define CMT_STONE 0x03
51 #define CMT_LIQUID_SOURCE 0x04
52 #define CMT_LIQUID 0x05
53 #define CMT_PLANT 0x06
55 #define CMT_GLASS 0x08
56 #define CMT_FLESH 0x09
58 /* the below are not for blocks */
59 #define CMT_COTTON 0x0B
60 #define CMT_CANVAS 0x0C
62 #define CMT_LEATHER 0x0E
63 #define CMT_ARMOUR 0x0F
67 #define CCT_PANTS 0x01
68 #define CCT_SHIRT 0x02
70 #define CCT_BOOTS 0x04
71 #define CCT_JACKET 0x05
73 #define CCT_DECORATIVE 0x07
74 #define CCT_MEDALLION 0x08
78 #define CTT_SPECIAL 0x01 /* special tools can't dig */
81 #define CTT_SHOVEL 0x04
82 #define CTT_SHEAR 0x05
83 #define CTT_BUCKET 0x06
84 #define CTT_SWORD 0x07
85 #define CTT_SPEAR 0x08
87 #define CTT_HAMMER 0x0A
90 /* flags used for graphics materials */
92 #define CMF_ROTATE 0x01 /* rotate top/bottom with nodebox */
93 #define CMF_TILED 0X02 /* for plantlike, use bottom/middle/top halves seperately */
95 /* flags used for collision data */
96 /* also determines the behaviour when pushed by a piston */
97 #define CCD_NONE 0x0000
98 #define CCD_WALKABLE 0x0001 /* can be walked through */
99 #define CCD_SELECTABLE 0x0002 /* can be pointed at */
100 #define CCD_TOOL_SELECTABLE 0x0004 /* can be pointed at with a tool, CCD_SELECTABLE applies this */
101 #define CCD_CLIMBABLE 0x0008 /* think ladders */
102 #define CCD_REPLACEABLE 0x0010 /* can be replaced by a material placed on/in it (old buildable_to) */
103 #define CCD_CRUSHABLE 0x0020 /* will be obliterated if pushed against another node */
104 #define CCD_DROPABLE 0x0040 /* may drop when above an upward-facing piston */
105 #define CCD_SOLID 0x0080
106 #define CCD_CRUSHED 0x0100 /* always obliterated when pushed */
107 #define CCD_MOBSAFE 0x0200 /* destructive_mob_safe */
108 #define CCD_UNJUMPABLE 0x0400
111 #define CDT_AIRLIKE 0x00
112 #define CDT_CUBELIKE 0x01
113 #define CDT_RAILLIKE 0x02
114 #define CDT_PLANTLIKE 0x03
115 #define CDT_PLANTLIKE_FERN 0x04
116 #define CDT_MELONLIKE 0x05
117 #define CDT_LIQUID 0x06
118 #define CDT_LIQUID_SOURCE 0x07
119 #define CDT_NODEBOX 0x08
120 #define CDT_GLASSLIKE 0x09
121 #define CDT_TORCHLIKE 0x0A
122 #define CDT_FENCELIKE 0x0B
123 #define CDT_FIRELIKE 0x0C
124 #define CDT_WALLLIKE 0x0D
125 #define CDT_ROOFLIKE 0x0E
126 #define CDT_LEAFLIKE 0x0F
127 #define CDT_NODEBOX_META 0x10
128 #define CDT_WIRELIKE 0x11
129 #define CDT_3DWIRELIKE 0x12
130 #define CDT_STAIRLIKE 0x13
131 #define CDT_SLABLIKE 0x14
132 #define CDT_TRUNKLIKE 0x15
133 #define CDT_DIRTLIKE 0x16
134 #define CDT_FLAGLIKE 0x17
137 #define CLM_BLOCKS 0x00
138 #define CLM_BRIGHT 0x01 /* disable lighting */
139 #define CLM_CLEAR 0x02 /* sunlight_propogates */
140 #define CLM_TRANSLUCENT 0x03 /* light_propogates */
142 /* digging effects */
143 #define CDE_UNDIGGABLE 0x00
144 #define CDE_DIGGABLE 0x01
145 #define CDE_IGNORE_BORDERSTONE 0x08 /* borderstone_diggable */
146 #define CDE_GIVE_INVENTORY 0x10 /* gives its inventory when dug */
147 #define CDE_GIVE_INV_AON 0x20 /* all or nothing for inventory */
149 /* circuits/energy type */
150 #define CET_NONE 0x00
151 #define CET_CONDUCTIVE 0x01
152 #define CET_SOURCE 0x02
153 #define CET_SWITCH 0x03
154 #define CET_GATE 0x04
155 #define CET_SINK 0x05
162 #define CT_BOTTOM0 0x10
163 #define CT_BOTTOM1 0x11
164 #define CT_BOTTOM2 0x12
165 #define CT_BOTTOM3 0x13
166 #define CT_RIGHT0 0x20
167 #define CT_RIGHT1 0x21
168 #define CT_RIGHT2 0x22
169 #define CT_RIGHT3 0x23
170 #define CT_LEFT0 0x30
171 #define CT_LEFT1 0x31
172 #define CT_LEFT2 0x32
173 #define CT_LEFT3 0x33
174 #define CT_BACK0 0x40
175 #define CT_BACK1 0x41
176 #define CT_BACK2 0x42
177 #define CT_BACK3 0x43
178 #define CT_FRONT0 0x50
179 #define CT_FRONT1 0x51
180 #define CT_FRONT2 0x52
181 #define CT_FRONT3 0x53
182 #define CT_BASE0 0x60
183 #define CT_BASE1 0x61
184 #define CT_BASE2 0x62
185 #define CT_BASE3 0x63
186 #define CT_INVENTORY 0x70
187 #define CT_META_TOP0 0x80
188 #define CT_META_TOP1 0x81
189 #define CT_META_TOP2 0x82
190 #define CT_META_TOP3 0x83
191 #define CT_META_BOTTOM0 0x90
192 #define CT_META_BOTTOM1 0x91
193 #define CT_META_BOTTOM2 0x92
194 #define CT_META_BOTTOM3 0x93
195 #define CT_META_RIGHT0 0xA0
196 #define CT_META_RIGHT1 0xA1
197 #define CT_META_RIGHT2 0xA2
198 #define CT_META_RIGHT3 0xA3
199 #define CT_META_LEFT0 0xB0
200 #define CT_META_LEFT1 0xB1
201 #define CT_META_LEFT2 0xB2
202 #define CT_META_LEFT3 0xB3
203 #define CT_META_BACK0 0xC0
204 #define CT_META_BACK1 0xC1
205 #define CT_META_BACK2 0xC2
206 #define CT_META_BACK3 0xC3
207 #define CT_META_FRONT0 0xD0
208 #define CT_META_FRONT1 0xD1
209 #define CT_META_FRONT2 0xD2
210 #define CT_META_FRONT3 0xD3
211 #define CT_META_BASE0 0xE0
212 #define CT_META_BASE1 0xE1
213 #define CT_META_BASE2 0xE2
214 #define CT_META_BASE3 0xE3
216 /* face text types */
217 #define CFT_NONE 0x00
218 #define CFT_INFO 0x01
219 #define CFT_BOOKCONTENT 0x02
220 #define CFT_OWNER 0x03
221 #define CFT_INVOWNER 0x04
223 #ifndef _HAVE_CONTENT_TYPE
224 #define _HAVE_CONTENT_TYPE
225 typedef uint16_t content_t
;
228 #ifndef _HAVE_NODEBOX_TYPE
229 #define _HAVE_NODEBOX_TYPE
230 typedef struct nodebox_s
{
237 #ifndef _HAVE_ITEM_TYPE
238 #define _HAVE_ITEM_TYPE
239 typedef struct item_s
{
246 #ifndef _HAVE_FACETEXT_TYPE
247 #define _HAVE_FACETEXT_TYPE
248 typedef struct facetext_s
{
254 #ifndef _HAVE_BLOCKFEATURES_TYPE
255 #define _HAVE_BLOCKFEATURES_TYPE
256 typedef struct blockfeatures_s
{
257 uint8_t vertex_alpha
;
258 colour_t post_effect_colour
;
260 /* when dug/punched also affects this */
261 pos_t onact_also_affects
;
262 /* can set the players home */
265 facetext_t facetexts
[6];
266 /* essentially "can mapgen put a tree/plant on this" */
267 uint8_t is_ground_content
;
268 /* 1 - fire can spread to and destroy this
269 * 2 - can be set on fire */
271 /* basically "can grass grow under this" */
272 uint8_t air_equivalent
;
273 /* what happens if/when dug */
274 uint16_t digging_info
;
276 /* if it has metadata, this is the metadata type */
280 content_t wallmount
; /* when placed on a wall */
281 content_t floormount
; /* when placed on a floor */
282 content_t roofmount
; /* when placed on a roof */
283 /* special content for things like slabs combining into cubes,
284 * walls connecting to blocks, or seeds growing to plants */
286 /* if locked/unlocked, replace with this */
288 /* if power state changes powered/unpowerd, replace with this */
289 content_t powerstate
;
293 /* liquid, both types of matching liquid */
296 /* a value from 1-7, with 7 being thickest */
300 /* when dropped on dirt, place this instead of inserting in a parcel */
303 /* if there's a ^block nearby, place this instead */
307 /* for circuits, the type of circuit object, and how much energy drops as it pases through */
314 content_t replace
; /* when dug, this block will replace the dug block */
315 content_t replace_requires
; /* ^replacement will only occur if this block is nearby (3 node radius) */
316 /* if a tool of param2 type is used, give this instead */
321 content_t replace
; /* when punched, replace with this block */
322 uint8_t borderstone
; /* if 0 ignore borderstone protection */
327 /* when CPT_PLANTGROWTH < 8 digging gives this */
328 content_t small_drop
;
329 /* when CPT_PLANTGROWTH > 7 digging gives this */
330 content_t large_drop
;
331 /* the maximum number of large items given */
332 uint16_t large_count
;
333 /* whether to also give small when large is given */
334 uint8_t large_gives_small
;
335 /* if this spreads to trellis to continue growing, then this is the on-trellis id */
336 content_t trellis_block
;
337 /* whether punching with fertilizer advances the growth rate */
338 uint8_t fertilizer_affects
;
343 #ifndef _HAVE_CLOTHESFEATURES_TYPE
344 #define _HAVE_CLOTHESFEATURES_TYPE
345 typedef struct clothesfeatures_s
{
346 /* the type of this clothing */
348 /* the strength as armour */
350 /* the effectiveness against the cold zone */
352 /* the effectiveness against vacuum / space */
354 /* the effectiveness against suffocation */
356 /* this determines how fast the item wears out from use */
358 /* for medallions, how much the affect durability of other items */
363 #ifndef _HAVE_MOBFEATURES_TYPE
364 #define _HAVE_MOBFEATURES_TYPE
365 typedef struct mobfeatures_s
{
366 int stuff
; /* TODO: mobfeatures_t */
370 #ifndef _HAVE_TOOLFEATURES_TYPE
371 #define _HAVE_TOOLFEATURES_TYPE
372 typedef struct toolfeatures_s
{
373 /* the type of this tool */
375 /* the number dropped on right click, -1 for all */
377 /* whether this tool can point at liquid nodes */
378 uint8_t liquids_pointable
;
379 /* whether this tool should die when trying to pick up damaging nodes */
380 uint8_t damaging_nodes_diggable
;
381 /* whether this tool has a punch effect, such as open doors */
382 uint8_t has_punch_effect
;
383 /* whether this tool can lock/unlock nodes (1 for true, 2 for super) */
384 uint8_t has_unlock_effect
;
385 /* whether this tool can rotate nodes */
386 uint8_t has_rotate_effect
;
387 /* whether this tool can start fires */
388 uint8_t has_fire_effect
;
389 /* the dig time of this tool */
391 /* the level of the tool, this affects the amount of minerals etc */
393 /* used for eg. bows throwing an arrow */
394 content_t thrown_item
;
398 #ifndef _HAVE_CRAFTITEMFEATURES_TYPE
399 #define _HAVE_CRAFTITEMFEATURES_TYPE
400 typedef struct craftitemfeatures_s
{
401 /* whether the item can be stacked in inventory */
403 /* whether the item can be eaten/drank, must be non-zero for *_effect to work */
405 /* if an item has both hunger and health effects, it will
406 * not affect health unless hunger is full
407 * number of hunger points this will refill */
408 int16_t hunger_effect
;
409 /* number of health points this will refill */
410 int16_t health_effect
;
411 /* number of seconds will protect player against cold damage */
413 /* will refill energy at double full speed for this many seconds */
414 int16_t energy_effect
;
415 /* the number dropped on right click, -1 for all */
417 /* if this teleports the player home, -2 = no, -1 = default home
418 * 0-7 for specific flag colours */
420 /* used by mobs that are picked up */
422 /* used by snowballs and such... things that are thrown */
423 content_t thrown_item
;
424 /* used by arrows and such... things that are shot by a tool */
426 } craftitemfeatures_t
;
429 #ifndef _HAVE_CONTENTFEATURES_TYPE
430 #define _HAVE_CONTENTFEATURES_TYPE
431 typedef struct contentfeatures_s
{
437 /* determines digging properties */
438 uint8_t material_type
;
446 uint16_t materials_info
;
449 /* collision info, for players, mobs, piston pushes, digging, placing etc */
450 array_t collision_boxes
;
451 uint16_t collision_info
;
453 /* if an item has a nodebox style wield, use this */
456 /* same info about how light reacts on this */
458 uint8_t light_source
;
460 /* what is returned when this is dug, a primary item, and a secondary item
461 * plus randomness for the extra item, and tool levels to obtain it */
463 item_t extra_dug_item
;
464 int extra_dug_item_rarity
;
465 uint8_t extra_dug_item_min_level
;
466 uint8_t extra_dug_item_max_level
;
471 /* wield it and use it, replaced with this */
472 item_t onuse_replace
;
473 /* if it can be enchanted, it gives this */
474 content_t enchanted_item
;
476 /* sound effects for the content */
478 char* access
; /* formspec accessed */
479 char* step
; /* stepped on/in */
480 char* dig
; /* when dug or killed */
481 char* place
; /* when placed or spawned */
482 char* punch
; /* when punched */
483 char* ambient
; /* constant sound effect */
484 char* use
; /* when weilded and used */
487 /* damage effects per second to players/mobs */
489 uint8_t hard
; /* hard damage cannot be protected against */
491 uint8_t temperature
; /* hot/cold */
492 uint8_t pressure
; /* vacuum */
495 /* the features for individual types */
497 blockfeatures_t block
;
498 clothesfeatures_t clothes
;
501 craftitemfeatures_t craftitem
;
506 #ifdef _CONTENT_LOCAL
507 /* defined in content.c */
508 extern contentfeatures_t
*contentfeatures
[16];
509 void content_defaults(contentfeatures_t
*f
);
512 /* defined in content.c */
513 contentfeatures_t
*content_features(content_t id
);
514 item_t
*content_item(item_t
*i
, content_t content
, uint8_t param1
, uint8_t param2
);
515 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
);
516 facetext_t
*content_facetext(facetext_t
*f
, uint16_t type
, float x
, float y
, float w
, float h
);
517 int content_init(void);
518 void content_exit(void);
520 /* defined in content_block.c */
521 int content_block_init(void);
523 /* defined in content_clothes.c */
524 int content_clothes_init(void);
526 /* defined in content_craftitem.c */
527 int content_craftitem_init(void);
529 /* defined in content_mob.c */
530 int content_mob_init(void);
532 /* defined in content_tool.c */
533 int content_tool_init(void);