PistonActivateAfterEventSignal Class

Manages callbacks that are connected to piston activations.

Examples

pistonAfterEvent.ts
import { world, system, PistonActivateAfterEvent } from '@minecraft/server';

world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
    console.warn(
        `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`,
    );
});

Methods

subscribe

subscribe(callback: (arg: PistonActivateAfterEvent) => void): (arg: PistonActivateAfterEvent) => void

Parameters

Returns (arg: PistonActivateAfterEvent) => void

Important

This function can't be called in read-only mode.

unsubscribe

unsubscribe(callback: (arg: PistonActivateAfterEvent) => void): void

Removes a callback from being called when a piston expands or retracts.

Parameters

Important

This function can't be called in read-only mode.

Examples

pistonAfterEvent.ts
import { world, system, PistonActivateAfterEvent } from '@minecraft/server';

world.afterEvents.pistonActivate.subscribe((pistonEvent: PistonActivateAfterEvent) => {
    console.warn(
        `Piston event at ${system.currentTick} ${(pistonEvent.piston.isMoving ? ' Moving' : 'Not moving')} with state: ${pistonEvent.piston.state}`,
    );
});