Jump to content

[1.10.2] Metadata Crop Blockstate/Models


Izzy Axel

Recommended Posts

So...I made a crop block and seeds, and there needed to be 5 colored variants of them, so I handled that with metadata, using a PropertyEnum for color, and PropertyInteger for age, but now that I'm moving on the models/blockstate files, I'm not sure what to do; what's the best/most efficient way of handling this?  I'd really like to not have to create 40 model files. <__<

 

 

Bonus question, how would I use a single set of greyscale stage textures for each color and apply colorations to them?

 

 

Enum

Link to comment
Share on other sites

Metadata is limited to 4 bits (16 possible values), you can't have 5 colours and 8 ages in a single

Block

. The age takes up 3 bits, leaving only 1 spare bit.

 

You'll need to create a

Block

for each colour and only store the age in the metadata.

 

You can register an

IBlockColor

to colour a block model at runtime, but each model element to be coloured must specify a tint index (see the wiki). If you also want the item model to be coloured, you'll need to register an

IItemColor

.

 

Register your

IBlockColor

/

IItemColor

implementations with the

BlockColors

/

ItemColors

instances in init, you can get these from

Minecraft

. I have some examples of this here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Metadata is limited to 4 bits (16 possible values), you can't have 5 colours and 8 ages in a single

Block

. The age takes up 3 bits, leaving only 1 spare bit.

 

You'll need to create a

Block

for each colour and only store the age in the metadata.

 

You can register an

IBlockColor

to colour a block model at runtime, but each model element to be coloured must specify a tint index (see the wiki). If you also want the item model to be coloured, you'll need to register an

IItemColor

.

 

Register your

IBlockColor

/

IItemColor

implementations with the

BlockColors

/

ItemColors

instances in init, you can get these from

Minecraft

. I have some examples of this here.

 

 

What would be the result of storing more than 4 bits, because the crops are the correct colors when planted and grow fully, they just don't have a model/texture.

Link to comment
Share on other sites

What would be the result of storing more than 4 bits, because the crops are the correct colors when planted and grow fully, they just don't have a model/texture.

 

Returning a value greater than 15 from

Block#getMetaFromState

will either break things or be truncated to 15.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

IIRC, it gets truncated binarily to 4 bits.  That is, 16 and 0 would be identical.

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.

Link to comment
Share on other sites

Where do you specify the tint index in forge's format?

Blockstate

 

The tint index is part of the model and can't be specified in the blockstates file (even with Forge's format). You need to copy the

block/cross

model, add a tint index to each face and then use this model instead of the vanilla one in your blockstates file.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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