Interface CustomBlock


@PowerNukkitXOnly @Since("1.6.0.0-PNX") public interface CustomBlock
继承这个类实现自定义方块,重写Block中的方法控制方块属性

Inherit this class to implement a custom block, override the methods in the Block to control the feature of the block.

  • Method Summary

    Modifier and Type
    Method
    Description
    default double
    breakTime(Item item, Player player)
    获取自定义方块的挖掘时间,它是服务端侧和客户端侧挖掘时间的最小值。
    该方法设置自定义方块的定义
    double
    覆写该方法设置自定义方块的摩擦因数
    double
    覆写该方法设置自定义方块的硬度,这有助于自定义方块在服务端侧计算挖掘时间(硬度越大服务端侧挖掘时间越长)
    default int
    该方法必须被覆写为使用接口的定义,请使用
    int
    覆写该方法设置自定义方块的吸收光的等级
    int
    覆写该方法设置自定义方块的发出光的等级
    default String
    该方法必须被覆写为使用接口的定义,请使用
    覆写该方法设置自定义方块的命名空间ID
    double
    覆写该方法设置自定义方块的爆炸抗性
    default boolean
     
    default Block
    Plugins do not need @Override
    default Block
    toCustomBlock(int meta)
    Plugins do not need @Override
    一般不需要被覆写,继承父类会提供
  • Method Details

    • getFrictionFactor

      double getFrictionFactor()
      覆写该方法设置自定义方块的摩擦因数

      @Override this method to set the friction factor of the custom block

    • getResistance

      double getResistance()
      覆写该方法设置自定义方块的爆炸抗性

      @Override this method to set the Explosive resistance of the custom block

    • getLightFilter

      int getLightFilter()
      覆写该方法设置自定义方块的吸收光的等级

      @Override this method to set the level of light absorption of the custom block

    • getLightLevel

      int getLightLevel()
      覆写该方法设置自定义方块的发出光的等级

      @Override this method to set the level of light emitted by the custom block

    • getHardness

      double getHardness()
      覆写该方法设置自定义方块的硬度,这有助于自定义方块在服务端侧计算挖掘时间(硬度越大服务端侧挖掘时间越长)

      @Override this method to set the hardness of the custom block, which helps to calculate the break time of the custom block on the server-side (the higher the hardness the longer the break time on the server-side)

    • getNamespaceId

      @NotNull String getNamespaceId()
      覆写该方法设置自定义方块的命名空间ID

      @Override this method to set the namespace ID of the custom block

    • toItem

      Item toItem()
      一般不需要被覆写,继承父类会提供

      Generally, it does not need to be @Override, extend from the parent class will provide

    • getDefinition

      CustomBlockDefinition getDefinition()
      该方法设置自定义方块的定义

      This method sets the definition of custom block

    • getId

      default int getId()
      该方法必须被覆写为使用接口的定义,请使用

      The method must be @Override to use the definition of the interface, please use the
      @Override
      public int getId() { return CustomBlock.super.getId(); }

    • getName

      default String getName()
      该方法必须被覆写为使用接口的定义,请使用

      The method must be @Override to use the definition of the interface, please use the
      @Override
      public String getName() { return CustomBlock.super.getName(); }

    • toCustomBlock

      default Block toCustomBlock()
      Plugins do not need @Override
      Returns:
      the block
    • toCustomBlock

      default Block toCustomBlock(int meta)
      Plugins do not need @Override
      Returns:
      the block
    • reverseSending

      default boolean reverseSending()
      Returns:
      是否反转自定义方块属性解析的顺序
      Whether to reverse the order of properties parsing
    • breakTime

      default double breakTime(@NotNull Item item, @Nullable Player player)
      获取自定义方块的挖掘时间,它是服务端侧和客户端侧挖掘时间的最小值。
      Parameters:
      item - the item
      player - the player
      Returns:
      the break time