Jump to content

Recommended Posts

Posted
1 minute ago, falaRonaldo said:

What is it

"a set of data that describes and gives information about other data."

1 minute ago, falaRonaldo said:

when I use metadata?

When your block or item has extra information that can be specified as an integer. IE BlockStates. Blocks are limited to 16 different combinations while items have a ridiculous upper limit. But these should only be used for similar items or blocks.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Let me get this straight. if I have an electric oven, it has 100 energy in it, if I take it off the ground and with metadata I could leave it saved on the item that it has 100 energy stored and at the time I put it on the floor I get the metadata of the item and see how much energy it has to put into the machine? would this be an example of a use for metadata?

Posted
1 hour ago, falaRonaldo said:

Let me get this straight. if I have an electric oven, it has 100 energy in it, if I take it off the ground and with metadata I could leave it saved on the item that it has 100 energy stored and at the time I put it on the floor I get the metadata of the item and see how much energy it has to put into the machine? would this be an example of a use for metadata?

Metadata has a maximum of 16 possible values. 100 > 16 so you can’t use metadata. Also I assume your machine will have horizontal facing (this uses up 4 values). You can use a tile entity for saving energy (saved in the world with NBT) and when you break it store the energy it the itemstacks nbt or attach an energy capability to it

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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
1 hour ago, falaRonaldo said:

would this be an example of a use for metadata?

No, that is not how you will want to do that. If you want to do that you should use capabilities.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
10 minutes ago, Cadiboo said:

horizontal facing (this uses up 4 values)

Look at log blocks

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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

In Minecraft modding, metadata is specifically a very condensed (using only 4-bits of information) way of coding information about a block at a position in the world. The reason why it is so condensed is because the number of block positions in a Minecraft world is very large -- there are 65 thousand positions in a single chunk! So to save memory, disk space and networking bandwidth they restrict the information for most blocks to 4-bits. 

 

4-bits allows for 16 states (0 to 15). That is enough to provide some functional variation. For example, you can have 16 different colors of a block that is otherwise mostly the same. Or you can code the orientation of a log block. And so forth.

 

However, sometimes you need more information associated with a block. For the example in the thread above, if you want to store an energy level that can go to 100 then you probably need to use a "tile entity". A tile entity can both store more information (using NBT format to and from disk) and can also process more complex logic. They need to be used sparingly though because they can tax performance -- for example you probably wouldn't be able to fill a chunk with furnaces that were all cooking at the same time without causing lag.

 

In early days of modding, modders would "think" directly in terms of metadata codes and NBT data. However, in modern times those are mostly hidden implementations and instead you work with Properties and IBlockStates, and for more complex blocks with tile entities you can use Capabilities.

 

So really your question should not be "how and when do I use metadata" but rather "what is best way to store this sort of information about a block"? If it is very simple information that can be stored within 16 values you can use properties and block states, otherwise you need to use tile entities (and likely capabilities attached to them).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.