Basic reformat, hit once, hope never again

This commit is contained in:
thatsIch
2015-04-03 08:54:31 +02:00
parent 4ff1631f89
commit d34c988c88
886 changed files with 31400 additions and 30990 deletions
@@ -46,11 +46,11 @@ public class BSCrate implements IMEInventory<IAEItemStack>
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if ( mode == Actionable.SIMULATE )
if( mode == Actionable.SIMULATE )
return null;
ItemStack failed = this.crateStorage.insertItems( input.getItemStack() );
if ( failed == null )
if( failed == null )
return null;
input.setStackSize( failed.stackSize );
return input;
@@ -59,7 +59,7 @@ public class BSCrate implements IMEInventory<IAEItemStack>
@Override
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if ( mode == Actionable.SIMULATE )
if( mode == Actionable.SIMULATE )
{
int howMany = this.crateStorage.getItemCount( request.getItemStack() );
return howMany > request.getStackSize() ? request : request.copy().setStackSize( howMany );
@@ -72,7 +72,7 @@ public class BSCrate implements IMEInventory<IAEItemStack>
@Override
public IItemList getAvailableItems( IItemList out )
{
for ( ItemStack is : this.crateStorage.getContents() )
for( ItemStack is : this.crateStorage.getContents() )
{
out.add( AEItemStack.create( is ) );
}
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -27,21 +28,21 @@ import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
public class BSCrateHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc)
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc )
{
return channel == StorageChannel.ITEMS && te instanceof ICrateStorage;
}
@Override
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src)
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src )
{
if ( channel == StorageChannel.ITEMS )
if( channel == StorageChannel.ITEMS )
return new BSCrate( te, ForgeDirection.UNKNOWN );
return null;
}
}
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import java.util.Iterator;
import net.mcft.copy.betterstorage.api.crate.ICrateStorage;
@@ -31,29 +32,31 @@ import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.ItemSlot;
import appeng.util.iterators.StackToSlotIterator;
public class BSCrateStorageAdaptor extends InventoryAdaptor
{
final ICrateStorage cs;
final ForgeDirection side;
public BSCrateStorageAdaptor(Object te, ForgeDirection d) {
public BSCrateStorageAdaptor( Object te, ForgeDirection d )
{
this.cs = (ICrateStorage) te;
this.side = d;
}
@Override
public ItemStack removeItems(int amount, ItemStack filter, IInventoryDestination destination)
public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack target = null;
for (ItemStack is : this.cs.getContents())
for( ItemStack is : this.cs.getContents() )
{
if ( is != null )
if( is != null )
{
if ( is.stackSize > 0 && ( filter == null || Platform.isSameItem( filter, is )) )
if( is.stackSize > 0 && ( filter == null || Platform.isSameItem( filter, is ) ) )
{
if ( destination == null || destination.canInsert( is ) )
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
@@ -62,7 +65,7 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
}
if ( target != null )
if( target != null )
{
ItemStack f = Platform.cloneItemStack( target );
f.stackSize = amount;
@@ -73,17 +76,17 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
@Override
public ItemStack simulateRemove(int amount, ItemStack filter, IInventoryDestination destination)
public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination )
{
ItemStack target = null;
for (ItemStack is : this.cs.getContents())
for( ItemStack is : this.cs.getContents() )
{
if ( is != null )
if( is != null )
{
if ( is.stackSize > 0 && ( filter == null || Platform.isSameItem( filter, is )) )
if( is.stackSize > 0 && ( filter == null || Platform.isSameItem( filter, is ) ) )
{
if ( destination == null || destination.canInsert( is ) )
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
@@ -92,12 +95,12 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
}
if ( target != null )
if( target != null )
{
int cnt = this.cs.getItemCount( target );
if ( cnt == 0 )
if( cnt == 0 )
return null;
if ( cnt > amount )
if( cnt > amount )
cnt = amount;
ItemStack c = target.copy();
c.stackSize = cnt;
@@ -108,17 +111,17 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
@Override
public ItemStack removeSimilarItems(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination)
public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack target = null;
for (ItemStack is : this.cs.getContents())
for( ItemStack is : this.cs.getContents() )
{
if ( is != null )
if( is != null )
{
if ( is.stackSize > 0 && (filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode )) )
if( is.stackSize > 0 && ( filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode ) ) )
{
if ( destination == null || destination.canInsert( is ) )
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
@@ -127,7 +130,7 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
}
if ( target != null )
if( target != null )
{
ItemStack f = Platform.cloneItemStack( target );
f.stackSize = amount;
@@ -138,17 +141,17 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
@Override
public ItemStack simulateSimilarRemove(int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination)
public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
{
ItemStack target = null;
for (ItemStack is : this.cs.getContents())
for( ItemStack is : this.cs.getContents() )
{
if ( is != null )
if( is != null )
{
if ( is.stackSize > 0 && (filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode )) )
if( is.stackSize > 0 && ( filter == null || Platform.isSameItemFuzzy( filter, is, fuzzyMode ) ) )
{
if ( destination == null || destination.canInsert( is ) )
if( destination == null || destination.canInsert( is ) )
{
target = is;
break;
@@ -157,12 +160,12 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
}
if ( target != null )
if( target != null )
{
int cnt = this.cs.getItemCount( target );
if ( cnt == 0 )
if( cnt == 0 )
return null;
if ( cnt > amount )
if( cnt > amount )
cnt = amount;
ItemStack c = target.copy();
c.stackSize = cnt;
@@ -173,17 +176,17 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
}
@Override
public ItemStack addItems(ItemStack toBeAdded )
public ItemStack addItems( ItemStack toBeAdded )
{
return this.cs.insertItems( toBeAdded );
}
@Override
public ItemStack simulateAdd(ItemStack toBeSimulated )
public ItemStack simulateAdd( ItemStack toBeSimulated )
{
int items = this.cs.getSpaceForItem( toBeSimulated );
ItemStack B = Platform.cloneItemStack( toBeSimulated );
if ( toBeSimulated.stackSize <= items )
if( toBeSimulated.stackSize <= items )
return null;
B.stackSize -= items;
return B;
@@ -200,5 +203,4 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor
{
return new StackToSlotIterator( this.cs.getContents().iterator() );
}
}
@@ -18,17 +18,19 @@
package appeng.integration.modules.helpers;
import net.minecraft.entity.player.EntityPlayerMP;
import cpw.mods.fml.common.eventhandler.Event;
public class FMPPacketEvent extends Event
{
public final EntityPlayerMP sender;
public FMPPacketEvent(EntityPlayerMP sender) {
public FMPPacketEvent( EntityPlayerMP sender )
{
this.sender = sender;
}
}
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -30,39 +31,76 @@ import appeng.api.storage.data.IItemList;
import appeng.integration.abstraction.IFZ;
import appeng.util.item.AEItemStack;
public class FactorizationBarrel implements IMEInventory<IAEItemStack>
{
private final TileEntity te;
final IFZ fProxy;
private final TileEntity te;
public FactorizationBarrel(IFZ proxy, TileEntity tile) {
public FactorizationBarrel( IFZ proxy, TileEntity tile )
{
this.te = tile;
this.fProxy = proxy;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
public long remainingItemTypes()
{
return this.fProxy.barrelGetItem( this.te ) == null ? 1 : 0;
}
public long remainingItemCount()
{
return this.fProxy.barrelGetMaxItemCount( this.te ) - this.fProxy.barrelGetItemCount( this.te );
}
public boolean containsItemType(IAEItemStack i, boolean acceptEmpty)
@Override
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
if( input == null )
return null;
if( input.getStackSize() == 0 )
return null;
ItemStack shared = input.getItemStack();
if( shared.isItemDamaged() )
return input;
if( this.remainingItemTypes() > 0 )
{
if( mode == Actionable.MODULATE )
this.fProxy.setItemType( this.te, input.getItemStack() );
}
if( this.containsItemType( input, mode == Actionable.SIMULATE ) )
{
int max = this.fProxy.barrelGetMaxItemCount( this.te );
int newTotal = (int) this.storedItemCount() + (int) input.getStackSize();
if( newTotal > max )
{
if( mode == Actionable.MODULATE )
this.fProxy.barrelSetCount( this.te, max );
IAEItemStack result = input.copy();
result.setStackSize( newTotal - max );
return result;
}
else
{
if( mode == Actionable.MODULATE )
this.fProxy.barrelSetCount( this.te, newTotal );
return null;
}
}
return input;
}
public long remainingItemTypes()
{
return this.fProxy.barrelGetItem( this.te ) == null ? 1 : 0;
}
public boolean containsItemType( IAEItemStack i, boolean acceptEmpty )
{
ItemStack currentItem = this.fProxy.barrelGetItem( this.te );
// empty barrels want your love too!
if ( acceptEmpty && currentItem == null )
if( acceptEmpty && currentItem == null )
return true;
return i.equals( currentItem );
@@ -74,55 +112,14 @@ public class FactorizationBarrel implements IMEInventory<IAEItemStack>
}
@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
if ( input == null )
return null;
if ( input.getStackSize() == 0 )
return null;
ItemStack shared = input.getItemStack();
if ( shared.isItemDamaged() )
return input;
if ( this.remainingItemTypes() > 0 )
{
if ( mode == Actionable.MODULATE )
this.fProxy.setItemType( this.te, input.getItemStack() );
}
if ( this.containsItemType( input, mode == Actionable.SIMULATE ) )
{
int max = this.fProxy.barrelGetMaxItemCount( this.te );
int newTotal = (int) this.storedItemCount() + (int) input.getStackSize();
if ( newTotal > max )
{
if ( mode == Actionable.MODULATE )
this.fProxy.barrelSetCount( this.te, max );
IAEItemStack result = input.copy();
result.setStackSize( newTotal - max );
return result;
}
else
{
if ( mode == Actionable.MODULATE )
this.fProxy.barrelSetCount( this.te, newTotal );
return null;
}
}
return input;
}
@Override
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
{
if ( this.containsItemType( request, false ) )
if( this.containsItemType( request, false ) )
{
int howMany = (int) this.storedItemCount();
if ( request.getStackSize() >= howMany )
if( request.getStackSize() >= howMany )
{
if ( mode == Actionable.MODULATE )
if( mode == Actionable.MODULATE )
{
this.fProxy.setItemType( this.te, null );
this.fProxy.barrelSetCount( this.te, 0 );
@@ -134,8 +131,8 @@ public class FactorizationBarrel implements IMEInventory<IAEItemStack>
}
else
{
if ( mode == Actionable.MODULATE )
this.fProxy.barrelSetCount( this.te, (int) (howMany - request.getStackSize()) );
if( mode == Actionable.MODULATE )
this.fProxy.barrelSetCount( this.te, (int) ( howMany - request.getStackSize() ) );
return request.copy();
}
}
@@ -143,10 +140,10 @@ public class FactorizationBarrel implements IMEInventory<IAEItemStack>
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
public IItemList<IAEItemStack> getAvailableItems( IItemList out )
{
ItemStack i = this.fProxy.barrelGetItem( this.te );
if ( i != null )
if( i != null )
{
i.stackSize = this.fProxy.barrelGetItemCount( this.te );
out.addStorage( AEItemStack.create( i ) );
@@ -155,4 +152,9 @@ public class FactorizationBarrel implements IMEInventory<IAEItemStack>
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
}
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -29,21 +30,21 @@ import appeng.integration.modules.FZ;
import appeng.me.storage.MEMonitorIInventory;
import appeng.util.inv.IMEAdaptor;
public class FactorizationHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc )
{
return chan == StorageChannel.ITEMS && FZ.instance.isBarrel( te );
}
@Override
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src )
{
if ( chan == StorageChannel.ITEMS )
if( chan == StorageChannel.ITEMS )
return new MEMonitorIInventory( new IMEAdaptor( FZ.instance.getFactorizationBarrel( te ), src ) );
return null;
}
}
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
@@ -29,19 +30,20 @@ import appeng.integration.modules.DSU;
import appeng.me.storage.MEMonitorIInventory;
import appeng.util.inv.IMEAdaptor;
public class MFRDSUHandler implements IExternalStorageHandler
{
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc)
public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource mySrc )
{
return chan == StorageChannel.ITEMS && DSU.instance.isDSU( te );
}
@Override
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src)
public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src )
{
if ( chan == StorageChannel.ITEMS )
if( chan == StorageChannel.ITEMS )
return new MEMonitorIInventory( new IMEAdaptor( DSU.instance.getDSU( te ), src ) );
return null;
@@ -18,6 +18,7 @@
package appeng.integration.modules.helpers;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -31,48 +32,44 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.util.item.AEItemStack;
public class MinefactoryReloadedDeepStorageUnit implements IMEInventory<IAEItemStack>
{
final IDeepStorageUnit dsu;
final TileEntity te;
public MinefactoryReloadedDeepStorageUnit(TileEntity ta) {
public MinefactoryReloadedDeepStorageUnit( TileEntity ta )
{
this.te = ta;
this.dsu = (IDeepStorageUnit) ta;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src )
{
ItemStack is = this.dsu.getStoredItemType();
if ( is != null )
if( is != null )
{
if ( input.equals( is ) )
if( input.equals( is ) )
{
long max = this.dsu.getMaxStoredCount();
long storedItems = is.stackSize;
if ( max == storedItems )
if( max == storedItems )
return input;
storedItems += input.getStackSize();
if ( storedItems > max )
if( storedItems > max )
{
IAEItemStack overflow = AEItemStack.create( is );
overflow.setStackSize( (int) (storedItems - max) );
if ( mode == Actionable.MODULATE )
overflow.setStackSize( (int) ( storedItems - max ) );
if( mode == Actionable.MODULATE )
this.dsu.setStoredItemCount( (int) max );
return overflow;
}
else
{
if ( mode == Actionable.MODULATE )
if( mode == Actionable.MODULATE )
this.dsu.setStoredItemCount( is.stackSize + (int) input.getStackSize() );
return null;
}
@@ -80,9 +77,9 @@ public class MinefactoryReloadedDeepStorageUnit implements IMEInventory<IAEItemS
}
else
{
if ( input.getTagCompound() != null )
if( input.getTagCompound() != null )
return input;
if ( mode == Actionable.MODULATE )
if( mode == Actionable.MODULATE )
this.dsu.setStoredItemType( input.getItemStack(), (int) input.getStackSize() );
return null;
}
@@ -90,21 +87,21 @@ public class MinefactoryReloadedDeepStorageUnit implements IMEInventory<IAEItemS
}
@Override
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src )
{
ItemStack is = this.dsu.getStoredItemType();
if ( request.equals( is ) )
if( request.equals( is ) )
{
if ( request.getStackSize() >= is.stackSize )
if( request.getStackSize() >= is.stackSize )
{
is = is.copy();
if ( mode == Actionable.MODULATE )
if( mode == Actionable.MODULATE )
this.dsu.setStoredItemCount( 0 );
return AEItemStack.create( is );
}
else
{
if ( mode == Actionable.MODULATE )
if( mode == Actionable.MODULATE )
this.dsu.setStoredItemCount( is.stackSize - (int) request.getStackSize() );
return request.copy();
}
@@ -113,14 +110,19 @@ public class MinefactoryReloadedDeepStorageUnit implements IMEInventory<IAEItemS
}
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out)
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
{
ItemStack is = this.dsu.getStoredItemType();
if ( is != null )
if( is != null )
{
out.add( AEItemStack.create( is ) );
}
return out;
}
@Override
public StorageChannel getChannel()
{
return StorageChannel.ITEMS;
}
}