Jump to content

[1.15.2] Storing data in block Client side different than Server side


Recommended Posts

Posted (edited)

I am trying to store some information inside of my block and most of it seems to be working fine. I can save the inventory perfectly, but when it comes to a few integers it seems that they are not appearing to be saved. When I show some logs after I pick up the block and put it back down, in the tick() method it shows the server with the correct int and the client with 0.

Does anyone have any knowledge around this?

  Reveal hidden contents


My loot_table:

  Reveal hidden contents

 

My Tile Entity:

  Reveal hidden contents

 

Edited by dgraygray
Posted

You don’t ever sync the values.

Read the Documentation.

Here’s an example of a TileEntity that syncs it’s energy every time it changes and here’s an example of a TileEntity that syncs its smeltTime whenever you’re in its GUI (see its container for the syncing)

  • Thanks 1

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Thank you for the speedy reply! From what I can see here, these are the functions that handle this sorta thing correct?
 

  Reveal hidden contents

I don't see in the second example a place where you are touching the smelting values though

Posted
  On 1/27/2020 at 4:47 AM, dgraygray said:

these are the functions that handle this sorta thing correct?

Expand  

Yeah

  On 1/27/2020 at 4:47 AM, dgraygray said:

I don't see in the second example a place where you are touching the smelting values though

Expand  
  On 1/27/2020 at 4:39 AM, Cadiboo said:

(see its container for the syncing)

Expand  

 

  • Like 1

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Thank you for the help! This should fix the issues I'm having! 

Last question: Is there a place where I can find out what should be done only on the client vs only on the server? Things like TE tick() and other things I should keep an I out for? 

Posted

Rendering and handling keyboard input should only be done on the client.

Logic (pretty much everything else) should be done on the sever.

 

However, to make stuff look smoother, vanilla runs some logic on both client and server (so that it appears to run smoothly on the client while the real result is synced a little bit later from the server)

  • Like 1

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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.