PistonEvent

Base piston event, use PistonEventPost and PistonPreEvent

The event is not cancelable.

The event does not have a result.

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.event.block.piston.PistonEvent;

Extending BlockEvent

PistonEvent extends BlockEvent. That means all methods available in BlockEvent are also available in PistonEvent

Methods

Gets the direction that the piston is facing.

Returns: the direction tha the piston is facing.
Return Type: Direction

script.zs
// PistonEvent.getDirection() as Direction
myPistonEvent.getDirection();

Gets the position that the piston is facing towards.

Returns: The position that the piston is facing towards.
Return Type: BlockPos

script.zs
// PistonEvent.getFaceOffsetPos() as BlockPos
myPistonEvent.getFaceOffsetPos();

Gets the move type of the piston (is it extending or retracting).

Returns: The move type of the piston.
Return Type: PistonMoveType

script.zs
// PistonEvent.getPistonMoveType() as PistonMoveType
myPistonEvent.getPistonMoveType();

Gets a nullable structure resolver that can be used to get all the blocks that will be affected by the piston.

Be sure to call the resolve() method on the structure resolver

Returns: A structure resolver.
Return Type: PistonStructureResolver?

script.zs
// PistonEvent.getStructureHelper() as PistonStructureResolver?
myPistonEvent.getStructureHelper();

Properties

NameTypeHas GetterHas SetterDescription
Name
direction
Type
Direction
Has Getter
true
Has Setter
false
Description
Gets the direction that the piston is facing.
Name
faceOffsetPos
Type
BlockPos
Has Getter
true
Has Setter
false
Description
Gets the position that the piston is facing towards.
Name
pistonMoveType
Type
PistonMoveType
Has Getter
true
Has Setter
false
Description
Gets the move type of the piston (is it extending or retracting).
Name
structureHelper
Type
PistonStructureResolver?
Has Getter
true
Has Setter
false
Description
Gets a nullable structure resolver that can be used to get all the blocks that will be affected by the piston.

Be sure to call the resolve() method on the structure resolver