Jump to content

What is the correct way to store many values on a single block in metadata?


Zetal
 Share

Recommended Posts

So, in general, it's best to limit the metadata of your block to 16 values. However, what do I do when my block has, for example, 21 values that need to be stored?

 

I have a custom cake block- the cake has seven different values depending on how 'eaten' it is.

 

The cake also has a 'quality' - Poor, Decent, or Superb.

 

How can I store these values in the block metadata without going over 16?

Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help!  http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/

Link to comment
Share on other sites

I suppose I figured that would be the answer, but it's still a shame there isn't another way since TileEntity's tend to be kinda bloated.

 

Well, whatever. Thanks.

Have a modding question? PM me and hopefully I'll be able to help. Good at 2d Pixel Art? We need your help!  http://www.minecraftforum.net/topic/1806355-looking-for-2d-pixel-artist/

Link to comment
Share on other sites

You could store the eaten integer in metadata in an abstract cake block class. Then make three different blocks (Poor, Decent, or Superb) extending that class. This would eat (pardon the expression) block ID bits instead of metadata bits.

 

The concept here is that the quality doesn't change over time (does it?) but the eaten does. So you can place the block once as some quality of manufacture and then update its metadata as it is eaten. It's only a matter of convenience; there are objects in the game that swap blocks when conditions change (or at least they did in past versions of MC).

 

The downside is that each new block needs its own registrations, ItemBlock and JSON, but you've learned to love writing JSON files right?

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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 Terms of Use.