tinycodinglm / mc /mc-0045.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
2.1 kB
opencode trace
System You are an expert Fabric mod developer. You write idiomatic Minecraft Fabric mods using Java, Fabric API, and Yarn mappings.

You are an expert Fabric mod developer. You write idiomatic Minecraft Fabric mods using Java, Fabric API, and Yarn mappings.

User

How do I create custom tool materials and armor materials in Fabric?

Assistant
java
package com.example.mymod;

import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ToolMaterial;
import net.minecraft.recipe.Ingredient;
import net.minecraft.sound.SoundEvents;

public class MyToolMaterials {
    public static final ToolMaterial CUSTOM_TOOL = new ToolMaterial(
        4, 1500, 8.0f, 4.0f, 15
    );

    public static final ToolItem CUSTOM_PICKAXE = new PickaxeItem(
        CUSTOM_TOOL,
        new Item.Settings().attributeModifiers(PickaxeItem.createAttributeModifiers(CUSTOM_TOOL, 1, -2.8f))
    );

    public static final ToolItem CUSTOM_AXE = new AxeItem(
        CUSTOM_TOOL,
        new Item.Settings().attributeModifiers(AxeItem.createAttributeModifiers(CUSTOM_TOOL, 5.0f, -3.0f))
    );

    public static final ToolItem CUSTOM_SWORD = new SwordItem(
        CUSTOM_TOOL,
        new Item.Settings().attributeModifiers(SwordItem.createAttributeModifiers(CUSTOM_TOOL, 3, -2.4f))
    );

    public static final ArmorMaterial CUSTOM_ARMOR = new ArmorMaterial(
        15, 0.8f, 18, SoundEvents.ITEM_ARMOR_EQUIP_NETHERITE,
        3.0f, 0.1f, Ingredient.ofItems(MyItems.CUSTOM_INGOT)
    );

    public static final ArmorItem CUSTOM_HELMET = new ArmorItem(
        CUSTOM_ARMOR, ArmorItem.Type.HELMET,
        new Item.Settings().maxDamage(ArmorItem.Type.HELMET.getMaxDamage(15))
    );

    public static final ArmorItem CUSTOM_CHESTPLATE = new ArmorItem(
        CUSTOM_ARMOR, ArmorItem.Type.CHESTPLATE,
        new Item.Settings().maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(15))
    );
}