Jump to content

[1.7.10] Problem syncing NBT tag compound between client and server


Roboguy99

Recommended Posts

So I have an NBT tag compound I'm saving to an item, and in single player it saves fine. On a server, all of the tags exist but are set to 0. I know this is an issue syncing something properly, despite having a packet.

 

I've tried playing around with many, many things but I can't get it to work properly. As you can currently see, I've tried constructing the NBTTagCompound and sending that in a packet, but it doesn't seem to actually update. At this point I'm out of ideas....

 

Here's the packet: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/network/packet/SettingsUpdate.java

Here's the NBT saving code: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/inventory/BagInventory.java#L265

Here's where the packet is sent from: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L316

 

If anybody could explain what I'm doing wrong, that would be great. Thanks.

I have no idea what I'm doing.

Link to comment
Share on other sites

You are approaching this from the wrong direction. Don't let the client tell the server "hey this is the new Item now, kthnxbai" and the server just trusts it. Instead send a packet when e.g. a button is pressed saying "hey, user pressed a button", then the server decides what to do with that information, in that case probably update some NBT on the ItemStack or something.

 

So if I have a bunch of client-side settings variables (see https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/Config.java), which are actually set through the user using a GUI, how would I go about doing this? I assume the settings variables should not be client-side, but as they're different for every instance of the mod (depending on a config file), I don't know how to do this.

 

I hope that made sense...

I have no idea what I'm doing.

Link to comment
Share on other sites

Right.

You need to send the serverside defaults (!) to the client when the GUI is opened. Then send any changes that the client makes to the server so it can apply them to the Item. Again, do not simply send a new Item, send a request stating "hey I wish to change this setting, please do that".

 

Right, I know that the request from client to server is going to be a packet. Will I send the instance of the GUI to the packet to get the variables, or will this just result in the same problem as before with the client sending data?

 

I'm sorry, I'm getting very confused over this...

I have no idea what I'm doing.

Link to comment
Share on other sites

Will I send the instance of the GUI to the packet to get the variables, or will this just result in the same problem as before with the client sending data?
Ehm... what.

"send the instance of the GUI" - No. The server sends a specific packet that contains the serverside defaults and also tells the client to open the GUI.

Then client sends back a different packet which contains things like "setting foo is now value bar please". Server then gets player's current Item, checks if it's yours and if so applies the change.

 

Ahh, that makes a lot more sense. Thanks.

I've just had nearly 2 weeks of exams so I'm a bit tired, and so a bit slow at the moment :|

I have no idea what I'm doing.

Link to comment
Share on other sites

Ok I think I've still got the wrong idea somewhere, so I thought it makes sense to come back here and ask again before I get way too far into the wrong thing. I've also got a feeling you still haven't 100% understood what I'm trying to do (which is my fault for not explaining it well enough), so here's a picture of my current situation; I'm not ignoring what you've said, I just don't quite have the understanding to incorporate it into the diagram. I hope it's clear enough...

 

1nes79j.png

 

I've been working on the packet which contains the defaults, and opens the GUI. Hopefully you'll be able to a) Understand what I want with the diagram and b) Agree that I've done something wrong.

 

https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/network/packet/SettingsOpen.java

I have no idea what I'm doing.

Link to comment
Share on other sites

So now you do want the config to be changed? I thought it was only for the default values...

 

There are 2 sets of values.

 

There are the default config values, which every item should start with as its settings. These are read from a config file, and so are on a per-mod-instance basis, allowing each user to have their own defaults.

There is then the item config values, which are loaded/saved from the item using NBT. If these don't exist, the default is used instead.

 

The config file does not need to be changed in game. The server's config file should not be used, as this would stop users from being able to change their own defaults. Obviously the item configs values should be changed and these are what are changed by the GUI.

I have no idea what I'm doing.

Link to comment
Share on other sites

I do not get your problem then...

 

My problem is that with my current approach, when connected to a server the config values for an item are read as 0, and I'm not sure whether what you previously said still remains correct given the full description of what's going on, or whether I should be doing something else to fix it.

I have no idea what I'm doing.

Link to comment
Share on other sites

Wait, what! How the heck are you storing per-item values in the Config class? Those need to go in the ItemStack.

 

Erm..I have no idea, but it sorta works...

 

I tell you what, I'm going to go away for a couple of days and just rework/figure out what I've made and try to fix it. We're both getting equally confused at this.

I have no idea what I'm doing.

