#Help Making Armor And Weapons Work

7 messages · Page 1 of 1 (latest)

meager vortex
#
package com.vyronyx.reforge.Item;

import com.vyronyx.reforge.Reforge;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.item.*;
import net.minecraft.item.equipment.EquipmentType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
#

import java.util.Map;
import java.util.function.Function;

public class RegisterItems {
    public static final RegistryKey<ItemGroup> CUSTOM_ITEM_GROUP_KEY = RegistryKey.of(Registries.ITEM_GROUP.getKey(), Identifier.of(Reforge.MOD_ID, "item_group"));
    public static final ItemGroup CUSTOM_ITEM_GROUP = FabricItemGroup.builder()
            .icon(() -> new ItemStack(RegisterItems.Blood_Token))
            .displayName(Text.translatable("Reforge"))
            .build();

    public static Item register(String name, Function<Item.Settings, Item> itemFactory, Item.Settings settings) {
        RegistryKey<Item> itemKey = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(Reforge.MOD_ID, name));
        Item item = itemFactory.apply(settings.registryKey(itemKey));
        Registry.register(Registries.ITEM, itemKey, item);
        return item;
    }

    public static void initialize() {
        Registry.register(Registries.ITEM_GROUP, CUSTOM_ITEM_GROUP_KEY, CUSTOM_ITEM_GROUP);

        ItemGroupEvents.modifyEntriesEvent(CUSTOM_ITEM_GROUP_KEY).register(itemGroup -> {

            itemGroup.add(RegisterItems.Heart);

            itemGroup.add(RegisterItems.Blood_Shard);
            itemGroup.add(RegisterItems.Blood_Token);
            itemGroup.add(RegisterItems.Blood_Ingot);

            itemGroup.add(RegisterItems.Blood_Axe);
            itemGroup.add(RegisterItems.Blood_Sword);

            itemGroup.add(RegisterItems.Blood_Helmet);
            itemGroup.add(RegisterItems.Blood_Chestplate);
            itemGroup.add(RegisterItems.Blood_Leggings);
            itemGroup.add(RegisterItems.Blood_Boots);

        });
    }

    
#
public static final Item Heart = register("heart", Item::new, new Item.Settings());

    public static final Item Blood_Shard = register("blood_shard", Item::new, new Item.Settings());
    public static final Item Blood_Token = register("blood_token", Item::new, new Item.Settings());
    public static final Item Blood_Ingot = register("blood_ingot", Item::new, new Item.Settings());

    public static final Item Blood_Sword = register("blood_sword", Item::new, new Item.Settings());
    public static final Item Blood_Axe = register("blood_axe", Item::new, new Item.Settings());

    public static final Item Blood_Helmet = register("blood_helmet", Item::new, new Item.Settings());
    public static final Item Blood_Chestplate = register("blood_chestplate", Item::new, new Item.Settings());
    public static final Item Blood_Leggings = register("blood_leggings", Item::new, new Item.Settings());
    public static final Item Blood_Boots = register("blood_boots", Item::new, new Item.Settings());


}
zealous spear
#

changes depending on the version you are working for
that code looks 1.21.5 you have to check the Items.class

public static final Item Blood_Sword = register("blood_sword", Item::new, 

(new Item.Settings()).sword(ToolMaterial.IRON, 3.0F, -2.4F)
);

public static final Item Blood_Helmet = register("blood_helmet", Item::new, 

(new Item.Settings()).armor(ArmorMaterials.IRON, EquipmentType.HELMET))
);

meager vortex
#

how do i make custom material @zealous spear

zealous spear
#

have not yet fix that part for mi own things
threes no need to register the custom materials class or specific location.name for it

you just copy the ToolMaterial.class to your folders rename to something like ModMaterial.class inside the class copy paste to make your own materials
the thing i haven't fixed yet is how to add a custom item as repair material

STEEL = new net.minecraft.item.ToolMaterial(BlockTags.INCORRECT_FOR_IRON_TOOL, 750, 6.0F, 2.0F, 14, ItemTags.IRON_TOOL_MATERIALS);

how do i replace the ItemTags.IRON_TOOL_MATERIALS for this to accept mi custom steel_ingot as repair material in the anvil ?

meager vortex
#

well i like want a custom armor and not the iron armor if you get what im saying