Fabric API

Fabric API

108M Downloads

[Suggestion] Replace `FabricBlockSettings.breakByTool` by extending the 1.17 vanilla tag system

Juuxel opened this issue ยท 1 comments

commented

In 1.17, Mojang added a system for defining the breaking tools and required tool levels with a set of builtin tags. (Previously, this was done with ugly if-statements in tool classes.) This makes the Fabric breakByTool system redundant for vanilla tools and vanilla mining levels.

  • Custom tool types can be done by passing a custom mineable tag for your tool, and passing it into MiningToolItem's constructor. There's no API needed here.
    • Multitools that have multiple tool types can just have a custom Item.isSuitableFor(BlockState) implementation, which is reasonable enough to implement manually IMO.
      • Example: state.isIn(#mineable/pickaxe) || state.isIn(#mineable/shovel) for a pickaxe-shovel multitool
  • Custom mining levels are a bit harder. The tags themselves are hardcoded in MiningToolItem.isSuitableFor, so a simple registry of "mining level (int) -> mining level block tag" could be made here.

Discord discussion:
Discord discussion

commented

Can those new mining tags be extended to shears or swords? I only found ones for axe, pickaxe, hoe and shovel.