ToolUtils

This nifty class will allow you to modify harvesting lists of various ItemTools: pickaxes, axes and shovels. It provides two static methods which you may call from your own mod:


 * CODE: SELECT ALL

where "Type" is one of the ToolUtils.Type.PICKAXE, ToolUtils.Type.AXE or ToolUtils.Type.SHOVEL

and


 * CODE: SELECT ALL

where "Harvester" is a basic interface through which you can provide an answer to the question if a tool can harvest some block, or not.

But I think it's much easier to understand by looking at examples. Here are the ones from the marble mod:


 * CODE: SELECT ALL

Here you can see how marble blocks are constructed and used in registerBlocks method, so that pickaxes will break less when applied vs. marble blocks. As for marbleHarvester class, here it goes:


 * CODE: SELECT ALL

As you can see, it checks if the current block is one of them marbles and then returns a definitive "true" if toolQuality >= 2 (i.e. iron tools or better), and definitive "false" if quality is lower. But if the current block isn't marble, then it returns DONT_KNOW, so that some other code (other mods or vanilla Minecraft) can decide what to do with other blocks.

So, why would you want to use it?

Mostly because it makes tool-adjusting mods compatible. Several mods can register their custom block harvesters, and they ALL will work well together! Just remember to return correct answer (DONT_KNOW if you don't want to mess with some block) in canHarvestBlock method so that other mods can apply their rules too.

To modders:

Code