Base piston event, use PistonEventPost and PistonPreEvent

The event is not cancelable.

The event does not have a result.

Импорт класса

Link to импорт-класса

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.

ZenScript
Copy
import crafttweaker.api.event.block.piston.PistonEvent;

Extending BlockEvent

Link to extending-blockevent

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

Name: getDirection

Gets the direction that the piston is facing.

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

ZenScript
Copy
// PistonEvent.getDirection() as Direction

myPistonEvent.getDirection();

Link to getFaceOffsetPos

Name: getFaceOffsetPos

Gets the position that the piston is facing towards.

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

ZenScript
Copy
// PistonEvent.getFaceOffsetPos() as BlockPos

myPistonEvent.getFaceOffsetPos();

Link to getPistonMoveType

Name: getPistonMoveType

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

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

ZenScript
Copy
// PistonEvent.getPistonMoveType() as PistonMoveType

myPistonEvent.getPistonMoveType();

Link to getStructureHelper

Name: getStructureHelper

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?

ZenScript
Copy
// PistonEvent.getStructureHelper() as PistonStructureResolver?

myPistonEvent.getStructureHelper();

Свойства

Link to свойства

НазваниеТипИмеет GetterИмеет SetterОписание
Название
direction
Тип
Direction
Имеет Getter
true
Имеет Setter
false
Описание
Gets the direction that the piston is facing.
Название
faceOffsetPos
Тип
BlockPos
Имеет Getter
true
Имеет Setter
false
Описание
Gets the position that the piston is facing towards.
Название
pistonMoveType
Тип
PistonMoveType
Имеет Getter
true
Имеет Setter
false
Описание
Gets the move type of the piston (is it extending or retracting).
Название
structureHelper
Тип
PistonStructureResolver?
Имеет Getter
true
Имеет Setter
false
Описание
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