User Tools

Site Tools


tutorial:colorprovider

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorial:colorprovider [2022/03/29 13:22] – [Registering a Block Color Provider] solidblocktutorial:colorprovider [2023/11/18 08:37] (current) – [Registering a Block Color Provider] solidblock
Line 25: Line 25:
 All we do here is say, "Hi, ''MY_BLOCK'' should be colored 0x3495eb," which is a blue color. You have ''BlockState'', ''World'', and ''BlockPos'' context, which is how you can change colors based on biome or position. The final int is the tintIndex; each one asks for a color individually, but in this case, we're always returning blue. All we do here is say, "Hi, ''MY_BLOCK'' should be colored 0x3495eb," which is a blue color. You have ''BlockState'', ''World'', and ''BlockPos'' context, which is how you can change colors based on biome or position. The final int is the tintIndex; each one asks for a color individually, but in this case, we're always returning blue.
  
-If you need to access ''BlockEntity'' data in the color provider, you'll want to implement ''RenderAttachmentBlockEntity'' to return the data you need. This is because blocks can be rendered on separate threads, so accessing the data directly is not safe. Additionally, if you query blocks with ''getBlockState'' you won't be able to view the entire world - make sure you only query within +-2 blocks x/y/z of the current position.+If you need to access ''BlockEntity'' data in the color provider, you'll want to implement ''RenderAttachmentBlockEntity'' to return the data you need. This is because blocks can be rendered on separate threads, so accessing the data directly is not safe. Additionally, if you query blocks with ''getBlockState'' you won't be able to view the entire world - make sure you only query within ±2 blocks x/y/z of the current position.
  
 The model is also important: the main note here is that you are //required// to define a tintindex for each portion of the model you want to hue. To see an example of this, check out ''leaves.json'', which is the base model used for vanilla leaves. Here's the model used for our block: The model is also important: the main note here is that you are //required// to define a tintindex for each portion of the model you want to hue. To see an example of this, check out ''leaves.json'', which is the base model used for vanilla leaves. Here's the model used for our block:
tutorial/colorprovider.txt · Last modified: 2023/11/18 08:37 by solidblock