Jump to content

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


Recommended Posts

Posted

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/

Posted

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.

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.