Skip to content

BlockRegistry

Namespace Mc.Scripting.Content · Kind class (sealed)

public sealed class BlockRegistry

Registers custom blocks.

Member Description
IReadOnlyList<CustomBlock> All { get; } Every registered block (a snapshot).
public IReadOnlyList<CustomBlock> All { get; }

Every registered block (a snapshot).

Member Description
CustomBlock? At(World world, BlockPos pos) The custom block a world position holds.
CustomBlock? Get(string id) The registered block with this id.
CustomBlock? Of(BlockState state) The custom block a block state stands for.
void Register(CustomBlock block) Registers a block for the plugin whose code is running: picks its block state (the same one after a restart), marks it custom in the engine and starts listening for its breaking and clicking.
public CustomBlock? At(World world, BlockPos pos)

The custom block a world position holds.

Parameters

Name Type Description
world World The dimension.
pos BlockPos The position.

Returns CustomBlock?: The definition, or null when the block there is not a registered custom block.

public CustomBlock? Get(string id)

The registered block with this id.

Parameters

Name Type Description
id string The id.

Returns CustomBlock?: The definition, or null.

public CustomBlock? Of(BlockState state)

The custom block a block state stands for.

Parameters

Name Type Description
state BlockState The state.

Returns CustomBlock?: The definition, or null.

public void Register(CustomBlock block)

Registers a block for the plugin whose code is running: picks its block state (the same one after a restart), marks it custom in the engine and starts listening for its breaking and clicking. Released when the plugin unloads.

Parameters

Name Type Description
block CustomBlock The definition.

Throws

  • System.InvalidOperationException: The id is taken by another plugin, no state is free, or no plugin code is running.

BlockPos · BlockState · CustomBlock · World