Making Tools
Tools are simply an extension of the Item
class. All of the logic is handled directly through one class with the others just being helpers to specify an exact tool type. Their implementations rely mainly on extending a specific class, it's properties, and the use of a tier system.
Tier
To create any tool that does not derive from vanilla tiers, you will need your own implementation of Tier
. This is the basis of which all tool levels are created. If you would like to use a vanilla tier, then you should specify one of the enums within Tiers
.
Here are what each methods defines:
Method | Return Type | Description |
---|---|---|
getUses |
Integer |
The durability of all items in this tier. |
getSpeed |
Float |
The efficiency multiplier of all items in this tier. |
getAttackDamageBonus |
Float |
The base attack damage of all items in this tier. |
getLevel |
Integer |
The harvest level of this tier. Vanilla uses values 0-4. |
getEnchantmentValue |
Integer |
How enchantable an item of this tier is. |
getRepairIngredient |
Ingredient |
What ingredient can be used to repair this item. |
Important
DiggerItem
DiggerItem
is the base of which all tool items extend. You do not necessarily have to use this or any of its supertypes/subtypes. However, it is convenient if you are looking for standard behavior. The subtypes normally referenced are AxeItem
, HoeItem
, PickaxeItem
, ShovelItem
.
Each tool has four parameters: tier, attack damage, attack speed, and properties. Tiers and properties have already been explained in this and within the item docs. Attack damage specifies how much damage to do above the current base set for that specific tier. Attack speed specifies the speed modifier to apply to your current attack speed (the base attack speed for a player is 4.0D
).
DiggerItem
, there will be a fifth parameter which defines a tag of which blocks this item is effective on.Registering
A tool must be registered the same as an item. If using one of the subtypes of DiggerItem
, that is all that is required. If not, you will need to chain addToolType
onto your properties. This will take in a ToolType
and a harvest level. The type is held within ToolType
itself. The harvest level will be the value from your tier using Tier#getLevel
.
ToolType::get
. All strings passed in should have their modid appended to them to remove any conflict issues (e.g. examplemod_custom_tool_type
). If a standard implementation across mods is used for compatibility, no namespace is needed.