How to get the appropriate tool for mining a block?

KianFakheriAghdam

New member
Jan 4, 2024
2
0
1
There are both Block.isValidTool() & Block.isPreferredTool() but they tell you if the block will drop something if you mine it with that tool. I want to know which tool can be used to mine the block faster. For example for dirt, a shovel. For oak logs, an axe & for wool, shears.

I can use paperweight (NMS) but I would prefer not to. I've seen the following relating posts but they aren't what I want & Item.canDestroySpecialBlock() seems to no longer be a thing for 1.20.4:
 
Version Output
[21:30:41 INFO]: Checking version, please wait...
[21:30:41 INFO]: This server is running Paper version git-Paper-370 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 1fa48d1)
You are 11 version(s) behind
Download the new version at: https://papermc.io/downloads/paper

SkytAsul

New member
Dec 20, 2022
6
1
3
Bretagne, France
linktr.ee
I just checked the server code to understand how is it done, and internally it is checking the tags of the block for "mineable/pickaxe" or "mineable/shovel" etc.
You can find a list of block tags here: https://minecraft.wiki/w/Tag#Blocks
And the interesting classes were those: net.minecraft.world.item.DiggerItem (method isCorrectToolForDrops) and the constructor of net.minecraft.world.item.PickaxeItem.