Jump to content

[SOLVED][1.8] setBlockState() seems to regenerate tile entities


jabelar

Recommended Posts

Okay, I have a custom crop that I do something special when it finishes growing.  So in 1.7.10 I had a tile entity associated with the block and the tile entity checked for finished growing and performed the code.

 

The problem I'm having in 1.8 is that in the grow() method of my crop block class I use the setBlockState() method to update the growth.  This is copied from the vanilla BlockCrop.  However, I noticed that the tile entity gets recreated every time the setBlockState() method is called.  This is a problem since I have other fields in the tile entity that are supposed to be preserved over time.

 

I am determining that it is recreating a tile entity by putting a console statement in the createTileEntity() method in my block class.

 

The weird thing is that the Block code seems to be correct -- it checks for a TileEntity before creating it:

                if (block.hasTileEntity(p_177436_2_))
                {
                    tileentity = this.func_177424_a(p_177436_1_, Chunk.EnumCreateEntityType.CHECK);

                    if (tileentity == null)
                    {
                        tileentity = block.createTileEntity(this.worldObj, p_177436_2_);
                        this.worldObj.setTileEntity(p_177436_1_, tileentity);
                    }

                    if (tileentity != null)
                    {
                        tileentity.updateContainingBlockInfo();
                    }
                }

 

So my question is -- how can you change a block's state without regenerating the tile entity?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.