Blocks & Ores
Blocks are defined using BlockData ScriptableObjects.
BlockData
Create a new block via:
- Right-click in Project →
Create → Pixit → Block World → Block
A typical BlockData contains:
id(byte)- 0 is reserved for Air.
- 1+ should map to solid blocks (grass, dirt, stone, ore, etc.).
displayName- Human-readable name for UI.
icon- Sprite used in hotbar/inventory.
worldPrefab- Prefab used for the block inside chunks or when held in hand.
- Usually a 1×1×1 cube aligned to the origin (or centered).
dropPrefab- Prefab spawned as a pickup when the block is broken.
- Typically a small floating cube with
BlockPickupattached. baseBreakTime- Base seconds needed to break the block with bare hands or default speed.
requiresPickaxe(optional)- If true, breaking without a pickaxe can be prevented or slowed down.
pickaxeMultiplier(optional)- Multiplier applied when using a valid pickaxe.
- Example:
0.3→ 3x faster than base break time.
Block IDs
The world stores blocks as a 3D array of byte IDs.
Example mapping:
- ID
0→ Air (empty) - ID
1→ Grass - ID
2→ Dirt - ID
3→ Stone - ID
4→ Diamond Ore
You are free to define your own mapping, but keep it consistent.
In code, the Chunk converts between ID and BlockData via a lookup
(often a dictionary or array managed by WorldSettings or a database asset).
Ores
Ore blocks are just BlockData with extra ore-related settings (field names
may differ in your version, but conceptually they look like this):
isOre(bool)minY,maxY- Vertical range where this ore is allowed.
rarity(0–1)- Chance that a suitable base block (e.g. stone, underground) will be replaced by this ore.
During world generation, a pass like this usually runs per chunk:
- Scan all blocks in the chunk.
- For each block that can host an ore (e.g. stone, underground):
- Sample a random value.
- If random <
rarityandyis in[minY, maxY], set this block’s ID to the ore block’s ID.
You can add multiple ore types (coal, iron, gold, etc.) by creating multiple
BlockData entries and defining different ranges and rarities.
Creating and Assigning Blocks
- Create all your
BlockDataassets (Grass, Dirt, Stone, Diamond Ore, etc.). - Open your
WorldSettingsasset: - Add references to each block in its block list / database reference.
- Ensure your
WorldGeneratororChunkcode uses that list to: - Map IDs to
BlockDatafor mesh building and drops. - Use the correct
worldPrefabanddropPrefab.