use of net.minecraft.client.renderer.color.ItemColors in project Random-Things by lumien231.
the class ClientProxy method registerColors.
private void registerColors() {
for (Entry<Object, Object> entry : scheduledColorRegister.entrySet()) {
if (entry.getKey() instanceof IRTBlockColor) {
final IRTBlockColor blockColor = (IRTBlockColor) entry.getKey();
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor() {
@Override
public int colorMultiplier(IBlockState state, IBlockAccess p_186720_2_, BlockPos pos, int tintIndex) {
return blockColor.colorMultiplier(state, p_186720_2_, pos, tintIndex);
}
}, (Block) entry.getValue());
} else if (entry.getKey() instanceof IRTItemColor) {
final IRTItemColor itemColor = (IRTItemColor) entry.getKey();
try {
ItemColors itemColors = (ItemColors) itemColorsField.get(Minecraft.getMinecraft());
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int colorMultiplier(ItemStack stack, int tintIndex) {
return itemColor.getColorFromItemstack(stack, tintIndex);
}
}, (Item) entry.getValue());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
use of net.minecraft.client.renderer.color.ItemColors in project SilentGems by SilentChaos512.
the class ColorHandlers method init.
public static void init() {
ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
// Tools
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return ToolHelper.getColorForPass(stack, tintIndex);
}
}, ModItems.tools.toArray(new Item[ModItems.tools.size()]));
// Shields
itemColors.registerItemColorHandler(new IItemColor() {
// 5 & 6 unused
int[] passes = { 2, 1, 3, 0, 4, 5, 6 };
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex < 0 || tintIndex >= passes.length)
return 0xFFFFFF;
return ToolHelper.getColorForPass(stack, passes[tintIndex]);
}
}, ModItems.shield);
// Armor (temp)
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
// FIXME: Multiple passes needed?
return ArmorHelper.getRenderColor(stack, EnumDecoPos.NORTH);
}
}, ModItems.gemHelmet, ModItems.gemChestplate, ModItems.gemLeggings, ModItems.gemBoots);
// Gem Shards
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return stack.getItemDamage() > 15 ? 0x999999 : 0xFFFFFF;
}
}, ModItems.gemShard);
// Enchantment Tokens
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 1)
return ModItems.enchantmentToken.getOutlineColor(stack);
return 0xFFFFFF;
}
}, ModItems.enchantmentToken);
// Return Home Charm
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return stack.getItemDamage() > 15 && tintIndex == 1 ? 0x999999 : 0xFFFFFF;
}
}, ModItems.returnHomeCharm);
// Node Mover
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return tintIndex != 1 ? 0xFFFFFF : ClientTickHandler.nodeMoverColor.getColor();
}
}, ModItems.nodeMover);
// Drawing Compass
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return tintIndex == 0 ? ModItems.drawingCompass.getColor(stack).getColor() : 0xFFFFFF;
}
}, ModItems.drawingCompass);
// Chaos Runes
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 1) {
ChaosBuff buff = ModItems.chaosRune.getBuff(stack);
if (buff != null) {
return buff.getColor();
}
}
return 0xFFFFFF;
}
}, ModItems.chaosRune);
// Holding Gem
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 1) {
if (stack.hasTagCompound()) {
int id = stack.getTagCompound().getShort(ItemHoldingGem.NBT_GEM_ID);
if (id >= 0 && id < EnumGem.values().length)
return EnumGem.values()[id].color;
}
} else if (tintIndex == 2) {
IBlockState state = ModItems.holdingGem.getBlockPlaced(stack);
if (state != null)
return state.getMapColor().colorValue;
}
return 0xFFFFFF;
}
}, ModItems.holdingGem);
}
use of net.minecraft.client.renderer.color.ItemColors in project Bewitchment by Um-Mitternacht.
the class ClientProxy method init.
@Override
public void init(FMLInitializationEvent event) {
Keybinds.registerKeys();
BlockColors blocks = Minecraft.getMinecraft().getBlockColors();
// Block Colors
blocks.registerBlockColorHandler(new BlockCandleColorHandler(), ModBlocks.candle_medium, ModBlocks.candle_small, ModBlocks.candle_medium_lit, ModBlocks.candle_small_lit);
blocks.registerBlockColorHandler(new IBlockColor() {
@Override
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
EnumGlyphType type = state.getValue(BlockCircleGlyph.TYPE);
switch(type) {
case ENDER:
return 0x770077;
case GOLDEN:
return 0xe3dc3c;
case NETHER:
return 0xbb0000;
default:
case NORMAL:
return 0xFFFFFF;
case ANY:
// A green one should never happen!
return 0x00FF00;
}
}
}, ModBlocks.ritual_glyphs);
blocks.registerBlockColorHandler(new IBlockColor() {
@Override
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
if (tintIndex == 1) {
return Color.HSBtoRGB((pos.getX() + pos.getY() + pos.getZ()) % 50 / 50f, 0.4f, 1f);
}
return -1;
}
}, ModBlocks.crystal_ball);
ItemColors items = Minecraft.getMinecraft().getItemColors();
// Item Colors
items.registerItemColorHandler(new ItemCandleColorHandler(), Item.getItemFromBlock(ModBlocks.candle_medium), Item.getItemFromBlock(ModBlocks.candle_small));
items.registerItemColorHandler(new BrewItemColorHandler(), ModItems.brew_phial_drink, ModItems.brew_phial_splash, ModItems.brew_phial_linger);
items.registerItemColorHandler(new IItemColor() {
@Override
public int colorMultiplier(ItemStack stack, int tintIndex) {
if (tintIndex == 0) {
ISpell s = ItemSpellPage.getSpellFromItemStack(stack);
if (s != null)
return s.getColor();
}
return -1;
}
}, ModItems.spell_page);
NetworkRegistry.INSTANCE.registerGuiHandler(Bewitchment.instance, new GuiHandler());
}
use of net.minecraft.client.renderer.color.ItemColors in project artisan-worktables by codetaylor.
the class ModuleTools method onClientInitializationEvent.
@Override
public void onClientInitializationEvent(FMLInitializationEvent event) {
super.onClientInitializationEvent(event);
if (this.registeredToolList.isEmpty()) {
// No tools were registered.
return;
}
// Register item color handlers to colorize layer 1 of each item model
// using the color stored in the material enum.
ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
itemColors.registerItemColorHandler((stack, tintIndex) -> (tintIndex == 1) ? ((ItemWorktableTool) stack.getItem()).getMaterial().getColor() : 0xFFFFFF, this.registeredToolList.toArray(new ItemWorktableTool[this.registeredToolList.size()]));
}
use of net.minecraft.client.renderer.color.ItemColors in project HorsePower by GoryMoon.
the class ColorGetter method getItemColors.
private static List<Color> getItemColors(ItemStack itemStack, int colorCount) {
final ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
final int renderColor = itemColors.colorMultiplier(itemStack, 0);
final TextureAtlasSprite textureAtlasSprite = getTextureAtlasSprite(itemStack);
if (textureAtlasSprite == null) {
return Collections.emptyList();
}
return getColors(textureAtlasSprite, renderColor, colorCount);
}
Aggregations