tutorial:biomecoloring
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
tutorial:biomecoloring [2019/10/25 17:41] – rework page draylar | tutorial:biomecoloring [2019/11/16 20:44] (current) – removed fudge | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== 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. | ||
- | |||
- | === Existing Examples === | ||
- | First, what existing vanilla content uses color providers? A few examples include: | ||
- | * grass | ||
- | * leaves | ||
- | * leather armor dying | ||
- | * redstone wire | ||
- | * plants such as melons, sugarcane, and lilypads | ||
- | * tipped arrows | ||
- | |||
- | The color provider is powerful, but Mojang has opted to stick with individual textures for colored blocks such as concrete, wool, and glass. The primary use case at this point is for biome shaded blocks and small tweaks to existing textures, such as the colored end of a tipped arrow. | ||
- | |||
- | The concept behind color providers is simple. You register a block or item to them, and when the block or item's model is rendered, the color provider applies a hue tweak to each layer of the texture. Both providers give you access to the layer of the model, which means you can hue each portion of a model separately, which is the case in leather armor & tipped arrows. This is useful for when you only want to change a few pixels, but not the entire texture. | ||
- | |||
- | Remember that the color provider is a client-side mechanic. Make sure to put any code related to it inside a client initializer. | ||
- | |||
- | ==== Registering a Block Color Provider ==== | ||
- | To register a block to the block color provider, you'll need to use Fabric' | ||
- | <code java [enable_line_numbers=" | ||
- | ColorProviderRegistry.BLOCK.register(new BlockColorProvider() { | ||
- | @Override | ||
- | public int getColor(BlockState state, ExtendedBlockView world, BlockPos pos, int layer) { | ||
- | return 0x3495eb; | ||
- | } | ||
- | }, MY_BLOCK); | ||
- | </ | ||
- | |||
- | All we do here is say, "Hi, '' | ||
- | |||
- | The model is also important: the main note here is that you are // | ||
- | <code json [enable_line_numbers=" | ||
- | { | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | }, | ||
- | " | ||
- | { " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | } | ||
- | } | ||
- | ] | ||
- | } | ||
- | </ | ||
- | In this instance, we're adding a single tintindex, which is what would appear in the `layer` parameter (layer 0). | ||
- | |||
- | Here's the final result-- note that the original model used the '' | ||
- | {{https:// | ||
- | |||
- | |||
tutorial/biomecoloring.1572025285.txt.gz · Last modified: 2019/10/25 17:41 by draylar