Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,50 +18,34 @@
|
||||
|
||||
package appeng.util.inv;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
|
||||
public class WrapperChainedInventory implements IInventory
|
||||
{
|
||||
|
||||
static class InvOffset
|
||||
{
|
||||
|
||||
int offset;
|
||||
int size;
|
||||
IInventory i;
|
||||
}
|
||||
|
||||
int fullSize = 0;
|
||||
|
||||
private List<IInventory> l;
|
||||
private HashMap<Integer, InvOffset> offsets;
|
||||
|
||||
public WrapperChainedInventory(IInventory... inventories) {
|
||||
this.setInventory( inventories );
|
||||
}
|
||||
|
||||
public WrapperChainedInventory(List<IInventory> inventories) {
|
||||
this.setInventory( inventories );
|
||||
}
|
||||
|
||||
public void cycleOrder()
|
||||
public WrapperChainedInventory( IInventory... inventories )
|
||||
{
|
||||
if ( this.l.size() > 1 )
|
||||
{
|
||||
List<IInventory> newOrder = new ArrayList<IInventory>( this.l.size() );
|
||||
newOrder.add( this.l.get( this.l.size() - 1 ) );
|
||||
for (int x = 0; x < this.l.size() - 1; x++)
|
||||
newOrder.add( this.l.get( x ) );
|
||||
this.setInventory( newOrder );
|
||||
}
|
||||
this.setInventory( inventories );
|
||||
}
|
||||
|
||||
public void setInventory( IInventory... a )
|
||||
{
|
||||
this.l = ImmutableList.copyOf( a );
|
||||
this.calculateSizes();
|
||||
}
|
||||
|
||||
public void calculateSizes()
|
||||
@@ -69,14 +53,14 @@ public class WrapperChainedInventory implements IInventory
|
||||
this.offsets = new HashMap<Integer, WrapperChainedInventory.InvOffset>();
|
||||
|
||||
int offset = 0;
|
||||
for (IInventory in : this.l)
|
||||
for( IInventory in : this.l )
|
||||
{
|
||||
InvOffset io = new InvOffset();
|
||||
io.offset = offset;
|
||||
io.size = in.getSizeInventory();
|
||||
io.i = in;
|
||||
|
||||
for (int y = 0; y < io.size; y++)
|
||||
for( int y = 0; y < io.size; y++ )
|
||||
{
|
||||
this.offsets.put( y + io.offset, io );
|
||||
}
|
||||
@@ -87,32 +71,43 @@ public class WrapperChainedInventory implements IInventory
|
||||
this.fullSize = offset;
|
||||
}
|
||||
|
||||
public void setInventory(IInventory... a)
|
||||
public WrapperChainedInventory( List<IInventory> inventories )
|
||||
{
|
||||
this.l = ImmutableList.copyOf( a );
|
||||
this.calculateSizes();
|
||||
this.setInventory( inventories );
|
||||
}
|
||||
|
||||
public void setInventory(List<IInventory> a)
|
||||
public void setInventory( List<IInventory> a )
|
||||
{
|
||||
this.l = a;
|
||||
this.calculateSizes();
|
||||
}
|
||||
|
||||
public IInventory getInv(int idx)
|
||||
public void cycleOrder()
|
||||
{
|
||||
if( this.l.size() > 1 )
|
||||
{
|
||||
List<IInventory> newOrder = new ArrayList<IInventory>( this.l.size() );
|
||||
newOrder.add( this.l.get( this.l.size() - 1 ) );
|
||||
for( int x = 0; x < this.l.size() - 1; x++ )
|
||||
newOrder.add( this.l.get( x ) );
|
||||
this.setInventory( newOrder );
|
||||
}
|
||||
}
|
||||
|
||||
public IInventory getInv( int idx )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
return io.i;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getInvSlot(int idx)
|
||||
public int getInvSlot( int idx )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
return idx - io.offset;
|
||||
}
|
||||
@@ -126,10 +121,10 @@ public class WrapperChainedInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int idx)
|
||||
public ItemStack getStackInSlot( int idx )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
return io.i.getStackInSlot( idx - io.offset );
|
||||
}
|
||||
@@ -137,10 +132,10 @@ public class WrapperChainedInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int idx, int var2)
|
||||
public ItemStack decrStackSize( int idx, int var2 )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
return io.i.decrStackSize( idx - io.offset, var2 );
|
||||
}
|
||||
@@ -148,10 +143,10 @@ public class WrapperChainedInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int idx)
|
||||
public ItemStack getStackInSlotOnClosing( int idx )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
return io.i.getStackInSlotOnClosing( idx - io.offset );
|
||||
}
|
||||
@@ -159,10 +154,10 @@ public class WrapperChainedInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int idx, ItemStack var2)
|
||||
public void setInventorySlotContents( int idx, ItemStack var2 )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
io.i.setInventorySlotContents( idx - io.offset, var2 );
|
||||
}
|
||||
@@ -174,12 +169,18 @@ public class WrapperChainedInventory implements IInventory
|
||||
return "ChainedInv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
int smallest = 64;
|
||||
|
||||
for (IInventory i : this.l)
|
||||
for( IInventory i : this.l )
|
||||
smallest = Math.min( smallest, i.getInventoryStackLimit() );
|
||||
|
||||
return smallest;
|
||||
@@ -188,14 +189,14 @@ public class WrapperChainedInventory implements IInventory
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
for (IInventory i : this.l)
|
||||
for( IInventory i : this.l )
|
||||
{
|
||||
i.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1)
|
||||
public boolean isUseableByPlayer( EntityPlayer var1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -211,20 +212,21 @@ public class WrapperChainedInventory implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int idx, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot( int idx, ItemStack itemstack )
|
||||
{
|
||||
InvOffset io = this.offsets.get( idx );
|
||||
if ( io != null )
|
||||
if( io != null )
|
||||
{
|
||||
return io.i.isItemValidForSlot( idx - io.offset, itemstack );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static class InvOffset
|
||||
{
|
||||
|
||||
int offset;
|
||||
int size;
|
||||
IInventory i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user