2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.util;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
2014-02-15 04:16:44 +01:00
|
|
|
import net.minecraft.block.BlockAir;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public class InWorldToolOperationResult
|
|
|
|
{
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
public final ItemStack BlockItem;
|
|
|
|
public final List<ItemStack> Drops;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public InWorldToolOperationResult()
|
|
|
|
{
|
|
|
|
this.BlockItem = null;
|
|
|
|
this.Drops = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public InWorldToolOperationResult( ItemStack block, List<ItemStack> drops )
|
|
|
|
{
|
|
|
|
this.BlockItem = block;
|
|
|
|
this.Drops = drops;
|
|
|
|
}
|
|
|
|
|
|
|
|
public InWorldToolOperationResult( ItemStack block )
|
|
|
|
{
|
|
|
|
this.BlockItem = block;
|
|
|
|
this.Drops = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static InWorldToolOperationResult getBlockOperationResult( ItemStack[] items )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
List<ItemStack> temp = new ArrayList<ItemStack>();
|
|
|
|
ItemStack b = null;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ItemStack l : items )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( b == null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
Block bl = Block.getBlockFromItem( l.getItem() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( bl != null && !( bl instanceof BlockAir ) )
|
2014-02-09 02:34:52 +01:00
|
|
|
{
|
|
|
|
b = l;
|
|
|
|
continue;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
temp.add( l );
|
|
|
|
}
|
|
|
|
|
|
|
|
return new InWorldToolOperationResult( b, temp );
|
|
|
|
}
|
|
|
|
}
|