Search in sources :

Example 1 with IPaintable

use of crazypants.enderio.base.paint.IPaintable 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;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) IPaintable(crazypants.enderio.base.paint.IPaintable) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ITintedBlock(crazypants.enderio.base.render.ITintedBlock)

Example 2 with IPaintable

use of crazypants.enderio.base.paint.IPaintable 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]));
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) ITintedItem(crazypants.enderio.base.render.ITintedItem) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) ITintedItem(crazypants.enderio.base.render.ITintedItem) IPaintable(crazypants.enderio.base.paint.IPaintable) NNList(com.enderio.core.common.util.NNList) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with IPaintable

use of crazypants.enderio.base.paint.IPaintable in project EnderIO by SleepyTrousers.

the class TOPCompatibility method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData hitData) {
    if (mode == ProbeMode.DEBUG) {
        probeInfo.text(blockState.toString());
    }
    if (probeInfo != null && world != null && blockState != null && hitData != null && (blockState.getBlock() instanceof BlockEio || blockState.getBlock() instanceof IPaintable)) {
        TileEntity tileEntity = BlockEnder.getAnyTileEntitySafe(world, NullHelper.notnull(hitData.getPos(), "JEI wants it so"));
        if (tileEntity != null) {
            EioBox eiobox = new EioBox(probeInfo);
            TOPData data = new TOPData(tileEntity, hitData);
            mkOwner(mode, eiobox, data);
            mkPaint(mode, eiobox, data);
            mkNotificationLine(mode, eiobox, data);
            mkProgressLine(mode, eiobox, data);
            mkRfLine(mode, eiobox, data);
            mkXPLine(mode, eiobox, data);
            mkRedstoneLine(mode, eiobox, data);
            mkSideConfigLine(mode, eiobox, data);
            mkRangeLine(mode, eiobox, data);
            mkTankLines(mode, eiobox, data);
            mkItemFillLevelLine(mode, eiobox, data);
            eiobox.finish();
            EioBox mobbox = new EioBox(probeInfo);
            mkMobsBox(mode, mobbox, world, data);
            mobbox.finish();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockEio(crazypants.enderio.base.BlockEio) IPaintable(crazypants.enderio.base.paint.IPaintable)

Example 4 with IPaintable

use of crazypants.enderio.base.paint.IPaintable in project EnderIO by SleepyTrousers.

the class PaintHelper method addDestroyEffects.

@SideOnly(Side.CLIENT)
public static boolean addDestroyEffects(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ParticleManager effectRenderer) {
    TextureAtlasSprite texture = null;
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() instanceof IPaintable) {
        IBlockState paintSource = ((IPaintable) state.getBlock()).getPaintSource(state, world, pos);
        if (paintSource != null) {
            texture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(paintSource);
        }
    }
    if (texture == null) {
        texture = lastTexture;
        if (texture == null) {
            return false;
        }
    }
    int i = 4;
    for (int j = 0; j < i; ++j) {
        for (int k = 0; k < i; ++k) {
            for (int l = 0; l < i; ++l) {
                double d0 = pos.getX() + (j + 0.5D) / i;
                double d1 = pos.getY() + (k + 0.5D) / i;
                double d2 = pos.getZ() + (l + 0.5D) / i;
                ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0);
                fx.setBlockPos(pos);
                fx.setParticleTexture(texture);
                effectRenderer.addEffect(fx);
            }
        }
    }
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) IPaintable(crazypants.enderio.base.paint.IPaintable) ParticleDigging(net.minecraft.client.particle.ParticleDigging) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 5 with IPaintable

use of crazypants.enderio.base.paint.IPaintable 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;
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) ITintedItem(crazypants.enderio.base.render.ITintedItem) IBlockState(net.minecraft.block.state.IBlockState) ITintedItem(crazypants.enderio.base.render.ITintedItem) IPaintable(crazypants.enderio.base.paint.IPaintable) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IPaintable (crazypants.enderio.base.paint.IPaintable)7 IBlockState (net.minecraft.block.state.IBlockState)5 Block (net.minecraft.block.Block)4 ITintedBlock (crazypants.enderio.base.render.ITintedBlock)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 ITintedItem (crazypants.enderio.base.render.ITintedItem)2 IBlockColor (net.minecraft.client.renderer.color.IBlockColor)2 IItemColor (net.minecraft.client.renderer.color.IItemColor)2 Item (net.minecraft.item.Item)2 ItemStack (net.minecraft.item.ItemStack)2 NNList (com.enderio.core.common.util.NNList)1 BlockEio (crazypants.enderio.base.BlockEio)1 Nonnull (javax.annotation.Nonnull)1 ParticleDigging (net.minecraft.client.particle.ParticleDigging)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1