Jump to content

Syncing client tile entity data with server? [SOLVED]


QuantumLeaf7895

Recommended Posts

So I want to use tile entity data to control what texture the related block uses, a bit like how IndustrialCraft fits so many types of blocks into a single ID, but the problem is that the client stubbornly refuses to store any tile entity data.  How can I make the server send tile entity data?    I've tried using tile entity description packets but I can't seem to make the client process them.

 

EDIT: So I've figured out how to sync server and client data, but on world load/unload the client's tile entity resets.  Is there any way to automatically send a tile entity description packet when the tile entity's chunk is loaded?

Link to comment
Share on other sites

So I want to use tile entity data to control what texture the related block uses, a bit like how IndustrialCraft fits so many types of blocks into a single ID, but the problem is that the client stubbornly refuses to store any tile entity data.  How can I make the server send tile entity data?    I've tried using tile entity description packets but I can't seem to make the client process them.

If it renders as a normal block, you can't use TE data.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

If it renders as a normal block, you can't use TE data.

 

Isn't there a method (getBlockTexture) that takes IBlockAccess as a parameter and returns an icon to display?  I was under the impression that the method could be used to grab a block's TE and use data from that to choose a texture to display on a certain side.

Link to comment
Share on other sites

Server and Client Tile Entities are synchronized via the Container class.

check out detectAndSaveChanges(), updateProgressBar(), addCraftingToCrafters() methods in the ContainerFurnace class and make you Tile Entity update itself the same way. Otherwise your client and server Tile entities will desync after you log out from the world or unload the chunk it is in.

Link to comment
Share on other sites

Isn't there a method (getBlockTexture) that takes IBlockAccess as a parameter and returns an icon to display?  I was under the impression that the method could be used to grab a block's TE and use data from that to choose a texture to display on a certain side.

That is indeed true. Just make sure you sync your TE fields with Packets, the client version is usually dumb and holds no data.

>.>

Thanks for solving my problem. I thought that method had been removed as of 1.5.2.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

Server and Client Tile Entities are synchronized via the Container class.

check out detectAndSaveChanges(), updateProgressBar(), addCraftingToCrafters() methods in the ContainerFurnace class and make you Tile Entity update itself the same way. Otherwise your client and server Tile entities will desync after you log out from the world or unload the chunk it is in.

 

Aren't containers designed to be used with GUIs?  I'm trying to use TE data to control what textures a block should be rendered with, similar to how signs use TE data to control what text to display.

 

I've tried using getTileEntityDescriptionPacket(), but I can't make the game process built-in (or custom!) TE description packets.  I'm working on using Forge's packet handling structure, but although I've managed to send xyz coordinates from server to client I have no idea how to send which world the coordinates originate from.

 

(Strangely, neither Packet132TileEntityData nor Packet130UpdateSign seem to have a "world" field, yet both obviously allow minecraft to identify where the described TE is located. . . must look into that.)

 

Link to comment
Share on other sites

You are right about the getDescriptionPacket. What you need to "receive" it on the client side is the onDataPacket method in the tile entity. It will be called when the packet from getDescriptionPacket arrives on the client.

Thanks for that, onDataPacket did the trick. 

(I can't help but wonder why most vanilla TE classes don't override it. . . ah well, the packet must be handled elsewhere in the code)

Link to comment
Share on other sites

It is automatically send on a chunk load (and also on a chunk "refresh"). Are you sure your TE is doing its work on a server side?

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Link to comment
Share on other sites

are you sure you're implementing writeEntitytoNBT and readEntityToNBT (or wtv the f they're called) in your tile entity ?

can we have the code of your tile entity ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

So I was double-checking my read/writeFromNBT methods and in the process noticed that the onDataPacket method didn't actually change the tile entity's data. . . thanks for the suggestions, though.  Problem's fixed, for now.

 

God only knows how onDataPacket could somehow not change the tile entity's data while sneakily appearing to.  (Although LexManos would probably know better. . .)

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.