Jump to content

Recommended Posts

Posted

 

 

Sorry for my bad english

I had a problem.

Here's the source code (Api Forge 1.8): http://vk.com/doc314307403_413247164

If you delete the line CreateItem(...) at CreateSword() and add GameRegistry.registerItem(...) everything works.

And if you remove the rendering, it all works.

This log(error information I've highlighted in bold):

 

  Reveal hidden contents

 

Posted

I did download it though to see what you are doing and you are going at it all wrong in your client proxy class.

 

public class Client extends Common
{
    
    @Override
    public void preInit(FMLPreInitializationEvent event)
    {
        super.preInit(event);


        RenderItem.preInit();
     }
   
    @Override
    public void init(FMLInitializationEvent event)
    {
        super.init(event);
        BasicSword.RenderSword();
    }
    
    @Override 
    public void postInit(FMLPostInitializationEvent event)
    {
        super.postInit(event);    
    }
}

 

@Override

    public void preInit(FMLPreInitializationEvent event)

    {

        super.preInit(event);

 

      [glow=red,2,300] //you need to register item first here not in your Item class[/glow]

 

        RenderItem.preInit();

    }

 

There is plenty more issues that I have noticed at least from how I code. If you register the item in your client proxy before you do your rendering it should fix your null pointer problem. 

~SureShotM/Leo~ gaming coding all around fun!

Posted

This?

public void preInit(FMLPreInitializationEvent event)
    {
        super.preInit(event);
         
        RenderItem.preInit();
        BasicSword.CreateSword();
     }

, after delete BasicSword.CreateSword() in Common.java due to an error 

Not work :( (

Posted
  On 8/19/2015 at 12:16 AM, Qunergy said:

This?

public void preInit(FMLPreInitializationEvent event)
    {
        super.preInit(event);
         
        RenderItem.preInit();
        BasicSword.CreateSword();
     }

, after delete BasicSword.CreateSword() in Common.java due to an error 

Not work :( (

 

No not like that.

 

public void preInit(FMLPreInitializationEvent event)
    {
        super.preInit(event);
         
        GameRegistry.registerItem(yourItem, nameOfItemasString);
        RenderItem.preInit();
     }

 

You need to register the item before it can render.

I suggest if you know java to look for some tutorials, if you do not know java I suggest you learn java.

My other tip to you is to look at github to see how other moders set up there environments since each one has different ways.

~SureShotM/Leo~ gaming coding all around fun!

Posted

I did so, but I do not like.

Why is the method through the function will not work? I have noticed that even if the write

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(BasicSword.wood_stone_sword, 0, new ModelResourceLocation(Core.MODID + ":" + BasicSword.wood_stone_sword.getUnlocalizedName().substring(5), "inventory"))  then it just is not working. Why? oO

Posted

I do not use that at all and will not be able to help, but so the others can help you more then I can, here is his code.

 

ItemClass:

 

  Reveal hidden contents

 

 

Client Proxy:

 

  Reveal hidden contents

 

 

Register Item class:

 

  Reveal hidden contents

 

 

Render Item class:

 

  Reveal hidden contents

 

 

I understood what the null pointer was but the rest is confusing me.

~SureShotM/Leo~ gaming coding all around fun!

Posted

Where's the main class? Is anything actually calling proxy.preinit(...) so that the registration happens?

 

As usual for such threads, I recommend setting a break point ahead of the crash (and maybe ahead of your entire mod's construction) and re-running in the debugger so you can walk through everything you *think* it is doing. When your program does something unexpected (or skips something critical), it's usually painfully obvious and easy to fix.

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.

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.

×
×
  • Create New...

Important Information

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