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) };
}
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;
}
Aggregations