Jump to content

Recommended Posts

Posted

Hello,

 

I have a problem with my mod IDs, my ID management is very wasteful and i will be fixed this with Metadata for Blocks. I have no idea how to do it.

My Mod have 1500 blocks with no metadata the Blocks are in a array, i want the IDs in the metadata because forge has a maximum ID limit.

If the mod included with other mods, minecraft crashed because there is a ID limit.

Can someone show me how to use Metadata in Minecraft 1.9.4 - 1.12+

 

An example would help very much.

 

Thanks in advance ^_^

 

Posted (edited)

Metadata in 1.9+ is blockstates.

Metadata is just the underlying integer representation.

 

http://mcforge.readthedocs.io/en/latest/blockstates/states/

 

You will want to combine blocks that have similar functionality (e.g. all colors of wool in Minecraft Vanilla are the same block, but with different metadata) but separated by some "TYPE" aspect (color, material, etc)

Edited by Draco18s

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

In case you haven't read it elsewhere: Because a Minecraft world has millions of blocks in play at any given time (view distance in blocks squared  x 256 height; do the math), block data is extremely limited. Instead of instantiating and saving an entire class object for each block in the world, there is only one instantiation of each class (what you'll see called a singleton around here). In effect, all block-class fields are static even if they're not declared as such.

 

What's stored (in chunks) in the world are arrays of short (16-bit) integers, one archaic short per block. Of each 16-bit short, 12 bits are used for block ID (0..4095) and 4 bits become "metadata" (0..15). Having coded satellite telemetry back in the stone-knives & bear-skins dark ages of the 1980s, I feel right at home. YMMV. This 16-bit system may change someday, maybe as soon as MC v1.13, but for now that's what we have.

 

Whenever a block class is put to work, it needs to be handed its context (its world and position therein). Vanilla coding already handles the translation from  metadata to properties and back again. I recommend stepping through those processes at least once to become familiar with what's being done for you (and wrap your head around the virtually static nature of block classes in everything except properties).

 

Note: If you design a block subclass to use a property for a non-display purpose (e.g. behavior), then you should research the code for telling the renderer to ignore your property.

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.