tutorial:biomecoloring
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:biomecolouring [2019/02/19 14:20] – mcrafterzz | tutorial:biomecoloring [2019/05/28 18:43] – mapping changes draylar | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Block Biome Coloring ====== | ====== Block Biome Coloring ====== | ||
- | In this tutorial we will show how to make blocks | + | In this tutorial, we'll look at adding biome-dependent colors |
- | | + | Remember to keep visual-related logic client-side, |
- | @Override | + | |
- | public void onInitializeClient() { | + | |
- | ColorProviderRegistry.BLOCK.register((block, pos, world, layer) -> { | + | |
- | | + | |
- | | + | |
- | }, block); | + | |
- | } | + | |
- | } | + | |
- | So what's happening here? Well, the register | + | <code java [enable_line_numbers=" |
+ | public class ExampleModClient implements ClientModInitializer { | ||
+ | @Override | ||
+ | public void onInitializeClient() { | ||
+ | ColorProviderRegistry.BLOCK.register((block, pos, world, layer) -> { | ||
+ | BlockColorProvider provider = ColorProviderRegistry.BLOCK.get(Blocks.GRASS); | ||
+ | return provider == null ? -1 : provider.getColor(block, | ||
+ | }, YOUR_BLOCK_INSTANCE); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
- | | + | So, what's happening here? The register |
- | @Override | + | |
- | public void onInitializeClient() { | + | |
- | | + | |
- | | + | |
- | }, block.getItem()); | + | |
- | } | + | |
- | } | + | |
- | 0.5D is the temperature and 1D is the humidity | + | <code java [enable_line_numbers=" |
+ | public class ExampleModClient implements ClientModInitializer { | ||
+ | @Override | ||
+ | public void onInitializeClient() { | ||
+ | ColorProviderRegistry.ITEM.register((item, | ||
+ | // These values are represented as temperature and humidity, and used as coordinates for the color map | ||
+ | double temperature = 0.5D; // a double value between 0 and 1 | ||
+ | double humidity = 1.0D; // a double value between 0 and 1 | ||
+ | return GrassColorHandler.getColor(temperature, | ||
+ | }, YOUR_ITEM_INSTANCE); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | Finished! |