Puts everywhere brackets

This commit is contained in:
thatsIch
2015-04-29 02:30:53 +02:00
parent 23aa8fd72d
commit 64ed05a1b4
465 changed files with 6726 additions and 14 deletions
@@ -120,13 +120,19 @@ public abstract class AEBaseContainer extends Container
protected IActionHost getActionHost()
{
if( this.obj instanceof IActionHost )
{
return (IActionHost) this.obj;
}
if( this.tileEntity instanceof IActionHost )
{
return (IActionHost) this.tileEntity;
}
if( this.part instanceof IActionHost )
{
return (IActionHost) this.part;
}
return null;
}
@@ -139,9 +145,13 @@ public abstract class AEBaseContainer extends Container
{
GuiSync annotation = f.getAnnotation( GuiSync.class );
if( this.syncData.containsKey( annotation.value() ) )
{
AELog.warning( "Channel already in use: " + annotation.value() + " for " + f.getName() );
}
else
{
this.syncData.put( annotation.value(), new SyncData( this, f, annotation ) );
}
}
}
}
@@ -154,7 +164,9 @@ public abstract class AEBaseContainer extends Container
this.obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null;
if( this.tileEntity == null && this.part == null && this.obj == null )
{
throw new IllegalArgumentException( "Must have a valid anchor, instead " + anchor + " in " + ip );
}
this.mySrc = new PlayerSource( ip.player, this.getActionHost() );
@@ -165,26 +177,34 @@ public abstract class AEBaseContainer extends Container
{
this.dataChunks.add( packetPartialItem );
if( packetPartialItem.getPageCount() == this.dataChunks.size() )
{
this.parsePartials();
}
}
private void parsePartials()
{
int total = 0;
for( PacketPartialItem ppi : this.dataChunks )
{
total += ppi.getSize();
}
byte[] buffer = new byte[total];
int cursor = 0;
for( PacketPartialItem ppi : this.dataChunks )
{
cursor = ppi.write( buffer, cursor );
}
try
{
NBTTagCompound data = CompressedStreamTools.readCompressed( new ByteArrayInputStream( buffer ) );
if( data != null )
{
this.setTargetStack( AEApi.instance().storage().createItemStack( ItemStack.loadItemStackFromNBT( data ) ) );
}
}
catch( IOException e )
{
@@ -208,13 +228,17 @@ public abstract class AEBaseContainer extends Container
ItemStack b = this.clientRequestedTargetItem == null ? null : this.clientRequestedTargetItem.getItemStack();
if( Platform.isSameItemPrecise( a, b ) )
{
return;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
NBTTagCompound item = new NBTTagCompound();
if( stack != null )
{
stack.writeToNBT( item );
}
try
{
@@ -262,11 +286,15 @@ public abstract class AEBaseContainer extends Container
public void verifyPermissions( SecurityPermissions security, boolean requirePower )
{
if( Platform.isClient() )
{
return;
}
this.ticksSinceCheck++;
if( this.ticksSinceCheck < 20 )
{
return;
}
this.ticksSinceCheck = 0;
this.isContainerValid = this.isContainerValid && this.hasAccess( security, requirePower );
@@ -288,12 +316,16 @@ public abstract class AEBaseContainer extends Container
{
IEnergyGrid eg = g.getCache( IEnergyGrid.class );
if( !eg.isNetworkPowered() )
{
return false;
}
}
ISecurityGrid sg = g.getCache( ISecurityGrid.class );
if( sg.hasPermission( this.invPlayer.player, perm ) )
{
return true;
}
}
}
}
@@ -309,11 +341,17 @@ public abstract class AEBaseContainer extends Container
public Object getTarget()
{
if( this.tileEntity != null )
{
return this.tileEntity;
}
if( this.part != null )
{
return this.part;
}
if( this.obj != null )
{
return this.obj;
}
return null;
}
@@ -354,9 +392,13 @@ public abstract class AEBaseContainer extends Container
for( int j = 0; j < 9; j++ )
{
if( this.locked.contains( j + i * 9 + 9 ) )
{
this.addSlotToContainer( new SlotDisabled( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) );
}
else
{
this.addSlotToContainer( new SlotPlayerInv( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) );
}
}
}
@@ -364,9 +406,13 @@ public abstract class AEBaseContainer extends Container
for( int i = 0; i < 9; i++ )
{
if( this.locked.contains( i ) )
{
this.addSlotToContainer( new SlotDisabled( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
}
else
{
this.addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
}
}
}
@@ -380,7 +426,9 @@ public abstract class AEBaseContainer extends Container
return super.addSlotToContainer( newSlot );
}
else
{
throw new IllegalArgumentException( "Invalid Slot [" + newSlot + "]for AE Container instead of AppEngSlot." );
}
}
@Override
@@ -395,7 +443,9 @@ public abstract class AEBaseContainer extends Container
ICrafting icrafting = (ICrafting) crafter;
for( SyncData sd : this.syncData.values() )
{
sd.tick( icrafting );
}
}
}
@@ -406,7 +456,9 @@ public abstract class AEBaseContainer extends Container
public ItemStack transferStackInSlot( EntityPlayer p, int idx )
{
if( Platform.isClient() )
{
return null;
}
boolean hasMETiles = false;
for( Object is : this.inventorySlots )
@@ -427,13 +479,17 @@ public abstract class AEBaseContainer extends Container
AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots!
if( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible )
{
return null;
}
if( clickSlot != null && clickSlot.getHasStack() )
{
tis = clickSlot.getStack();
if( tis == null )
{
return null;
}
List<Slot> selectedSlots = new ArrayList<Slot>();
@@ -512,7 +568,9 @@ public abstract class AEBaseContainer extends Container
for( Slot d : selectedSlots )
{
if( d instanceof SlotDisabled || d instanceof SlotME )
{
continue;
}
if( d.isItemValid( tis ) )
{
@@ -524,7 +582,9 @@ public abstract class AEBaseContainer extends Container
{
int maxSize = t.getMaxStackSize();
if( maxSize > d.getSlotStackLimit() )
{
maxSize = d.getSlotStackLimit();
}
int placeAble = maxSize - t.stackSize;
@@ -548,7 +608,9 @@ public abstract class AEBaseContainer extends Container
return null;
}
else
{
this.updateSlot( d );
}
}
}
}
@@ -558,7 +620,9 @@ public abstract class AEBaseContainer extends Container
for( Slot d : selectedSlots )
{
if( d instanceof SlotDisabled || d instanceof SlotME )
{
continue;
}
if( d.isItemValid( tis ) )
{
@@ -570,7 +634,9 @@ public abstract class AEBaseContainer extends Container
{
int maxSize = t.getMaxStackSize();
if( d.getSlotStackLimit() < maxSize )
{
maxSize = d.getSlotStackLimit();
}
int placeAble = maxSize - t.stackSize;
@@ -596,18 +662,24 @@ public abstract class AEBaseContainer extends Container
return null;
}
else
{
this.updateSlot( d );
}
}
}
else
{
int maxSize = tis.getMaxStackSize();
if( maxSize > d.getSlotStackLimit() )
{
maxSize = d.getSlotStackLimit();
}
ItemStack tmp = tis.copy();
if( tmp.stackSize > maxSize )
{
tmp.stackSize = maxSize;
}
tis.stackSize -= tmp.stackSize;
d.putStack( tmp );
@@ -626,7 +698,9 @@ public abstract class AEBaseContainer extends Container
return null;
}
else
{
this.updateSlot( d );
}
}
}
}
@@ -654,7 +728,9 @@ public abstract class AEBaseContainer extends Container
if( this.isContainerValid )
{
if( this.tileEntity instanceof IInventory )
{
return ( (IInventory) this.tileEntity ).isUseableByPlayer( entityplayer );
}
return true;
}
return false;
@@ -694,9 +770,13 @@ public abstract class AEBaseContainer extends Container
case PICKUP_OR_SET_DOWN:
if( hand == null )
{
s.putStack( null );
}
else
{
s.putStack( hand.copy() );
}
break;
case PLACE_SINGLE:
@@ -715,9 +795,13 @@ public abstract class AEBaseContainer extends Container
if( is != null )
{
if( hand == null )
{
is.stackSize--;
}
else if( hand.isItemEqual( is ) )
{
is.stackSize = Math.min( is.getMaxStackSize(), is.stackSize + 1 );
}
else
{
is = hand.copy();
@@ -749,11 +833,15 @@ public abstract class AEBaseContainer extends Container
for( Object j : this.inventorySlots )
{
if( j instanceof Slot && j.getClass() == s.getClass() )
{
from.add( (Slot) j );
}
}
for( Slot fr : from )
{
this.transferStackInSlot( player, fr.slotNumber );
}
}
return;
@@ -766,7 +854,9 @@ public abstract class AEBaseContainer extends Container
{
case SHIFT_CLICK:
if( this.powerSrc == null || this.cellInv == null )
{
return;
}
if( slotItem != null )
{
@@ -780,16 +870,22 @@ public abstract class AEBaseContainer extends Container
myItem = adp.simulateAdd( myItem );
if( myItem != null )
{
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
}
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
if( ais != null )
{
adp.addItems( ais.getItemStack() );
}
}
break;
case ROLL_DOWN:
if( this.powerSrc == null || this.cellInv == null )
{
return;
}
int releaseQty = 1;
ItemStack isg = player.inventory.getItemStack();
@@ -807,7 +903,9 @@ public abstract class AEBaseContainer extends Container
ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
if( fail == null )
{
this.cellInv.extractItems( extracted, Actionable.MODULATE, this.mySrc );
}
this.updateHeld( player );
}
@@ -817,7 +915,9 @@ public abstract class AEBaseContainer extends Container
case ROLL_UP:
case PICKUP_SINGLE:
if( this.powerSrc == null || this.cellInv == null )
{
return;
}
if( slotItem != null )
{
@@ -827,9 +927,13 @@ public abstract class AEBaseContainer extends Container
if( item != null )
{
if( item.stackSize >= item.getMaxStackSize() )
{
liftQty = 0;
}
if( !Platform.isSameItemPrecise( slotItem.getItemStack(), item ) )
{
liftQty = 0;
}
}
if( liftQty > 0 )
@@ -843,7 +947,9 @@ public abstract class AEBaseContainer extends Container
ItemStack fail = ia.addItems( ais.getItemStack() );
if( fail != null )
{
this.cellInv.injectItems( ais, Actionable.MODULATE, this.mySrc );
}
this.updateHeld( player );
}
@@ -852,7 +958,9 @@ public abstract class AEBaseContainer extends Container
break;
case PICKUP_OR_SET_DOWN:
if( this.powerSrc == null || this.cellInv == null )
{
return;
}
if( player.inventory.getItemStack() == null )
{
@@ -862,9 +970,13 @@ public abstract class AEBaseContainer extends Container
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
if( ais != null )
{
player.inventory.setItemStack( ais.getItemStack() );
}
else
{
player.inventory.setItemStack( null );
}
this.updateHeld( player );
}
}
@@ -873,16 +985,22 @@ public abstract class AEBaseContainer extends Container
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
ais = Platform.poweredInsert( this.powerSrc, this.cellInv, ais, this.mySrc );
if( ais != null )
{
player.inventory.setItemStack( ais.getItemStack() );
}
else
{
player.inventory.setItemStack( null );
}
this.updateHeld( player );
}
break;
case SPLIT_OR_PLACE_SINGLE:
if( this.powerSrc == null || this.cellInv == null )
{
return;
}
if( player.inventory.getItemStack() == null )
{
@@ -901,9 +1019,13 @@ public abstract class AEBaseContainer extends Container
}
if( ais != null )
{
player.inventory.setItemStack( ais.getItemStack() );
}
else
{
player.inventory.setItemStack( null );
}
this.updateHeld( player );
}
}
@@ -917,7 +1039,9 @@ public abstract class AEBaseContainer extends Container
ItemStack is = player.inventory.getItemStack();
is.stackSize--;
if( is.stackSize <= 0 )
{
player.inventory.setItemStack( null );
}
this.updateHeld( player );
}
}
@@ -935,7 +1059,9 @@ public abstract class AEBaseContainer extends Container
case MOVE_REGION:
if( this.powerSrc == null || this.cellInv == null )
{
return;
}
if( slotItem != null )
{
@@ -952,13 +1078,19 @@ public abstract class AEBaseContainer extends Container
myItem = adp.simulateAdd( myItem );
if( myItem != null )
{
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
}
ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc );
if( ais != null )
{
adp.addItems( ais.getItemStack() );
}
else
{
return;
}
}
}
@@ -986,10 +1118,14 @@ public abstract class AEBaseContainer extends Container
public ItemStack shiftStoreItem( ItemStack input )
{
if( this.powerSrc == null || this.cellInv == null )
{
return input;
}
IAEItemStack ais = Platform.poweredInsert( this.powerSrc, this.cellInv, AEApi.instance().storage().createItemStack( input ), this.mySrc );
if( ais == null )
{
return null;
}
return ais.getItemStack();
}
@@ -1009,21 +1145,31 @@ public abstract class AEBaseContainer extends Container
ICustomNameObject name = null;
if( this.part instanceof ICustomNameObject )
{
name = (ICustomNameObject) this.part;
}
if( this.tileEntity instanceof ICustomNameObject )
{
name = (ICustomNameObject) this.tileEntity;
}
if( this.obj instanceof ICustomNameObject )
{
name = (ICustomNameObject) this.obj;
}
if( this instanceof ICustomNameObject )
{
name = (ICustomNameObject) this;
}
if( name != null )
{
if( name.hasCustomName() )
{
this.customName = name.getCustomName();
}
if( this.customName != null )
{
@@ -1048,30 +1194,42 @@ public abstract class AEBaseContainer extends Container
// NPE protection...
if( a == null || b == null )
{
return;
}
ItemStack isA = a.getStack();
ItemStack isB = b.getStack();
// something to do?
if( isA == null && isB == null )
{
return;
}
// can take?
if( isA != null && !a.canTakeStack( this.invPlayer.player ) )
{
return;
}
if( isB != null && !b.canTakeStack( this.invPlayer.player ) )
{
return;
}
// swap valid?
if( isB != null && !a.isItemValid( isB ) )
{
return;
}
if( isA != null && !b.isItemValid( isA ) )
{
return;
}
ItemStack testA = isB == null ? null : isB.copy();
ItemStack testB = isA == null ? null : isA.copy();
@@ -1080,7 +1238,9 @@ public abstract class AEBaseContainer extends Container
if( testA != null && testA.stackSize > a.getSlotStackLimit() )
{
if( testB != null )
{
return;
}
int totalA = testA.stackSize;
testA.stackSize = a.getSlotStackLimit();
@@ -1092,7 +1252,9 @@ public abstract class AEBaseContainer extends Container
if( testB != null && testB.stackSize > b.getSlotStackLimit() )
{
if( testA != null )
{
return;
}
int totalB = testB.stackSize;
testB.stackSize = b.getSlotStackLimit();
@@ -45,7 +45,9 @@ public class ContainerOpenContext
public TileEntity getTile()
{
if( this.isItem )
{
return null;
}
return this.w.getTileEntity( this.x, this.y, this.z );
}
}
@@ -60,9 +60,13 @@ public class SyncData
{
Object val = this.field.get( this.source );
if( val != null && this.clientVersion == null )
{
this.send( c, val );
}
else if( !val.equals( this.clientVersion ) )
{
this.send( c, val );
}
}
catch( IllegalArgumentException e )
{
@@ -83,7 +87,9 @@ public class SyncData
if( val instanceof String )
{
if( o instanceof EntityPlayerMP )
{
NetworkHandler.instance.sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (EntityPlayerMP) o );
}
}
else if( this.field.getType().isEnum() )
{
@@ -111,9 +117,13 @@ public class SyncData
{
Object oldValue = this.field.get( this.source );
if( val instanceof String )
{
this.updateString( oldValue, (String) val );
}
else
{
this.updateValue( oldValue, (Long) val );
}
}
catch( IllegalArgumentException e )
{
@@ -160,17 +170,29 @@ public class SyncData
else
{
if( this.field.getType().equals( int.class ) )
{
this.field.set( this.source, (int) val );
}
else if( this.field.getType().equals( long.class ) )
{
this.field.set( this.source, val );
}
else if( this.field.getType().equals( boolean.class ) )
{
this.field.set( this.source, val == 1 );
}
else if( this.field.getType().equals( Integer.class ) )
{
this.field.set( this.source, (int) val );
}
else if( this.field.getType().equals( Long.class ) )
{
this.field.set( this.source, val );
}
else if( this.field.getType().equals( Boolean.class ) )
{
this.field.set( this.source, val == 1 );
}
}
this.source.onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) );
@@ -67,7 +67,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
ICellWorkbenchItem cwi = this.workBench.getCell();
if( cwi != null )
{
cwi.setFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf );
}
}
public void nextCopyMode()
@@ -101,18 +103,22 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
// null, 3 * 8 );
for( int w = 0; w < 7; w++ )
{
for( int z = 0; z < 9; z++ )
{
this.addSlotToContainer( new SlotFakeTypeOnly( inv, offset, x + z * 18, y + w * 18 ) );
offset++;
}
}
for( int zz = 0; zz < 3; zz++ )
{
for( int z = 0; z < 8; z++ )
{
int iSLot = zz * 8 + z;
this.addSlotToContainer( new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this.invPlayer ) );
}
}
/*
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new
* OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) );
@@ -187,7 +193,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
public void onUpdate( String field, Object oldValue, Object newValue )
{
if( field.equals( "copyMode" ) )
{
this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.copyMode );
}
super.onUpdate( field, oldValue, newValue );
}
@@ -196,7 +204,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
inv.setInventorySlotContents( x, null );
}
this.detectAndSendChanges();
}
@@ -204,7 +214,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
ICellWorkbenchItem cwi = this.workBench.getCell();
if( cwi != null )
{
return cwi.getFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
}
return FuzzyMode.IGNORE_ALL;
}
@@ -230,7 +242,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
inv.setInventorySlotContents( x, g );
}
else
{
inv.setInventorySlotContents( x, null );
}
}
this.detectAndSendChanges();
@@ -98,14 +98,22 @@ public class ContainerCraftConfirm extends AEBaseContainer
public void cycleCpu( boolean next )
{
if( next )
{
this.selectedCpu++;
}
else
{
this.selectedCpu--;
}
if( this.selectedCpu < -1 )
{
this.selectedCpu = this.cpus.size() - 1;
}
else if( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
}
if( this.selectedCpu == -1 )
{
@@ -125,7 +133,9 @@ public class ContainerCraftConfirm extends AEBaseContainer
public void detectAndSendChanges()
{
if( Platform.isClient() )
{
return;
}
ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
@@ -136,16 +146,24 @@ public class ContainerCraftConfirm extends AEBaseContainer
{
boolean found = false;
for( CraftingCPURecord ccr : this.cpus )
{
if( ccr.cpu == c )
{
found = true;
}
}
boolean matched = this.cpuMatches( c );
if( matched )
{
matches++;
}
if( found == !matched )
{
changed = true;
}
}
if( changed || this.cpus.size() != matches )
@@ -154,7 +172,9 @@ public class ContainerCraftConfirm extends AEBaseContainer
for( ICraftingCPU c : cpuSet )
{
if( this.cpuMatches( c ) )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
}
this.sendCPUs();
@@ -180,7 +200,9 @@ public class ContainerCraftConfirm extends AEBaseContainer
}
}
else
{
this.simulation = true;
}
try
{
@@ -223,13 +245,19 @@ public class ContainerCraftConfirm extends AEBaseContainer
}
if( o.getStackSize() > 0 )
{
a.appendItem( o );
}
if( p.getStackSize() > 0 )
{
b.appendItem( p );
}
if( c != null && m != null && m.getStackSize() > 0 )
{
c.appendItem( m );
}
}
for( Object g : this.crafters )
@@ -239,7 +267,9 @@ public class ContainerCraftConfirm extends AEBaseContainer
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
if( c != null )
{
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
}
}
}
}
@@ -297,16 +327,24 @@ public class ContainerCraftConfirm extends AEBaseContainer
IActionHost ah = this.getActionHost();
if( ah instanceof WirelessTerminalGuiObject )
{
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
}
if( ah instanceof PartTerminal )
{
OriginalGui = GuiBridge.GUI_ME;
}
if( ah instanceof PartCraftingTerminal )
{
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
}
if( ah instanceof PartPatternTerminal )
{
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
}
if( this.result != null && !this.simulation )
{
@@ -67,14 +67,20 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
{
this.findNode( host, ForgeDirection.UNKNOWN );
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
{
this.findNode( host, d );
}
}
if( te instanceof TileCraftingTile )
{
this.setCPU( (ICraftingCPU) ( (TileCraftingTile) te ).getCluster() );
}
if( this.network == null && Platform.isServer() )
{
this.isContainerValid = false;
}
}
private void findNode( IGridHost host, ForgeDirection d )
@@ -83,17 +89,23 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
{
IGridNode node = host.getGridNode( d );
if( node != null )
{
this.network = node.getGrid();
}
}
}
protected void setCPU( ICraftingCPU c )
{
if( c == this.monitor )
{
return;
}
if( this.monitor != null )
{
this.monitor.removeListener( this );
}
for( Object g : this.crafters )
{
@@ -143,7 +155,9 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
super.removeCraftingFromCrafters( c );
if( this.crafters.isEmpty() && this.monitor != null )
{
this.monitor.removeListener( this );
}
}
@Override
@@ -151,7 +165,9 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
{
super.onContainerClosed( player );
if( this.monitor != null )
{
this.monitor.removeListener( this );
}
}
@Override
@@ -179,13 +195,19 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
if( g instanceof EntityPlayer )
{
if( !a.isEmpty() )
{
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
}
if( !b.isEmpty() )
{
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
}
if( !c.isEmpty() )
{
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
}
}
}
}
@@ -60,16 +60,24 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
{
boolean found = false;
for( CraftingCPURecord ccr : this.cpus )
{
if( ccr.cpu == c )
{
found = true;
}
}
boolean matched = this.cpuMatches( c );
if( matched )
{
matches++;
}
if( found == !matched )
{
changed = true;
}
}
if( changed || this.cpus.size() != matches )
@@ -78,7 +86,9 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
for( ICraftingCPU c : cpuSet )
{
if( this.cpuMatches( c ) )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
}
this.sendCPUs();
@@ -109,31 +119,47 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
}
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
{
this.selectedCpu = 0;
}
if( this.selectedCpu != -1 )
{
if( this.cpus.get( this.selectedCpu ).cpu != this.monitor )
{
this.setCPU( this.cpus.get( this.selectedCpu ).cpu );
}
}
else
{
this.setCPU( null );
}
}
public void cycleCpu( boolean next )
{
if( next )
{
this.selectedCpu++;
}
else
{
this.selectedCpu--;
}
if( this.selectedCpu < -1 )
{
this.selectedCpu = this.cpus.size() - 1;
}
else if( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
}
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
{
this.selectedCpu = 0;
}
if( this.selectedCpu == -1 )
{
@@ -52,8 +52,12 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
IInventory crafting = this.ct.getInventoryByName( "crafting" );
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 3; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) );
}
}
this.addSlotToContainer( this.outputSlot = new SlotCraftingTerm( this.getPlayerInv().player, this.mySrc, this.powerSrc, monitorable, crafting, crafting, this.output, 131, -72 + 18, this ) );
@@ -72,7 +76,9 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
InventoryCrafting ic = new InventoryCrafting( cn, 3, 3 );
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, this.craftingSlots[x].getStack() );
}
this.outputSlot.putStack( CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj ) );
}
@@ -37,10 +37,12 @@ public class ContainerDrive extends AEBaseContainer
this.drive = drive;
for( int y = 0; y < 5; y++ )
{
for( int x = 0; x < 2; x++ )
{
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, drive, x + y * 2, 71 + x * 18, 14 + y * 18, this.invPlayer ) );
}
}
this.bindPlayerInventory( ip, 0, 199 - /* height of player inventory */82 );
}
@@ -67,9 +67,13 @@ public class ContainerFormationPlane extends ContainerUpgradeable
for( int x = 0; x < 9; x++ )
{
if( y < 2 )
{
this.addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
}
else
{
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
}
}
}
@@ -65,14 +65,22 @@ public class ContainerIOPort extends ContainerUpgradeable
IInventory cells = this.upgradeable.getInventoryByName( "cells" );
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 2; x++ )
{
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells, x + y * 2, offX + x * 18, offY + y * 18, this.invPlayer ) );
}
}
offX = 122;
offY = 17;
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 2; x++ )
{
this.addSlotToContainer( new SlotOutput( cells, 6 + x + y * 2, offX + x * 18, offY + y * 18, SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon ) );
}
}
IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() );
@@ -118,7 +118,9 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
for( ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
{
if( Platform.isSameItemPrecise( optional, is ) )
{
return false;
}
}
boolean matches = false;
@@ -138,13 +140,17 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
for( ItemStack option : recipe.getInputs() )
{
if( Platform.isSameItemPrecise( is, option ) )
{
found = true;
}
}
}
}
if( matches && !found )
{
return false;
}
}
if( ( s == this.top && bot != null ) || ( s == this.bottom && top != null ) )
@@ -152,9 +158,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
boolean isValid = false;
ItemStack otherSlot = null;
if( s == this.top )
{
otherSlot = this.bottom.getStack();
}
else
{
otherSlot = this.top.getStack();
}
// name presses
final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress();
@@ -176,11 +186,15 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
}
if( isValid )
{
break;
}
}
if( !isValid )
{
return false;
}
}
return true;
@@ -51,13 +51,19 @@ public class ContainerInterface extends ContainerUpgradeable
this.myDuality = te.getInterfaceDuality();
for( int x = 0; x < 9; x++ )
{
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, this.myDuality.getPatterns(), x, 8 + 18 * x, 90 + 7, this.invPlayer ) );
}
for( int x = 0; x < 8; x++ )
{
this.addSlotToContainer( new SlotFake( this.myDuality.getConfig(), x, 17 + 18 * x, 35 ) );
}
for( int x = 0; x < 8; x++ )
{
this.addSlotToContainer( new SlotNormal( this.myDuality.getStorage(), x, 17 + 18 * x, 35 + 18 ) );
}
}
@Override
@@ -72,7 +72,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
super( ip, anchor );
if( Platform.isServer() )
{
this.grid = anchor.getActionableNode().getGrid();
}
this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 );
}
@@ -81,12 +83,16 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
public void detectAndSendChanges()
{
if( Platform.isClient() )
{
return;
}
super.detectAndSendChanges();
if( this.grid == null )
{
return;
}
int total = 0;
boolean missing = false;
@@ -103,17 +109,23 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
{
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO )
{
continue;
}
InvTracker t = this.diList.get( ih );
if( t == null )
{
missing = true;
}
else
{
DualityInterface dual = ih.getInterfaceDuality();
if( !t.unlocalizedName.equals( dual.getTermName() ) )
{
missing = true;
}
}
total++;
@@ -126,17 +138,23 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
{
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO )
{
continue;
}
InvTracker t = this.diList.get( ih );
if( t == null )
{
missing = true;
}
else
{
DualityInterface dual = ih.getInterfaceDuality();
if( !t.unlocalizedName.equals( dual.getTermName() ) )
{
missing = true;
}
}
total++;
@@ -146,7 +164,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
}
if( total != this.diList.size() || missing )
{
this.regenList( this.data );
}
else
{
for( Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet() )
@@ -155,7 +175,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
for( int x = 0; x < inv.server.getSizeInventory(); x++ )
{
if( this.isDifferent( inv.server.getStackInSlot( x ), inv.client.getStackInSlot( x ) ) )
{
this.addItems( this.data, inv, x, 1 );
}
}
}
}
@@ -199,7 +221,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
{
ItemStack inSlot = theSlot.getStackInSlot( 0 );
if( inSlot == null )
{
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
}
else
{
inSlot = inSlot.copy();
@@ -211,7 +235,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
if( player.inventory.getItemStack() == null )
{
player.inventory.setItemStack( inSlot );
}
else
{
player.inventory.setItemStack( inHand );
@@ -232,17 +258,25 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
{
ItemStack extra = playerHand.removeItems( 1, null, null );
if( extra != null )
{
extra = interfaceSlot.addItems( extra );
}
if( extra != null )
{
playerHand.addItems( extra );
}
}
else if( is != null )
{
ItemStack extra = interfaceSlot.removeItems( ( is.stackSize + 1 ) / 2, null, null );
if( extra != null )
{
extra = playerHand.addItems( extra );
}
if( extra != null )
{
interfaceSlot.addItems( extra );
}
}
break;
@@ -294,7 +328,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
DualityInterface dual = ih.getInterfaceDuality();
if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
{
this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
}
}
for( IGridNode gn : this.grid.getMachines( PartInterface.class ) )
@@ -302,7 +338,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
DualityInterface dual = ih.getInterfaceDuality();
if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
{
this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
}
}
}
}
@@ -320,10 +358,14 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
private boolean isDifferent( ItemStack a, ItemStack b )
{
if( a == null && b == null )
{
return false;
}
if( a == null || b == null )
{
return true;
}
return !ItemStack.areItemStacksEqual( a, b );
}
@@ -349,7 +391,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
inv.client.setInventorySlotContents( x + offset, is == null ? null : is.copy() );
if( is != null )
{
is.writeToNBT( itemNBT );
}
tag.setTag( Integer.toString( x + offset ), itemNBT );
}
@@ -81,13 +81,21 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" );
if( this.availableUpgrades() > 0 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() );
}
if( this.availableUpgrades() > 1 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ) ).setNotDraggable() );
}
if( this.availableUpgrades() > 2 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ) ).setNotDraggable() );
}
if( this.availableUpgrades() > 3 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ) ).setNotDraggable() );
}
IInventory inv = this.upgradeable.getInventoryByName( "config" );
this.addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
@@ -129,7 +137,9 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
if( field.equals( "EmitterValue" ) )
{
if( this.textField != null )
{
this.textField.setText( String.valueOf( this.EmitterValue ) );
}
}
}
}
@@ -58,7 +58,9 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
ItemStack is = mac.getStackInSlot( 10 );
if( is == null )
{
return false;
}
if( is.getItem() instanceof ItemEncodedPattern )
{
@@ -66,7 +68,9 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
if( ph.isCraftable() )
{
return ph.isValidItemForSlot( slotIndex, i, w );
}
}
return false;
@@ -87,11 +91,13 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
IInventory mac = this.upgradeable.getInventoryByName( "mac" );
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 3; x++ )
{
SlotMACPattern s = new SlotMACPattern( this, mac, x + y * 3, offX + x * 18, offY + y * 18 );
this.addSlotToContainer( s );
}
}
offX = 126;
offY = 16;
@@ -112,9 +112,13 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
this.cellInv = this.monitor;
if( monitorable instanceof IPortableCell )
{
this.powerSrc = (IPortableCell) monitorable;
}
else if( monitorable instanceof IMEChest )
{
this.powerSrc = (IMEChest) monitorable;
}
else if( monitorable instanceof IGridHost )
{
IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN );
@@ -123,15 +127,21 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
this.networkNode = node;
IGrid g = node.getGrid();
if( g != null )
{
this.powerSrc = new ChannelPowerSrc( this.networkNode, (IEnergyGrid) g.getCache( IEnergyGrid.class ) );
}
}
}
}
else
{
this.isContainerValid = false;
}
}
else
{
this.monitor = null;
}
this.canAccessViewCells = false;
if( monitorable instanceof IViewCellStorage )
@@ -145,7 +155,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
if( bindInventory )
{
this.bindPlayerInventory( ip, 0, 0 );
}
}
public IGridNode getNetworkNode()
@@ -159,7 +171,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
if( Platform.isServer() )
{
if( this.monitor != this.host.getItemInventory() )
{
this.isContainerValid = false;
}
for( Settings set : this.serverCM.getSettings() )
{
@@ -200,7 +214,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
piu.appendItem( is );
}
else
{
piu.appendItem( send );
}
}
if( !piu.isEmpty() )
@@ -210,7 +226,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
for( Object c : this.crafters )
{
if( c instanceof EntityPlayer )
{
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
}
}
}
}
@@ -229,7 +247,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
for( int y = 0; y < 5; y++ )
{
if( this.cellView[y] != null )
{
this.cellView[y].allowEdit = this.canAccessViewCells;
}
}
}
@@ -242,11 +262,17 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
try
{
if( this.networkNode != null )
{
this.hasPower = this.networkNode.isActive();
}
else if( this.powerSrc instanceof IEnergyGrid )
{
this.hasPower = ( (IEnergyGrid) this.powerSrc ).isNetworkPowered();
}
else
{
this.hasPower = this.powerSrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8;
}
}
catch( Throwable t )
{
@@ -260,8 +286,12 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
if( field.equals( "canAccessViewCells" ) )
{
for( int y = 0; y < 5; y++ )
{
if( this.cellView[y] != null )
{
this.cellView[y].allowEdit = this.canAccessViewCells;
}
}
}
super.onUpdate( field, oldValue, newValue );
@@ -313,7 +343,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
super.removeCraftingFromCrafters( c );
if( this.crafters.isEmpty() && this.monitor != null )
{
this.monitor.removeListener( this );
}
}
@Override
@@ -321,7 +353,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
super.onContainerClosed( player );
if( this.monitor != null )
{
this.monitor.removeListener( this );
}
}
@Override
@@ -334,7 +368,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source )
{
for( IAEItemStack is : change )
{
this.items.add( is );
}
}
@Override
@@ -354,14 +390,18 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
if( this.gui != null )
{
this.gui.updateSetting( manager, settingName, newValue );
}
}
@Override
public IConfigManager getConfigManager()
{
if( Platform.isServer() )
{
return this.serverCM;
}
return this.clientCM;
}
@@ -370,7 +410,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
ItemStack[] list = new ItemStack[this.cellView.length];
for( int x = 0; x < this.cellView.length; x++ )
{
list[x] = this.cellView[x].getStack();
}
return list;
}
@@ -68,16 +68,24 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
if( currentItem != null )
{
if( Platform.isSameItem( this.civ.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
}
else
{
this.isContainerValid = false;
}
}
else
{
this.isContainerValid = false;
}
}
}
else
{
this.isContainerValid = false;
}
// drain 1 ae t
this.ticks++;
@@ -67,11 +67,15 @@ public class ContainerNetworkStatus extends AEBaseContainer
{
this.findNode( host, ForgeDirection.UNKNOWN );
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
{
this.findNode( host, d );
}
}
if( this.network == null && Platform.isServer() )
{
this.isContainerValid = false;
}
}
private void findNode( IGridHost host, ForgeDirection d )
@@ -80,7 +84,9 @@ public class ContainerNetworkStatus extends AEBaseContainer
{
IGridNode node = host.getGridNode( d );
if( node != null )
{
this.network = node.getGrid();
}
}
}
@@ -123,13 +129,17 @@ public class ContainerNetworkStatus extends AEBaseContainer
}
for( IAEItemStack ais : list )
{
piu.appendItem( ais );
}
}
for( Object c : this.crafters )
{
if( c instanceof EntityPlayer )
{
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
}
}
}
catch( IOException e )
@@ -46,8 +46,12 @@ public class ContainerNetworkTool extends AEBaseContainer
this.lockPlayerInventorySlot( ip.currentItem );
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 3; x++ )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te, y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.invPlayer ) ) );
}
}
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
@@ -73,10 +77,14 @@ public class ContainerNetworkTool extends AEBaseContainer
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
else
{
this.isContainerValid = false;
}
}
else
{
this.isContainerValid = false;
}
}
if( this.isContainerValid )
@@ -91,8 +91,12 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
this.crafting = this.ct.getInventoryByName( "crafting" );
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 3; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
}
}
this.addSlotToContainer( this.craftSlot = new SlotPatternTerm( ip.player, this.mySrc, this.powerSrc, monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this ) );
this.craftSlot.IIcon = -1;
@@ -120,14 +124,18 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
this.craftSlot.xDisplayPosition = -9000;
for( int y = 0; y < 3; y++ )
{
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].defX;
}
}
else
{
this.craftSlot.xDisplayPosition = this.craftSlot.defX;
for( int y = 0; y < 3; y++ )
{
this.outputSlots[y].xDisplayPosition = -9000;
}
}
}
@@ -149,7 +157,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
InventoryCrafting ic = new InventoryCrafting( this, 3, 3 );
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ic.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) );
}
ItemStack is = CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj );
this.cOut.setInventorySlotContents( 0, is );
@@ -177,23 +187,29 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
// if there is no input, this would be silly.
if( in == null || out == null )
{
return;
}
// first check the output slots, should either be null, or a pattern
if( output != null && !this.isPattern( output ) )
{
return;
// if nothing is there we should snag a new pattern.
}// if nothing is there we should snag a new pattern.
else if( output == null )
{
output = this.patternSlotIN.getStack();
if( output == null || !this.isPattern( output ) )
{
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if( output.stackSize == 0 )
{
this.patternSlotIN.putStack( null );
}
// add a new encoded pattern.
for( ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
@@ -210,10 +226,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
NBTTagList tagOut = new NBTTagList();
for( ItemStack i : in )
{
tagIn.appendTag( this.createItemTag( i ) );
}
for( ItemStack i : out )
{
tagOut.appendTag( this.createItemTag( i ) );
}
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
@@ -231,11 +251,15 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
input[x] = this.craftingSlots[x].getStack();
if( input[x] != null )
{
hasValue = true;
}
}
if( hasValue )
{
return input;
}
return null;
}
@@ -246,7 +270,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
ItemStack out = this.getAndUpdateOutput();
if( out != null && out.stackSize > 0 )
{
return new ItemStack[] { out };
}
}
else
{
@@ -264,7 +290,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
if( hasValue )
{
return list.toArray( new ItemStack[list.size()] );
}
}
return null;
@@ -273,7 +301,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
private boolean isPattern( ItemStack output )
{
if( output == null )
{
return false;
}
final IDefinitions definitions = AEApi.instance().definitions();
@@ -288,7 +318,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
NBTTagCompound c = new NBTTagCompound();
if( i != null )
{
i.writeToNBT( c );
}
return c;
}
@@ -297,11 +329,17 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
public boolean isSlotEnabled( int idx )
{
if( idx == 1 )
{
return Platform.isServer() ? !this.ct.isCraftingRecipe() : !this.craftingMode;
}
else if( idx == 2 )
{
return Platform.isServer() ? this.ct.isCraftingRecipe() : this.craftingMode;
}
else
{
return false;
}
}
public void craftOrGetItem( PacketPatternSlot packetPatternSlot )
@@ -313,10 +351,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player );
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, ForgeDirection.UNKNOWN );
if( packetPatternSlot.shift )
{
inv = playerInv;
}
if( inv.simulateAdd( out.getItemStack() ) != null )
{
return;
}
IAEItemStack extracted = Platform.poweredExtraction( this.powerSrc, this.cellInv, out, this.mySrc );
EntityPlayer p = this.getPlayerInv().player;
@@ -325,7 +367,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
inv.addItems( extracted.getItemStack() );
if( p instanceof EntityPlayerMP )
{
this.updateHeld( (EntityPlayerMP) p );
}
this.detectAndSendChanges();
return;
}
@@ -340,7 +384,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
if( r == null )
{
return;
}
IMEMonitor<IAEItemStack> storage = this.ct.getItemInventory();
IItemList<IAEItemStack> all = storage.getStorageList();
@@ -367,12 +413,16 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) );
if( failed != null )
{
p.dropPlayerItemWithRandomChoice( failed, false );
}
}
inv.addItems( is );
if( p instanceof EntityPlayerMP )
{
this.updateHeld( (EntityPlayerMP) p );
}
this.detectAndSendChanges();
}
else
@@ -441,10 +491,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
public void clear()
{
for( Slot s : this.craftingSlots )
{
s.putStack( null );
}
for( Slot s : this.outputSlots )
{
s.putStack( null );
}
this.detectAndSendChanges();
this.getAndUpdateOutput();
@@ -82,7 +82,9 @@ public class ContainerPriority extends AEBaseContainer
if( field.equals( "PriorityValue" ) )
{
if( this.textField != null )
{
this.textField.setText( String.valueOf( this.PriorityValue ) );
}
}
super.onUpdate( field, oldValue, newValue );
@@ -76,12 +76,18 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
if( currentItem != null )
{
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
else
{
this.isContainerValid = false;
}
}
else
{
this.isContainerValid = false;
}
}
super.detectAndSendChanges();
@@ -91,7 +97,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
public void onContainerClosed( EntityPlayer par1EntityPlayer )
{
if( this.inSlot.getStackInSlot( 0 ) != null )
{
par1EntityPlayer.dropPlayerItemWithRandomChoice( this.inSlot.getStackInSlot( 0 ), false );
}
}
@Override
@@ -117,7 +125,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
{
ItemStack input = this.inSlot.getStackInSlot( 0 );
if( input == null )
{
return null;
}
if( SlotRestrictedInput.isMetalIngot( input ) )
{
@@ -143,7 +153,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
if( is != null )
{
if( this.makePlate() )
{
return is;
}
}
return null;
}
@@ -176,7 +188,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
public void setInventorySlotContents( int var1, ItemStack var2 )
{
if( var2 == null && Platform.isServer() )
{
this.makePlate();
}
}
@Override
@@ -79,9 +79,13 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
{
IBiometricCard bc = (IBiometricCard) a.getItem();
if( bc.hasPermission( a, permission ) )
{
bc.removePermission( a, permission );
}
else
{
bc.addPermission( a, permission );
}
}
}
catch( EnumConstantNotPresentException ex )
@@ -103,7 +107,9 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
IBiometricCard bc = (IBiometricCard) a.getItem();
for( SecurityPermissions sp : bc.getPermissions( a ) )
{
this.security |= ( 1 << sp.ordinal() );
}
}
this.updatePowerStatus();
@@ -117,10 +123,14 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
super.onContainerClosed( player );
if( this.wirelessIn.getHasStack() )
{
player.dropPlayerItemWithRandomChoice( this.wirelessIn.getStack(), false );
}
if( this.wirelessOut.getHasStack() )
{
player.dropPlayerItemWithRandomChoice( this.wirelessOut.getStack(), false );
}
}
@Override
@@ -140,11 +150,15 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
INetworkEncodable networkEncodable = null;
if( term.getItem() instanceof INetworkEncodable )
{
networkEncodable = (INetworkEncodable) term.getItem();
}
IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term );
if( wTermHandler != null )
{
networkEncodable = wTermHandler;
}
if( networkEncodable != null )
{
@@ -55,7 +55,9 @@ public class ContainerSpatialIOPort extends AEBaseContainer
this.spatialIOPort = spatialIOPort;
if( Platform.isServer() )
{
this.network = spatialIOPort.getGridNode( ForgeDirection.UNKNOWN ).getGrid();
}
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, spatialIOPort, 0, 52, 48, this.invPlayer ) );
this.addSlotToContainer( new SlotOutput( spatialIOPort, 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) );
@@ -79,9 +79,13 @@ public class ContainerStorageBus extends ContainerUpgradeable
for( int x = 0; x < 9; x++ )
{
if( y < 2 )
{
this.addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
}
else
{
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
}
}
}
@@ -132,7 +136,9 @@ public class ContainerStorageBus extends ContainerUpgradeable
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
inv.setInventorySlotContents( x, null );
}
this.detectAndSendChanges();
}
@@ -158,7 +164,9 @@ public class ContainerStorageBus extends ContainerUpgradeable
inv.setInventorySlotContents( x, g );
}
else
{
inv.setInventorySlotContents( x, null );
}
}
this.detectAndSendChanges();
@@ -104,8 +104,12 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
if( this.hasToolbox() )
{
for( int v = 0; v < 3; v++ )
{
for( int u = 0; u < 3; u++ )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.tbInventory, u + v * 3, 186 + u * 18, this.getHeight() - 82 + v * 18, this.invPlayer ) ).setPlayerSide() );
}
}
}
this.setupConfig();
@@ -150,13 +154,21 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" );
if( this.availableUpgrades() > 0 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() );
}
if( this.availableUpgrades() > 1 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ) ).setNotDraggable() );
}
if( this.availableUpgrades() > 2 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ) ).setNotDraggable() );
}
if( this.availableUpgrades() > 3 )
{
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ) ).setNotDraggable() );
}
}
protected boolean supportCapacity()
@@ -188,7 +200,9 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
OptionalSlotFake fs = (OptionalSlotFake) o;
if( !fs.isEnabled() && fs.getDisplayStack() != null )
{
fs.clearStack();
}
}
}
@@ -200,7 +214,9 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
this.fzMode = (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE );
this.rsMode = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED );
if( this.upgradeable instanceof PartExportBus )
{
this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY );
}
}
public void checkToolbox()
@@ -214,12 +230,18 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
if( currentItem != null )
{
if( Platform.isSameItem( this.tbInventory.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
}
else
{
this.isContainerValid = false;
}
}
else
{
this.isContainerValid = false;
}
}
}
}
@@ -235,9 +257,13 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY );
if( idx == 1 && upgrades > 0 )
{
return true;
}
if( idx == 2 && upgrades > 1 )
{
return true;
}
return false;
}
@@ -46,7 +46,9 @@ public class ContainerWirelessTerm extends ContainerMEPortableCell
if( !this.wirelessTerminalGUIObject.rangeCheck() )
{
if( Platform.isServer() && this.isContainerValid )
{
this.getPlayerInv().player.addChatMessage( PlayerMessages.OutOfRange.get() );
}
this.isContainerValid = false;
}
@@ -44,7 +44,9 @@ public class CraftingCPURecord implements Comparable<CraftingCPURecord>
{
int a = ItemSorters.compareLong( o.processors, this.processors );
if( a != 0 )
{
return a;
}
return ItemSorters.compareLong( o.size, this.size );
}
}
@@ -74,7 +74,9 @@ public class AppEngSlot extends Slot
public boolean isItemValid( ItemStack par1ItemStack )
{
if( this.isEnabled() )
{
return super.isItemValid( par1ItemStack );
}
return false;
}
@@ -82,10 +84,14 @@ public class AppEngSlot extends Slot
public ItemStack getStack()
{
if( !this.isEnabled() )
{
return null;
}
if( this.inventory.getSizeInventory() <= this.getSlotIndex() )
{
return null;
}
if( this.isDisplay )
{
@@ -103,7 +109,9 @@ public class AppEngSlot extends Slot
super.putStack( par1ItemStack );
if( this.myContainer != null )
{
this.myContainer.onSlotChange( this );
}
}
}
@@ -111,9 +119,13 @@ public class AppEngSlot extends Slot
public void onSlotChanged()
{
if( this.inventory instanceof AppEngInternalInventory )
{
( (AppEngInternalInventory) this.inventory ).markDirty( this.getSlotIndex() );
}
else
{
super.onSlotChanged();
}
this.isValid = hasCalculatedValidness.NotAvailable;
}
@@ -122,7 +134,9 @@ public class AppEngSlot extends Slot
public boolean canTakeStack( EntityPlayer par1EntityPlayer )
{
if( this.isEnabled() )
{
return super.canTakeStack( par1EntityPlayer );
}
return false;
}
@@ -49,7 +49,9 @@ public class OptionalSlotFake extends SlotFake
if( !this.isEnabled() )
{
if( this.getDisplayStack() != null )
{
this.clearStack();
}
}
return super.getStack();
@@ -59,7 +61,9 @@ public class OptionalSlotFake extends SlotFake
public boolean isEnabled()
{
if( this.host == null )
{
return false;
}
return this.host.isSlotEnabled( this.groupNum );
}
@@ -38,9 +38,13 @@ public class OptionalSlotFakeTypeOnly extends OptionalSlotFake
{
is = is.copy();
if( is.stackSize > 1 )
{
is.stackSize = 1;
}
else if( is.stackSize < -1 )
{
is.stackSize = -1;
}
}
super.putStack( is );
@@ -39,7 +39,9 @@ public class OptionalSlotNormal extends AppEngSlot
public boolean isEnabled()
{
if( this.host == null )
{
return false;
}
return this.host.isSlotEnabled( this.groupNum );
}
@@ -40,7 +40,9 @@ public class OptionalSlotRestrictedInput extends SlotRestrictedInput
public boolean isEnabled()
{
if( this.host == null )
{
return false;
}
return this.host.isSlotEnabled( this.groupNum );
}
@@ -87,9 +87,13 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
public void doClick( InventoryAction action, EntityPlayer who )
{
if( this.getStack() == null )
{
return;
}
if( Platform.isClient() )
{
return;
}
IMEMonitor<IAEItemStack> inv = this.storage.getItemInventory();
int howManyPerCraft = this.getStack().stackSize;
@@ -116,11 +120,15 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
maxTimesToCraft = this.CapCraftingAttempts( maxTimesToCraft );
if( ia == null )
{
return;
}
ItemStack rs = Platform.cloneItemStack( this.getStack() );
if( rs == null )
{
return;
}
for( int x = 0; x < maxTimesToCraft; x++ )
{
@@ -158,7 +166,9 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
{
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, this.pattern.getStackInSlot( x ) );
}
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
@@ -172,9 +182,13 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
{
ItemStack pis = ic.getStackInSlot( x );
if( pis == null )
{
continue;
}
if( pis.getItem() != target )
{
isBad = true;
}
}
if( !isBad )
{
@@ -247,12 +261,16 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
// eek! put it back!
IAEItemStack fail = inv.injectItems( AEItemStack.create( set[x] ), Actionable.MODULATE, this.mySrc );
if( fail != null )
{
drops.add( fail.getItemStack() );
}
}
}
}
if( drops.size() > 0 )
{
Platform.spawnDrops( p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops );
}
}
}
@@ -56,7 +56,9 @@ public class SlotFake extends AppEngSlot
public void putStack( ItemStack is )
{
if( is != null )
{
is = is.copy();
}
super.putStack( is );
}
@@ -38,9 +38,13 @@ public class SlotFakeTypeOnly extends SlotFake
{
is = is.copy();
if( is.stackSize > 1 )
{
is.stackSize = 1;
}
else if( is.stackSize < -1 )
{
is.stackSize = -1;
}
}
super.putStack( is );
@@ -60,7 +60,9 @@ public class SlotInaccessible extends AppEngSlot
{
ItemStack dsp = super.getDisplayStack();
if( dsp != null )
{
this.dspStack = dsp.copy();
}
}
return this.dspStack;
}
@@ -59,7 +59,9 @@ public class SlotPatternTerm extends SlotCraftingTerm
if( !this.isEnabled() )
{
if( this.getDisplayStack() != null )
{
this.clearStack();
}
}
return super.getStack();
@@ -69,7 +71,9 @@ public class SlotPatternTerm extends SlotCraftingTerm
public boolean isEnabled()
{
if( this.host == null )
{
return false;
}
return this.host.isSlotEnabled( this.groupNum );
}
@@ -71,7 +71,9 @@ public class SlotRestrictedInput extends AppEngSlot
public int getSlotStackLimit()
{
if( this.stackLimit != -1 )
{
return this.stackLimit;
}
return super.getSlotStackLimit();
}
@@ -95,18 +97,28 @@ public class SlotRestrictedInput extends AppEngSlot
public boolean isItemValid( ItemStack i )
{
if( !this.myContainer.isValidForSlot( this, i ) )
{
return false;
}
if( i == null )
{
return false;
}
if( i.getItem() == null )
{
return false;
}
if( !this.inventory.isItemValidForSlot( this.getSlotIndex(), i ) )
{
return false;
}
if( !this.allowEdit )
{
return false;
}
final IDefinitions definitions = AEApi.instance().definitions();
final IMaterials materials = definitions.materials();
@@ -120,7 +132,9 @@ public class SlotRestrictedInput extends AppEngSlot
ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.worldObj );
if( de != null )
{
return de.isCraftable();
}
}
return false;
case VALID_ENCODED_PATTERN_W_OUTPUT:
@@ -128,7 +142,9 @@ public class SlotRestrictedInput extends AppEngSlot
case ENCODED_PATTERN:
{
if( i.getItem() instanceof ICraftingPatternItem )
{
return true;
}
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem)
// i.getItem()).getPatternForItem( i ) : null;
return false;// pattern != null;
@@ -139,7 +155,9 @@ public class SlotRestrictedInput extends AppEngSlot
case PATTERN:
if( i.getItem() instanceof ICraftingPatternItem )
{
return true;
}
return materials.blankPattern().isSameAs( i );
@@ -150,8 +168,12 @@ public class SlotRestrictedInput extends AppEngSlot
}
for( ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() )
{
if( Platform.isSameItemPrecise( optional, i ) )
{
return true;
}
}
return false;
@@ -190,7 +212,9 @@ public class SlotRestrictedInput extends AppEngSlot
return i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i );
case TRASH:
if( AEApi.instance().registries().cell().isCellHandled( i ) )
{
return false;
}
return !( i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ) );
case ENCODABLE_ITEM:
@@ -223,7 +247,9 @@ public class SlotRestrictedInput extends AppEngSlot
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
ItemStack out = iep.getOutput( is );
if( out != null )
{
return out;
}
}
}
return super.getStack();
@@ -232,14 +258,18 @@ public class SlotRestrictedInput extends AppEngSlot
public static boolean isMetalIngot( ItemStack i )
{
if( Platform.isSameItemPrecise( i, new ItemStack( Items.iron_ingot ) ) )
{
return true;
}
for( String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" } )
{
for( ItemStack ingot : OreDictionary.getOres( "ingot" + name ) )
{
if( Platform.isSameItemPrecise( i, ingot ) )
{
return true;
}
}
}