Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I created an item "Copper Ingot" whose tag is "forge:ingots/copper". I made a constant which contains that tag.

public final class ForgeItemTags
{
	public static final Tag<Item> COPPER_INGOT = ItemTags.getCollection().getOrCreate(new ResourceLocation("forge", "ingots/copper"));
	
	private ForgeItemTags() {}
}

And I used Ingredient.fromTag() method to set all copper ingots, including my copper ingot, to be repair materials of copper tools.

public enum BiomeOreItemTier implements IItemTier
{
	COPPER(2, 223, 5.7F, 2.0F, 15, Ingredient.fromTag(ForgeItemTags.COPPER_INGOT));
	
	private final int harvestLevel;
	private final int maxUses;
	private final float efficiency;
	private final float attackDamage;
	private final int enchantability;
	private final Ingredient repairMaterial;
	
	BiomeOreItemTier(int harvestLevel, int maxUses, float efficiency, float attackDamage, int enchantability, Ingredient repairMaterial)
	{
		this.harvestLevel = harvestLevel;
		this.maxUses = maxUses;
		this.efficiency = efficiency;
		this.attackDamage = attackDamage;
		this.enchantability = enchantability;
		this.repairMaterial = repairMaterial;
	}
	
	/...
}

Then I used the COPPER ItemTier to make my copper sword.

public static final Item COPPER_SWORD = register("copper_sword", new SwordItem(BiomeOreItemTier.COPPER, 3, -2.4F, new Item.Properties().group(BiomeOreItemGroup.BIOME_ORE_TOOL)));

But in the game, I cannot repair my sword using my copper ingot. I can't figure out what is wrong with my codes. When I printed the item tag of my copper ingot using onItemRightClick() method in Item class the ingot had the tag "forge:ingots/copper". But it cannot repair my copper tools. How can I fix it?

while you created the tag, the tag is not filled with anything. For that you must create this json "resources/forge/tags/items/ingots/copper.json" and fill it with

{
  "replace": false,
  "values": [
    "modid:yourCopperIngot"
  ]
}

 

Edited by cheaterpaul

  • Author
58 minutes ago, cheaterpaul said:

while you created the tag, the tag is not filled with anything. For that you must create this json "resources/forge/tags/items/ingots/copper.json" and fill it with


{
  "replace": false,
  "values": [
    "modid:yourCopperIngot"
  ]
}

 

Of course I made that file, but it didn't work.

while i cant see your whole code, this works for me:

package com.example.examplemod;
*imports
@Mod("examplemod")
public class ExampleMod
{
    public static Tag<Item> coppertag = new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/copper"));
    public ExampleMod() {
    }
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
        @SubscribeEvent
        public static void onItemRegistry(final RegistryEvent.Register<Item> blockRegistryEvent) {
            blockRegistryEvent.getRegistry().register(new Item(new Item.Properties().group(ItemGroup.BREWING)).setRegistryName("examplemod:copper"));
            blockRegistryEvent.getRegistry().register(new SwordItem(new Tier(),4,1,new Item.Properties().group(ItemGroup.BREWING)).setRegistryName("examplemod:coppersword"));
        }
    }

    public static class Tier implements IItemTier{
        @Override
        public int getMaxUses() {
            return 100;
        }

        @Override
        public float getEfficiency() {
            return 4;
        }

        @Override
        public float getAttackDamage() {
            return 2;
        }

        @Override
        public int getHarvestLevel() {
            return 1;
        }

        @Override
        public int getEnchantability() {
            return 50;
        }

        @Override
        public Ingredient getRepairMaterial() {
            return Ingredient.fromTag(coppertag);
        }

        public Tier() {
        }
    }
}

 but i think the problem is that you need

public static final Tag<Item> COPPER_INGOT = new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/copper"));

not

public static final Tag<Item> COPPER_INGOT = ItemTags.getCollection().getOrCreate(new ResourceLocation("forge", "ingots/copper"));

 

otherwise your copper.json is in a wrong directory

Edited by cheaterpaul

  • Author
43 minutes ago, cheaterpaul said:

while i cant see your whole code, this works for me:


package com.example.examplemod;
*imports
@Mod("examplemod")
public class ExampleMod
{
    public static Tag<Item> coppertag = new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/copper"));
    public ExampleMod() {
    }
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
        @SubscribeEvent
        public static void onItemRegistry(final RegistryEvent.Register<Item> blockRegistryEvent) {
            blockRegistryEvent.getRegistry().register(new Item(new Item.Properties().group(ItemGroup.BREWING)).setRegistryName("examplemod:copper"));
            blockRegistryEvent.getRegistry().register(new SwordItem(new Tier(),4,1,new Item.Properties().group(ItemGroup.BREWING)).setRegistryName("examplemod:coppersword"));
        }
    }

    public static class Tier implements IItemTier{
        @Override
        public int getMaxUses() {
            return 100;
        }

        @Override
        public float getEfficiency() {
            return 4;
        }

        @Override
        public float getAttackDamage() {
            return 2;
        }

        @Override
        public int getHarvestLevel() {
            return 1;
        }

        @Override
        public int getEnchantability() {
            return 50;
        }

        @Override
        public Ingredient getRepairMaterial() {
            return Ingredient.fromTag(coppertag);
        }

        public Tier() {
        }
    }
}

 but i think the problem is that you need


public static final Tag<Item> COPPER_INGOT = new ItemTags.Wrapper(new ResourceLocation("forge", "ingots/copper"));

not


public static final Tag<Item> COPPER_INGOT = ItemTags.getCollection().getOrCreate(new ResourceLocation("forge", "ingots/copper"));

 

otherwise your copper.json is in a wrong directory

It finally works! Thank you very much.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.