EffectiveBlock

abstract class EffectiveBlock

Base class for a custom block backed by a note-block state. ⚠️ Work in progress. Mining, drops and sounds are less battle-tested than items; getCustomBlocks goes through the internal world block cache, which has known bugs. The API may change.

A subclass declares identity (getNamespacedData), a server-unique state (getVariation, 0..799), textures (getResourcePackData) and the block item's meta (editItemMeta); mining, sounds, drops and hooks are tuned through the open methods. Like the other bases, the object must be instantiated (init() from onEnable) to register.

Textures

The model and note-block blockstates are generated only into a built pack: call EffectiveResourcepack.addServerResourcepack(this, "", "") in onEnable after the blocks' init(), otherwise the block places but looks like a plain note block. The server also needs block-updates.disable-noteblock-updates: true in paper-global.yml.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class ResourcePackData(val texture: String, val up: String? = null, val down: String? = null, val north: String? = null, val south: String? = null, val east: String? = null, val west: String? = null, val particle: String? = null)

Block textures for the generated cube model (minecraft:block/cube). texture is the main texture used for every face and the particle; override any single face with up/down/north/south/ east/west (or particle) — a null override falls back to texture. When building the model use the resolved *Texture accessors.

Properties

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

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).