|This Article is up to date with Custom Stuff 2|
The harvestBlocks attribute is typically only used for Tools. The harvestBlocks attribute adds to the list of blocks that can be harvested (will drop things upon being broken) by the tool, beyond those related to its toolClass attribute. These behaviors, as the names would suggest, mimic the behaviors of vanilla pickaxes.
Most of what this attribute does is done by the toolClass and harvestLevel attributes, and these should be set prior to using this attribute. Instead, think of harvestBlocks as an extension of this functionality, rather than being the primary provider of it.
Instead of being the broad stroke categories of its sister attributes, harvestBlocks allows you to specify specific block IDs that you desire your tool to be able to harvest regardless of its other attributes.
For example, if you are creating a pickaxe and want it to be able to harvest obsidian, you would add the following line to your item's .js file:
If you wanted this pick to also be able to harvest glass and glass panes, in addition to obsidian, you would specify all three values like so:
harvestBlocks="49, 20, 102";
This allows the pick to break glass and pick it up afterwards. Note that this is not the same as the Silk Touch enchantment in that it will only cause a block to drop its primary drop. In the case of ores, this will be the item instead of the ore block.
The harvestblocks attribute is typically only used for Tools. The harvestblocks attribute adds to the list of blocks that can be harvested (will drop things upon being broken) by the tool, beyond those related to its toolclass attribute. These behaviors, as the names would suggest, mimic the behaviors of vanilla pickaxes. If you would like to setup this attribute, add the following line to your .item file:
The valid strings that you can use to replace "all" in that line are:
- (Any block ID)
This attribute has been largely outmoded by the inclusion of the harvestlevel and toolclass attributes. When first added, it was designed for an ore-centric system that would allow a custom tool to mimic the behavior of vanilla pickaxes. With the inclusion of the two attributes mentioned above, the four main options of the tool are now redundant, meaning its best use is to add either 'all' blocks to the tool's harvest list, or to specify specific block IDs to be added beyond what is normal. Custom made shovels and axes will generally use the 'default' value since there's nothing that you can harvest with them that you can't also harvest with your bare hands.
To add a similar function on a block, defining which tools can harvest it, you'll need to specify both harvestlevel and toolclass on the block.