diff --git a/src/Block.c b/src/Block.c index ff7f35e3e..f3d0f8cc8 100644 --- a/src/Block.c +++ b/src/Block.c @@ -7,6 +7,7 @@ #include "Inventory.h" #include "Event.h" #include "Picking.h" +#include "Lighting.h" struct _BlockLists Blocks; @@ -22,11 +23,16 @@ const char* const Sound_Names[SOUND_COUNT] = { #define FOG_WATER PackedCol_Make( 5, 5, 51, 255) #define FOG_LAVA PackedCol_Make(153, 25, 0, 255) +/* Brightness */ +#define BRIT_NONE 0 +#define BRIT_FULL MODERN_LIGHTING_MAX_LEVEL +#define BRIT_MAGM 1 + struct SimpleBlockDef { const char* name; cc_uint8 topTexture, sideTexture, bottomTexture, height; PackedCol fogColor; cc_uint8 fogDensity; - cc_bool fullBright, blocksLight; cc_uint8 gravity; + cc_uint8 brightness, blocksLight; cc_uint8 gravity; cc_uint8 draw, collide, digSound, stepSound; }; static const struct SimpleBlockDef invalid_blockDef = { @@ -35,82 +41,82 @@ static const struct SimpleBlockDef invalid_blockDef = { /* Properties for all built-in blocks (Classic and CPE blocks) */ static const struct SimpleBlockDef core_blockDefs[] = { -/*NAME TOP SID BOT HEI FOG_COLOR DENS FULL BLOCKS GRAV DRAW_MODE COLLIDE_MODE DIG_SOUND STEP_SOUND */ -{ "Air", 0, 0, 0, 16, FOG_NONE , 0, false, false, 100, DRAW_GAS, COLLIDE_NONE, SOUND_NONE, SOUND_NONE }, -{ "Stone", 1, 1, 1, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Grass", 0, 3, 2, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, -{ "Dirt", 2, 2, 2, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRAVEL, SOUND_GRAVEL }, -{ "Cobblestone", 16, 16, 16, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Wood", 4, 4, 4, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, -{ "Sapling", 15, 15, 15, 16, FOG_NONE , 0, false, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, -{ "Bedrock", 17, 17, 17, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +/*NAME TOP SID BOT HEI FOG_COLOR DENS BRIT BLOCKS GRAV DRAW_MODE COLLIDE_MODE DIG_SOUND STEP_SOUND */ +{ "Air", 0, 0, 0, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_GAS, COLLIDE_NONE, SOUND_NONE, SOUND_NONE }, +{ "Stone", 1, 1, 1, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Grass", 0, 3, 2, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, +{ "Dirt", 2, 2, 2, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRAVEL, SOUND_GRAVEL }, +{ "Cobblestone", 16, 16, 16, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Wood", 4, 4, 4, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, +{ "Sapling", 15, 15, 15, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, +{ "Bedrock", 17, 17, 17, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Water", 14, 14, 14, 16, FOG_WATER, 10, false, true, 100, DRAW_TRANSLUCENT, COLLIDE_WATER, SOUND_NONE, SOUND_NONE }, -{ "Still water", 14, 14, 14, 16, FOG_WATER, 10, false, true, 100, DRAW_TRANSLUCENT, COLLIDE_WATER, SOUND_NONE, SOUND_NONE }, -{ "Lava", 30, 30, 30, 16, FOG_LAVA , 180, true, true, 100, DRAW_OPAQUE, COLLIDE_LAVA, SOUND_NONE, SOUND_NONE }, -{ "Still lava", 30, 30, 30, 16, FOG_LAVA , 180, true, true, 100, DRAW_OPAQUE, COLLIDE_LAVA, SOUND_NONE, SOUND_NONE }, -{ "Sand", 18, 18, 18, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_SAND, SOUND_SAND }, -{ "Gravel", 19, 19, 19, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRAVEL, SOUND_GRAVEL }, -{ "Gold ore", 32, 32, 32, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Iron ore", 33, 33, 33, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Water", 14, 14, 14, 16, FOG_WATER, 10, BRIT_NONE, true, 100, DRAW_TRANSLUCENT, COLLIDE_WATER, SOUND_NONE, SOUND_NONE }, +{ "Still water", 14, 14, 14, 16, FOG_WATER, 10, BRIT_NONE, true, 100, DRAW_TRANSLUCENT, COLLIDE_WATER, SOUND_NONE, SOUND_NONE }, +{ "Lava", 30, 30, 30, 16, FOG_LAVA , 180, BRIT_FULL, true, 100, DRAW_OPAQUE, COLLIDE_LAVA, SOUND_NONE, SOUND_NONE }, +{ "Still lava", 30, 30, 30, 16, FOG_LAVA , 180, BRIT_FULL, true, 100, DRAW_OPAQUE, COLLIDE_LAVA, SOUND_NONE, SOUND_NONE }, +{ "Sand", 18, 18, 18, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_SAND, SOUND_SAND }, +{ "Gravel", 19, 19, 19, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRAVEL, SOUND_GRAVEL }, +{ "Gold ore", 32, 32, 32, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Iron ore", 33, 33, 33, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Coal ore", 34, 34, 34, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Log", 21, 20, 21, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, -{ "Leaves", 22, 22, 22, 16, FOG_NONE , 0, false, false, 40, DRAW_TRANSPARENT_THICK, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, -{ "Sponge", 48, 48, 48, 16, FOG_NONE , 0, false, true, 90, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, -{ "Glass", 49, 49, 49, 16, FOG_NONE , 0, false, false, 100, DRAW_TRANSPARENT, COLLIDE_SOLID, SOUND_GLASS,SOUND_STONE}, -{ "Red", 64, 64, 64, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Orange", 65, 65, 65, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Yellow", 66, 66, 66, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Coal ore", 34, 34, 34, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Log", 21, 20, 21, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, +{ "Leaves", 22, 22, 22, 16, FOG_NONE , 0, BRIT_NONE, false, 40, DRAW_TRANSPARENT_THICK, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, +{ "Sponge", 48, 48, 48, 16, FOG_NONE , 0, BRIT_NONE, true, 90, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, +{ "Glass", 49, 49, 49, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_TRANSPARENT, COLLIDE_SOLID, SOUND_GLASS,SOUND_STONE}, +{ "Red", 64, 64, 64, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Orange", 65, 65, 65, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Yellow", 66, 66, 66, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Lime", 67, 67, 67, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Green", 68, 68, 68, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Teal", 69, 69, 69, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Aqua", 70, 70, 70, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Cyan", 71, 71, 71, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Blue", 72, 72, 72, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Indigo", 73, 73, 73, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Violet", 74, 74, 74, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Lime", 67, 67, 67, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Green", 68, 68, 68, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Teal", 69, 69, 69, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Aqua", 70, 70, 70, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Cyan", 71, 71, 71, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Blue", 72, 72, 72, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Indigo", 73, 73, 73, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Violet", 74, 74, 74, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Magenta", 75, 75, 75, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Pink", 76, 76, 76, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Black", 77, 77, 77, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Gray", 78, 78, 78, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "White", 79, 79, 79, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Dandelion", 13, 13, 13, 16, FOG_NONE , 0, false, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, -{ "Rose", 12, 12, 12, 16, FOG_NONE , 0, false, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, -{ "Brown mushroom", 29, 29, 29, 16, FOG_NONE , 0, false, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, +{ "Magenta", 75, 75, 75, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Pink", 76, 76, 76, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Black", 77, 77, 77, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Gray", 78, 78, 78, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "White", 79, 79, 79, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Dandelion", 13, 13, 13, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, +{ "Rose", 12, 12, 12, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, +{ "Brown mushroom", 29, 29, 29, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, -{ "Red mushroom", 28, 28, 28, 16, FOG_NONE , 0, false, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, -{ "Gold", 24, 40, 56, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_METAL, SOUND_METAL }, -{ "Iron", 23, 39, 55, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_METAL, SOUND_METAL }, -{ "Double slab", 6, 5, 6, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Slab", 6, 5, 6, 8, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Brick", 7, 7, 7, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "TNT", 9, 8, 10, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, -{ "Bookshelf", 4, 35, 4, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, +{ "Red mushroom", 28, 28, 28, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_GRASS, SOUND_NONE }, +{ "Gold", 24, 40, 56, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_METAL, SOUND_METAL }, +{ "Iron", 23, 39, 55, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_METAL, SOUND_METAL }, +{ "Double slab", 6, 5, 6, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Slab", 6, 5, 6, 8, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Brick", 7, 7, 7, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "TNT", 9, 8, 10, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_GRASS, SOUND_GRASS }, +{ "Bookshelf", 4, 35, 4, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, -{ "Mossy rocks", 36, 36, 36, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Obsidian", 37, 37, 37, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Cobblestone slab", 16, 16, 16, 8, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Rope", 11, 11, 11, 16, FOG_NONE , 0, false, false, 100, DRAW_SPRITE, COLLIDE_CLIMB, SOUND_CLOTH, SOUND_CLOTH }, -{ "Sandstone", 25, 41, 57, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Snow", 50, 50, 50, 4, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_NONE, SOUND_SNOW, SOUND_SNOW }, -{ "Fire", 38, 38, 38, 16, FOG_NONE , 0, true, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_WOOD, SOUND_NONE }, -{ "Light pink", 80, 80, 80, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Mossy rocks", 36, 36, 36, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Obsidian", 37, 37, 37, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Cobblestone slab", 16, 16, 16, 8, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Rope", 11, 11, 11, 16, FOG_NONE , 0, BRIT_NONE, false, 100, DRAW_SPRITE, COLLIDE_CLIMB, SOUND_CLOTH, SOUND_CLOTH }, +{ "Sandstone", 25, 41, 57, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Snow", 50, 50, 50, 4, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_NONE, SOUND_SNOW, SOUND_SNOW }, +{ "Fire", 38, 38, 38, 16, FOG_NONE , 0, BRIT_FULL, false, 100, DRAW_SPRITE, COLLIDE_NONE, SOUND_WOOD, SOUND_NONE }, +{ "Light pink", 80, 80, 80, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Forest green", 81, 81, 81, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Brown", 82, 82, 82, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Deep blue", 83, 83, 83, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Turquoise", 84, 84, 84, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, -{ "Ice", 51, 51, 51, 16, FOG_NONE , 0, false, true, 100, DRAW_TRANSLUCENT, COLLIDE_ICE, SOUND_STONE, SOUND_STONE }, -{ "Ceramic tile", 54, 54, 54, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Magma", 86, 86, 86, 16, FOG_NONE , 0, true, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Pillar", 26, 42, 58, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Forest green", 81, 81, 81, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Brown", 82, 82, 82, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Deep blue", 83, 83, 83, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Turquoise", 84, 84, 84, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_CLOTH, SOUND_CLOTH }, +{ "Ice", 51, 51, 51, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_TRANSLUCENT, COLLIDE_ICE, SOUND_STONE, SOUND_STONE }, +{ "Ceramic tile", 54, 54, 54, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Magma", 86, 86, 86, 16, FOG_NONE , 0, BRIT_MAGM, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, +{ "Pillar", 26, 42, 58, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE }, -{ "Crate", 53, 53, 53, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, -{ "Stone brick", 52, 52, 52, 16, FOG_NONE , 0, false, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE } -/*NAME TOP SID BOT HEI FOG_COLOR DENS FULL BLOCKS GRAV DRAW_MODE COLLIDE_MODE DIG_SOUND STEP_SOUND */ +{ "Crate", 53, 53, 53, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_WOOD, SOUND_WOOD }, +{ "Stone brick", 52, 52, 52, 16, FOG_NONE , 0, BRIT_NONE, true, 100, DRAW_OPAQUE, COLLIDE_SOLID, SOUND_STONE, SOUND_STONE } +/*NAME TOP SID BOT HEI FOG_COLOR DENS BRIT BLOCKS GRAV DRAW_MODE COLLIDE_MODE DIG_SOUND STEP_SOUND */ }; /* Returns a backwards compatible collide type of a block */ @@ -462,7 +468,7 @@ void Block_ResetProps(BlockID block) { const cc_string name = String_FromReadonly(def->name); Blocks.BlocksLight[block] = def->blocksLight; - Blocks.FullBright[block] = def->fullBright; + Blocks.Brightness[block] = def->brightness; Blocks.FogCol[block] = def->fogColor; Blocks.FogDensity[block] = def->fogDensity / 100.0f; Block_SetCollide(block, def->collide); @@ -518,6 +524,10 @@ int Block_Parse(const cc_string* name) { return Block_FindID(name); } +cc_uint8 Block_ReadBrightness(cc_uint8 fullBright) { + //TODO, then use in Formats.c and Protocol.c + return 0; +} /*########################################################################################################################* *-------------------------------------------------------AutoRotate--------------------------------------------------------* diff --git a/src/Block.h b/src/Block.h index 41fb52999..69c05aaec 100644 --- a/src/Block.h +++ b/src/Block.h @@ -46,7 +46,7 @@ CC_VAR extern struct _BlockLists { /* Whether this block prevents lights from passing through it. */ cc_bool BlocksLight[BLOCK_COUNT]; /* Whether this block is fully bright/light emitting. (Like lava) */ - cc_bool FullBright[BLOCK_COUNT]; + cc_uint8 Brightness[BLOCK_COUNT]; /* Fog colour when player is inside this block. */ /* NOTE: Only applies if fog density is not 0. */ PackedCol FogCol[BLOCK_COUNT]; @@ -112,6 +112,7 @@ if (Blocks.Tinted[block]) col = PackedCol_Tint(col, Blocks.FogCol[block]); /* The difference can be seen by placing a lower and upper slab block on a wall, */ /* and comparing whether the block directly behind them is in shadow or not */ #define LIGHT_FLAG_SHADES_FROM_BELOW 6 +cc_uint8 Block_ReadBrightness(cc_uint8 fullBright); /* Returns whether the given block has been changed from default */ cc_bool Block_IsCustomDefined(BlockID block); diff --git a/src/Builder.c b/src/Builder.c index 7327ae9b5..4253783cc 100644 --- a/src/Builder.c +++ b/src/Builder.c @@ -178,7 +178,7 @@ static void PrepareChunk(int x1, int y1, int z1) { if (Blocks.Draw[b] == DRAW_SPRITE) { AddSpriteVertices(b); continue; } Builder_X = x; Builder_Y = y; Builder_Z = z; - Builder_FullBright = Blocks.FullBright[b]; + Builder_FullBright = Blocks.Brightness[b]; tileIdx = b * BLOCK_COUNT; /* All of these function calls are inlined as they can be called tens of millions to hundreds of millions of times. */ @@ -499,7 +499,7 @@ static void Builder_DrawSprite(int x, int y, int z) { if (offsetType == 7) { y1 -= valY; y2 -= valY; } } - bright = Blocks.FullBright[Builder_Block]; + bright = Blocks.Brightness[Builder_Block]; part = &Builder_Parts[Atlas1D_Index(loc)]; v.Col = bright ? PACKEDCOL_WHITE : Lighting.Color_Fast(x, y, z); Block_Tint(v.Col, Builder_Block); @@ -655,7 +655,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) { if (!count_XMin && !count_XMax && !count_ZMin && !count_ZMax && !count_YMin && !count_YMax) return; - fullBright = Blocks.FullBright[Builder_Block]; + fullBright = Blocks.Brightness[Builder_Block]; baseOffset = (Blocks.Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES; lightFlags = Blocks.LightOffset[Builder_Block]; @@ -809,9 +809,9 @@ static int Adv_Lit(int x, int y, int z, int cIndex) { flags |= Lighting.IsLit_Fast(x, (y + 1) - offset, z) ? LIT_P1 : 0; /* If a block is fullbright, it should also look as if that spot is lit */ - if (Blocks.FullBright[Builder_Chunk[cIndex - 324]]) flags |= LIT_M1; - if (Blocks.FullBright[block]) flags |= LIT_CC; - if (Blocks.FullBright[Builder_Chunk[cIndex + 324]]) flags |= LIT_P1; + if (Blocks.Brightness[Builder_Chunk[cIndex - 324]]) flags |= LIT_M1; + if (Blocks.Brightness[block]) flags |= LIT_CC; + if (Blocks.Brightness[Builder_Chunk[cIndex + 324]]) flags |= LIT_P1; return flags; } @@ -1208,7 +1208,7 @@ static void Adv_RenderBlock(int index, int x, int y, int z) { if (!count_XMin && !count_XMax && !count_ZMin && !count_ZMax && !count_YMin && !count_YMax) return; - Builder_FullBright = Blocks.FullBright[Builder_Block]; + Builder_FullBright = Blocks.Brightness[Builder_Block]; adv_baseOffset = (Blocks.Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES; adv_tinted = Blocks.Tinted[Builder_Block]; @@ -1559,7 +1559,7 @@ static void Modern_RenderBlock(int index, int x, int y, int z) { if (!count_XMin && !count_XMax && !count_ZMin && !count_ZMax && !count_YMin && !count_YMax) return; - Builder_FullBright = Blocks.FullBright[Builder_Block]; + Builder_FullBright = Blocks.Brightness[Builder_Block]; adv_baseOffset = (Blocks.Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES; adv_tinted = Blocks.Tinted[Builder_Block]; diff --git a/src/EnvRenderer.c b/src/EnvRenderer.c index 8261cf78a..30e0008ba 100644 --- a/src/EnvRenderer.c +++ b/src/EnvRenderer.c @@ -698,7 +698,7 @@ static void UpdateMapSides(void) { data = (struct VertexTextured*)Gfx_RecreateAndLockVb(&sides_vb, VERTEX_FORMAT_TEXTURED, sides_vertices); - sides_fullBright = Blocks.FullBright[block]; + sides_fullBright = Blocks.Brightness[block]; color = sides_fullBright ? PACKEDCOL_WHITE : Env.ShadowCol; Block_Tint(color, block) @@ -744,7 +744,7 @@ static void UpdateMapEdges(void) { data = (struct VertexTextured*)Gfx_RecreateAndLockVb(&edges_vb, VERTEX_FORMAT_TEXTURED, edges_vertices); - edges_fullBright = Blocks.FullBright[block]; + edges_fullBright = Blocks.Brightness[block]; color = edges_fullBright ? PACKEDCOL_WHITE : Env.SunCol; Block_Tint(color, block) diff --git a/src/Formats.c b/src/Formats.c index 55d858327..089bc2f61 100644 --- a/src/Formats.c +++ b/src/Formats.c @@ -761,7 +761,7 @@ static void Cw_Callback_5(struct NbtTag* tag) { if (IsTag(tag, "CollideType")) { Blocks.Collide[id] = NbtTag_U8(tag); return; } if (IsTag(tag, "Speed")) { Blocks.SpeedMultiplier[id] = NbtTag_F32(tag); return; } if (IsTag(tag, "TransmitsLight")) { Blocks.BlocksLight[id] = NbtTag_U8(tag) == 0; return; } - if (IsTag(tag, "FullBright")) { Blocks.FullBright[id] = NbtTag_U8(tag) != 0; return; } + if (IsTag(tag, "FullBright")) { Blocks.Brightness[id] = NbtTag_U8(tag) != 0; return; } if (IsTag(tag, "BlockDraw")) { Blocks.Draw[id] = NbtTag_U8(tag); return; } if (IsTag(tag, "Shape")) { Blocks.SpriteOffset[id] = NbtTag_U8(tag); return; } @@ -1407,7 +1407,7 @@ static cc_result Cw_WriteBockDef(struct Stream* stream, int b) { cur = Nbt_WriteUInt8(cur, "TransmitsLight", Blocks.BlocksLight[b] ? 0 : 1); cur = Nbt_WriteUInt8(cur, "WalkSound", Blocks.DigSounds[b]); - cur = Nbt_WriteUInt8(cur, "FullBright", Blocks.FullBright[b] ? 1 : 0); + cur = Nbt_WriteUInt8(cur, "FullBright", Blocks.Brightness[b] ? 1 : 0); cur = Nbt_WriteUInt8(cur, "Shape", sprite ? 0 : (cc_uint8)(Blocks.MaxBB[b].Y * 16)); cur = Nbt_WriteUInt8(cur, "BlockDraw", sprite ? Blocks.SpriteOffset[b] : Blocks.Draw[b]); diff --git a/src/IsometricDrawer.c b/src/IsometricDrawer.c index 753737d18..f4d4451f4 100644 --- a/src/IsometricDrawer.c +++ b/src/IsometricDrawer.c @@ -139,7 +139,7 @@ void IsometricDrawer_BeginBatch(struct VertexTextured* vertices, GfxResourceID v } void IsometricDrawer_DrawBatch(BlockID block, float size, float x, float y) { - cc_bool bright = Blocks.FullBright[block]; + cc_bool bright = Blocks.Brightness[block]; Vec3 min, max; if (Blocks.Draw[block] == DRAW_GAS) return; diff --git a/src/Lighting.c b/src/Lighting.c index 415208e35..0d0f7efa3 100644 --- a/src/Lighting.c +++ b/src/Lighting.c @@ -618,8 +618,8 @@ static cc_uint8 GetBlocklight(int x, int y, int z, cc_bool sun) { } static cc_bool CanLightPass(BlockID thisBlock, Face face) { - /* If it's not opaque and it doesn't block light, or it's fullbright, we can always pass through */ - if ((Blocks.Draw[thisBlock] > DRAW_OPAQUE && !Blocks.BlocksLight[thisBlock]) || Blocks.FullBright[thisBlock]) { return true; } + /* If it's not opaque and it doesn't block light, or it is brighter than 0, we can always pass through */ + if ((Blocks.Draw[thisBlock] > DRAW_OPAQUE && !Blocks.BlocksLight[thisBlock]) || Blocks.Brightness[thisBlock]) { return true; } /* Light can always pass through leaves and water */ if (Blocks.Draw[thisBlock] == DRAW_TRANSPARENT_THICK || Blocks.Draw[thisBlock] == DRAW_TRANSLUCENT) { return true; } @@ -627,7 +627,7 @@ static cc_bool CanLightPass(BlockID thisBlock, Face face) { /* We can assume a block is full sized if none of the LightOffset flags are 0 */ if (Blocks.BlocksLight[thisBlock] && Blocks.LightOffset[thisBlock] == 0xFF) { return false; } - /* Is stone's face hidden by thisBlock? */ + /* Is stone's face hidden by thisBlock? TODO: Don't hardcode using stone */ return !Block_IsFaceHidden(BLOCK_STONE, thisBlock, face); } @@ -824,8 +824,8 @@ static void CalculateChunkLightingSelf(int chunkIndex, int cx, int cy, int cz) { for (x = chunkStartX; x < chunkEndX; x++) { BlockID curBlock = World_GetBlock(x, y, z); - if (Blocks.FullBright[curBlock]) { - CalcBlockLight(MODERN_LIGHTING_MAX_LEVEL, x, y, z); + if (Blocks.Brightness[curBlock]) { + CalcBlockLight(Blocks.Brightness[curBlock], x, y, z); } //this cell is exposed to sunlight diff --git a/src/Model.c b/src/Model.c index 7587fa46b..84ba381ad 100644 --- a/src/Model.c +++ b/src/Model.c @@ -2062,7 +2062,7 @@ static void BlockModel_Draw(struct Entity* p) { bModel_index = 0; if (Blocks.Draw[bModel_block] == DRAW_GAS) return; - if (Blocks.FullBright[bModel_block]) { + if (Blocks.Brightness[bModel_block]) { for (i = 0; i < FACE_COUNT; i++) { Models.Cols[i] = PACKEDCOL_WHITE; } diff --git a/src/Particle.c b/src/Particle.c index 41adf9ac8..d26f99e87 100644 --- a/src/Particle.c +++ b/src/Particle.c @@ -221,7 +221,7 @@ static void TerrainParticle_Render(struct TerrainParticle* p, float t, struct Ve Vec3_Lerp(&pos, &p->base.lastPos, &p->base.nextPos, t); size.X = p->base.size * 0.015625f; size.Y = size.X; - if (!Blocks.FullBright[p->block]) { + if (!Blocks.Brightness[p->block]) { x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z); col = Lighting.Color_XSide(x, y, z); } diff --git a/src/Protocol.c b/src/Protocol.c index f9f8bae54..275b118df 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -1701,7 +1701,7 @@ static BlockID BlockDefs_DefineBlockCommonStart(cc_uint8** ptr, cc_bool uniqueSi Blocks.DigSounds[block] = sound; if (sound == SOUND_GLASS) Blocks.StepSounds[block] = SOUND_STONE; - Blocks.FullBright[block] = *data++ != 0; + Blocks.Brightness[block] = *data++ != 0; *ptr = data; return block; }