Jump to content

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


Recommended Posts

Posted

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!

Posted

Hi

 

Curious.

 

I don't know what the problem is.

 

But I suspect you can get some clues by putting a breakpoint in TileEntity.createAndLoadEntity and finding out why it doesn't call your readFromNBT.  Or if it does - why it doesn't work.

 

-TGG

Posted

The Data seems to get lost between the TileEntity.readFromNBT([...]) and the later called Block.getBlockTexture([...]), where i use the Tile Entity.  :(

 

Trying to find out why

-siiikooo

Minecraft!

Posted

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

Posted

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)

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.