Jump to content

Recommended Posts

Posted

Hello everyone.

 

I need your help, I have a problem with TileEntity, it doesn't save any information after logging out. So you can enter string, int (number) or any other information, which can be contained in NBTTagCompound, then click save-button. And all this information will be saved until you relogging. After that all information will be cleared.

 

I think this is due to the fact that my TileEntity doesn't send new values to the server side, so they cannot be saved. My another assumption is that my TileEntity doesn't get updated properly. Anyway I can't solve this problem by myself, hope for your help.

 

Source:

 

 

  Reveal hidden contents

 

 

Thanks in advance. And sorry for my english.

With best regards, Alexey.

Posted

You need to send a custom packet within the GUI to the server. To do so, you need a Packet Handler.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Thank you for your answer.

I've never used the packets before, and I couldn't find any guides, which can be useful for me. So could you help me?

 

According to this common guide - http://www.minecraftforge.net/wiki/Packet_Handling, I added the following code to my GUI:

 

 

  Reveal hidden contents

 

 

Debug message works fine, so I can send and handle the packet, but there is a question - how can I save all this information and use it later? All useful guides are extremely welcome. Thanks in advance.

Posted

If you wanna see how I did it with several blocks, look at the fresh Turret Mod 3 source on github, here: https://github.com/SanAndreasP/TurretModv3/tree/master/sanandreasp/mods/TurretMod3

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Well, i suggest more easy way — just add these few lines to tileEntity class, instead of that pile of code

public Packet getDescriptionPacket()
{
   NBTTagCompound nbtTag = new NBTTagCompound();
   this.writeToNBT(nbtTag);
   return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}

public void onDataPacket(INetworkManager net, Packet132TileEntityData packet)
{
   readFromNBT(packet.customParam1);
}

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted

diesieben07, don't know what you mean, but code works fine for me. Everything saves and loads perfectly.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

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.