Jump to content

[SOLVED][1.8]world.setBlockState and tile entity validation


decebaldecebal

Recommended Posts

Hello,

I recently began updating my mod for 1.8 and now I am trying to update my multiblock.It works perfectly except for one thing: if I try to change the state of the block in the world, the tile entity in that position in the world is going to change, and all that I modified in my initial tile entity will go to waste.I did try and validate the tile and then use world.setTileEntity to set the original tile back in the world but with no luck.

Here is the function that changes the block state.It worked perfectly in 1.7 and it is almost the same, except with setBlockState instead of setBlockMetadata.

 

public static void setState(boolean formed, World world, BlockPos pos, ACRTileE core)
{
	IBlockState state = world.getBlockState(pos);
        TileEntity tile = world.getTileEntity(pos);

        keepInv = true;

	if(formed)
	{
		world.setBlockState(pos, state.withProperty(FORMED, true), 2);
	}
	else
	{
		world.setBlockState(pos, state.withProperty(FORMED, false), 2);
	}

	keepInv = false;

        //world.setBlockState(pos, world.getBlockState(pos).withProperty(KEEPINV, false), 2);

        if (tile != null)
        {
        	tile.validate();
        	world.setTileEntity(pos, tile);
        	//((ACRTileE)tile).setCore(core);
        }
}

 

There are some comments because I tried puting the keepinv in a property (I did this with some other block) and I commented it here to see where the problem lies.If the lines that contain world.setBlockState are deleted or commented, the multiblock works PERFECTLY, but it doesn't change the texture which is to be expected...

 

I really do not know what is going on here and why the tile entity is different(which it is because I tested it with that core variable and set the core to the new tile entity after using world.setBlockState which kind of worked, but my core was now a tile entity that had no block associated to it because it didn't exist in the world anymore).

  • Like 1
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.