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 [2025/04/01 12:10] solidblocktutorial:colorprovider [2025/12/05 17:03] (current) – redirect to docs cassiancc
Line 1: Line 1:
 +~~REDIRECT>https://docs.fabricmc.net/develop/blocks/transparency-and-tinting~~
 +~~REDIRECT>https://docs.fabricmc.net/develop/items/item-appearance~~
 ======= Color Providers ======= ======= Color Providers =======
 Ever wonder how grass and leaves change hues depending on the biome, or how leather armor can have seemingly infinite color patterns? Meet **color providers**, which allow you to hue and tint block & item model textures based on properties such as location, NBT, or block states. Ever wonder how grass and leaves change hues depending on the biome, or how leather armor can have seemingly infinite color patterns? Meet **color providers**, which allow you to hue and tint block & item model textures based on properties such as location, NBT, or block states.
Line 252: Line 254:
  
 ===== Custom item tint (1.21.4 and after) ===== ===== Custom item tint (1.21.4 and after) =====
-Since 1.21.4 开始, tints of items are defined in item models definitions. Some common tint source types are provided in vanilla, see [[https://minecraft.wiki/w/Item models definition|Minecraft Wiki]]. In this example, we directly set the color of the item, so we can write the item models definition as follows:+Since 1.21.4, tints of items are defined in the Items model definition. Some common tint source types are provided in vanilla, see [[https://minecraft.wiki/w/Items_model_definition|Minecraft Wiki]]. In this example, we directly set the color of the item, so we can write the items model definition as follows:
 <code javascript /resources/assets/tutorial/items/color_block.json> <code javascript /resources/assets/tutorial/items/color_block.json>
 { {
Line 272: Line 274:
 > If the tint does not work, check the value of tintindex in the model, which should be consistent with the element subscript in the ''%%"tints"%%'' list in the item models definition. For example, if the tintindex is 2, it uses the third tint source in the item models definition. > If the tint does not work, check the value of tintindex in the model, which should be consistent with the element subscript in the ''%%"tints"%%'' list in the item models definition. For example, if the tintindex is 2, it uses the third tint source in the item models definition.
  
-In version 1.21.3 and before, item model providers are also registered with Fabric API. Different from blocks, the context provided, instead of having a state, world, or position, has access to the ''ItemStack''.+In version 1.21.3 and before, item model providers were instead registered with Fabric API. Different from blocks, the context provided, instead of having a state, world, or position, has access to the ''ItemStack''.
  
 For item models, we can directly inherite the block model that uses tintindex: For item models, we can directly inherite the block model that uses tintindex:
tutorial/colorprovider.txt · Last modified: 2025/12/05 17:03 by cassiancc