@SideOnly(Side.CLIENT) public void registerItemTints(){ ItemColors ic = Minecraft.getMinecraft().getItemColors(); ic.registerItemColorHandler((stack, tintIndex) -> { if (stack.getItem() instanceof ItemGlassJar && stack.getMetadata() == 1) { if (tintIndex == 1) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) return 0xFFFFFF; if (nbt.getInteger("type") == 0) return 0xBF1316; else if (nbt.getInteger("type") == 1) return 0x7D90AD; else if (nbt.getInteger("type") == 2) return 0x62D47E; } } return 0xFFFFFF; }, GeneraItems.ItemGlassJar); }
public static void renderQuads(VertexBuffer renderer, List<BakedQuad> quads, int color, ItemStack stack) { boolean flag = (color == -1) && (!stack.isEmpty()); int i = 0; for (int j = quads.size(); i < j; i++) { BakedQuad bakedquad = quads.get(i); int k = color; if ((flag) && (bakedquad.hasTintIndex())) { ItemColors itemColors = Minecraft.getMinecraft().getItemColors(); k = itemColors.getColorFromItemstack(stack, bakedquad.getTintIndex()); if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } k |= 0xFF000000; } LightUtil.renderQuadColor(renderer, bakedquad, k); } }
public RenderItem(TextureManager p_i46552_1_, ModelManager p_i46552_2_, ItemColors p_i46552_3_) { this.textureManager = p_i46552_1_; this.modelManager = p_i46552_2_; if (Reflector.ItemModelMesherForge_Constructor.exists()) { this.itemModelMesher = (ItemModelMesher)Reflector.newInstance(Reflector.ItemModelMesherForge_Constructor, new Object[] {p_i46552_2_}); } else { this.itemModelMesher = new ItemModelMesher(p_i46552_2_); } this.registerItems(); this.itemColors = p_i46552_3_; }
@Override public void init() { BlockColors blockColors = Minecraft.getMinecraft().getBlockColors(); ItemColors itemColors = Minecraft.getMinecraft().getItemColors(); for (IBlockColored block : COLOR_BLOCKS) { blockColors.registerBlockColorHandler(block::getColorMultiplier,(Block)block); } for (IItemColored item : COLOR_ITEMS) { itemColors.registerItemColorHandler(item::getColorFromItemstack,(Item)item); } registerTESRs(); }
public RenderItem(TextureManager p_i46552_1_, ModelManager p_i46552_2_, ItemColors p_i46552_3_) { this.textureManager = p_i46552_1_; this.itemModelMesher = new net.minecraftforge.client.ItemModelMesherForge(p_i46552_2_); this.registerItems(); this.itemColors = p_i46552_3_; }
@Load(side = Side.CLIENT, value = LoaderState.POSTINITIALIZATION) @SideOnly(Side.CLIENT) public void loadColors() { try { Field field = ItemColors.class.getDeclaredField("itemColorMap"); field.setAccessible(true); Map<IRegistryDelegate<Item>, IItemColor> itemColorMap = (Map<IRegistryDelegate<Item>, IItemColor>) field.get(Minecraft.getMinecraft().getItemColors()); cachedLiqueurs.forEach(liqueur -> itemColorMap.entrySet().stream().filter(entry -> entry.getKey().get().equals(liqueur)).forEach(entry -> Minecraft.getMinecraft().getItemColors().registerItemColorHandler(entry.getValue(), entry.getKey().get()))); } catch (Exception e) { FoodCraftReloaded.getLogger().error("Cannot get custom mesh definitions", e); } }
/** * Register the {@link IItemColor} handlers * * @param blockColors The BlockColors instance * @param itemColors The ItemColors instance */ private static void registerItemColourHandlers(final BlockColors blockColors, final ItemColors itemColors) { // Use the Block's colour handler for an ItemBlock // final IItemColor itemBlockColourHandler = (stack, tintIndex) -> { // @SuppressWarnings("deprecation") // final IBlockState state = ((ItemBlock) stack.getItem()).getBlock().getStateFromMeta(stack.getMetadata()); // return blockColors.colorMultiplier(state, null, null, tintIndex); // }; // // itemColors.registerItemColorHandler(itemBlockColourHandler, ModBlocks.WATER_GRASS); }
private static <T extends Item & IColorItem> void registerItemColor() { ItemColors colors = Minecraft.getMinecraft().getItemColors(); for (T t : (List<T>) item_color) { IItemColor color = t.getItemColor(); if (color != null) { colors.registerItemColorHandler(color, t); AlchemyInitHook.push_event(t); } } }
@Override public void registerRenders() { int i; for (i = 0; i < ItemEnderBag.COLOURS.length; ++i) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.enderbag, i, new ModelResourceLocation("enderbags" + ":" + "enderbag", "inventory")); } ItemColors items = Minecraft.getMinecraft().getItemColors(); items.registerItemColorHandler(new IItemColor() { @Override public int getColorFromItemstack(ItemStack stack, int tintIndex) { Item item = stack.getItem(); if (item instanceof IColorable) { return ((IColorable) item).getColorFromItemStack(stack, tintIndex); } else { return 0xFFFFFF; } } }, ModItems.enderbag); }
@SideOnly(Side.CLIENT) public static void registerRendering() { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); BlockColors colors = Minecraft.getMinecraft().getBlockColors(); ItemColors icolors = Minecraft.getMinecraft().getItemColors(); for(Block block : blocks) { renderItem.getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(RefStrings.MODID + ":" + block.getUnlocalizedName().substring(5), "inventory")); colors.registerBlockColorHandler(new EverythingBlockColor(), block); icolors.registerItemColorHandler(new EverythingItemColor(), block); } }
@Override public void registerRenders() { int i; for (i = 0; i < OpenLootBagsApi.INSTANCE.getBagManager().getBagTypes().size(); ++i) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(OpenLootBags.lootbag, i, new ModelResourceLocation("openlootbags" + ":" + "lootbag", "inventory")); } ItemColors items = Minecraft.getMinecraft().getItemColors(); items.registerItemColorHandler(new IItemColor() { @Override public int getColorFromItemstack(ItemStack stack, int tintIndex) { Item item = stack.getItem(); if (item instanceof IColorable) { return ((IColorable) item).getColorFromItemStack(stack, tintIndex); } else { return 0xFFFFFF; } } }, OpenLootBags.lootbag); }
@SideOnly(Side.CLIENT) public static void registerItemColour(Object object, IItemColor colourProvider) { ItemColors itemColors = Minecraft.getMinecraft().getItemColors(); if (object instanceof Item) itemColors.registerItemColorHandler(colourProvider, (Item) object); else if (object instanceof Block) itemColors.registerItemColorHandler(colourProvider, (Block) object); }
@Override public void registerColors(){ ItemColors items = Minecraft.getMinecraft().getItemColors(); BlockColors blocks = Minecraft.getMinecraft().getBlockColors(); items.registerItemColorHandler(new DustPouchItemColor(), WizardryRegistry.dust_pouch); registerDustColors(items); registerDustBlockColors(blocks,items); }
private static void registerDustColors(ItemColors itcols){ for(IDust dust:DustRegistry.getAllDusts()){ if(!dust.hasCustomIcon()){ itcols.registerItemColorHandler(DustItemColor.instance(), dust); } } }
private static void registerDustBlockColors(BlockColors bcols, ItemColors icols){ for(IDustStorageBlock block: DustRegistry.getAllBlocks()){ if(block.getInstance() instanceof ADustStorageBlock){ bcols.registerBlockColorHandler(DustStorageBlockColor.instance(), block.getInstance()); icols.registerItemColorHandler(DustStorageItemBlockColor.instance(),Item.getItemFromBlock(block.getInstance())); } } }
@Override public void registerColorHandler(ItemColors itemColors) { Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> this.color, this); }
public DankNullRenderItem(TextureManager textureManager, ModelManager modelManager, ItemColors colors, @Nonnull ItemStack dankNull, boolean useLg, ContainerDankNull container) { super(textureManager, modelManager, colors); this.useLg = useLg; this.dankNull = dankNull; this.container = container; }
public ItemColors getItemColors() { return this.itemColors; }
private void registerPendingIItemColorItems() { ItemColors colors = Minecraft.getMinecraft().getItemColors(); for (ItemDynamicColor i : RegistryItems.pendingDynamicColorItems) { colors.registerItemColorHandler(i::getColorFromItemstack, (Item) i); } }
/** Find the average color of an item */ public static int getAverageColorUnbounded(ItemStack stack) { ItemColors cols = Minecraft.getMinecraft().getItemColors(); // null -> return white if(stack == null) return DEFAULT_COLOR; ItemStack nStack = stack.copy(); nStack.stackSize = 1; // constant size (for counting / caching) Item item = nStack.getItem(); // this stack overrides all color calculations if(item instanceof IOverrideEBColor) { return ((IOverrideEBColor)item).getEverythingBlockColor(nStack); } // non-overridden calculations cached for performance if(itemColorCache.containsKey(item.toString())) { return itemColorCache.get(item.toString()); } else if(stackColorCache.containsKey(nStack.toString())) { return stackColorCache.get(nStack.toString()); } // the color of potion stacks is their liquid color if(item instanceof ItemPotion) { return addStackToColorCache(nStack, cols.getColorFromItemstack(stack, 0)); } // the color of spawn egg blocks is the average of their layers if(item instanceof ItemMonsterPlacer) { IntList colList = (IntList) new IntList().join(cols.getColorFromItemstack(stack, 0)).join(cols.getColorFromItemstack(stack, 1)); return addStackToColorCache(nStack, ColorHelper.averageColors(colList)); } // dyeable armor returns a slightly darkened dye color if(item instanceof ItemArmor && ((ItemArmor)item).getColor(stack) > -1) { return addStackToColorCache(nStack, ColorHelper.averageColors(((ItemArmor)item).getColor(stack), 0, 0.75)); } // sensitive code try { // get the texture from the ItemStack (IN GAME, not in init methods or events!) TextureAtlasSprite sprite = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(nStack).getParticleTexture(); if(sprite == null) return addStackToColorCache(nStack, cols.getColorFromItemstack(stack, 0)); // default to item stack color int w = sprite.getIconWidth(); int h = sprite.getIconHeight(); // now look at the pixels IntList colors = new IntList(); int[] aint = sprite.getFrameTextureData(0)[0]; for(int x = 0; x < w; x++) { for(int y = 0; y < h; y++) { int c = aint[x + y * h]; if(c == 0) continue; // skip alpha pixels colors.add(c); } } // this is the base color int baseColor = ColorHelper.averageColors(colors); // now get the defined item stack color int stackColor = cols.getColorFromItemstack(stack, 0); // get the subtractive mix, add it to the cache, and return! return addStackToColorCache(nStack, ColorHelper.subtractMixColors(baseColor, stackColor)); } catch (Exception e) { Log.logger.warn("Exception caught getting color from ItemStack " + nStack.toString()); return addStackToColorCache(nStack, DEFAULT_COLOR); } }
@SubscribeEvent public static void registerItemColormHandlers(ColorHandlerEvent.Item evt) { final ItemColors itemColors = evt.getItemColors(); final BlockColors blockColors = evt.getBlockColors(); if (OpenBlocks.Items.paintBrush != null) { itemColors.registerItemColorHandler(new ItemPaintBrush.ColorHandler(), OpenBlocks.Items.paintBrush); } if (OpenBlocks.Items.crayonGlasses != null) { itemColors.registerItemColorHandler(new ItemImaginationGlasses.CrayonColorHandler(), OpenBlocks.Items.crayonGlasses); } if (OpenBlocks.Blocks.paintCan != null) { itemColors.registerItemColorHandler(new ItemPaintCan.ItemColorHandler(), OpenBlocks.Blocks.paintCan); blockColors.registerBlockColorHandler(new BlockPaintCan.BlockColorHandler(), OpenBlocks.Blocks.paintCan); } if (OpenBlocks.Blocks.imaginary != null) { itemColors.registerItemColorHandler(new ItemImaginary.CrayonColorHandler(), OpenBlocks.Blocks.imaginary); } if (OpenBlocks.Items.devNull != null) { itemColors.registerItemColorHandler(new ItemDevNull.NestedItemColorHandler(itemColors), OpenBlocks.Items.devNull); } if (OpenBlocks.Blocks.elevator != null) { blockColors.registerBlockColorHandler(new BlockElevator.BlockColorHandler(), OpenBlocks.Blocks.elevator); itemColors.registerItemColorHandler(new ItemElevator.ItemColorHandler(), OpenBlocks.Blocks.elevator); } if (OpenBlocks.Blocks.elevatorRotating != null) { blockColors.registerBlockColorHandler(new BlockElevator.BlockColorHandler(), OpenBlocks.Blocks.elevatorRotating); itemColors.registerItemColorHandler(new ItemElevator.ItemColorHandler(), OpenBlocks.Blocks.elevatorRotating); } if (OpenBlocks.Blocks.flag != null) { itemColors.registerItemColorHandler(new ItemFlagBlock.ItemColorHandler(), OpenBlocks.Blocks.flag); blockColors.registerBlockColorHandler(new BlockFlag.BlockColorHandler(), OpenBlocks.Blocks.flag); } }
public NestedItemColorHandler(ItemColors itemColors) { this.itemColors = itemColors; }
@SideOnly(Side.CLIENT) public void registerColorHandler(ItemColors itemColors){ }