Search in sources :

Example 6 with IPaintable

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

the class BasicPainterTemplate method getCompletedResult.

@Override
@Nonnull
public ResultStack[] getCompletedResult(@Nonnull ItemStack paintSource, @Nonnull ItemStack target) {
    Block targetBlock = getTargetBlock(target);
    if (Prep.isInvalid(target) || Prep.isInvalid(paintSource) || targetBlock == null) {
        return new ResultStack[0];
    }
    Block paintBlock = PaintUtil.getBlockFromItem(paintSource);
    if (paintBlock == null) {
        return new ResultStack[0];
    }
    IBlockState paintState = PaintUtil.Block$getBlockFromItem_stack$getItem___$getStateFromMeta_stack$getMetadata___(paintSource, paintBlock);
    if (paintState == null) {
        return new ResultStack[0];
    }
    ItemStack result = isUnpaintingOp(paintSource, target);
    if (Prep.isInvalid(result)) {
        result = mkItemStack(target, targetBlock);
        if (targetBlock == Block.getBlockFromItem(target.getItem()) && target.hasTagCompound()) {
            result.setTagCompound(NullHelper.notnullM(target.getTagCompound(), "ItemStack.getTagCompound() after .hasTagCompound()").copy());
        }
        ((IPaintable) targetBlock).setPaintSource(targetBlock, result, paintState);
    } else if (result.getItem() == target.getItem() && target.hasTagCompound()) {
        result.setTagCompound(NullHelper.notnullM(target.getTagCompound(), "ItemStack.getTagCompound() after .hasTagCompound()").copy());
        Block realresult = PaintUtil.getBlockFromItem(result);
        if (realresult instanceof IPaintable) {
            ((IPaintable) realresult).setPaintSource(realresult, result, null);
        } else {
            PaintUtil.setSourceBlock(result, null);
        }
    }
    return new ResultStack[] { new ResultStack(result) };
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IPaintable(crazypants.enderio.base.paint.IPaintable) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 7 with IPaintable

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

the class PaintHelper method addHitEffects.

@SideOnly(Side.CLIENT)
public static boolean addHitEffects(@Nonnull IBlockState state, @Nonnull World world, @Nonnull RayTraceResult target, @Nonnull ParticleManager effectRenderer) {
    if (state.getBlock() instanceof IPaintable) {
        BlockPos pos = target.getBlockPos();
        IBlockState paintSource = ((IPaintable) state.getBlock()).getPaintSource(state, world, pos);
        if (paintSource != null) {
            addBlockHitEffects(world, state, paintSource, pos, target.sideHit, effectRenderer);
            lastTexture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(paintSource);
            return true;
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IPaintable(crazypants.enderio.base.paint.IPaintable) BlockPos(net.minecraft.util.math.BlockPos) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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