Jump to content

Recommended Posts

Posted

after following a few guides I have created a new block however when I craft it I get a crash, the crash report seems to point to the blocks meta data but I have no idea why.

 

Spawning the block in works fine, but has no texture when holding.

 

My Custom Block:

 

  Reveal hidden contents

 

 

My Main Class (where I register)

 

  Reveal hidden contents

 

 

blockstate > barkwall.json

 

  Reveal hidden contents

 

 

models > block > barkwall.json

 

  Reveal hidden contents

 

 

models > item > barkwall.json

 

  Reveal hidden contents

 

 

Crash Report

http://pastebin.com/BHmvLFYJ

Posted

You've created a recipe for an

ItemStack

with a

null

Item

. This is because you've registered your recipes before instantiating and registering your blocks.

 

You should instantiate and register your items and blocks in preInit (don't instantiate them in field initialisers) and then add recipes in init.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 10/4/2015 at 4:46 AM, Choonster said:

You've created a recipe for an

ItemStack

with a

null

Item

. This is because you've registered your recipes before instantiating and registering your blocks.

 

You should instantiate and register your items and blocks in preInit (don't instantiate them in field initialisers) and then add recipes in init.

 

Thanks! worked like a charm, does your second sentence mean that I should move my

public static Item sharpstick = new SharpStick(); etc.

into a method like I did with blocks and call that in preInit also?

 

PS: should I register the blocks in the constructor like I did in in items?

package statslevelmod;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class SharpStick extends Item {

private final String name = "sharpstick";

public SharpStick() {
	super();

	GameRegistry.registerItem(this, name);
	setCreativeTab(CreativeTabs.tabMisc);
	setUnlocalizedName(name);
	setMaxStackSize(64);
}
}

 

or is doing it in a method like in blocks is the ideal way to go? seems like what I have done with items and blocks are two different ways to do the same thing but how should I do it?

Posted
  On 10/4/2015 at 5:09 AM, statphantom said:

Thanks! worked like a charm, does your second sentence mean that I should move my

public static Item sharpstick = new SharpStick(); etc.

into a method like I did with blocks and call that in preInit also?

 

Yes. I'd recommend creating a separate class each for your blocks and items and using those classes to instantiate, register and store your

Block

/

Item

instances. You can see an example of what I'm talking about here.

 

  Quote

PS: should I register the blocks in the constructor like I did in in items?

...

or is doing it in a method like in blocks is the ideal way to go? seems like what I have done with items and blocks are two different ways to do the same thing but how should I do it?

 

You should keep the registration out of the constructor, that way you can more easily use the same class for multiple block/item types.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 10/4/2015 at 5:25 AM, statphantom said:

I still have no texture in the crafting table or in my hand :(

 

There should be some errors in the log telling you what went wrong.

 

The Grey Ghost has a guide to troubleshooting block and item rendering here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
  On 10/4/2015 at 8:24 AM, Choonster said:

  Quote

I still have no texture in the crafting table or in my hand :(

 

There should be some errors in the log telling you what went wrong.

 

The Grey Ghost has a guide to troubleshooting block and item rendering here.

 

Thanks, had no idea you had to render it as an item AND a block, the guide I followed skipped that step :P

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.