API reference Obsidian.API.Blocks
BlockProperties class
What a plugin's block is like: its states, how it collides, lights and breaks, and what it does when used.
public sealed class BlockProperties
In Obsidian.API.
Constructors
public BlockProperties();Properties
Behavior
public IBlockBehavior Behavior { get; init; }What the block does when players use or place it, when it or its neighbours change, when it ticks and when entities touch it, or null for nothing.
DefaultState
public IReadOnlyDictionary<string, string> DefaultState { get; init; }The default state's value of each property, by name; a property not listed defaults to its first value.
ExplosionResistance
public float? ExplosionResistance { get; init; }How well the block resists explosions, like vanilla's explosion resistance: 6 for stone, 1200 for obsidian. Null gives it its BlockProperties.Hardness, as vanilla's strength does, or bedrock's resistance when it's unbreakable.
Hardness
public float Hardness { get; init; }How long the block takes to break, like vanilla's destroy time: 1.5 for stone, 0 to break instantly, -1 to make it unbreakable.
HasCollision
public bool HasCollision { get; init; }Whether the block is a full cube that entities collide with, like stone; otherwise entities pass through it, like a flower.
Item
public ItemProperties Item { get; init; }The properties of the block's item, which has the block's identifier, places the block and is what the block drops; null for a block without an item.
LightEmission
public int LightEmission { get; init; }The light level the block gives off, from 0 to 15.
LootTable
public string LootTable { get; init; }The drop table's identifier. Null uses <namespace>:blocks/<path>, falling back to the block's own item when that table is absent. An explicit missing table drops nothing.
Opaque
public bool Opaque { get; init; }Whether the block hides what's behind it and blocks light, like stone rather than glass. Only blocks with collision can be opaque.
RandomlyTicks
public bool RandomlyTicks { get; init; }Whether the block's behaviour gets random ticks (IBlockBehavior.RandomTick), like vanilla's randomTicks. Like BlockProperties.Behavior, it's the plugin's: a reload replaces it.
RequiresCorrectTool
public bool RequiresCorrectTool { get; init; }Whether a player must use the right tool for the block to drop loot. Explosions bypass this check.
SoundType
public BlockSoundProperties SoundType { get; init; }The block's interaction sounds, declared on both sides; stone by default.
StateLightEmission
public Func<IReadOnlyDictionary<string, string>, int> StateLightEmission { get; init; }The light level, from 0 to 15, of a state of the block given its property values by name, like vanilla's per-state light level: values => values["lit"] == "true" ? 15 : 0 for a lamp. It replaces BlockProperties.LightEmission when set. It's asked once for each state when the block is registered (again when the plugin reloads), and not kept: the levels it gave are.
StateProperties
public IReadOnlyList<StateProperty> StateProperties { get; init; }The properties the block's states vary by; none gives the block a single state. They can't change while the server runs, since clients number states by them.
StateShapes
public Func<IReadOnlyDictionary<string, string>, BlockShapes> StateShapes { get; init; }The collision and outline shapes of a state of the block given its property values by name, like the shapes vanilla's fences, walls and panes take from their connections; null for a state keeps the block's usual shapes (a full block). It's asked once for each state when the block is registered (again when the plugin reloads), and not kept: the shapes it gave are. A block entity's shapes (BlockEntity.GetShapes) win over them.
Remarks
Shapes decide what entities collide with, what mobs path around and what players aim at; whether the block blocks light and hides its neighbours' faces stays BlockProperties.Opaque's, and a block without BlockProperties.HasCollision can't give a state collision boxes. A reload may change the shapes.
TreeGrower
public TreeGrower TreeGrower { get; init; }The trees the block grows into, which makes it a sapling: it grows in light on random ticks and with bone meal like vanilla's saplings. Null for a block that doesn't grow. Like BlockProperties.Behavior, it's the plugin's: the block stops growing when the plugin unloads, and a reload replaces it.