Interface Tool


@NullMarked @Experimental @NonExtendable public interface Tool
Controls the behavior of the item as a tool.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builder for Tool.
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether this tool can destroy blocks in creative mode.
    @org.checkerframework.checker.index.qual.NonNegative int
    Amount of durability to remove each time a block is mined with this tool.
    float
    Mining speed to use if no rules match and don't override mining speed.
    static Tool.Rule
    rule(RegistryKeySet<BlockType> blocks, @Nullable Float speed, TriState correctForDrops)
    Creates a mining rule that specifies how an item interacts with certain block types.
    @Unmodifiable List<Tool.Rule>
    List of rule entries.
     
  • Method Details

    • tool

      @Contract(value="-> new", pure=true) static Tool.Builder tool()
    • rule

      static Tool.Rule rule(RegistryKeySet<BlockType> blocks, @Nullable Float speed, TriState correctForDrops)
      Creates a mining rule that specifies how an item interacts with certain block types.

      This method allows you to define a rule for a set of block types, optionally setting a custom mining speed and determining whether the item should correct for drops when mining these blocks.

      Parameters:
      blocks - The set of block types this rule applies to.
      speed - The custom mining speed multiplier for these blocks. If null, the default speed is used.
      correctForDrops - A TriState indicating how to handle item drops:
      Returns:
      A new Tool.Rule instance representing the mining rule.
    • defaultMiningSpeed

      @Contract(pure=true) float defaultMiningSpeed()
      Mining speed to use if no rules match and don't override mining speed.
      Returns:
      default mining speed
    • damagePerBlock

      @Contract(pure=true) @org.checkerframework.checker.index.qual.NonNegative int damagePerBlock()
      Amount of durability to remove each time a block is mined with this tool.
      Returns:
      durability
    • rules

      @Contract(pure=true) @Unmodifiable List<Tool.Rule> rules()
      List of rule entries.
      Returns:
      rules
    • canDestroyBlocksInCreative

      @Contract(pure=true) boolean canDestroyBlocksInCreative()
      Whether this tool can destroy blocks in creative mode.
      Returns:
      whether this tool can destroy blocks in creative mode