Script API - v1.19.70
    Preparing search index...

    Manages callbacks that are connected to piston activations.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Beta

      Parameters

      Returns (arg: PistonActivateEvent) => void

      Adds a callback that will be called when a piston expands or retracts.

      let canceled = false;

      const pistonLoc: mc.Vector3 = {
      x: Math.floor(targetLocation.x) + 1,
      y: Math.floor(targetLocation.y) + 2,
      z: Math.floor(targetLocation.z) + 1,
      };

      const pistonCallback = mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => {
      if (pistonEvent.piston.location.equals(pistonLoc)) {
      log("Cancelling piston event");
      pistonEvent.cancel = true;
      canceled = true;
      }
      });

    • Beta

      Parameters

      Returns void

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

      This function can throw errors.