ItemStack paintBall = getColor( is );
IMEInventory<IAEItemStack> inv = AEApi.instance().registries().cell().getCellInventory( is, null, StorageChannel.ITEMS );
if ( inv != null )
{
IAEItemStack option = inv.extractItems( AEItemStack.create( paintBall ), Actionable.SIMULATE, new BaseActionSource() );
if ( option != null )
{
paintBall = option.getItemStack();
paintBall.stackSize = 1;
}
else
paintBall = null;
if ( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) )
return false;
if ( paintBall != null && paintBall.getItem() instanceof ItemSnowball )
{
ForgeDirection orientation = ForgeDirection.getOrientation( side );
TileEntity te = w.getTileEntity( x, y, z );
// clean cables.
if ( te instanceof IColorableTile )
{
if ( getAECurrentPower( is ) > powerPerUse && ((IColorableTile) te).getColor() != AEColor.Transparent )
{
if ( ((IColorableTile) te).recolourBlock( orientation, AEColor.Transparent, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
extractAEPower( is, powerPerUse );
return true;
}
}
}
// clean paint balls..
Block testBlk = w.getBlock( x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ );
TileEntity painted = w.getTileEntity( x + orientation.offsetX, y + orientation.offsetY, z + orientation.offsetZ );
if ( getAECurrentPower( is ) > powerPerUse && testBlk instanceof BlockPaint && painted instanceof TilePaint )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
extractAEPower( is, powerPerUse );
((TilePaint) painted).cleanSide( orientation.getOpposite() );
return true;
}
}
else if ( paintBall != null )
{
AEColor color = getColorFromItem( paintBall );
if ( color != null && getAECurrentPower( is ) > powerPerUse )
{
if ( color != AEColor.Transparent
&& recolourBlock( blk, ForgeDirection.getOrientation( side ), w, x, y, z, ForgeDirection.getOrientation( side ), color, p ) )
{
inv.extractItems( AEItemStack.create( paintBall ), Actionable.MODULATE, new BaseActionSource() );
extractAEPower( is, powerPerUse );
return true;
}
}