I tried to add an item to my minecraft mod following this tutorial: https://www.youtube.com/watch?v=_JZ7bnk3oiM. The code is this:
public class ProvaMod implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("modid");
public static final Item IDK_IDK = new Item(new Item.Settings().group(ItemGroup.MISC));
@Override
public void onInitialize() {
Registry.register(Registry.ITEM, new Identifier("provamod", "idk_idk"), IDK_IDK);
}
}
It Underlines red MISC (Line 7) and ITEM(Line 11) and gives this errors:
MISC cannot be resolved or is not a field
ITEM cannot be resolved or is not a field
In 1.19.3 Registry must be replaced with Registries. The code is:
public class ProvaMod implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("modid");
public static final Item Sapphire =Registry.register(Registries.ITEM, new Identifier("provamod","sapphire"), new Item(new FabricItemSettings()));
@Override
public void onInitialize() {
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register(itemGroup -> itemGroup.add(Sapphire) );
}
}