1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2026-05-31 01:42:06 +00:00
Files
CC-Tweaked/doc/reference/block_details.md
T
Jonathan Coates 8a1a545ab1 Add reference for item details
Also change potion display name to include potency, to match
enchantments.
2025-12-17 18:27:45 +00:00

2.5 KiB


module: [kind=reference] block_details since: 1.64 changed: 1.76 Added block state. changed: 1.117.0 Added map colour.

Block details

Several functions in CC: Tweaked, such as [turtle.inspect] and [commands.getBlockInfo] provide a way to get information about a block in the world. This page details information about blocks that CC: Tweaked may return.

Basic information

Block information will always contain:

  • name: string: The namespaced ID for this block, e.g. minecraft:dirt. See the Minecraft wiki for a list of vanilla block IDs.
  • state: { [string] = any}: A table containing the block state of the block.

Example

A fully hydrated block of farmland:

{
    name = "minecraft:farmland",
    state = {
        moisture = 7
    }
}

An extended piston, facing upwards:

{
    name = "minecraft:piston",
    state = {
        facing = "up",
        extended = true
    }
}

Block tags

The tags a block has.

  • tags: { [string] = boolean }: The set of tags for this block. This is a mapping of tag name to true.

While the representation of tags is a little more complicated then a single list, this makes it very easy to check if a block has a certain tag:

--- Check if the block in front of the turtle is a log.
local function is_log()
    local ok, block = turtle.inspect()
    return ok and block.tags["minecraft:logs"]
end

Example

A fully hydrated block of farmland:

{
    name = "minecraft:farmland",
    state = { ... },
    tags = {
        ["minecraft:mineable/shovel"] = true,
    }
}

Map colour

The colour the block will appear on the map, if specified.

  • mapColour?: number: The colour of the block, as an RGB hex value.
  • mapColor?: number: The color of the block, as an RGB hex value.

The map colour is just returned as a plain number (e.g. 9923917 for farmland). It can either be displayed in hex with [string.format], or converted to individual RGB values with [colors.unpackRGB].

Example

A fully hydrated block of farmland:

{
    name = "minecraft:farmland",
    state = { ... },
    mapColour = 9923917,
    mapColor = 9923917,
}