Jump to content

[1.12.2] Get texture from texture map


That_Martin_Guy

Recommended Posts

I am creating a 3x3x3 structure that will have different textures for each block. I think it would be a waste to create 27 blocks and/or blockstates for a single structure, though. So I have a texture map with it's size being a multiple of 16, and I'm wondering if I can take a portion out of it to get the blocks texture (like how textures used to be made back in the modloader days). How would I do this if it is possible?

Link to comment
Share on other sites

You can have 27 (or more) states in a single Block if you store them somewhere other than the metadata, just override Block#getActualState to return the state based on information stored in a TileEntity or derived from the world (e.g. how many blocks are adjacent to this one and where they are in relation to it).

 

You can tell each element of a model which part of a texture to render with the "uv" property (see the wiki for more details), but this would require making 27 individual models with different UV coordinates. If all the blocks are the same shape (or some of them are), you can make a single model and specify a different texture file for each state using Forge's blockstates format.

 

You could probably mess around with dynamically-generated models or textures, but I think this is the simplest way to do it.

Edited by Choonster
  • Like 1

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

I think a tile entity would suit best here, but I'm not sure how I'd be able to tell which block should have a certain model. I tried making the tile entity store a vector containing its structure position (0,0,0 would be a corner, 1,0,1 would be the top middle etc) and integer block properties storing their values, but I ran into the problem where I don't know how to translate this into json, and I'm not sure how I'd be able to store the values back in the tile entity.

Link to comment
Share on other sites

9 minutes ago, That_Martin_Guy said:

I think a tile entity would suit best here, but I'm not sure how I'd be able to tell which block should have a certain model. I tried making the tile entity store a vector containing its structure position (0,0,0 would be a corner, 1,0,1 would be the top middle etc) and integer block properties storing their values, but I ran into the problem where I don't know how to translate this into json,

 

If you use three separate properties for the coordinates, you'll need to use fully-specified variants in the blockstates file; like in the standard Vanilla format (e.g. "x=0,y=0,z=0": { ... }).

 

If you use a single property, you can use Forge-style variants (e.g."position": { "0": { ... }, "1": { ... }, ... }).

 

Each { ... } represents a single variant, where you can set the model, texture, rotation, etc.

 

 

9 minutes ago, That_Martin_Guy said:

and I'm not sure how I'd be able to store the values back in the tile entity.

 

 

I don't know what you mean by this. Block#getActualState just has to read the values from the TileEntity and return an IBlockState with the appropriate property values set, it shouldn't be storing anything in the TileEntity.

  • Like 1

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

1 hour ago, That_Martin_Guy said:

Don't I have to store the values to retain the coordinates? I can't do it when setting the blockstate to my block AFAIK, and I don't know when to do it otherwise.

 

You do need to set the values at some point. Probably when the multiblock has been formed.

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.