Block

@CataloguedBy(catalogue = Blocks::class)
interface Block : StateHolder<BlockState> , BlockLike, ItemLike, Translatable, Keyed

A block with certain properties.

These are immutable and do not contain any state-specific information, such as the world or location they are in, so they can be easily reused in many places, which from a technical standpoint, reduces allocations, but also makes them much more thread-safe.

Functions

Link copied to clipboard
open override fun asBlock(): Block

Gets the block representation, or null if there is no block representation.

Link copied to clipboard
abstract fun asItem(): ItemType

Converts this object to its item representation.

Link copied to clipboard
abstract fun canRespawnIn(): Boolean

If this block can be respawned inside of.

Link copied to clipboard
abstract fun getProperty(name: String): Property<*>?

Gets the property with the given name for this holder, or returns null if there is no property with the given name for this holder.

Link copied to clipboard
abstract fun hasBlockEntity(): Boolean

If this block has an associated block entity.

Link copied to clipboard
abstract fun hasGravity(): Boolean

If this block has gravity.

Link copied to clipboard
@NotNull
abstract fun key(): @NotNull Key
Link copied to clipboard
@NotNull
abstract fun translationKey(): @NotNull String

Properties

Link copied to clipboard
@get:JvmName(name = "availableProperties")
abstract val availableProperties: @Unmodifiable Collection<Property<*>>

All of the properties that can be set on the states of this holder.

Link copied to clipboard
@get:JvmName(name = "defaultState")
abstract val defaultState: BlockState

The default state that this holder will appear in.

Link copied to clipboard
@get:JvmName(name = "explosionResistance")
abstract val explosionResistance: Double

How resistant this block is to explosions. Higher means more resistant.

Link copied to clipboard
@get:JvmName(name = "friction")
abstract val friction: Double

The friction of this block.

Link copied to clipboard
@get:JvmName(name = "soundGroup")
abstract val soundGroup: BlockSoundGroup

The group of sounds for this block.

Link copied to clipboard
@get:JvmName(name = "states")
abstract val states: @Unmodifiable List<BlockState>

All of the states that this holder can be in.