Whenever I run the client from vsc it crashes because it can't execute the entrypoint which is caused by it trying to register an item twice,
Caused by: java.lang.RuntimeException: Attempted to register ID ResourceKey[minecraft:item / cauldrons:gold-base] at different raw IDs (1100, 1102)! If you're trying to override an item, use .set(), not .register()!
and my code in the .java file is:
package net.cauldrons;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class cauldrons implements ModInitializer {
// bases
public static final Item GOLD_BASE = new Item(new FabricItemSettings().group(ItemGroup.BREWING));
public static final Item IRON_BASE = new Item(new FabricItemSettings().group(ItemGroup.BREWING));
public static final Item DIAMOND_BASE = new Item(new FabricItemSettings().group(ItemGroup.BREWING));
public static final Item NETHERITE_BASE = new Item(new FabricItemSettings().group(ItemGroup.BREWING));
@Override
public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier("cauldrons", "gold-base"), GOLD_BASE);
Registry.register(Registry.ITEM, new Identifier("cauldrons", "iron-base"), IRON_BASE);
Registry.register(Registry.ITEM, new Identifier("cauldrons", "gold-base"), DIAMOND_BASE);
Registry.register(Registry.ITEM, new Identifier("cauldrons", "iron-base"), NETHERITE_BASE);
}
}
Does anyone know what could be causing this?
You are trying to register cauldrons:gold-base
and cauldrons:iron-base
twice. What you are likely trying to do is register cauldrons:diamond_base
and cauldrons:netherite_base
, but it looks like you copy-pasted the registration without actually setting those values.
Fixed code:
@Override
public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier("cauldrons", "gold-base"), GOLD_BASE);
Registry.register(Registry.ITEM, new Identifier("cauldrons", "iron-base"), IRON_BASE);
Registry.register(Registry.ITEM, new Identifier("cauldrons", "diamond-base"), DIAMOND_BASE);
Registry.register(Registry.ITEM, new Identifier("cauldrons", "netherite-base"), NETHERITE_BASE);
}