Jump to content

Recommended Posts

Posted

Wherever you initialize and register your blocks, you also need to register your tile entity:

GameRegistry.registerTileEntity(YourTileEntity.class, "uniqueTileEntityName");

Are you 100% sure that your data is not saving and loading correctly, and not just that you are not seeing it on the client when you reload? Custom tile entity data is not automatically sent to the client, so if you require your "color" variable, for example, to render your tile entity, of course it will be "reset" when you re-load the world, since the client side doesn't know about the server side values.

 

I recommend you first put some debugging statements in your read from NBT method to print the variables stored in there. If those are printing correct values, then you need to add the following two methods to your tile entity class:

@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}

That should synchronize the client-side tile entity when it is loaded from NBT on the server.

Posted

Wherever you initialize and register your blocks, you also need to register your tile entity:

GameRegistry.registerTileEntity(YourTileEntity.class, "uniqueTileEntityName");

Are you 100% sure that your data is not saving and loading correctly, and not just that you are not seeing it on the client when you reload? Custom tile entity data is not automatically sent to the client, so if you require your "color" variable, for example, to render your tile entity, of course it will be "reset" when you re-load the world, since the client side doesn't know about the server side values.

 

I recommend you first put some debugging statements in your read from NBT method to print the variables stored in there. If those are printing correct values, then you need to add the following two methods to your tile entity class:

@Override
public Packet getDescriptionPacket() {
NBTTagCompound tag = new NBTTagCompound();
this.writeToNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}

That should synchronize the client-side tile entity when it is loaded from NBT on the server.

 

 

I added those 2 methods and BOOM it worked thanks alot!

I'm always happy to help others!

 

Java is not my main programming language but I have alot experience in PHP/HTML/JS/CSS3/C#/SQL

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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