Class PistonBlockEntity

java.lang.Object
org.geysermc.geyser.translator.level.block.entity.PistonBlockEntity

public class PistonBlockEntity extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    PistonBlockEntity​(GeyserSession session, com.nukkitx.math.vector.Vector3i position, Direction orientation, boolean sticky, boolean extended)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.nukkitx.nbt.NbtMap
    buildStaticPistonTag​(com.nukkitx.math.vector.Vector3i position, boolean extended, boolean sticky)
    Create a piston data tag that has fully extended/retracted
    boolean
     
    boolean
    checkCollision​(com.nukkitx.math.vector.Vector3i blockPos, BoundingBox boundingBox)
     
    double
    computeCollisionOffset​(com.nukkitx.math.vector.Vector3i blockPos, BoundingBox boundingBox, Axis axis, double movement)
    Compute the maximum movement of a bounding box that won't collide with the moving block attached to this piston
    com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType
     
    com.nukkitx.math.vector.Vector3i
     
    boolean
     
    void
    Push the player If the player is pushed, the displacement is added to playerDisplacement in PistonCache If the player contacts a slime block, playerMotion in PistonCache is updated
    void
    setAction​(com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType action)
    Set whether the piston is pulling or pushing blocks
    void
    setAction​(com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType action, it.unimi.dsi.fastutil.objects.Object2IntMap<com.nukkitx.math.vector.Vector3i> attachedBlocks)
     
    void
    Place attached blocks in their final position when done pushing or pulling
    void
    Update the position of the piston head, moving blocks, and players.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PistonBlockEntity

      public PistonBlockEntity(GeyserSession session, com.nukkitx.math.vector.Vector3i position, Direction orientation, boolean sticky, boolean extended)
  • Method Details

    • setAction

      public void setAction(com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType action)
      Set whether the piston is pulling or pushing blocks
      Parameters:
      action - PULLING or PUSHING or CANCELED_MID_PUSH
    • setAction

      public void setAction(com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType action, it.unimi.dsi.fastutil.objects.Object2IntMap<com.nukkitx.math.vector.Vector3i> attachedBlocks)
    • updateMovement

      public void updateMovement()
      Update the position of the piston head, moving blocks, and players.
    • updateBlocks

      public void updateBlocks()
      Place attached blocks in their final position when done pushing or pulling
    • pushPlayer

      public void pushPlayer()
      Push the player If the player is pushed, the displacement is added to playerDisplacement in PistonCache If the player contacts a slime block, playerMotion in PistonCache is updated
    • computeCollisionOffset

      public double computeCollisionOffset(com.nukkitx.math.vector.Vector3i blockPos, BoundingBox boundingBox, Axis axis, double movement)
      Compute the maximum movement of a bounding box that won't collide with the moving block attached to this piston
      Parameters:
      blockPos - The position of the moving block
      boundingBox - The bounding box of the moving entity
      axis - The axis of movement
      movement - The movement in the axis
      Returns:
      The adjusted movement
    • checkCollision

      public boolean checkCollision(com.nukkitx.math.vector.Vector3i blockPos, BoundingBox boundingBox)
    • isDone

      public boolean isDone()
      Returns:
      True if the piston has finished its movement, otherwise false
    • canBeRemoved

      public boolean canBeRemoved()
    • buildStaticPistonTag

      public static com.nukkitx.nbt.NbtMap buildStaticPistonTag(com.nukkitx.math.vector.Vector3i position, boolean extended, boolean sticky)
      Create a piston data tag that has fully extended/retracted
      Parameters:
      position - The position for the base of the piston
      extended - Whether the piston is extended or retracted
      sticky - Whether the piston is a sticky piston or a regular piston
      Returns:
      A piston data tag for a fully extended/retracted piston
    • getPosition

      public com.nukkitx.math.vector.Vector3i getPosition()
    • getAction

      public com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType getAction()