use of crazypants.enderio.base.render.ITintedItem in project EnderIO by SleepyTrousers.
the class SmartModelAttacher method registerColoredBlocksAndItems.
@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]));
}
use of crazypants.enderio.base.render.ITintedItem 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;
}
Aggregations