接口 ToolComponent

所有超级接口:
ConfigurationSerializable

@Experimental public interface ToolComponent extends ConfigurationSerializable
表示一个可以将任何物品转变为工具的组件。
  • 方法详细资料

    • getDefaultMiningSpeed

      float getDefaultMiningSpeed()
      获取此工具的默认挖掘速度。如果没有规则明确覆盖此值,则工具使用此值。1.0为标准挖掘速度。

      原文:Get the default mining speed of this tool. This value is used by the tool if no rule explicitly overrides it. 1.0 is standard mining speed.

      返回:
      默认挖掘速度
      另请参阅:
    • setDefaultMiningSpeed

      void setDefaultMiningSpeed(float speed)
      设置此工具的默认挖掘速度。如果没有规则明确覆盖此值,则工具使用此值。1.0为标准挖掘速度。

      原文:Set the default mining speed of this tool. This value is used by the tool if no rule explicitly overrides it. 1.0 is standard mining speed.

      参数:
      speed - 要设置的速度
    • getDamagePerBlock

      int getDamagePerBlock()
      获取每次破坏方块时从工具中移除的耐久度。

      原文:Get the amount of durability to be removed from the tool each time a block is broken.

      返回:
      每个方块的伤害值
    • setDamagePerBlock

      void setDamagePerBlock(int damage)
      设置每次破坏方块时从工具中移除的耐久度。

      原文:Set the amount of durability to be removed from the tool each time a block is broken.

      参数:
      damage - 要设置的伤害值。必须为0或正整数
    • canDestroyBlocksInCreative

      boolean canDestroyBlocksInCreative()
      获取此工具是否可以在创造模式下破坏方块。

      原文:Get whether this tool can destroy blocks in creative.

      返回:
      是否可以破坏
    • setCanDestroyBlocksInCreative

      void setCanDestroyBlocksInCreative(boolean destroy)
      设置此工具是否可以在创造模式下破坏方块。

      原文:Set whether this tool can destroy blocks in creative.

      参数:
      destroy - 是否可以破坏
    • getRules

      获取适用于此工具的 ToolRules 列表。

      原文:Get the list of ToolRules that apply to this tool.

      返回:
      所有工具规则。返回列表的可变性无法保证,但其内容是可变的,可以更改其值
    • setRules

      设置适用于此工具的 ToolRules 列表。这将移除所有现有的工具规则。

      原文:Set the list of ToolRules to apply to this tool. This will remove any existing tool rules.

      参数:
      rules - 要设置的规则
    • addRule

      向此工具组件添加新规则,提供关于特定方块类型的进一步信息。

      原文:Add a new rule to this tool component, which provides further information about a specific block type.

      参数:
      block - 规则适用的方块类型
      speed - 挖掘该方块时使用的挖掘速度,或null使用默认挖掘速度
      correctForDrops - 此工具在挖掘该方块时是否被视为该方块的最佳工具,并在破坏时掉落物品,或null使用Minecraft定义的默认工具检查行为
      返回:
      添加到此工具的 ToolComponent.ToolRule 实例
    • addRule

      向此工具组件添加新规则,提供关于一组方块类型的进一步信息。

      原文:Add a new rule to this tool component, which provides further information about a collection of block types.

      参数:
      blocks - 规则适用的方块类型
      speed - 挖掘其中一个方块时使用的挖掘速度,或null使用默认挖掘速度
      correctForDrops - 此工具在挖掘其中一个方块时是否被视为该方块的最佳工具,并在破坏时掉落物品,或null使用Minecraft定义的默认工具检查行为
      返回:
      添加到此工具的 ToolComponent.ToolRule 实例
    • addRule

      向此工具组件添加新规则,提供关于由方块 Tag 表示的一组方块类型的进一步信息。

      原文:Add a new rule to this tool component, which provides further information about a collection of block types represented by a block Tag.

      参数:
      tag - 包含规则适用方块类型的方块标签
      speed - 挖掘其中一个方块时使用的挖掘速度,或null使用默认挖掘速度
      correctForDrops - 此工具在挖掘其中一个方块时是否被视为该方块的最佳工具,并在破坏时掉落物品,或null使用Minecraft定义的默认工具检查行为
      返回:
      添加到此工具的 ToolComponent.ToolRule 实例
      抛出:
      IllegalArgumentException - 如果传入的 tag 不是方块标签
    • removeRule

      boolean removeRule(@NotNull @NotNull ToolComponent.ToolRule rule)
      从此工具中移除给定的 ToolComponent.ToolRule。

      原文:Remove the given ToolComponent.ToolRule from this tool.

      参数:
      rule - 要移除的规则
      返回:
      如果规则被移除则返回true,如果此组件不包含匹配的规则则返回false