Jump to content

Recommended Posts

Posted

My aim is to save settings for an item on a per-item basis, and so I want to save the settings to NBT. The items have inventories, and the NBT data is saved fine and its working correctly, but I cannot get the settings to save (although they stay loaded even if you exit a world and load it again, if you restart the game everything is set to 0).

 

Each of the variables is correct when writing to NBT, but no tag is actually created. Then, when it reads obviously no tag is found so the variable is set to 0.

 

The NBT reading/writing code is here (and everything below that in that class): https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/inventory/BagInventory.java#L169

 

The class that handles the changing/saving/loading of settings to/from NBT is here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java

I have no idea what I'm doing.

Posted

I'm sure it would help if writeSettingsToNBT and readSettingsFromNBT was actually being called somewhere.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I'm sure it would help if writeSettingsToNBT and readSettingsFromNBT was actually being called somewhere.

 

They are...inside GuiConfig. Sorry, I probably should have specified.

 

See here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L96

And here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L205

And here: https://github.com/Roboguy99/HotbarBag/blob/master/src/main/java/roboguy99/hotbarBag/gui/GuiConfig.java#L229

 

I don't think I'm missing anything that stupid, am I?

I have no idea what I'm doing.

Posted

GUIs are CLIENT-side only, so any settings you change there are lost when the client closes. You need to save settings on the server, so you will need to send packets if you want the settings to be changed from client side.

 

Also, I didn't actually look at the settings you are changing, but most settings should only be set server side anyway and usually you don't want to expose them client-side at all.

Posted

GUIs are CLIENT-side only, so any settings you change there are lost when the client closes. You need to save settings on the server, so you will need to send packets if you want the settings to be changed from client side.

 

Also, I didn't actually look at the settings you are changing, but most settings should only be set server side anyway and usually you don't want to expose them client-side at all.

 

Ah ok, I thought that you didn't need packets with NBT. As for the settings, they're purely for client-side settings. Even if I do put any server-side values in, they won't be anything beyond the colour of an item or its name, so there's no real danger of exploits there.

I have no idea what I'm doing.

Posted

ItemStack NBT data syncs only one way automatically: from server to client. So, if you make changes on the server (e.g. by sending a packet from the GUI), those changes will be visible on the client side as well.

 

Ah, that makes sense. Thanks a lot.

I have no idea what I'm doing.

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

    • My friends and I are playing a modified version of BMC4 and we're noticing stuff like passive mobs. (I think) like creatures/animals from Alex mobs, naturalist, let's do nature and even vanilla MC (sheep, cow, pigs, chickens, horses, donkeys) don't really spawn in, unlike the sea creatures and hostile monsters spawn in just fine and normal numbers. Here is a mod list from a crash report: https://pastebin.ubuntu.com/p/K9vJxxx6n4/ Just a quick copy and paste of the mod list from an unrelated crash report If anything please let me know if I should post pics of the mods from my mods folder I want to know how to increase their spawn rate/amount and if there are any mods that are causing the scarce appearances of these mobs
    • I'm locally hosting a server and when Connecting to it Me (and my friends) get disconnected with the Warning:  [00:55:21] [Server thread/INFO] [minecraft/ServerGamePacketListenerImpl]: butterrocker lost connection: Disconnected [00:55:21] [Server thread/INFO] [minecraft/MinecraftServer]: butterrocker left the game [00:55:21] [Server thread/WARN] [minecraft/Connection]: handleDisconnection() called twice Server latest.log Client latest.log This server is hosted locally, Minecraft ver 1.20.1 and forge ver 47.3.22 I can connect the the sever just fine locally, but when connecting to the IP Others and I cannot connect, I've changed "-Dfml.readTimeout=240" from 30 to 240, to no affect.  I've removed the client side config files, to No avail, Checked mod vers by moving around the files, still nothing. I'm at a loss currently. Yesterday 1/13/25 everything worked fine and My friends and I could all connect, but now we cannot. Any assistance would be greatly appreciated.  If any further information is required please let me know, Thanks!
    • pick a block to be the base. get the location of that block when placed use setPlacedBy to place the other blocks   when any of the blocks are delete again get the location a removed the other blocks  
    • That server does not appear to be running Minecraft Forge. You should probably check for support from papermc for best results.
    • hey! i have 0 clue why my server is crashing, but here's the logs https://mclo.gs/GAWAPn1 it was working perfectly fine just a moment ago
×
×
  • Create New...

Important Information

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