use of net.minecraft.client.renderer.color.IItemColor 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.IItemColor in project EnderIO by SleepyTrousers.
the class PaintTintHandler method colorMultiplier.
@Override
public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) {
if (Prep.isInvalid(stack)) {
return -1;
}
Item item = stack.getItem();
Block block = Block.getBlockFromItem(item);
if (block instanceof IPaintable) {
IBlockState paintSource = ((IPaintable) block).getPaintSource(block, stack);
if (paintSource != null) {
final ItemStack paintStack = new ItemStack(paintSource.getBlock(), 1, paintSource.getBlock().getMetaFromState(paintSource));
if (paintStack.getItem() != item) {
return Minecraft.getMinecraft().getItemColors().colorMultiplier(paintStack, tintIndex);
}
}
}
if (item instanceof IItemColor) {
return ((IItemColor) item).colorMultiplier(stack, tintIndex);
}
if (item instanceof ITintedItem) {
return ((ITintedItem) item).getItemTint(stack, tintIndex);
}
if (block instanceof IItemColor) {
return ((IItemColor) block).colorMultiplier(stack, tintIndex);
}
if (block instanceof ITintedItem) {
return ((ITintedItem) block).getItemTint(stack, tintIndex);
}
return -1;
}
use of net.minecraft.client.renderer.color.IItemColor in project pnc-repressurized by TeamPneumatic.
the class ItemColorHandler method registerColorHandlers.
public static void registerColorHandlers() {
final IItemColor ammoColor = (stack, tintIndex) -> {
switch(tintIndex) {
case 1:
return getAmmoColor(stack);
default:
return Color.WHITE.getRGB();
}
};
final IItemColor plasticColor = (stack, tintIndex) -> {
int plasticColour = ItemPlastic.getColour(stack);
return plasticColour >= 0 ? plasticColour : 0xffffff;
};
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ammoColor, Itemss.GUN_AMMO);
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(plasticColor, Itemss.PLASTIC);
}
Aggregations