MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a tool"
/* To create a custom tool in Minecraft Forge, first extend one of the existing tool classes (e.g., PickaxeItem, AxeItem, ShovelItem, or HoeItem) and then register the tool in your mod's item registry. Here's an example of creating a custom pickaxe: */ public class CustomPickaxe extends PickaxeItem { public CustomPickaxe(ToolMaterial material, int attackDamage, float attackSpeed, Item.Properties properties) { super(material, attackDamage, attackSpeed, properties); } } /* Now, register the custom pickaxe in your mod's item registry: */ public static final RegistryObject<Item> CUSTOM_PICKAXE = ITEMS.register("custom_pickaxe", () -> new CustomPickaxe(ModToolMaterials.CUSTOM_MATERIAL, 1, -2.8F, new Item.Properties().tab(ItemGroup.TAB_TOOLS))); /* Don't forget to create a custom ToolMaterial (e.g., ModToolMaterials.CUSTOM_MATERIAL) for your custom tool. Here's an example: */ public enum ModToolMaterials implements ToolMaterial { CUSTOM_MATERIAL(3, 2000, 12.0F, 5.0F, 22, () -> { return Ingredient.of(Items.DIAMOND); }); private final int level; private final int uses; private final float speed; private final float damage; private final int enchantmentValue; private final LazyValue<Ingredient> repairIngredient; ModToolMaterials(int level, int uses, float speed, float damage, int enchantmentValue, Supplier<Ingredient> repairIngredient) { this.level = level; this.uses = uses; this.speed = speed; this.damage = damage; this.enchantmentValue = enchantmentValue; this.repairIngredient = new LazyValue<>(repairIngredient); } @Override public int getUses() { return uses; } @Override public float getSpeed() { return speed; } @Override public float getAttackDamageBonus() { return damage; } @Override public int getLevel() { return level; } @Override public int getEnchantmentValue() { return enchantmentValue; } @Override public Ingredient getRepairIngredient() { return repairIngredient.get(); } }