Java 类net.minecraft.client.renderer.color.IItemColor 实例源码

项目:pnc-repressurized    文件:ItemColorHandler.java   
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);
}
项目:T.E.C.H    文件:BaseBlocks.java   
public static void init() {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    for (Map.Entry<String, Block> ent : renderMap.entrySet()) {
        renderItem.getItemModelMesher().register(Item.getItemFromBlock(ent.getValue()), 0, new ModelResourceLocation(Reference.MODID + ":" + ent.getKey(), "inventory"));
    }
    //TODO Convert to Lambda
    for (Map.Entry<Material, Block> entry : oreBlockMap.entrySet()) {
        Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
            @Override
            public int getColorFromItemstack(ItemStack stack, int tintIndex) {
                return entry.getKey().getColour().getRGB();
            }

        }, entry.getValue());
    }
}
项目:JustBackpack    文件:ClientProxy.java   
@Override
public void init() 
{
    super.init();

    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(BackpackMod.backpackItem, 0, new ModelResourceLocation("meddleBackpack", "inventory"));

    Minecraft.getMinecraft().itemColors.registerItemColor(new IItemColor() {

        @Override
        public int getItemColor(ItemStack arg0, int arg1) {
            Item item = arg0.getItem();
            if (item instanceof ItemBackpack) {
                return ((ItemBackpack)item).getColorFromItemStack(arg0,  arg1);
            }
            return 0xFFFFFFFF;
        }           
    }, BackpackMod.backpackItem);

    MeddleClient.registerGuiHandler(this);
}
项目:EnderIO    文件:SmartModelAttacher.java   
@SideOnly(Side.CLIENT)
public static void registerColoredBlocksAndItems() {
  NNList<Block> blocklist = new NNList<Block>();
  NNList<Item> itemlist = new NNList<Item>();
  for (RegistrationHolder<?, ?> holder : blocks) {
    Block block = holder.block;
    Item item = Item.getItemFromBlock(block);
    if (block instanceof IPaintable || block instanceof ITintedBlock || block instanceof ITintedItem || item instanceof ITintedItem) {
      blocklist.add(block);
      if (item != Items.AIR) {
        itemlist.add(item);
      }
    } else {
      if (block instanceof IBlockColor) {
        Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((IBlockColor) block, block);
      }
      if (item instanceof IItemColor) {
        Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor) item, item);
      }
    }
  }

  PaintTintHandler handler = new PaintTintHandler();
  Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(handler, blocklist.toArray(new Block[0]));
  Minecraft.getMinecraft().getItemColors().registerItemColorHandler(handler, itemlist.toArray(new Item[0]));
}
项目:FoodCraft-Reloaded    文件:LiqueurLoader.java   
@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);
    }
}
项目:wolfarmor    文件:ClientProxy.java   
@Override
public void registerItemColorHandlers(@Nonnull FMLInitializationEvent initializationEvent) {
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
        @Override
        public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) {
            return tintIndex > 0 ? -1 : ((ItemWolfArmor) stack.getItem()).getColor(stack);
        }
    }, Items.LEATHER_WOLF_ARMOR);
}
项目:Alchemy    文件:AlchemyItemRecord.java   
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() {
    return new IItemColor() {
        @Override
        public int getColorFromItemstack(ItemStack item, int index) {
            return index == 0 ? color : -1;
        }
    };
}
项目:Alchemy    文件:AlchemyItemColor.java   
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() {
    return new IItemColor() {
        @Override
        public int getColorFromItemstack(ItemStack item, int index) {
            return index == 0 ? color : -1;
        }
    };
}
项目:Alchemy    文件:AlchemyItemBlock.java   
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() {
    return new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack item, int index) {
            return color == null ? -1 : color.getColorFromItemstack(item, index);
        }

    };
}
项目:Alchemy    文件:BlockOre.java   
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() {
    return new IItemColor() {

        @Override
        public int getColorFromItemstack(ItemStack stack, int tintIndex) {
            return color;
        }

    };
}
项目:Alchemy    文件:AlchemyColorLoader.java   
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);
        }
    }
}
项目:EnderBags    文件:ClientProxy.java   
@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);
}
项目:OpenLootBags    文件:ClientProxy.java   
@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);
}
项目:MMDLib-old    文件:MMDLibRegistry.java   
@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);
}
项目:NordMod    文件:RegisterColorHelper.java   
@Override
public void registerItemColorHandler(Block block){
    Item item = Item.getItemFromBlock(block);
    if (item instanceof IItemColor){
        IItemColor iItemColor = (IItemColor)item;
        itemColor.registerItemColorHandler(iItemColor,block);
    }
}
项目:NordMod    文件:RegisterColorHelper.java   
@Override
public void registerItemColorHandler(Item item){
    if (item instanceof IItemColor){
        IItemColor iItemColor = (IItemColor)item;
        itemColor.registerItemColorHandler(iItemColor,item);
    }
}
项目:JsonLootBags    文件:ClientHelper.java   
public static void init()
{
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
        @Override
        public int colorMultiplier(ItemStack stack, int tintIndex)
        {
            return ((ItemLootBag) stack.getItem()).getColor(stack, tintIndex);
        }
    }, (Item[]) ItemLootBag.getLootBags());
}
项目:EnderIO    文件:PaintTintHandler.java   
@Override
public int getColorFromItemstack(@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().getColorFromItemstack(paintStack, tintIndex);
      }
    }
  }
  if (item instanceof IItemColor) {
    return ((IItemColor) item).getColorFromItemstack(stack, tintIndex);
  }
  if (item instanceof ITintedItem) {
    return ((ITintedItem) item).getItemTint(stack, tintIndex);
  }
  if (block instanceof IItemColor) {
    return ((IItemColor) block).getColorFromItemstack(stack, tintIndex);
  }
  if (block instanceof ITintedItem) {
    return ((ITintedItem) block).getItemTint(stack, tintIndex);
  }
  return -1;
}
项目:BetterWithAddons    文件:ItemToolShard.java   
@Override
public IItemColor getItemColor() {
    return ColorHandlers.MIMIC_COLORING;
}
项目:BetterWithAddons    文件:ItemSamuraiArmor.java   
@Override
public IItemColor getItemColor() {
    return ColorHandlers.ARMOR_COLORING;
}
项目:BetterWithAddons    文件:BlockExtraGrass.java   
@Override
public IItemColor getItemColor() {
    return ColorHandlers.BLOCK_ITEM_COLORING;
}
项目:BetterWithAddons    文件:BlockEcksieSapling.java   
@Override
public IItemColor getItemColor() {
    return ColorHandlers.ECKSIE_COLORING;
}
项目:BetterWithAddons    文件:IColorable.java   
@SideOnly(Side.CLIENT)
IItemColor getItemColor();
项目:BetterWithAddons    文件:BlockWirePCB.java   
@Override
public IItemColor getItemColor() {
    return null;
}
项目:CommonUtils    文件:ProxyModBase.java   
@SideOnly(Side.CLIENT)
public void addItemColors(IItemColor itemColor, Collection<Item> blocks) {
    addItemColors(itemColor, blocks.toArray(new Item[0]));
}
项目:CommonUtils    文件:ProxyModBase.java   
@SideOnly(Side.CLIENT)
public void addItemColors(IItemColor itemColor, Item... blocks) {
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(itemColor, blocks);
}
项目:CommonUtils    文件:ProxyModBase.java   
@SideOnly(Side.CLIENT)
public void addItemColors(IItemColor itemColor, Block[] blocks) {
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(itemColor, blocks);
}
项目:Alchemy    文件:ItemHeadFollower.java   
@Override
@SideOnly(Side.CLIENT)
public IItemColor getItemColor() { return null; }
项目:Alchemy    文件:IColorItem.java   
@SideOnly(Side.CLIENT)
IItemColor getItemColor();
项目:SecurityCraft    文件:ClientProxy.java   
@Override
@SideOnly(Side.CLIENT)
public void registerRenderThings(){
    KeyBindings.init();

    RenderingRegistry.registerEntityRenderingHandler(EntityBouncingBetty.class, new RenderBouncingBetty(Minecraft.getMinecraft().getRenderManager()));
    RenderingRegistry.registerEntityRenderingHandler(EntityIMSBomb.class, new RenderIMSBomb(Minecraft.getMinecraft().getRenderManager()));
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityKeypadChest.class, new TileEntityKeypadChestRenderer());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySecurityCamera.class, new TileEntitySecurityCameraRenderer());

    TileEntityItemStackRenderer.instance = new ItemKeypadChestRenderer();

    Block[] blocksToTint = {
            SCContent.reinforcedBrick,
            SCContent.reinforcedCobblestone,
            SCContent.reinforcedCompressedBlocks,
            SCContent.reinforcedDirt,
            SCContent.reinforcedDoubleStoneSlabs,
            SCContent.reinforcedDoubleStoneSlabs2,
            SCContent.reinforcedDoubleWoodSlabs,
            SCContent.reinforcedEndStoneBricks,
            SCContent.reinforcedHardenedClay,
            SCContent.reinforcedMetals,
            SCContent.reinforcedMossyCobblestone,
            SCContent.reinforcedNetherBrick,
            SCContent.reinforcedNewLogs,
            SCContent.reinforcedOldLogs,
            SCContent.reinforcedPrismarine,
            SCContent.reinforcedPurpur,
            SCContent.reinforcedQuartz,
            SCContent.reinforcedRedNetherBrick,
            SCContent.reinforcedRedSandstone,
            SCContent.reinforcedSandstone,
            SCContent.reinforcedStainedHardenedClay,
            SCContent.reinforcedStairsAcacia,
            SCContent.reinforcedStairsBirch,
            SCContent.reinforcedStairsBrick,
            SCContent.reinforcedStairsCobblestone,
            SCContent.reinforcedStairsDarkoak,
            SCContent.reinforcedStairsJungle,
            SCContent.reinforcedStairsNetherBrick,
            SCContent.reinforcedStairsOak,
            SCContent.reinforcedStairsPurpur,
            SCContent.reinforcedStairsQuartz,
            SCContent.reinforcedStairsRedSandstone,
            SCContent.reinforcedStairsSandstone,
            SCContent.reinforcedStairsSpruce,
            SCContent.reinforcedStairsStone,
            SCContent.reinforcedStairsStoneBrick,
            SCContent.reinforcedStone,
            SCContent.reinforcedStoneBrick,
            SCContent.reinforcedStoneSlabs,
            SCContent.reinforcedStoneSlabs2,
            SCContent.reinforcedWoodPlanks,
            SCContent.reinforcedWoodSlabs,
            SCContent.reinforcedWool
    };
    //registering reinforced blocks color overlay for world
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> 0x999999, blocksToTint);
    //same thing for inventory
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor)(stack, tintIndex) -> 0x999999, blocksToTint);
}
项目:SecurityCraft    文件:ClientProxy.java   
@Override
@SideOnly(Side.CLIENT)
public void registerRenderThings(){
    KeyBindings.init();

    RenderingRegistry.registerEntityRenderingHandler(EntityBouncingBetty.class, new RenderBouncingBetty(Minecraft.getMinecraft().getRenderManager()));
    RenderingRegistry.registerEntityRenderingHandler(EntityIMSBomb.class, new RenderIMSBomb(Minecraft.getMinecraft().getRenderManager()));
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityKeypadChest.class, new TileEntityKeypadChestRenderer());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySecurityCamera.class, new TileEntitySecurityCameraRenderer());

    TileEntityItemStackRenderer.instance = new ItemKeypadChestRenderer();

    Block[] blocksToTint = {
            SCContent.reinforcedBrick,
            SCContent.reinforcedCobblestone,
            SCContent.reinforcedCompressedBlocks,
            SCContent.reinforcedDirt,
            SCContent.reinforcedDoubleStoneSlabs,
            SCContent.reinforcedDoubleStoneSlabs2,
            SCContent.reinforcedDoubleWoodSlabs,
            SCContent.reinforcedEndStoneBricks,
            SCContent.reinforcedHardenedClay,
            SCContent.reinforcedMetals,
            SCContent.reinforcedMossyCobblestone,
            SCContent.reinforcedNetherBrick,
            SCContent.reinforcedNewLogs,
            SCContent.reinforcedOldLogs,
            SCContent.reinforcedPrismarine,
            SCContent.reinforcedPurpur,
            SCContent.reinforcedQuartz,
            SCContent.reinforcedRedNetherBrick,
            SCContent.reinforcedRedSandstone,
            SCContent.reinforcedSandstone,
            SCContent.reinforcedStainedHardenedClay,
            SCContent.reinforcedStairsAcacia,
            SCContent.reinforcedStairsBirch,
            SCContent.reinforcedStairsBrick,
            SCContent.reinforcedStairsCobblestone,
            SCContent.reinforcedStairsDarkoak,
            SCContent.reinforcedStairsJungle,
            SCContent.reinforcedStairsNetherBrick,
            SCContent.reinforcedStairsOak,
            SCContent.reinforcedStairsPurpur,
            SCContent.reinforcedStairsQuartz,
            SCContent.reinforcedStairsRedSandstone,
            SCContent.reinforcedStairsSandstone,
            SCContent.reinforcedStairsSpruce,
            SCContent.reinforcedStairsStone,
            SCContent.reinforcedStairsStoneBrick,
            SCContent.reinforcedStone,
            SCContent.reinforcedStoneBrick,
            SCContent.reinforcedStoneSlabs,
            SCContent.reinforcedStoneSlabs2,
            SCContent.reinforcedWoodPlanks,
            SCContent.reinforcedWoodSlabs,
            SCContent.reinforcedWool
    };
    //registering reinforced blocks color overlay for world
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> 0x999999, blocksToTint);
    //same thing for inventory
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor)(stack, tintIndex) -> 0x999999, blocksToTint);
}
项目:SecurityCraft    文件:ClientProxy.java   
@Override
@SideOnly(Side.CLIENT)
public void registerRenderThings(){
    KeyBindings.init();

    RenderingRegistry.registerEntityRenderingHandler(EntityBouncingBetty.class, new RenderBouncingBetty(Minecraft.getMinecraft().getRenderManager()));
    RenderingRegistry.registerEntityRenderingHandler(EntityIMSBomb.class, new RenderIMSBomb(Minecraft.getMinecraft().getRenderManager()));
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityKeypadChest.class, new TileEntityKeypadChestRenderer());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySecurityCamera.class, new TileEntitySecurityCameraRenderer());

    TileEntityItemStackRenderer.instance = new ItemKeypadChestRenderer();

    Block[] blocksToTint = {
            SCContent.reinforcedBrick,
            SCContent.reinforcedCobblestone,
            SCContent.reinforcedCompressedBlocks,
            SCContent.reinforcedConcrete,
            SCContent.reinforcedDirt,
            SCContent.reinforcedDoubleStoneSlabs,
            SCContent.reinforcedDoubleStoneSlabs2,
            SCContent.reinforcedDoubleWoodSlabs,
            SCContent.reinforcedEndStoneBricks,
            SCContent.reinforcedHardenedClay,
            SCContent.reinforcedMetals,
            SCContent.reinforcedMossyCobblestone,
            SCContent.reinforcedNetherBrick,
            SCContent.reinforcedNewLogs,
            SCContent.reinforcedOldLogs,
            SCContent.reinforcedPrismarine,
            SCContent.reinforcedPurpur,
            SCContent.reinforcedQuartz,
            SCContent.reinforcedRedNetherBrick,
            SCContent.reinforcedRedSandstone,
            SCContent.reinforcedSandstone,
            SCContent.reinforcedStainedHardenedClay,
            SCContent.reinforcedStairsAcacia,
            SCContent.reinforcedStairsBirch,
            SCContent.reinforcedStairsBrick,
            SCContent.reinforcedStairsCobblestone,
            SCContent.reinforcedStairsDarkoak,
            SCContent.reinforcedStairsJungle,
            SCContent.reinforcedStairsNetherBrick,
            SCContent.reinforcedStairsOak,
            SCContent.reinforcedStairsPurpur,
            SCContent.reinforcedStairsQuartz,
            SCContent.reinforcedStairsRedSandstone,
            SCContent.reinforcedStairsSandstone,
            SCContent.reinforcedStairsSpruce,
            SCContent.reinforcedStairsStone,
            SCContent.reinforcedStairsStoneBrick,
            SCContent.reinforcedStone,
            SCContent.reinforcedStoneBrick,
            SCContent.reinforcedStoneSlabs,
            SCContent.reinforcedStoneSlabs2,
            SCContent.reinforcedWoodPlanks,
            SCContent.reinforcedWoodSlabs,
            SCContent.reinforcedWool
    };
    //registering reinforced blocks color overlay for world
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((state, worldIn, pos, tintIndex) -> 0x999999, blocksToTint);
    //same thing for inventory
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor)(stack, tintIndex) -> 0x999999, blocksToTint);
}
项目:Bookshelf    文件:IColorfulItem.java   
/**
 * Gets the color handler for the item.
 *
 * @return The color handler for the item.
 */
@SideOnly(Side.CLIENT)
public IItemColor getColorHandler ();
项目:Bookshelf    文件:RegistryHelper.java   
/**
 * Registers a color handler for an item. This method is client side only, and should be
 * called during the init stage.
 *
 * @param item The item to register the handler for.
 * @param color The color handler to register.
 */
@SideOnly(Side.CLIENT)
public void registerColorHandler (@Nonnull Item item, @Nonnull IItemColor color) {

    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(color, item);
}