Search in sources :

Example 1 with IColoredItem

use of biomesoplenty.common.item.IColoredItem in project BiomesOPlenty by Glitchfiend.

the class ClientProxy method registerColouring.

@Override
public void registerColouring() {
    // do this here purely for timing reasons
    ModelLoader.registerItemVariants(ForgeModContainer.getInstance().universalBucket, bucketModelLocations);
    for (Block block : blocksToColour) {
        IBOPBlock bopBlock = (IBOPBlock) block;
        if (bopBlock.getBlockColor() != null)
            Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(bopBlock.getBlockColor(), block);
        if (bopBlock.getItemColor() != null)
            Minecraft.getMinecraft().getItemColors().registerItemColorHandler(bopBlock.getItemColor(), block);
    }
    for (Item item : itemsToColor) {
        IColoredItem coloredItem = (IColoredItem) item;
        Minecraft.getMinecraft().getItemColors().registerItemColorHandler(coloredItem.getItemColor(), item);
    }
}
Also used : Item(net.minecraft.item.Item) IColoredItem(biomesoplenty.common.item.IColoredItem) IBOPBlock(biomesoplenty.common.block.IBOPBlock) Block(net.minecraft.block.Block) IBOPBlock(biomesoplenty.common.block.IBOPBlock) IColoredItem(biomesoplenty.common.item.IColoredItem)

Example 2 with IColoredItem

use of biomesoplenty.common.item.IColoredItem in project BiomesOPlenty by Glitchfiend.

the class ClientProxy method registerItemSided.

@Override
public void registerItemSided(Item item) {
    // register sub types if there are any
    if (item.getHasSubtypes()) {
        NonNullList<ItemStack> subItems = NonNullList.create();
        item.getSubItems(CreativeTabBOP.instance, subItems);
        for (ItemStack subItem : subItems) {
            String subItemName = item.getUnlocalizedName(subItem);
            // remove 'item.' from the front
            subItemName = subItemName.substring(subItemName.indexOf(".") + 1);
            ModelLoader.registerItemVariants(item, new ResourceLocation(BiomesOPlenty.MOD_ID, subItemName));
            ModelLoader.setCustomModelResourceLocation(item, subItem.getMetadata(), new ModelResourceLocation(BiomesOPlenty.MOD_ID + ":" + subItemName, "inventory"));
        }
    } else {
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(BiomesOPlenty.MOD_ID + ":" + item.delegate.name().getResourcePath(), "inventory"));
    }
    // Register colour handlers
    if (item instanceof IColoredItem && ((IColoredItem) item).getItemColor() != null) {
        itemsToColor.add(item);
    }
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ItemStack(net.minecraft.item.ItemStack) IColoredItem(biomesoplenty.common.item.IColoredItem)

Aggregations

IColoredItem (biomesoplenty.common.item.IColoredItem)2 IBOPBlock (biomesoplenty.common.block.IBOPBlock)1 Block (net.minecraft.block.Block)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 ResourceLocation (net.minecraft.util.ResourceLocation)1