Jump to content

[1.9.4] Tile NBT


Recommended Posts

I'm trying to create a wrench function for my blocks. I'm trying to retrieve the tile's NBT via getTileData(). getTileData() always returns an empty tag. The tile retains the NBT data so long as the block is placed. I can verify this because the block is a solar panel that generates RF. It retains the RF data through logging out and restarting the client. I have implemented packet handling to send the server data to the client as well. Following are the relevant methods:



public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {

	TileEntitySolarPanel te = getTE(worldIn, pos);
	if (te != null) {
		if (!playerIn.isSneaking()) {
			if (worldIn.isRemote) {
				GuiHandler.launchGui(Globals.GUINUM_SOLARPANEL, playerIn, worldIn, pos.getX(), pos.getY(), pos.getZ());
		else {
			BlockUtils.wrenchBlock(worldIn, pos, state, te);
	return true;



private TileEntitySolarPanel getTE(World worldIn, BlockPos pos) {
	return (TileEntitySolarPanel) BlockUtils.getTE(worldIn, pos);



public static void wrenchBlock(World worldIn, BlockPos pos, IBlockState state, TileEntity te) {
	if (!worldIn.isRemote) {
		ItemStack blockStack = new ItemStack(Item.getItemFromBlock(worldIn.getBlockState(pos).getBlock()), 1);

		if (te.getBlockMetadata() > 0) {
		if (te.getTileData() != null) {
			NBTTagCompound nbt = te.getTileData();
		EntityItem entityItem = new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), blockStack);
		if (te != null) {
			dropTEItems(worldIn, pos);

Link to comment
Share on other sites


is for storing external data on a


, it doesn't contain the


's own data.




(inherited by


) to write an


object to NBT.

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.

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.

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.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.