Jump to content

Recommended Posts

Posted

In the mod I am creating, I am attempting to register a block. However, the game seems to crash now that I have attempted to do so. I have my code and an error message that seems to be useful to display.

 

Here they are:

 

 

 

The blocks are registered under preInit() in FirstMod.java and the class that makes the blocks (BlockMaker.java) and the class with the Block registering methods (MyBlocks.java) are in the init package.

 

 

What can I do to fix the crashing and be able to spawn in the block?

 

 

If you need any more information, I would be more than happy to share it.

 

[move]Thank you![/move]

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

Posted

In the mod I am creating, I am attempting to register a block. However, the game seems to crash now that I have attempted to do so. I have my code and an error message that seems to be useful to display.

 

Here they are:

 

 

 

The blocks are registered under preInit() in FirstMod.java and the class that makes the blocks (BlockMaker.java) and the class with the Block registering methods (MyBlocks.java) are in the init package.

 

 

What can I do to fix the crashing and be able to spawn in the block?

 

 

If you need any more information, I would be more than happy to share it.

 

[move]Thank you![/move]

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

Posted
Item item = Item.getItemFromBlock(block);

is returning null because you didn't register an ItemBlock for your block.  That no longer happens automatically.

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
Item item = Item.getItemFromBlock(block);

is returning null because you didn't register an ItemBlock for your block.  That no longer happens automatically.

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

Item item = Item.getItemFromBlock(block);

is returning null because you didn't register an ItemBlock for your block.  That no longer happens automatically.

 

I'm kinda confused here. I am not sure what an ItemBlock is or how it works. Does it have to do with a block .json? Could I get a small example?

 

My apologies  :-[

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

Posted

Item item = Item.getItemFromBlock(block);

is returning null because you didn't register an ItemBlock for your block.  That no longer happens automatically.

 

I'm kinda confused here. I am not sure what an ItemBlock is or how it works. Does it have to do with a block .json? Could I get a small example?

 

My apologies  :-[

"I'm not afraid of computers taking over the world. They're just sitting there. I can hit them with a two by four." - Thom Yorke

Posted

The class Block relates to blocks taking up space in the world. When a block breaks and drops something, the floater is an item (actually an ItemStack). If the item dropped  is the "block itself", then it is the ItemBlock derived from the block. The ItemBlock is also what appears in your hand and in inventory.

 

Almost every block has a related ItemBlock. Exceptions are things like flowing water and lava source blocks. If your block is something that can drop and be picked up, then it needs a related ItemBlock.

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

The class Block relates to blocks taking up space in the world. When a block breaks and drops something, the floater is an item (actually an ItemStack). If the item dropped  is the "block itself", then it is the ItemBlock derived from the block. The ItemBlock is also what appears in your hand and in inventory.

 

Almost every block has a related ItemBlock. Exceptions are things like flowing water and lava source blocks. If your block is something that can drop and be picked up, then it needs a related ItemBlock.

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

In Minecraft, blocks only exist in the world. In your inventory, everything is a

ItemStack

which contains an

Item

. When you register your block, you also need to register an

ItemBlock

, which is the in-inventory representation of your block, for your block. When you call

GameRegister.register

it only registers the block. To register an

ItemBlock

you'll need to use something like this:

 

GameRegistry.register(new ItemBlock(cheese_block).setRegistryName(cheese_block.getRegistryName()));

 

Also, you're registering

cheese_blockName

which is created in the

register

method but your using

MyBlocks.cheese_block

everywhere else.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Posted

In Minecraft, blocks only exist in the world. In your inventory, everything is a

ItemStack

which contains an

Item

. When you register your block, you also need to register an

ItemBlock

, which is the in-inventory representation of your block, for your block. When you call

GameRegister.register

it only registers the block. To register an

ItemBlock

you'll need to use something like this:

 

GameRegistry.register(new ItemBlock(cheese_block).setRegistryName(cheese_block.getRegistryName()));

 

Also, you're registering

cheese_blockName

which is created in the

register

method but your using

MyBlocks.cheese_block

everywhere else.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Posted

The class Block relates to blocks taking up space in the world. When a block breaks and drops something, the floater is an item (actually an ItemStack).

 

Actually an ItemEntity containing an ItemStack.

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

The class Block relates to blocks taking up space in the world. When a block breaks and drops something, the floater is an item (actually an ItemStack).

 

Actually an ItemEntity containing an ItemStack.

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.

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.