SerenityJS
    Preparing search index...

    Class BlockButtonTrait

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    block: Block

    The block that this trait is attached to.

    component: null | typeof BlockTypeComponent = ...

    The block component that this trait is attached to.

    dimension: Dimension

    The dimension that the block is in.

    identifier: string = ...

    The identifier of the trait.

    releaseTick: bigint = -1n

    The tick at which the button will be released.

    state: null | string = ...

    The block state key that this trait is attached to.

    tag: null | string = ...

    The block tag that this trait is attached to.

    component: null | typeof BlockTypeComponent = null

    The block component that this trait is compatible with by default. If null, the trait will not attach to any block by default.

    identifier: "button"

    The identifier of the trait.

    state: "button_pressed_bit"

    The block state key that this trait is compatible with by default. If null, the trait will not be initialized by any block state.

    tag: null | string = null

    The block tag that this trait is compatible with by default. If null, the trait will not attach to any block by default.

    types: string[] = []

    The block type identifiers that this trait is compatible with by default.

    Methods

    • Breaks the block on the next tick, dropping it, if it is still not held up then. Breaking a block updates its neighbours, so blocks held up by one another break one per tick, as in vanilla, rather than all at once, which spreads the work of breaking many blocks over many ticks.

      Parameters

      • isSupported: () => boolean

        Checks whether the block is held up.

      Returns void

    • Gets the number of ticks the button stays pressed for. Stone buttons stay pressed for 20 ticks, and wooden buttons for 30.

      Returns bigint

    • Sets the probability of this trait being randomly ticked each tick.

      Parameters

      • numerator: number

        The numerator of the probability fraction.

      • denominator: number

        The denominator of the probability fraction.

      Returns void

    • Set the state of the button.

      Parameters

      • state: boolean

        The desired state of the button (true for pressed, false for not pressed).

      • silent: boolean = false

        If the sound event should be played (default is false).

      Returns void

    • Wether this trait should be randomly ticked this tick.

      Parameters

      • factor: number = 1

        A factor to multiply the chance by. Default is 1.

      Returns boolean

      True if the trait should be randomly ticked, false otherwise.