Jump to content

Recommended Posts

Posted

I only started coding a few days ago, so I am fairly new. I have been learning of a book, and came across an error in eclipse when trying to register an Item: 

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)
    {
        
    }
}

under registerItem is an error saying "The method registerItem(Item, String) is undefined for the type GameRegistry"

How do i fix this? I tried running the game and it just crashed rip

Posted (edited)

Im fairly new, and that seems to be a bit complicated. The book said I should use GameRegistry.registerItem, is it a change in the newer versions of forge? And do you know what exact code i should use? All videos and books i see seem to have GameRegistry.registerItem and it doesnt work ;-; help me pls

Edited by MrFiretruck
Posted
11 hours ago, MrFiretruck said:

I'm fairly new, and that seems to be a bit complicated.

I suggest that you explore the features of Eclipse to see what it can do for you (the web has tutorials). When you discover the many ways to select elements of code and jump to them, try them out on all the vanilla Minecraft elements you can, starting with GameRegistry. Look through it to see what public methods exist for registering items.

 

After sufficient explorations, that will no longer seem to be a bit complicated.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted (edited)
13 hours ago, jeffryfisher said:

I suggest that you explore the features of Eclipse to see what it can do for you (the web has tutorials). When you discover the many ways to select elements of code and jump to them, try them out on all the vanilla Minecraft elements you can, starting with GameRegistry. Look through it to see what public methods exist for registering items.

 

After sufficient explorations, that will no longer seem to be a bit complicated.

I looked through GameRegistry, and I can't figure out much that will register items. Can you help?

Edited by MrFiretruck
Posted

Hmm. Let me see here...

Quote

Forge uses registries with ResourceLocation keys to register objects, which are of type IForgeRegistryEntry

Quote

E.g. there’s a registry for Blocks, and a registry for Items

 

Can you find anything that uses IForgeRegistryEntry instead?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
On 5/3/2017 at 11:19 PM, diesieben07 said:

Did you even read the "Registering Things" section?

Sorry, I had an extension that was blocking certain parts. Thanks for your help.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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