Jump to content

[Solved]Why does my TileEntity lose its Data on World reload??


siiikooo0743

Recommended Posts

Hi,

 

my TileEntity loses its Data when i save and reload the world.

Why?

 

TileEntity:

public class TE_BuildingBlock extends TileEntity
{

public int TextureBlockID;
public int TextureBlockMetadata;

@Override
public void writeToNBT(NBTTagCompound par1)
{
   super.writeToNBT(par1);
   par1.setInteger("TextureBlockID", TextureBlockID);
   par1.setInteger("TextureBlockMetadata", TextureBlockMetadata);
}

@Override
public void readFromNBT(NBTTagCompound par1)
{
   super.readFromNBT(par1);
   TextureBlockID = par1.getInteger("TextureBlockID");
   TextureBlockMetadata = par1.getInteger("TextureBlockMetadata");
}

}

 

MainMod:

GameRegistry.registerTileEntity(TE_BuildingBlock.class, "buildingBlock");

 

Block:

public TileEntity createTileEntity(World world, int metadata)
{
    return new TE_BuildingBlock();
}

@Override
public boolean hasTileEntity(int metadata)
{
	return true;
}

 

Thanks

siiikooo

Minecraft!

Link to comment
Share on other sites

Hi

 

Does your Block implement ITileEntityProvider?

Once Chunk.setChunkBlockTileEntity is used

this.chunkTileEntityMap.put(chunkposition, par4TileEntity);

your TileEntity should be in there for good.  Can you breakpoint that and inspect it?

A breakpoint in TileEntity.invalidate() might also highlight a problem with your freshly minted TileEntity being thrown away?

 

-TGG

Link to comment
Share on other sites

You need to implement the tile entity method of getDescriptionPacket() in order to send your data to client.

 

I bet the data is read properly on server, but the client never sees it -- it gets a blank tile-entity with the default initialized values for those fields.

 

--edit oh: you will also need to implement the packet-reading methods....

public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)

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.