Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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!

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

  • Author

My problem at the moment is to get breakpoints working in my project setup.

But i might just use the standart setup now.

 

-siiikooo

Minecraft!

  • Author

Got breakpoints working and the data gets actually properly read.

The Block just doesn't update right.

I'm fixing that now.

 

siiikooo

Minecraft!

  • Author

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!

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

  • Author

Hi,

 

TileEntity.invalidate()

never get's called.

this.chunkTileEntityMap.put(chunkposition, par4TileEntity);

gets called and

par4TileEntity

has all the data.

 

-siiikooo

Minecraft!

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.