EffectiveBlockWithEntity

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())
}
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
fun addInteractHandler(click: EffectiveAbstractInteract.Click, callback: (EffectiveBlockInteractable.EventsCallOptions) -> EffectiveAbstractInteract.Result)

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.

Link copied to clipboard
abstract fun editItemMeta(meta: ItemMeta)
Link copied to clipboard
open fun getBreakSound(): String

Sound played when this block is broken. Defaults to the vanilla wood break sound (via required.wood.break).

Link copied to clipboard

Tool types that mine this block faster; empty (default) means no tool preference (base speed for any).

Link copied to clipboard
fun getCustomBlocks(): List<Block>
Link copied to clipboard
Link copied to clipboard
open fun getHardness(): Double

Block hardness — controls how long it takes to mine (vanilla note block is 0.8). <= 0 breaks instantly.

Link copied to clipboard
fun getMarkerEntity(block: Block): Marker?
Link copied to clipboard

Minimum tool tier that can harvest this block, checked when requiresCorrectTool. Default EffectiveToolTier.HAND.

Link copied to clipboard
abstract fun getNamespacedData(): Pair<JavaPlugin, String>
Link copied to clipboard
Link copied to clipboard
fun getNoteBlockData(): NoteBlock

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.

Link copied to clipboard
open fun getPlaceSound(): String

Sound played when this block is placed. Defaults to the vanilla wood place sound (via required.wood.place).

Link copied to clipboard
open fun getStepSound(): String

Sound played when an entity walks on this block. Defaults to the vanilla wood step sound (via required.wood.step).

Link copied to clipboard
abstract fun getVariation(): Int
Link copied to clipboard
open fun isIgnitable(): Boolean
Link copied to clipboard
open fun onBreak(event: BlockBreakEvent)

Called when this block is broken, just before its sound and drops are handled.

Link copied to clipboard
open fun onPlace(event: BlockPlaceEvent)

Called right after this block is placed (at BlockPlaceEvent MONITOR — the placement is already committed).

Link copied to clipboard

Whether this block only drops its item when mined with a correct tool (getCorrectTools + getMinTier).