reformatted all src files (#141)
This commit is contained in:
@@ -19,12 +19,6 @@
|
||||
package appeng.util.inv;
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -35,173 +29,145 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
public class IMEAdaptor extends InventoryAdaptor
|
||||
{
|
||||
public class IMEAdaptor extends InventoryAdaptor {
|
||||
|
||||
private final IMEInventory<IAEItemStack> target;
|
||||
private final IActionSource src;
|
||||
private int maxSlots = 0;
|
||||
private final IMEInventory<IAEItemStack> target;
|
||||
private final IActionSource src;
|
||||
private int maxSlots = 0;
|
||||
|
||||
public IMEAdaptor( final IMEInventory<IAEItemStack> input, final IActionSource src )
|
||||
{
|
||||
this.target = input;
|
||||
this.src = src;
|
||||
}
|
||||
public IMEAdaptor(final IMEInventory<IAEItemStack> input, final IActionSource src) {
|
||||
this.target = input;
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSlots()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean hasSlots() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ItemSlot> iterator()
|
||||
{
|
||||
return new IMEAdaptorIterator( this, this.getList() );
|
||||
}
|
||||
@Override
|
||||
public Iterator<ItemSlot> iterator() {
|
||||
return new IMEAdaptorIterator(this, this.getList());
|
||||
}
|
||||
|
||||
private IItemList<IAEItemStack> getList()
|
||||
{
|
||||
return this.target.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
|
||||
}
|
||||
private IItemList<IAEItemStack> getList() {
|
||||
return this.target.getAvailableItems(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeItems( final int amount, final ItemStack filter, final IInventoryDestination destination )
|
||||
{
|
||||
return this.doRemoveItems( amount, filter, destination, Actionable.MODULATE );
|
||||
}
|
||||
@Override
|
||||
public ItemStack removeItems(final int amount, final ItemStack filter, final IInventoryDestination destination) {
|
||||
return this.doRemoveItems(amount, filter, destination, Actionable.MODULATE);
|
||||
}
|
||||
|
||||
private ItemStack doRemoveItems( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type )
|
||||
{
|
||||
IAEItemStack req = null;
|
||||
private ItemStack doRemoveItems(final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type) {
|
||||
IAEItemStack req = null;
|
||||
|
||||
if( filter.isEmpty() )
|
||||
{
|
||||
final IItemList<IAEItemStack> list = this.getList();
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
req = list.getFirstItem();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
req = AEItemStack.fromItemStack( filter );
|
||||
}
|
||||
if (filter.isEmpty()) {
|
||||
final IItemList<IAEItemStack> list = this.getList();
|
||||
if (!list.isEmpty()) {
|
||||
req = list.getFirstItem();
|
||||
}
|
||||
} else {
|
||||
req = AEItemStack.fromItemStack(filter);
|
||||
}
|
||||
|
||||
IAEItemStack out = null;
|
||||
IAEItemStack out = null;
|
||||
|
||||
if( req != null )
|
||||
{
|
||||
req.setStackSize( amount );
|
||||
out = this.target.extractItems( req, type, this.src );
|
||||
}
|
||||
if (req != null) {
|
||||
req.setStackSize(amount);
|
||||
out = this.target.extractItems(req, type, this.src);
|
||||
}
|
||||
|
||||
if( out != null )
|
||||
{
|
||||
return out.createItemStack();
|
||||
}
|
||||
if (out != null) {
|
||||
return out.createItemStack();
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateRemove( final int amount, final ItemStack filter, final IInventoryDestination destination )
|
||||
{
|
||||
return this.doRemoveItems( amount, filter, destination, Actionable.SIMULATE );
|
||||
}
|
||||
@Override
|
||||
public ItemStack simulateRemove(final int amount, final ItemStack filter, final IInventoryDestination destination) {
|
||||
return this.doRemoveItems(amount, filter, destination, Actionable.SIMULATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeSimilarItems( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination )
|
||||
{
|
||||
if( filter.isEmpty() )
|
||||
{
|
||||
return this.doRemoveItems( amount, null, destination, Actionable.MODULATE );
|
||||
}
|
||||
return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.MODULATE, fuzzyMode );
|
||||
}
|
||||
@Override
|
||||
public ItemStack removeSimilarItems(final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination) {
|
||||
if (filter.isEmpty()) {
|
||||
return this.doRemoveItems(amount, null, destination, Actionable.MODULATE);
|
||||
}
|
||||
return this.doRemoveItemsFuzzy(amount, filter, destination, Actionable.MODULATE, fuzzyMode);
|
||||
}
|
||||
|
||||
private ItemStack doRemoveItemsFuzzy( final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type, final FuzzyMode fuzzyMode )
|
||||
{
|
||||
final IAEItemStack reqFilter = AEItemStack.fromItemStack( filter );
|
||||
if( reqFilter == null )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
private ItemStack doRemoveItemsFuzzy(final int amount, final ItemStack filter, final IInventoryDestination destination, final Actionable type, final FuzzyMode fuzzyMode) {
|
||||
final IAEItemStack reqFilter = AEItemStack.fromItemStack(filter);
|
||||
if (reqFilter == null) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
IAEItemStack out = null;
|
||||
IAEItemStack out = null;
|
||||
|
||||
for( final IAEItemStack req : ImmutableList.copyOf( this.getList().findFuzzy( reqFilter, fuzzyMode ) ) )
|
||||
{
|
||||
if( req != null )
|
||||
{
|
||||
req.setStackSize( amount );
|
||||
out = this.target.extractItems( req, type, this.src );
|
||||
if( out != null )
|
||||
{
|
||||
return out.createItemStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final IAEItemStack req : ImmutableList.copyOf(this.getList().findFuzzy(reqFilter, fuzzyMode))) {
|
||||
if (req != null) {
|
||||
req.setStackSize(amount);
|
||||
out = this.target.extractItems(req, type, this.src);
|
||||
if (out != null) {
|
||||
return out.createItemStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateSimilarRemove( final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination )
|
||||
{
|
||||
if( filter.isEmpty() )
|
||||
{
|
||||
return this.doRemoveItems( amount, ItemStack.EMPTY, destination, Actionable.SIMULATE );
|
||||
}
|
||||
return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.SIMULATE, fuzzyMode );
|
||||
}
|
||||
@Override
|
||||
public ItemStack simulateSimilarRemove(final int amount, final ItemStack filter, final FuzzyMode fuzzyMode, final IInventoryDestination destination) {
|
||||
if (filter.isEmpty()) {
|
||||
return this.doRemoveItems(amount, ItemStack.EMPTY, destination, Actionable.SIMULATE);
|
||||
}
|
||||
return this.doRemoveItemsFuzzy(amount, filter, destination, Actionable.SIMULATE, fuzzyMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack addItems( final ItemStack toBeAdded )
|
||||
{
|
||||
final IAEItemStack in = AEItemStack.fromItemStack( toBeAdded );
|
||||
if( in != null )
|
||||
{
|
||||
final IAEItemStack out = this.target.injectItems( in, Actionable.MODULATE, this.src );
|
||||
if( out != null )
|
||||
{
|
||||
return out.createItemStack();
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack addItems(final ItemStack toBeAdded) {
|
||||
final IAEItemStack in = AEItemStack.fromItemStack(toBeAdded);
|
||||
if (in != null) {
|
||||
final IAEItemStack out = this.target.injectItems(in, Actionable.MODULATE, this.src);
|
||||
if (out != null) {
|
||||
return out.createItemStack();
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd( final ItemStack toBeSimulated )
|
||||
{
|
||||
final IAEItemStack in = AEItemStack.fromItemStack( toBeSimulated );
|
||||
if( in != null )
|
||||
{
|
||||
final IAEItemStack out = this.target.injectItems( in, Actionable.SIMULATE, this.src );
|
||||
if( out != null )
|
||||
{
|
||||
return out.createItemStack();
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@Override
|
||||
public ItemStack simulateAdd(final ItemStack toBeSimulated) {
|
||||
final IAEItemStack in = AEItemStack.fromItemStack(toBeSimulated);
|
||||
if (in != null) {
|
||||
final IAEItemStack out = this.target.injectItems(in, Actionable.SIMULATE, this.src);
|
||||
if (out != null) {
|
||||
return out.createItemStack();
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItems()
|
||||
{
|
||||
return !this.getList().isEmpty();
|
||||
}
|
||||
@Override
|
||||
public boolean containsItems() {
|
||||
return !this.getList().isEmpty();
|
||||
}
|
||||
|
||||
int getMaxSlots()
|
||||
{
|
||||
return this.maxSlots;
|
||||
}
|
||||
int getMaxSlots() {
|
||||
return this.maxSlots;
|
||||
}
|
||||
|
||||
void setMaxSlots( final int maxSlots )
|
||||
{
|
||||
this.maxSlots = maxSlots;
|
||||
}
|
||||
void setMaxSlots(final int maxSlots) {
|
||||
this.maxSlots = maxSlots;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user