I have just started to learn to mod from reading a book, and have come up to registering items. This is my code:
package com.mrfiretruck.extramoddedminecraft;
import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.enchantment.Enchantment;
@Mod(modid = ExtraModdedMinecraft.MODID, version = ExtraModdedMinecraft.VERSION)
public class ExtraModdedMinecraft
{
public static final String MODID = "mrfiretruck_extramoddedminecraft";
public static final String VERSION = "1.0";
public static Item ruby;
@EventHandler
public void preInit(FMLInitializationEvent event)
{
//Item init
ruby = new ItemRuby();
//Item Registry
GameRegistry.registerItem(ruby, "Ruby");
}
public void init(FMLInitializationEvent event)
{
}
}
I have been getting an error under registerItem saying "The method registerItem(Item, String) is undefined for the type GameRegistry". What code should I use otherwise? Every book or video I see uses that method without errors. Help D:
diesieben07 already linked you Forge's documentation here, which explains how to register Blocks, Items and other IForgeRegistryEntry implementations.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
How can you be so confused? Everything is explained in that documentation you were linked. It even tells you the old way if you really can't figure out how to register during the events.
Are you using "Sams Teach Yourself Minecraft Mod Development in 24 Hours"???
That's what I used to begin learning minecraft modding, and halfway through the book I realized that this was terribly outdated.
If you are using that book and using a newer version of Minecraft then, well, stop using the book, or switch to the minecraft version that the book uses.
I will tell you that there was a big change in the code for registering an item in between 1.7.10 and 1.8, and in my opinion, it made it ten times harder, but you can still figure it out.
I'm pretty sure that 1.11 works almost the same way as 1.10 when it comes to registering items.
First of all you need to use
GameRegistry.register(item, "itemname");
to register the item.
You also need a custom json model to render the texture for the item.
This may sound a little confusing, but it's explained very well in this tutorial.
Also this may help someone in the future looking at this thread:
When I was adding the JSON model for my items, I never actually added the "src/main/resources" as a source path in eclipse. It should have a special symbol and look the same as the "src/main/java" path.
I have just started to learn to mod from reading a book, and have come up to registering items. This is my code:
I have been getting an error under registerItem saying "The method registerItem(Item, String) is undefined for the type GameRegistry". What code should I use otherwise? Every book or video I see uses that method without errors. Help D:
wutes uop m9 haven e grext deey?
diesieben07 already linked you Forge's documentation here, which explains how to register Blocks, Items and other IForgeRegistryEntry implementations.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I canttt see howw toooooooo ;-;
wutes uop m9 haven e grext deey?
How can you be so confused? Everything is explained in that documentation you were linked. It even tells you the old way if you really can't figure out how to register during the events.
Hehehehehehe...
Are you using "Sams Teach Yourself Minecraft Mod Development in 24 Hours"???
That's what I used to begin learning minecraft modding, and halfway through the book I realized that this was terribly outdated.
If you are using that book and using a newer version of Minecraft then, well, stop using the book, or switch to the minecraft version that the book uses.
I will tell you that there was a big change in the code for registering an item in between 1.7.10 and 1.8, and in my opinion, it made it ten times harder, but you can still figure it out.
I'm pretty sure that 1.11 works almost the same way as 1.10 when it comes to registering items.
First of all you need to use
to register the item.
You also need a custom json model to render the texture for the item.
This may sound a little confusing, but it's explained very well in this tutorial.
Also this may help someone in the future looking at this thread:
When I was adding the JSON model for my items, I never actually added the "src/main/resources" as a source path in eclipse. It should have a special symbol and look the same as the "src/main/java" path.