Search in sources :

Example 1 with IRTBlockColor

use of lumien.randomthings.lib.IRTBlockColor 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();
            }
        }
    }
}
Also used : IRTBlockColor(lumien.randomthings.lib.IRTBlockColor) IBlockState(net.minecraft.block.state.IBlockState) IBlockAccess(net.minecraft.world.IBlockAccess) IRTItemColor(lumien.randomthings.lib.IRTItemColor) IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) EntityProjectedItem(lumien.randomthings.entitys.EntityProjectedItem) RenderProjectedItem(lumien.randomthings.client.render.RenderProjectedItem) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) ItemColors(net.minecraft.client.renderer.color.ItemColors) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

RenderProjectedItem (lumien.randomthings.client.render.RenderProjectedItem)1 EntityProjectedItem (lumien.randomthings.entitys.EntityProjectedItem)1 IRTBlockColor (lumien.randomthings.lib.IRTBlockColor)1 IRTItemColor (lumien.randomthings.lib.IRTItemColor)1 IBlockState (net.minecraft.block.state.IBlockState)1 IBlockColor (net.minecraft.client.renderer.color.IBlockColor)1 IItemColor (net.minecraft.client.renderer.color.IItemColor)1 ItemColors (net.minecraft.client.renderer.color.ItemColors)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 IBlockAccess (net.minecraft.world.IBlockAccess)1