Link to comment
Share on other sites

If you have client values, read and used by the clients...

They should stay on client side. Never into the world data, which is server property, including item NBT.

Write the client stuff on the client config file.

 

Now if the server use values, the defaults should be from the server configuration. Because there may be no client connected.

If the client need to know about those values, the server would send them through packet at appropriate time.

 

 

Let say there is a value such that both sides care about.

Server config contains "X" as default, sends it over to client.

->X | X  (both sides)

Client config applies a "client modifier=A" on it:

->X | X*A (use it for its own purposes)

User makes a modification "+" in GUI.

->X | X*A+A (temporary client side evaluated expression, based on client config)

Client send "+" packet, (contains GUI id and other stuff for identifying source) server receives "+" packet and applies its change.

-> X + 1 | X*A+A

Server may need to send back an update (could be same packet as first time), just in case...

-> X + 1 | X + 1

Which client config still apply client modifier on before use

-> X + 1 | (X+1)*A

etc.

In summary:

"A" is never sent over the network. It is kept by the client side data (in config file, probably).

"X" is sent by the server to the client. It is kept by the server data (in world save, probably), send by packet to client.

"+" is an operation known to both sides (or only server, in which case update packet is mandatory everytime). It is not data, and is thus not saved by either.

Client to server packet will ask server to perform "+" operation on its value, based on mutual agreement of the code needed in the packet to identify as "+" operation, such as channel name.

"*" is a client side operation. Server doesn't care nor understand.

Link to comment
Share on other sites

I am very happy today (exams), so may I suggest my assistance in solving your problem via Skype? I really feel like coding some shit before I restart my own works :D Skype: ernio333

 

I haven't really got enough time tonight, and my head isn't quite in the right place. I'm going to just go and sort it out over the weekend, and once the code seems to make some sort of sense I'll come back here.

 

Thanks for the offer though.

I have no idea what I'm doing.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan   Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan.   Keamanan Sebagai Prioritas Utama   Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah.   Beragam Permainan yang Menarik   Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi   Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar.   Layanan Pelanggan yang Responsif   Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien.   Kesimpulan   OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain.   Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!      
    • i notice a change if i add the min and max ram in the line like this for example:    # Xmx and Xms set the maximum and minimum RAM usage, respectively. # They can take any number, followed by an M or a G. # M means Megabyte, G means Gigabyte. # For example, to set the maximum to 3GB: -Xmx3G # To set the minimum to 2.5GB: -Xms2500M # A good default for a modded server is 4GB. # Uncomment the next line to set it. -Xmx10240M -Xms8192M    i need to make more experiments but for now this apparently works.
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Slot Gacor untuk Sensasi Bermain Maksimal Olahraga cepat dan seru dengan slot gacor di OLXTOTO. Rasakan sensasi bermain maksimal dengan mesin slot yang memberikan kemenangan beruntun. Temukan keberuntungan Anda di antara berbagai pilihan slot gacor yang tersedia dan rasakan kegembiraan bermain judi slot yang tak terlupakan. Situs Slot Terpercaya dengan Pilihan Terlengkap OLXTOTO adalah situs slot terpercaya yang menawarkan pilihan terlengkap dalam perjudian online. Nikmati berbagai genre dan tema slot online yang menarik, dari slot klasik hingga slot video yang inovatif. Dipercaya oleh jutaan pemain, OLXTOTO memberikan pengalaman bermain yang aman dan terjamin.   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.  
    • LOGIN DAN DAFTAR DISINI SEKARANG !!!! Blacktogel adalah situs judi slot online yang menjadi pilihan banyak penggemar judi slot gacor di Indonesia. Dengan platform yang sangat user-friendly dan berbagai macam permainan slot yang tersedia, Blacktogel menjadi tempat yang tepat untuk penggemar judi slot online. Dalam artikel ini, kami akan membahas tentang Blacktogel dan keunggulan situs slot gacor online yang disediakan.  
    • Situs bandar slot online Gacor dengan bonus terbesar saat ini sedang menjadi sorotan para pemain judi online. Dengan persaingan yang semakin ketat dalam industri perjudian online, pemain mencari situs yang tidak hanya menawarkan permainan slot yang gacor (sering memberikan kemenangan), tetapi juga bonus terbesar yang bisa meningkatkan peluang menang. Daftar disini : https://gesit.io/googlegopek
  • Topics

×
×
  • Create New...

Important Information

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