Block¶
Represents a block in the game, describing its type, light emission, and other characteristics.
Fields¶
burnable: boolean — Read-Only¶
Indicates whether the block is flammable.
data: table — Read-Only¶
A reference to the modifiable collection of additional block-specific attributes. For example, a "ladder" has a "facing" attribute, and "grass" has a "snowy" attribute.
Example:
local hit = spell.owner:raycastBlock(5)
if not hit or hit.side == "up" or hit.side == "down" then return end
spell.pos = hit.blockPos
spell:move(hit.side)
local ladder = Block:new("ladder")
ladder.data.facing = hit.side
spell.block = ladder
luminance: number — Read-Only¶
The light level emitted by the block.
opaque: boolean — Read-Only¶
Indicates whether the block is opaque and blocks light.
toolRequired: boolean — Read-Only¶
Indicates whether a specific tool is required to break the block effectively.
type: BlockType — Read-Only¶
A reference to the specific type of the block (e.g., stone, dirt).
Methods¶
new(id: string) → block: Block¶
Initializes a new block with the specified type.
Example
Parameters
- id: string — The identifier for the block type (e.g., "stone", "wood").
Returns
- block: Block — A new instance of a Block with the specified type.