use of net.minecraft.client.renderer.color.IItemColor in project SilentGems by SilentChaos512.
the class ColorHandlers method init.
public static void init() {
ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
// Tools
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return ToolRenderHelper.getInstance().getColor(stack, ToolPartPosition.forRenderPass(tintIndex));
}
}, ModItems.tools.toArray(new Item[ModItems.tools.size()]));
// Shields
itemColors.registerItemColorHandler(new IItemColor() {
int[] passes = { ToolRenderHelper.PASS_HEAD, ToolRenderHelper.PASS_ROD };
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex < 0 || tintIndex >= passes.length)
return 0xFFFFFF;
return ToolRenderHelper.getInstance().getColor(stack, ToolPartPosition.forRenderPass(tintIndex));
}
}, ModItems.shield);
// Armor (temp)
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
// FIXME: Multiple passes needed?
return ArmorHelper.getRenderColor(stack, ArmorPartPosition.NORTH);
}
}, ModItems.gemHelmet, ModItems.gemChestplate, ModItems.gemLeggings, ModItems.gemBoots);
// Enchantment Tokens
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 1)
return ModItems.enchantmentToken.getOutlineColor(stack);
return 0xFFFFFF;
}
}, ModItems.enchantmentToken);
// Return Home Charm
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 0) {
int meta = stack.getItemDamage();
if (meta >= 0 && meta < EnumGem.values().length) {
EnumGem gem = EnumGem.values()[meta];
return gem.color;
}
}
return 0xFFFFFF;
}
}, ModItems.returnHomeCharm);
// Node Mover
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return tintIndex != 1 ? 0xFFFFFF : ClientTickHandler.nodeMoverColor.getColor();
}
}, ModItems.nodeMover);
// Drawing Compass
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
return tintIndex == 0 ? ModItems.drawingCompass.getColor(stack).getColor() : 0xFFFFFF;
}
}, ModItems.drawingCompass);
// Chaos Runes
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 1) {
ChaosBuff buff = ModItems.chaosRune.getBuff(stack);
if (buff != null) {
return buff.getColor();
}
}
return 0xFFFFFF;
}
}, ModItems.chaosRune);
// Holding Gem
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
if (tintIndex == 1) {
if (stack.hasTagCompound()) {
int id = stack.getTagCompound().getShort(ItemHoldingGem.NBT_GEM_ID);
if (id >= 0 && id < EnumGem.values().length)
return EnumGem.values()[id].color;
}
} else if (tintIndex == 2) {
IBlockState state = ModItems.holdingGem.getBlockPlaced(stack);
if (state != null) {
return 0xFFFFFF;
// return state.getMapColor().colorValue;
}
}
return 0xFFFFFF;
}
}, ModItems.holdingGem);
// Soul Gems
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
Soul soul = ModItems.soulGem.getSoul(stack);
if (soul == null) {
return 0xFFFFFF;
} else if (tintIndex == 1) {
return soul.colorSecondary;
} else {
return soul.colorPrimary;
}
}
}, ModItems.soulGem);
// Tool Soul
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
// TODO Auto-generated method stub
ToolSoul soul = ModItems.toolSoul.getSoul(stack);
if (soul == null)
return tintIndex == 1 ? 0xFF00FF : tintIndex == 2 ? 0x0 : 0xFFFFFF;
switch(tintIndex) {
case 0:
float ratio = 0.5f + MathHelper.sin((float) ClientTickHandler.ticksInGame / 15) / 6;
return Color.blend(soul.getPrimaryElement().color, soul.getSecondaryElement().color, ratio);
case 1:
return soul.getPrimaryElement().color;
case 2:
return soul.getSecondaryElement().color;
default:
return 0xFFFFFF;
}
}
}, ModItems.toolSoul);
// Arrows
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
// TODO Auto-generated method stub
return 0xFFFFFF;
}
}, ModItems.arrow);
}
use of net.minecraft.client.renderer.color.IItemColor 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 net.minecraft.client.renderer.color.IItemColor in project Minestuck by mraof.
the class ClientProxy method registerRenderers.
public static void registerRenderers() {
Minecraft mc = Minecraft.getMinecraft();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySkaiaPortal.class, new RenderSkaiaPortal());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityGate.class, new RenderGate());
// MinecraftForgeClient.registerItemRenderer(Minestuck.captchaCard, new RenderCard());
mc.getItemColors().registerItemColorHandler(new IItemColor() {
@Override
public int colorMultiplier(ItemStack stack, int tintIndex) {
if (tintIndex == 0 || tintIndex == 1) {
int color = stack.getMetadata() == 0 ? -1 : ColorCollector.getColor(stack.getMetadata() - 1);
if (tintIndex == 1) {
int i0 = ((color & 255) + 255) / 2;
int i1 = (((color >> 8) & 255) + 255) / 2;
int i2 = (((color >> 16) & 255) + 255) / 2;
color = i0 | (i1 << 8) | (i2 << 16);
}
return color;
} else
return -1;
}
}, MinestuckItems.cruxiteDowel, MinestuckItems.cruxiteApple, MinestuckItems.cruxitePotion);
}
use of net.minecraft.client.renderer.color.IItemColor in project Random-Things by lumien231.
the class ClientProxy method registerColors.
private void registerColors() {
for (Entry<Object, Object> entry : scheduledColorRegister.entrySet()) {
if (entry.getKey() instanceof IRTBlockColor) {
final IRTBlockColor blockColor = (IRTBlockColor) entry.getKey();
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor() {
@Override
public int colorMultiplier(IBlockState state, IBlockAccess p_186720_2_, BlockPos pos, int tintIndex) {
return blockColor.colorMultiplier(state, p_186720_2_, pos, tintIndex);
}
}, (Block) entry.getValue());
} else if (entry.getKey() instanceof IRTItemColor) {
final IRTItemColor itemColor = (IRTItemColor) entry.getKey();
try {
ItemColors itemColors = (ItemColors) itemColorsField.get(Minecraft.getMinecraft());
itemColors.registerItemColorHandler(new IItemColor() {
@Override
public int colorMultiplier(ItemStack stack, int tintIndex) {
return itemColor.getColorFromItemstack(stack, tintIndex);
}
}, (Item) entry.getValue());
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
use of net.minecraft.client.renderer.color.IItemColor in project CompositeGear by TwilightWingsStudio.
the class CompositeGear method registerItemColorHandler.
@SideOnly(Side.CLIENT)
public void registerItemColorHandler() {
modLog.info("Registering IItemColor handler for mod items.");
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new IItemColor() {
public int colorMultiplier(ItemStack stack, int tintIndex) {
return tintIndex > 0 ? -1 : ((ItemArmor) stack.getItem()).getColor(stack);
}
}, ItemsCG.compositeHelmet, ItemsCG.compositeChestplate, ItemsCG.compositeLeggings, ItemsCG.compositeBoots, ItemsCG.compositeFaceplate, ItemsCG.ushankaHat, ItemsCG.balaclavaMask, ItemsCG.shemaghMask, ItemsCG.rubberGasmask, ItemsCG.respiratorMask, ItemsCG.respiratorMaskComposite, ItemsCG.compositeLightHelmet, ItemsCG.compositeLightVest, ItemsCG.compositeLightLeggings, ItemsCG.compositeLightBoots);
}
Aggregations