#Can anyone help me?

2 messages · Page 1 of 1 (latest)

radiant gyro
#

import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public final class CustomTab {

    // Define the custom item group
    public static final ItemGroup GHOST_GROUP = FabricItemGroup.builder()
            .icon(() -> new ItemStack(Items.BARRIER))
            .displayName(Text.translatable("itemGroup.ghost.op_items"))
            .entries((context, entries) -> {
                // Create a list of ItemStacks with NBT data and add them to the item group

                // Example Item 1: Enchanted Diamond Sword
                ItemStack enchantedSword = new ItemStack(Items.DIAMOND_SWORD);
                NbtCompound swordNbt = enchantedSword.getOrCreateNbt();
                swordNbt.putString("Enchantments", "[{id:\"minecraft:sharpness\",lvl:5}]");
                enchantedSword.setNbt(swordNbt);
                entries.add(enchantedSword);

                // Example Item 2: Custom Named Golden Apple
                ItemStack customGoldenApple = new ItemStack(Items.GOLDEN_APPLE);
                NbtCompound appleNbt = customGoldenApple.getOrCreateNbt();
                NbtCompound displayTag = new NbtCompound();
                displayTag.putString("Name", "{\"text\":\"Ghostly Apple\",\"color\":\"gold\"}");
                appleNbt.put("display", displayTag);
                entries.add(customGoldenApple);

                // Example Item 3: Custom Potion
                ItemStack customPotion = new ItemStack(Items.POTION);
                NbtCompound potionNbt = customPotion.getOrCreateNbt();
                potionNbt.putString("Potion", "minecraft:strong_healing");
                entries.add(customPotion);
            })
            .build();

    // Method to initialize and register the item group
    public static void initialize() {
        Registry.register(Registries.ITEM_GROUP, Identifier.of("ghost", "ghost_group"), GHOST_GROUP);
    }
}
``` can anyone fix this
pine skiff
#

item nbt was replaced with components