🇬🇧 English
🇬🇧 English
Appearance
🇬🇧 English
🇬🇧 English
Appearance
This page is written for version:
1.21.4
This page is written for version:
1.21.4
Tools are essential for survival and progression, allowing players to gather resources, construct buildings, and defend themselves.
You can create a tool material by instantiating a new ToolMaterial
object and storing it in a field that can be used later to create the tool items that use the material.
public static final ToolMaterial GUIDITE_TOOL_MATERIAL = new ToolMaterial(
BlockTags.INCORRECT_FOR_WOODEN_TOOL,
455,
5.0F,
1.5F,
22,
GuiditeArmorMaterial.REPAIRS_GUIDITE_ARMOR
);
The ToolMaterial
constructor accepts the following parameters, in this specific order:
Parameter | Description |
---|---|
incorrectBlocksForDrops | If a block is in the incorrectBlocksForDrops tag, it means that when you use a tool made from this ToolMaterial on that block, the block will not drop any items. |
durability | The durability of all tools that are of this ToolMaterial . |
speed | The mining speed of the tools that are of this ToolMaterial . |
attackDamageBonus | The additional attack damage of the tools that are of this ToolMaterial will have. |
enchantmentValue | The "Enchantability" of tools which are of this ToolMaterial . |
repairItems | Any items within this tag can be used to repair tools of this ToolMaterial in an anvil. |
If you're struggling to determine balanced values for any of the numerical parameters, you should consider looking at the vanilla tool material constants, such as ToolMaterial.STONE
or ToolMaterial.DIAMOND
.
Using the same utility function as in the Creating Your First Item guide, you can create your tool items:
public static final RegistryKey<Item> GUIDITE_SWORD_KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(FabricDocsReference.MOD_ID, "guidite_sword"));
public static final Item GUIDITE_SWORD = register(new SwordItem(GUIDITE_TOOL_MATERIAL, 1f, 1f, new Item.Settings().registryKey(GUIDITE_SWORD_KEY)), GUIDITE_SWORD_KEY);
The two float values (1f, 1f
) refer to the attack damage of the tool and the attack speed of the tool respectively.
Remember to add them to an item group if you want to access them from the creative inventory!
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS)
.register((itemGroup) -> itemGroup.add(ModItems.GUIDITE_SWORD));
You will also have to add a texture, item translation and item model. However, for the item model, you'll want to use the item/handheld
model as your parent instead of the usual item/generated
.
For this example, I will be using the following model and texture for the "Guidite Sword" item:
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "fabric-docs-reference:item/guidite_sword"
}
}
That's pretty much it! If you go in-game you should see your tool item(s) in the tools tab of the creative inventory menu.