Jump to content

Recommended Posts

Posted

Hey everyone, I have a problem with my mod. My tools aren't working, every time I start minecraft it crashes:

 

  Reveal hidden contents

 

 

Here I have the ModItemSword File:

 

  Reveal hidden contents

 

 

And here is the ModItems File:

 

  Reveal hidden contents

 

 

I hope someone can help me.

Posted

 

here it is:

 

package Launcraft.src;

 

import net.minecraftforge.common.EnumHelper;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.EnumArmorMaterial;

import net.minecraft.item.ItemStack;

 

public class ModEnumMaterial

{

    public static EnumToolMaterial COPPER;

public static EnumToolMaterial SILVER;

public static EnumToolMaterial GEMSTONE;

 

public static EnumArmorMaterial COPPERARMOR;

public static EnumArmorMaterial SILVERARMOR;

public static EnumArmorMaterial GEMSTONEARMOR;

   

    public static void initModEnumMaterial()

    {

COPPER = EnumHelper.addToolMaterial("COPPER", 2, 200, 4.0f, 5, 15);

SILVER = EnumHelper.addToolMaterial("SILVER", 2, 400, 5.0f, 6, 18);

GEMSTONE = EnumHelper.addToolMaterial("GEMSTONE", 2, 1500, 7.0f, 8, 22);

 

COPPERARMOR = EnumHelper.addArmorMaterial("COPPERARMOR", 12, new int[]{2, 5, 4, 1}, 12);

SILVERARMOR = EnumHelper.addArmorMaterial("SILVERARMOR", 18, new int[]{3, 7, 5, 2}, 12);

GEMSTONEARMOR = EnumHelper.addArmorMaterial("GEMSTONEARMOR", 30, new int[]{3, 8, 6, 3}, 25);

    }

}

Posted

Ahh I see, I think you just have to rename 'public static void initModEnumMaterial()' to 'public ModEnumMaterial()' since I think the reason that it crashes is that initModEnumMaterial() not gets called before there's a call to the ModItems class cousing it to not get assigned and couse a null pointer exception. Try it :)

Posted

I tried it but I get an error because I have to load it in the main File. But how can I make that? It has no init.

 

sorry if that question is dumb but I'm actually not very good with java.

Posted

You're doing it the hard way, just use enum helper to register a new enum(in 1 line of code) in your mod files init

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

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.