use of net.minecraft.client.renderer.color.IBlockColor in project EnderIO by SleepyTrousers.
the class PaintTintHandler method colorMultiplier.
@Override
public int colorMultiplier(@Nonnull IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
if (world == null || pos == null) {
return -1;
}
Block block = state.getBlock();
IBlockState paintSource = null;
if (block instanceof IPaintable) {
paintSource = ((IPaintable) block).getPaintSource(state, world, pos);
if (paintSource != null && paintSource.getBlock() != block) {
block = paintSource.getBlock();
state = paintSource;
} else {
paintSource = null;
}
}
if (block instanceof ITintedBlock) {
return ((ITintedBlock) block).getBlockTint(state, world, pos, tintIndex);
}
if (block instanceof IBlockColor) {
return ((IBlockColor) block).colorMultiplier(state, world, pos, tintIndex);
}
if (paintSource != null) {
return Minecraft.getMinecraft().getBlockColors().colorMultiplier(paintSource, world, pos, tintIndex);
}
return -1;
}
use of net.minecraft.client.renderer.color.IBlockColor 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.IBlockColor 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.IBlockColor in project Bewitchment by Um-Mitternacht.
the class ClientProxy method init.
@Override
public void init(FMLInitializationEvent event) {
Keybinds.registerKeys();
BlockColors blocks = Minecraft.getMinecraft().getBlockColors();
// Block Colors
blocks.registerBlockColorHandler(new BlockCandleColorHandler(), ModBlocks.candle_medium, ModBlocks.candle_small, ModBlocks.candle_medium_lit, ModBlocks.candle_small_lit);
blocks.registerBlockColorHandler(new IBlockColor() {
@Override
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
EnumGlyphType type = state.getValue(BlockCircleGlyph.TYPE);
switch(type) {
case ENDER:
return 0x770077;
case GOLDEN:
return 0xe3dc3c;
case NETHER:
return 0xbb0000;
default:
case NORMAL:
return 0xFFFFFF;
case ANY:
// A green one should never happen!
return 0x00FF00;
}
}
}, ModBlocks.ritual_glyphs);
blocks.registerBlockColorHandler(new IBlockColor() {
@Override
public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
if (tintIndex == 1) {
return Color.HSBtoRGB((pos.getX() + pos.getY() + pos.getZ()) % 50 / 50f, 0.4f, 1f);
}
return -1;
}
}, ModBlocks.crystal_ball);
ItemColors items = Minecraft.getMinecraft().getItemColors();
// Item Colors
items.registerItemColorHandler(new ItemCandleColorHandler(), Item.getItemFromBlock(ModBlocks.candle_medium), Item.getItemFromBlock(ModBlocks.candle_small));
items.registerItemColorHandler(new BrewItemColorHandler(), ModItems.brew_phial_drink, ModItems.brew_phial_splash, ModItems.brew_phial_linger);
items.registerItemColorHandler(new IItemColor() {
@Override
public int colorMultiplier(ItemStack stack, int tintIndex) {
if (tintIndex == 0) {
ISpell s = ItemSpellPage.getSpellFromItemStack(stack);
if (s != null)
return s.getColor();
}
return -1;
}
}, ModItems.spell_page);
NetworkRegistry.INSTANCE.registerGuiHandler(Bewitchment.instance, new GuiHandler());
}
use of net.minecraft.client.renderer.color.IBlockColor in project pnc-repressurized by TeamPneumatic.
the class BlockColorHandler method registerColorHandlers.
public static void registerColorHandlers() {
final IBlockColor heatColor = (state, blockAccess, pos, tintIndex) -> {
if (blockAccess != null && pos != null) {
TileEntity te = blockAccess.getTileEntity(pos);
int heatLevel = 10;
if (te instanceof TileEntityCompressedIronBlock) {
heatLevel = ((TileEntityCompressedIronBlock) te).getHeatLevel();
} else if (te instanceof TileEntityVortexTube) {
switch(tintIndex) {
case 0:
heatLevel = ((TileEntityVortexTube) te).getHotHeatLevel();
break;
case 1:
heatLevel = ((TileEntityVortexTube) te).getColdHeatLevel();
break;
}
}
double[] color = TileEntityCompressedIronBlock.getColorForHeatLevel(heatLevel);
return 0xFF000000 + ((int) (color[0] * 255) << 16) + ((int) (color[1] * 255) << 8) + (int) (color[2] * 255);
}
return 0xFFFFFFFF;
};
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(heatColor, Blockss.COMPRESSED_IRON, Blockss.HEAT_SINK, Blockss.VORTEX_TUBE);
final IBlockColor uvLightBoxLampColor = (state, blockAccess, pos, tintIndex) -> {
if (blockAccess != null && pos != null) {
TileEntity te = blockAccess.getTileEntity(pos);
if (te instanceof TileEntityUVLightBox) {
return ((TileEntityUVLightBox) te).areLightsOn ? 0xFF4000FF : 0xFFAFAFE4;
}
}
return 0xFFAFAFE4;
};
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(uvLightBoxLampColor, Blockss.UV_LIGHT_BOX);
final IBlockColor camoColor = (state, worldIn, pos, tintIndex) -> {
if (pos == null || worldIn == null)
return 0xffffff;
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof ICamouflageableTE && ((ICamouflageableTE) te).getCamouflage() != null) {
return Minecraft.getMinecraft().getBlockColors().colorMultiplier(((ICamouflageableTE) te).getCamouflage(), te.getWorld(), pos, tintIndex);
} else {
return 0xffffff;
}
};
for (Block b : Blockss.blocks) {
if (b instanceof BlockPneumaticCraftCamo) {
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(camoColor, b);
}
}
}
Aggregations