Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] What is the best way to serialize a IBlockState


Blackout
 Share

Recommended Posts

Hello,

 

I need to serialize a IBlockState.

When I was on 1.7.10, I serialized block by name using GameData.getBlockRegistry().getNameForObject(myBlock) and metadata using its int value.

I saw Block have a static function Block.getStateId() but I understood we should not use id anymore.

 

What should I use ? IBlockState doesn't have a writeToNBTTag() function like ??

Link to comment
Share on other sites

Using the ID is fine for networking purposes (and in that context the best option). In theory you can also use it for saving to the world (because IDs are consistent within a world), but this will cause problems with things like mods that allow moving parts of the world between worlds.

 

The best way would be to save the block ID like you already did before (e.g. "minecraft:stone") and the metadata (block.getMetaFromState). This is the most compatible you can be.

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.