Jump to content

[1.8] Problems using world.setBlockState with Custom Blocks


Midbin

Recommended Posts

As stated in the title the world.setBlockState() does not work for me with my custom Block. Here is a code extract:

IBlockState crafting_table_state = Blocks.crafting_table.getDefaultState();

    	MyCustomBlock c = new MyCustomBlock();
    	IBlockState my_custom_block_state = c.getDefaultState();

    	world.setBlockState(new BlockPos(1, 128, 1), my_custom_block_state);
    	world.setBlockState(new BlockPos(2, 128, 1), crafting_table_state);

 

When I look at the Point (1, 128, 1), I can see the Crafting Table, but not my Custom Block.

I have already checked, that the IBlockState.getBlock() returns a MyCustomBlock.

When I place my Block from my Inventory it Renders normal.

Has somebody an idea how I could find the error?

Link to comment
Share on other sites

Hi

 

MyCustomBlock c = new MyCustomBlock();

 

That's not how Blocks are used - you don't create a new instance of your block every time you place it.  Instead, you create an instance once, during preInit(), and register it with Forge.

 

It's probably worth reading a few of the introductory tutorials on modding.

This is one, there are lots of others.  Wuppy29 has some good ones.

 

http://greyminecraftcoder.blogspot.com.au/2013/10/the-most-important-minecraft-classes_9.html

and

http://greyminecraftcoder.blogspot.co.at/2014/12/blocks-18.html

 

-TGG

 

Link to comment
Share on other sites

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.