Class BlockRail

All Implemented Interfaces:
BlockID, IBlockState, IMutableBlockState, AxisAlignedBB, Metadatable, Faceable, Cloneable
Direct Known Subclasses:
BlockRailActivator, BlockRailDetector, BlockRailPowered

public class BlockRail extends BlockFlowable implements Faceable
Since:
2016/1/11
Author:
Snake1999
  • Field Details

  • Constructor Details

    • BlockRail

      public BlockRail()
    • BlockRail

      public BlockRail(int meta)
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in class Block
    • getId

      public int getId()
      Specified by:
      getId in class Block
    • getProperties

      @Since("1.4.0.0-PN") @PowerNukkitOnly @NotNull public BlockProperties getProperties()
      Description copied from class: Block
      The properties that fully describe all possible and valid states that this block can have.
      Specified by:
      getProperties in interface IBlockState
      Specified by:
      getProperties in class BlockMeta
    • getHardness

      public double getHardness()
      Description copied from class: Block
      控制方块硬度
      Overrides:
      getHardness in class BlockFlowable
      Returns:
      方块的硬度
    • getResistance

      public double getResistance()
      Description copied from class: Block
      控制方块爆炸抗性
      Overrides:
      getResistance in class BlockFlowable
      Returns:
      方块的爆炸抗性
    • canPassThrough

      public boolean canPassThrough()
      Overrides:
      canPassThrough in class BlockFlowable
    • getToolType

      public int getToolType()
      Description copied from class: Block
      控制挖掘方块的工具类型
      Overrides:
      getToolType in class Block
      Returns:
      挖掘方块的工具类型
    • sticksToPiston

      public boolean sticksToPiston()
      Overrides:
      sticksToPiston in class BlockFlowable
      Returns:
      是否可以粘在粘性活塞上
    • onUpdate

      public int onUpdate(int type)
      Overrides:
      onUpdate in class Block
    • getMaxY

      public double getMaxY()
      Specified by:
      getMaxY in interface AxisAlignedBB
      Overrides:
      getMaxY in class Block
    • recalculateBoundingBox

      public AxisAlignedBB recalculateBoundingBox()
      Overrides:
      recalculateBoundingBox in class BlockFlowable
    • getColor

      public BlockColor getColor()
      Overrides:
      getColor in class BlockTransparentMeta
    • place

      public boolean place(@NotNull Item item, @NotNull Block block, @NotNull Block target, @NotNull BlockFace face, double fx, double fy, double fz, Player player)
      Description copied from class: Block
      Place and initialize a this block correctly in the world.

      The current instance must have level, x, y, z, and layer properties already set before calling this method.

      Overrides:
      place in class Block
      Parameters:
      item - The item being used to place the block. Should be used as an optional reference, may mismatch the block that is being placed depending on plugin implementations.
      block - The current block that is in the world and is getting replaced by this instance. It has the same x, y, z, layer, and level as this block.
      target - The block that was clicked to create the place action in this block position.
      face - The face that was clicked in the target block
      fx - The detailed X coordinate of the clicked target block face
      fy - The detailed Y coordinate of the clicked target block face
      fz - The detailed Z coordinate of the clicked target block face
      player - The player that is placing the block. May be null.
      Returns:
      true if the block was properly place. The implementation is responsible for reverting any partial change.
    • checkRailsConnected

      protected Map<BlockRail,BlockFace> checkRailsConnected()
    • isAbstract

      public boolean isAbstract()
    • canPowered

      public boolean canPowered()
    • getRailDirection

      @PowerNukkitOnly @Since("1.4.0.0-PN") @NotNull public final Rail.Orientation getRailDirection()
    • setRailDirection

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setRailDirection(Rail.Orientation orientation)
      Changes the rail direction without changing anything else.
      Parameters:
      orientation - The new orientation
    • getOrientation

      public Rail.Orientation getOrientation()
    • setOrientation

      public void setOrientation(Rail.Orientation o)
      Changes the rail direction and update the state in the world if the orientation changed in a single call.

      Note that the level block won't change if the current block has already the given orientation.

      See Also:
    • getRealMeta

      @Deprecated @DeprecationDetails(since="1.4.0.0-PN", by="PowerNukkit", reason="This hack is no longer needed after the block state implementation and is no longer maintained") public int getRealMeta()
      Deprecated.
    • isActive

      public boolean isActive()
    • setActive

      public void setActive(boolean active)
      Changes the active flag and update the state in the world in a single call.

      The active flag will not change if the block state don't have the ACTIVE property, and it will not throw exceptions related to missing block properties.

      The level block will always update.

      See Also:
    • isRailActive

      @PowerNukkitOnly @Since("1.4.0.0-PN") public OptionalBoolean isRailActive()
    • setRailActive

      @PowerNukkitOnly @Since("1.4.0.0-PN") public void setRailActive(boolean active) throws NoSuchElementException
      Throws:
      NoSuchElementException - If attempt to set the rail to active but it don't have the ACTIVE property.
    • toItem

      public Item toItem()
      Overrides:
      toItem in class Block
    • getBlockFace

      public BlockFace getBlockFace()
      Specified by:
      getBlockFace in interface Faceable
    • canBePushed

      public boolean canBePushed()
      Overrides:
      canBePushed in class Block
      Returns:
      方块是否可以被活塞推动
    • canBePulled

      @PowerNukkitOnly public boolean canBePulled()
      Overrides:
      canBePulled in class Block
      Returns:
      方块是否可以被活塞拉动
    • breaksWhenMoved

      @PowerNukkitOnly public boolean breaksWhenMoved()
      Overrides:
      breaksWhenMoved in class BlockFlowable
      Returns:
      当被活塞移动时是否会被破坏