forked from Vogtinator/crafti
-
Notifications
You must be signed in to change notification settings - Fork 0
Block Definitions
Bluebotlabz edited this page Jul 2, 2022
·
2 revisions
Regular blocks are each defines with an ID, similar to early versions of Minecraft
In order to create an additional block, you must first define it in the terrain.h block definitions:
typedef uint8_t BLOCK;
typedef uint16_t BLOCK_WDATA;
constexpr BLOCK BLOCK_AIR = 0;
constexpr BLOCK BLOCK_STONE = 1;
constexpr BLOCK BLOCK_DIRT = 2;
constexpr BLOCK BLOCK_SAND = 3;
constexpr BLOCK BLOCK_WOOD = 4;
constexpr BLOCK BLOCK_LEAVES = 5;
constexpr BLOCK BLOCK_PLANKS_NORMAL = 6;
constexpr BLOCK BLOCK_WALL = 7;
constexpr BLOCK BLOCK_COAL_ORE = 8;
constexpr BLOCK BLOCK_GOLD_ORE = 9;
constexpr BLOCK BLOCK_IRON_ORE = 10;
constexpr BLOCK BLOCK_DIAMOND_ORE = 11;
constexpr BLOCK BLOCK_REDSTONE_ORE = 12;
constexpr BLOCK BLOCK_TNT = 13;
constexpr BLOCK BLOCK_SPONGE = 14;
constexpr BLOCK BLOCK_PLANKS_DARK = 15;
constexpr BLOCK BLOCK_PLANKS_BRIGHT = 16;
constexpr BLOCK BLOCK_FURNACE = 17;
constexpr BLOCK BLOCK_CRAFTING_TABLE = 18;
constexpr BLOCK BLOCK_BOOKSHELF = 19;
constexpr BLOCK BLOCK_GRASS = 20;
constexpr BLOCK BLOCK_PUMPKIN = 21;
constexpr BLOCK BLOCK_BEDROCK = 22;
constexpr BLOCK BLOCK_GLASS = 23;
constexpr BLOCK BLOCK_COBBLESTONE = 24;
constexpr BLOCK BLOCK_GLOWSTONE = 25;
constexpr BLOCK BLOCK_IRON = 26;
constexpr BLOCK BLOCK_GOLD = 27;
constexpr BLOCK BLOCK_DIAMOND = 28;
constexpr BLOCK BLOCK_NETHERRACK = 29;
constexpr BLOCK BLOCK_CACTUS = 30;
// Regular blocks end here
constexpr BLOCK BLOCK_NORMAL_LAST = BLOCK_CACTUS;
//Special blocks begin here
constexpr int BLOCK_SPECIAL_START = 127;
constexpr BLOCK BLOCK_TORCH = 127; //Data: Direction (BLOCK_SIDE)
constexpr BLOCK BLOCK_FLOWER = 128; //Data: Flower type
constexpr BLOCK BLOCK_SPIDERWEB = 129;
constexpr BLOCK BLOCK_CAKE = 130;
constexpr BLOCK BLOCK_MUSHROOM = 131; //Data: Mushroom type
constexpr BLOCK BLOCK_DOOR = 132; //Data: (top: 1<<3) | BLOCK_SIDE
constexpr BLOCK BLOCK_WATER = 133; //Data: range
constexpr BLOCK BLOCK_LAVA = 134; //Data: range
constexpr BLOCK BLOCK_WHEAT = 135; //Data: growth
constexpr BLOCK BLOCK_REDSTONE_LAMP = 146; //Data: On/Off
constexpr BLOCK BLOCK_REDSTONE_SWITCH = 147; //Data: BLOCK_SIDE
constexpr BLOCK BLOCK_REDSTONE_WIRE = 148; //Data: (active: 1<<6, visited: 1<<5)
constexpr BLOCK BLOCK_REDSTONE_TORCH = 149; //Data: See BLOCK_TORCH
constexpr BLOCK BLOCK_PRESSURE_PLATE = 150; //Data: How many ticks kept active
constexpr BLOCK BLOCK_WOOL = 151; // Data: Colour
constexpr BLOCK BLOCK_SPECIAL_LAST = BLOCK_WOOL;As you can see, each block has an integer ID, for example, air:
constexpr BLOCK BLOCK_AIR = 0;When adding a new regular block, make sure that you add it within the regular block section, rather than the special block section and also give it a valid ID as so:
constexpr BLOCK BLOCK_GOLD = 27;
constexpr BLOCK BLOCK_DIAMOND = 28;
constexpr BLOCK BLOCK_NETHERRACK = 29;
constexpr BLOCK BLOCK_CACTUS = 30;
constexpr BLOCK BLOCK_NEWBLOCK = 31; ///// NEW BLOCK ADDEDAdditionally, when adding a new block with a new ID, do not forget to change the BLOCK_NORMAL_LAST variable:
constexpr BLOCK BLOCK_GOLD = 27;
constexpr BLOCK BLOCK_DIAMOND = 28;
constexpr BLOCK BLOCK_NETHERRACK = 29;
constexpr BLOCK BLOCK_CACTUS = 30;
constexpr BLOCK BLOCK_NEWBLOCK = 31; ///// NEW BLOCK ADDED
// Regular blocks end here
constexpr BLOCK BLOCK_NORMAL_LAST = BLOCK_NEWBLOCK;
//Special blocks begin here
// Make sure you do not add your regular blocks with IDs which go into the special-blocks sectionRember that IDs 127 onwards are reserved for special blocks
- Home
- Building Crafti
- Crafti Versions
- Crafti Textures
-
Crafti Development
-
Inventory
- Adding blocks to inventory
- Changing inventory parameters
-
Blocks
- Regular Blocks
- Special Blocks
- Special Block Definitions
- Special Block Textures
- Special Block Name
- Special Block Renderers/Logic
- Special Block Data
- Tick() and Saving Data
- Tutorial: Redstone Wool
- Advanced Block Documentation
- Warning
- All Included Renderers
- Block Meshes
- Block Collision
- Block Transparency
- Block Renderer Texture "Cropping"
- All Block Renderer Parameters
- All Block Renderer Functions
- Block Data Structure
- Redstone
- How Redstone works in Crafti
- Redstone in special blocks
- World
- Chunks
- World Generation
- Structure Generation
- Localisation
- Setting the game's language
- Adding a language
-
Inventory