Effective Block With Entity
An EffectiveBlock that carries a Marker entity at its centre — a place to keep per-block data.
On placement a marker (invisible, no hitbox) is spawned in the block; on break it is removed, and removing the marker by other means removes the block. Reach it with getMarkerEntity and store per-block state in its persistent data (owner, charge, contents, …) via ru.hukm.effectiveSpigot.minecraft.utils.EffectiveDataContainerUtils.
object Altar : EffectiveBlockWithEntity() {
// …EffectiveBlock overrides…
override fun onPlace(event: BlockPlaceEvent) {
val marker = getMarkerEntity(event.blockPlaced) ?: return
EffectiveDataContainerUtils.setContainerValue(marker, OWNER, event.player.uniqueId.toString())
}
}Properties
The placeable item: a note block carrying the block's model and force-placing this block's getNoteBlockData state (via the item's block-data / block_state component), so it shows the custom block right away.
Functions
Registers an interact handler for blocks of this custom type (matched by note-block state). RIGHT = right-click on the block, LEFT = left-click (attack) it.
Sound played when this block is broken. Defaults to the vanilla wood break sound (via required.wood.break).
Tool types that mine this block faster; empty (default) means no tool preference (base speed for any).
Block hardness — controls how long it takes to mine (vanilla note block is 0.8). <= 0 breaks instantly.
Minimum tool tier that can harvest this block, checked when requiresCorrectTool. Default EffectiveToolTier.HAND.
Maps getVariation (0..799) to a note-block state: instrument (0..15), note (0..24) and powered. Layout: powered = variation >= 400, then instrument = (variation % 400) / 25, note = % 25.
Sound played when this block is placed. Defaults to the vanilla wood place sound (via required.wood.place).
Sound played when an entity walks on this block. Defaults to the vanilla wood step sound (via required.wood.step).
Whether this block only drops its item when mined with a correct tool (getCorrectTools + getMinTier).