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
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
@@ -45,33 +46,32 @@ import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
public class ContainerCellWorkbench extends ContainerUpgradeable
{
final TileCellWorkbench workBench;
final AppEngNullInventory ni = new AppEngNullInventory();
@GuiSync( 2 )
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
IInventory UpgradeInventoryWrapper;
ItemStack prevStack = null;
int lastUpgrades = 0;
ItemStack LastCell;
public IInventory getCellUpgradeInventory()
public ContainerCellWorkbench( InventoryPlayer ip, TileCellWorkbench te )
{
IInventory ri = this.workBench.getCellUpgradeInventory();
return ri == null ? this.ni : ri;
super( ip, te );
this.workBench = te;
}
public void setFuzzy(FuzzyMode valueOf)
public void setFuzzy( FuzzyMode valueOf )
{
ICellWorkbenchItem cwi = this.workBench.getCell();
if ( cwi != null )
if( cwi != null )
cwi.setFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf );
}
private FuzzyMode getFuzzyMode()
{
ICellWorkbenchItem cwi = this.workBench.getCell();
if ( cwi != null )
return cwi.getFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
return FuzzyMode.IGNORE_ALL;
}
public void nextCopyMode()
{
this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, Platform.nextEnum( this.getCopyMode() ) );
@@ -82,6 +82,161 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
return (CopyMode) this.workBench.getConfigManager().getSetting( Settings.COPY_MODE );
}
@Override
protected int getHeight()
{
return 251;
}
@Override
protected void setupConfig()
{
int x = 8;
int y = 29;
int offset = 0;
IInventory cell = this.upgradeable.getInventoryByName( "cell" );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.invPlayer ) );
IInventory inv = this.upgradeable.getInventoryByName( "config" );
this.UpgradeInventoryWrapper = new Upgrades();// Platform.isServer() ? new Upgrades() : new AppEngInternalInventory(
// 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, this.UpgradeInventoryWrapper, 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 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 2, 2 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 4, 3 ) ); }
*/
}
@Override
public int availableUpgrades()
{
ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if( this.prevStack != is )
{
this.prevStack = is;
return this.lastUpgrades = this.getCellUpgradeInventory().getSizeInventory();
}
return this.lastUpgrades;
}
@Override
public void detectAndSendChanges()
{
ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if( Platform.isServer() )
{
for( Object crafter : this.crafters )
{
ICrafting icrafting = (ICrafting) crafter;
if( this.prevStack != is )
{
// if the bars changed an item was probably made, so just send shit!
for( Object s : this.inventorySlots )
{
if( s instanceof OptionalSlotRestrictedInput )
{
OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false;
}
}
this.copyMode = this.getCopyMode();
this.fzMode = this.getFuzzyMode();
}
this.prevStack = is;
this.standardDetectAndSendChanges();
}
@Override
public boolean isSlotEnabled( int idx )
{
return idx < this.availableUpgrades();
}
public IInventory getCellUpgradeInventory()
{
IInventory ri = this.workBench.getCellUpgradeInventory();
return ri == null ? this.ni : ri;
}
@Override
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 );
}
public void clear()
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
for( int x = 0; x < inv.getSizeInventory(); x++ )
inv.setInventorySlotContents( x, null );
this.detectAndSendChanges();
}
private FuzzyMode getFuzzyMode()
{
ICellWorkbenchItem cwi = this.workBench.getCell();
if( cwi != null )
return cwi.getFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
return FuzzyMode.IGNORE_ALL;
}
public void partition()
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory( this.upgradeable.getInventoryByName( "cell" ).getStackInSlot( 0 ), null, StorageChannel.ITEMS );
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
i = list.iterator();
}
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
if( i.hasNext() )
{
ItemStack g = i.next().getItemStack();
g.stackSize = 1;
inv.setInventorySlotContents( x, g );
}
else
inv.setInventorySlotContents( x, null );
}
this.detectAndSendChanges();
}
class Upgrades implements IInventory
{
@@ -92,13 +247,13 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
}
@Override
public ItemStack getStackInSlot(int i)
public ItemStack getStackInSlot( int i )
{
return ContainerCellWorkbench.this.getCellUpgradeInventory().getStackInSlot( i );
}
@Override
public ItemStack decrStackSize(int i, int j)
public ItemStack decrStackSize( int i, int j )
{
IInventory inv = ContainerCellWorkbench.this.getCellUpgradeInventory();
ItemStack is = inv.decrStackSize( i, j );
@@ -107,7 +262,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
public ItemStack getStackInSlotOnClosing( int i )
{
IInventory inv = ContainerCellWorkbench.this.getCellUpgradeInventory();
ItemStack is = inv.getStackInSlotOnClosing( i );
@@ -116,7 +271,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
public void setInventorySlotContents( int i, ItemStack itemstack )
{
IInventory inv = ContainerCellWorkbench.this.getCellUpgradeInventory();
inv.setInventorySlotContents( i, itemstack );
@@ -148,7 +303,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
public boolean isUseableByPlayer( EntityPlayer entityplayer )
{
return false;
}
@@ -164,168 +319,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
public boolean isItemValidForSlot( int i, ItemStack itemstack )
{
return ContainerCellWorkbench.this.getCellUpgradeInventory().isItemValidForSlot( i, itemstack );
}
}
IInventory UpgradeInventoryWrapper;
ItemStack prevStack = null;
int lastUpgrades = 0;
@GuiSync(2)
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
public ContainerCellWorkbench(InventoryPlayer ip, TileCellWorkbench te) {
super( ip, te );
this.workBench = te;
}
@Override
protected int getHeight()
{
return 251;
}
@Override
public int availableUpgrades()
{
ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( this.prevStack != is )
{
this.prevStack = is;
return this.lastUpgrades = this.getCellUpgradeInventory().getSizeInventory();
}
return this.lastUpgrades;
}
@Override
public boolean isSlotEnabled(int idx)
{
return idx < this.availableUpgrades();
}
@Override
protected void setupConfig()
{
int x = 8;
int y = 29;
int offset = 0;
IInventory cell = this.upgradeable.getInventoryByName( "cell" );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.invPlayer ) );
IInventory inv = this.upgradeable.getInventoryByName( "config" );
this.UpgradeInventoryWrapper = new Upgrades();// Platform.isServer() ? new Upgrades() : new AppEngInternalInventory(
// 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, this.UpgradeInventoryWrapper, 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 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 2, 2 ) );
*
* for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly(
* inv, this, offset++, x, y, z, w + 4, 3 ) ); }
*/
}
ItemStack LastCell;
@Override
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 );
}
@Override
public void detectAndSendChanges()
{
ItemStack is = this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
if ( Platform.isServer() )
{
for (Object crafter : this.crafters)
{
ICrafting icrafting = (ICrafting) crafter;
if ( this.prevStack != is )
{
// if the bars changed an item was probably made, so just send shit!
for (Object s : this.inventorySlots)
{
if ( s instanceof OptionalSlotRestrictedInput )
{
OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
}
}
this.copyMode = this.getCopyMode();
this.fzMode = this.getFuzzyMode();
}
this.prevStack = is;
this.standardDetectAndSendChanges();
}
public void clear()
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
for (int x = 0; x < inv.getSizeInventory(); x++)
inv.setInventorySlotContents( x, null );
this.detectAndSendChanges();
}
public void partition()
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell()
.getCellInventory( this.upgradeable.getInventoryByName( "cell" ).getStackInSlot( 0 ), null, StorageChannel.ITEMS );
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if ( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
i = list.iterator();
}
for (int x = 0; x < inv.getSizeInventory(); x++)
{
if ( i.hasNext() )
{
ItemStack g = i.next().getItemStack();
g.stackSize = 1;
inv.setInventorySlotContents( x, g );
}
else
inv.setInventorySlotContents( x, null );
}
this.detectAndSendChanges();
}
}
@@ -18,18 +18,21 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.storage.TileChest;
public class ContainerChest extends AEBaseContainer
{
final TileChest chest;
public ContainerChest(InventoryPlayer ip, TileChest chest) {
public ContainerChest( InventoryPlayer ip, TileChest chest )
{
super( ip, chest, null );
this.chest = chest;
@@ -37,5 +40,4 @@ public class ContainerChest extends AEBaseContainer
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.CondenserOutput;
@@ -30,18 +31,26 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
public class ContainerCondenser extends AEBaseContainer implements IProgressProvider
{
final TileCondenser condenser;
@GuiSync( 0 )
public long requiredEnergy = 0;
@GuiSync( 1 )
public long storedPower = 0;
@GuiSync( 2 )
public CondenserOutput output = CondenserOutput.TRASH;
public ContainerCondenser(InventoryPlayer ip, TileCondenser condenser) {
public ContainerCondenser( InventoryPlayer ip, TileCondenser condenser )
{
super( ip, condenser, null );
this.condenser = condenser;
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.TRASH, condenser, 0, 51, 52, ip ) );
this.addSlotToContainer( new SlotOutput( condenser, 1, 105, 52, -1 ) );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, condenser.getInternalInventory(), 2, 101, 26, ip )).setStackLimit( 1 ) );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, condenser.getInternalInventory(), 2, 101, 26, ip ) ).setStackLimit( 1 ) );
this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 );
}
@@ -49,7 +58,7 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
@Override
public void detectAndSendChanges()
{
if ( Platform.isServer() )
if( Platform.isServer() )
{
double maxStorage = this.condenser.getStorage();
double requiredEnergy = this.condenser.getRequiredPower();
@@ -62,15 +71,6 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
super.detectAndSendChanges();
}
@GuiSync(0)
public long requiredEnergy = 0;
@GuiSync(1)
public long storedPower = 0;
@GuiSync(2)
public CondenserOutput output = CondenserOutput.TRASH;
@Override
public int getCurrentProgress()
{
@@ -82,5 +82,4 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
{
return (int) this.requiredEnergy;
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.world.World;
@@ -33,15 +34,16 @@ import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotInaccessible;
import appeng.tile.inventory.AppEngInternalInventory;
public class ContainerCraftAmount extends AEBaseContainer
{
final ITerminalHost priHost;
public IAEItemStack whatToMake;
public final Slot craftingItem;
final ITerminalHost priHost;
public IAEItemStack whatToMake;
public ContainerCraftAmount(InventoryPlayer ip, ITerminalHost te) {
public ContainerCraftAmount( InventoryPlayer ip, ITerminalHost te )
{
super( ip, te );
this.priHost = te;
@@ -58,7 +60,7 @@ public class ContainerCraftAmount extends AEBaseContainer
public IGrid getGrid()
{
IActionHost h = ((IActionHost) this.getTarget());
IActionHost h = ( (IActionHost) this.getTarget() );
return h.getActionableNode().getGrid();
}
@@ -71,5 +73,4 @@ public class ContainerCraftAmount extends AEBaseContainer
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}
}
@@ -18,13 +18,12 @@
package appeng.container.implementations;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.Future;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -33,6 +32,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import com.google.common.collect.ImmutableSet;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
@@ -62,78 +63,51 @@ import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartTerminal;
import appeng.util.Platform;
public class ContainerCraftConfirm extends AEBaseContainer
{
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
final ITerminalHost priHost;
public Future<ICraftingJob> job;
public ICraftingJob result;
@GuiSync(0)
@GuiSync( 0 )
public long bytesUsed;
@GuiSync(1)
@GuiSync( 1 )
public long cpuBytesAvail;
@GuiSync(2)
@GuiSync( 2 )
public int cpuCoProcessors;
@GuiSync(3)
@GuiSync( 3 )
public boolean autoStart = false;
@GuiSync(4)
@GuiSync( 4 )
public boolean simulation = true;
@GuiSync(5)
@GuiSync( 5 )
public int selectedCpu = -1;
@GuiSync(6)
@GuiSync( 6 )
public boolean noCPU = true;
@GuiSync(7)
@GuiSync( 7 )
public String myName = "";
protected long cpuIdx = Long.MIN_VALUE;
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
public ContainerCraftConfirm(InventoryPlayer ip, ITerminalHost te) {
public ContainerCraftConfirm( InventoryPlayer ip, ITerminalHost te )
{
super( ip, te );
this.priHost = te;
}
private void sendCPUs()
public void cycleCpu( boolean next )
{
Collections.sort( this.cpus );
if ( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
this.cpuBytesAvail = 0;
this.cpuCoProcessors = 0;
this.myName = "";
}
else if ( this.selectedCpu != -1 )
{
this.myName = this.cpus.get( this.selectedCpu ).myName;
this.cpuBytesAvail = this.cpus.get( this.selectedCpu ).size;
this.cpuCoProcessors = this.cpus.get( this.selectedCpu ).processors;
}
}
public void cycleCpu(boolean next)
{
if ( next )
if( next )
this.selectedCpu++;
else
this.selectedCpu--;
if ( this.selectedCpu < -1 )
if( this.selectedCpu < -1 )
this.selectedCpu = this.cpus.size() - 1;
else if ( this.selectedCpu >= this.cpus.size() )
else if( this.selectedCpu >= this.cpus.size() )
this.selectedCpu = -1;
if ( this.selectedCpu == -1 )
if( this.selectedCpu == -1 )
{
this.cpuBytesAvail = 0;
this.cpuCoProcessors = 0;
@@ -150,7 +124,7 @@ public class ContainerCraftConfirm extends AEBaseContainer
@Override
public void detectAndSendChanges()
{
if ( Platform.isClient() )
if( Platform.isClient() )
return;
ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
@@ -158,28 +132,28 @@ public class ContainerCraftConfirm extends AEBaseContainer
int matches = 0;
boolean changed = false;
for (ICraftingCPU c : cpuSet)
for( ICraftingCPU c : cpuSet )
{
boolean found = false;
for (CraftingCPURecord ccr : this.cpus)
if ( ccr.cpu == c )
for( CraftingCPURecord ccr : this.cpus )
if( ccr.cpu == c )
found = true;
boolean matched = this.cpuMatches( c );
if ( matched )
if( matched )
matches++;
if ( found == !matched )
if( found == !matched )
changed = true;
}
if ( changed || this.cpus.size() != matches )
if( changed || this.cpus.size() != matches )
{
this.cpus.clear();
for (ICraftingCPU c : cpuSet)
for( ICraftingCPU c : cpuSet )
{
if ( this.cpuMatches( c ) )
if( this.cpuMatches( c ) )
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
@@ -190,16 +164,16 @@ public class ContainerCraftConfirm extends AEBaseContainer
super.detectAndSendChanges();
if ( this.job != null && this.job.isDone() )
if( this.job != null && this.job.isDone() )
{
try
{
this.result = this.job.get();
if ( !this.result.isSimulation() )
if( !this.result.isSimulation() )
{
this.simulation = false;
if ( this.autoStart )
if( this.autoStart )
{
this.startJob();
return;
@@ -219,7 +193,7 @@ public class ContainerCraftConfirm extends AEBaseContainer
this.bytesUsed = this.result.getByteTotal();
for (IAEItemStack out : plan)
for( IAEItemStack out : plan )
{
IAEItemStack m = null;
@@ -234,12 +208,12 @@ public class ContainerCraftConfirm extends AEBaseContainer
IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class );
IMEInventory<IAEItemStack> items = sg.getItemInventory();
if ( c != null && this.result.isSimulation() )
if( c != null && this.result.isSimulation() )
{
m = o.copy();
o = items.extractItems( o, Actionable.SIMULATE, this.mySrc );
if ( o == null )
if( o == null )
{
o = m.copy();
o.setStackSize( 0 );
@@ -248,33 +222,33 @@ public class ContainerCraftConfirm extends AEBaseContainer
m.setStackSize( m.getStackSize() - o.getStackSize() );
}
if ( o.getStackSize() > 0 )
if( o.getStackSize() > 0 )
a.appendItem( o );
if ( p.getStackSize() > 0 )
if( p.getStackSize() > 0 )
b.appendItem( p );
if ( c != null && m != null && m.getStackSize() > 0 )
if( c != null && m != null && m.getStackSize() > 0 )
c.appendItem( m );
}
for (Object g : this.crafters)
for( Object g : this.crafters )
{
if ( g instanceof EntityPlayer )
if( g instanceof EntityPlayer )
{
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
if ( c != null )
if( c != null )
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
}
}
}
catch (IOException e)
catch( IOException e )
{
// :P
}
}
catch (Throwable e)
catch( Throwable e )
{
this.getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) );
AELog.error( e );
@@ -287,34 +261,59 @@ public class ContainerCraftConfirm extends AEBaseContainer
this.verifyPermissions( SecurityPermissions.CRAFT, false );
}
private boolean cpuMatches(ICraftingCPU c)
public IGrid getGrid()
{
IActionHost h = ( (IActionHost) this.getTarget() );
return h.getActionableNode().getGrid();
}
private boolean cpuMatches( ICraftingCPU c )
{
return c.getAvailableStorage() >= this.bytesUsed && !c.isBusy();
}
private void sendCPUs()
{
Collections.sort( this.cpus );
if( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
this.cpuBytesAvail = 0;
this.cpuCoProcessors = 0;
this.myName = "";
}
else if( this.selectedCpu != -1 )
{
this.myName = this.cpus.get( this.selectedCpu ).myName;
this.cpuBytesAvail = this.cpus.get( this.selectedCpu ).size;
this.cpuCoProcessors = this.cpus.get( this.selectedCpu ).processors;
}
}
public void startJob()
{
GuiBridge OriginalGui = null;
IActionHost ah = this.getActionHost();
if ( ah instanceof WirelessTerminalGuiObject )
if( ah instanceof WirelessTerminalGuiObject )
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
if ( ah instanceof PartTerminal )
if( ah instanceof PartTerminal )
OriginalGui = GuiBridge.GUI_ME;
if ( ah instanceof PartCraftingTerminal )
if( ah instanceof PartCraftingTerminal )
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
if ( ah instanceof PartPatternTerminal )
if( ah instanceof PartPatternTerminal )
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
if ( this.result != null && !this.simulation )
if( this.result != null && !this.simulation )
{
ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
ICraftingLink g = cc.submitJob( this.result, null, this.selectedCpu == -1 ? null : this.cpus.get( this.selectedCpu ).cpu, true, this.getActionSrc() );
this.autoStart = false;
if ( g != null && OriginalGui != null && this.openContext != null )
if( g != null && OriginalGui != null && this.openContext != null )
{
NetworkHandler.instance.sendTo( new PacketSwitchGuis( OriginalGui ), (EntityPlayerMP) this.invPlayer.player );
@@ -324,41 +323,35 @@ public class ContainerCraftConfirm extends AEBaseContainer
}
}
@Override
public void onContainerClosed(EntityPlayer par1EntityPlayer)
public BaseActionSource getActionSrc()
{
super.onContainerClosed( par1EntityPlayer );
if ( this.job != null )
{
this.job.cancel( true );
this.job = null;
}
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}
@Override
public void removeCraftingFromCrafters(ICrafting c)
public void removeCraftingFromCrafters( ICrafting c )
{
super.removeCraftingFromCrafters( c );
if ( this.job != null )
if( this.job != null )
{
this.job.cancel( true );
this.job = null;
}
}
public IGrid getGrid()
@Override
public void onContainerClosed( EntityPlayer par1EntityPlayer )
{
IActionHost h = ((IActionHost) this.getTarget());
return h.getActionableNode().getGrid();
super.onContainerClosed( par1EntityPlayer );
if( this.job != null )
{
this.job.cancel( true );
this.job = null;
}
}
public World getWorld()
{
return this.getPlayerInv().player.worldObj;
}
public BaseActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
@@ -47,62 +48,74 @@ import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
{
final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
protected IGrid network;
CraftingCPUCluster monitor = null;
String cpuName = null;
protected IGrid network;
int delay = 40;
final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
public ContainerCraftingCPU(InventoryPlayer ip, Object te) {
public ContainerCraftingCPU( InventoryPlayer ip, Object te )
{
super( ip, te );
IGridHost host = (IGridHost) (te instanceof IGridHost ? te : null);
IGridHost host = (IGridHost) ( te instanceof IGridHost ? te : null );
if ( host != null )
if( host != null )
{
this.findNode( host, ForgeDirection.UNKNOWN );
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
this.findNode( host, d );
}
if ( te instanceof TileCraftingTile )
this.setCPU( (ICraftingCPU) ((TileCraftingTile) te).getCluster() );
if( te instanceof TileCraftingTile )
this.setCPU( (ICraftingCPU) ( (TileCraftingTile) te ).getCluster() );
if ( this.network == null && Platform.isServer() )
if( this.network == null && Platform.isServer() )
this.isContainerValid = false;
}
protected void setCPU(ICraftingCPU c)
private void findNode( IGridHost host, ForgeDirection d )
{
if ( c == this.monitor )
if( this.network == null )
{
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 )
if( this.monitor != null )
this.monitor.removeListener( this );
for (Object g : this.crafters)
for( Object g : this.crafters )
{
if ( g instanceof EntityPlayer )
if( g instanceof EntityPlayer )
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (EntityPlayerMP) g );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
}
}
if ( c instanceof CraftingCPUCluster )
if( c instanceof CraftingCPUCluster )
{
this.cpuName = c.getName();
this.monitor = (CraftingCPUCluster) c;
if ( this.monitor != null )
if( this.monitor != null )
{
this.list.resetStatus();
this.monitor.getListOfItem( this.list, CraftingItemList.ALL );
@@ -118,45 +131,33 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
public void cancelCrafting()
{
if ( this.monitor != null )
if( this.monitor != null )
{
this.monitor.cancel();
}
}
private void findNode(IGridHost host, ForgeDirection d)
{
if ( this.network == null )
{
IGridNode node = host.getGridNode( d );
if ( node != null )
this.network = node.getGrid();
}
}
int delay = 40;
@Override
public void onContainerClosed(EntityPlayer player)
public void removeCraftingFromCrafters( ICrafting c )
{
super.onContainerClosed( player );
if ( this.monitor != null )
super.removeCraftingFromCrafters( c );
if( this.crafters.isEmpty() && this.monitor != null )
this.monitor.removeListener( this );
}
@Override
public void removeCraftingFromCrafters(ICrafting c)
public void onContainerClosed( EntityPlayer player )
{
super.removeCraftingFromCrafters( c );
if ( this.crafters.isEmpty() && this.monitor != null )
super.onContainerClosed( player );
if( this.monitor != null )
this.monitor.removeListener( this );
}
@Override
public void detectAndSendChanges()
{
if ( Platform.isServer() && this.monitor != null && !this.list.isEmpty() )
if( Platform.isServer() && this.monitor != null && !this.list.isEmpty() )
{
try
{
@@ -164,7 +165,7 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 );
for (IAEItemStack out : this.list)
for( IAEItemStack out : this.list )
{
a.appendItem( this.monitor.getItemStack( out, CraftingItemList.STORAGE ) );
b.appendItem( this.monitor.getItemStack( out, CraftingItemList.ACTIVE ) );
@@ -173,40 +174,39 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH
this.list.resetStatus();
for (Object g : this.crafters)
for( Object g : this.crafters )
{
if ( g instanceof EntityPlayer )
if( g instanceof EntityPlayer )
{
if ( !a.isEmpty() )
if( !a.isEmpty() )
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
if ( !b.isEmpty() )
if( !b.isEmpty() )
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
if ( !c.isEmpty() )
if( !c.isEmpty() )
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
}
}
}
catch (IOException e)
catch( IOException e )
{
// :P
}
}
super.detectAndSendChanges();
}
@Override
public boolean isValid(Object verificationToken)
public boolean isValid( Object verificationToken )
{
return true;
}
@Override
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource)
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource )
{
for (IAEItemStack is : change)
for( IAEItemStack is : change )
{
is = is.copy();
is.setStackSize( 1 );
@@ -18,56 +18,34 @@
package appeng.container.implementations;
import java.util.ArrayList;
import java.util.Collections;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.InventoryPlayer;
import com.google.common.collect.ImmutableSet;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.storage.ITerminalHost;
import appeng.container.guisync.GuiSync;
public class ContainerCraftingStatus extends ContainerCraftingCPU
{
@GuiSync(5)
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
@GuiSync( 5 )
public int selectedCpu = -1;
@GuiSync(6)
@GuiSync( 6 )
public boolean noCPU = true;
@GuiSync(7)
@GuiSync( 7 )
public String myName = "";
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
private void sendCPUs()
public ContainerCraftingStatus( InventoryPlayer ip, ITerminalHost te )
{
Collections.sort( this.cpus );
if ( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
this.myName = "";
}
else if ( this.selectedCpu != -1 )
{
this.myName = this.cpus.get( this.selectedCpu ).myName;
}
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 );
super( ip, te );
}
@Override
@@ -78,28 +56,28 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
int matches = 0;
boolean changed = false;
for (ICraftingCPU c : cpuSet)
for( ICraftingCPU c : cpuSet )
{
boolean found = false;
for (CraftingCPURecord ccr : this.cpus)
if ( ccr.cpu == c )
for( CraftingCPURecord ccr : this.cpus )
if( ccr.cpu == c )
found = true;
boolean matched = this.cpuMatches( c );
if ( matched )
if( matched )
matches++;
if ( found == !matched )
if( found == !matched )
changed = true;
}
if ( changed || this.cpus.size() != matches )
if( changed || this.cpus.size() != matches )
{
this.cpus.clear();
for (ICraftingCPU c : cpuSet)
for( ICraftingCPU c : cpuSet )
{
if ( this.cpuMatches( c ) )
if( this.cpuMatches( c ) )
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
}
@@ -111,31 +89,53 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
super.detectAndSendChanges();
}
private boolean cpuMatches(ICraftingCPU c)
private boolean cpuMatches( ICraftingCPU c )
{
return c.isBusy();
}
public ContainerCraftingStatus(InventoryPlayer ip, ITerminalHost te) {
super( ip, te );
private void sendCPUs()
{
Collections.sort( this.cpus );
if( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
this.myName = "";
}
else if( this.selectedCpu != -1 )
{
this.myName = this.cpus.get( this.selectedCpu ).myName;
}
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)
public void cycleCpu( boolean next )
{
if ( next )
if( next )
this.selectedCpu++;
else
this.selectedCpu--;
if ( this.selectedCpu < -1 )
if( this.selectedCpu < -1 )
this.selectedCpu = this.cpus.size() - 1;
else if ( this.selectedCpu >= this.cpus.size() )
else if( this.selectedCpu >= this.cpus.size() )
this.selectedCpu = -1;
if ( this.selectedCpu == -1 && this.cpus.size() > 0 )
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
this.selectedCpu = 0;
if ( this.selectedCpu == -1 )
if( this.selectedCpu == -1 )
{
this.myName = "";
this.setCPU( null );
@@ -146,5 +146,4 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU
this.setCPU( this.cpus.get( this.selectedCpu ).cpu );
}
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
@@ -34,39 +35,24 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IContainerCraftingPacket
{
public final PartCraftingTerminal ct;
final AppEngInternalInventory output = new AppEngInternalInventory( this, 1 );
final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
final SlotCraftingTerm outputSlot;
public final PartCraftingTerminal ct;
/**
* Callback for when the crafting matrix is changed.
*/
@Override
public void onCraftMatrixChanged(IInventory par1IInventory)
public ContainerCraftingTerm( InventoryPlayer ip, ITerminalHost monitorable )
{
ContainerNull cn = new ContainerNull();
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 ) );
}
public ContainerCraftingTerm(InventoryPlayer ip, ITerminalHost monitorable) {
super( ip, monitorable, false );
this.ct = (PartCraftingTerminal) monitorable;
IInventory crafting = this.ct.getInventoryByName( "crafting" );
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
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 ) );
@@ -76,6 +62,21 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
this.onCraftMatrixChanged( crafting );
}
/**
* Callback for when the crafting matrix is changed.
*/
@Override
public void onCraftMatrixChanged( IInventory par1IInventory )
{
ContainerNull cn = new ContainerNull();
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 ) );
}
@Override
public void saveChanges()
{
@@ -83,15 +84,15 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
}
@Override
public IInventory getInventoryByName(String name)
public IInventory getInventoryByName( String name )
{
if (name.equals("player"))
if( name.equals( "player" ) )
{
return this.invPlayer;
}
@@ -18,28 +18,30 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.storage.TileDrive;
public class ContainerDrive extends AEBaseContainer
{
final TileDrive drive;
public ContainerDrive(InventoryPlayer ip, TileDrive drive) {
public ContainerDrive( InventoryPlayer ip, TileDrive drive )
{
super( ip, drive, null );
this.drive = drive;
for (int y = 0; y < 5; y++)
for (int x = 0; x < 2; x++)
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 );
}
}
@@ -55,26 +55,6 @@ public class ContainerFormationPlane extends ContainerUpgradeable
return 251;
}
@Override
public int availableUpgrades()
{
return 5;
}
@Override
protected boolean supportCapacity()
{
return true;
}
@Override
public boolean isSlotEnabled( int idx )
{
int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY );
return upgrades > idx;
}
@Override
protected void setupConfig()
{
@@ -82,11 +62,11 @@ public class ContainerFormationPlane extends ContainerUpgradeable
int yo = 23 + 6;
IInventory config = this.upgradeable.getInventoryByName( "config" );
for ( int y = 0; y < 7; y++ )
for( int y = 0; y < 7; y++ )
{
for ( int x = 0; x < 9; x++ )
for( int x = 0; x < 9; x++ )
{
if ( y < 2 )
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 ) );
@@ -101,18 +81,37 @@ public class ContainerFormationPlane extends ContainerUpgradeable
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.invPlayer ) ).setNotDraggable() );
}
@Override
protected boolean supportCapacity()
{
return true;
}
@Override
public int availableUpgrades()
{
return 5;
}
@Override
public void detectAndSendChanges()
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.fzMode = ( FuzzyMode ) this.upgradeable.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.placeMode = ( YesNo ) this.upgradeable.getConfigManager().getSetting( Settings.PLACE_BLOCK );
this.fzMode = (FuzzyMode) this.upgradeable.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.placeMode = (YesNo) this.upgradeable.getConfigManager().getSetting( Settings.PLACE_BLOCK );
}
this.standardDetectAndSendChanges();
}
@Override
public boolean isSlotEnabled( int idx )
{
int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY );
return upgrades > idx;
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
@@ -26,12 +27,14 @@ import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.grindstone.TileGrinder;
public class ContainerGrinder extends AEBaseContainer
{
final TileGrinder grinder;
public ContainerGrinder(InventoryPlayer ip, TileGrinder grinder) {
public ContainerGrinder( InventoryPlayer ip, TileGrinder grinder )
{
super( ip, grinder, null );
this.grinder = grinder;
@@ -47,5 +50,4 @@ public class ContainerGrinder extends AEBaseContainer
this.bindPlayerInventory( ip, 0, 176 - /* height of player inventory */82 );
}
}
@@ -50,6 +50,12 @@ public class ContainerIOPort extends ContainerUpgradeable
this.ioPort = te;
}
@Override
protected int getHeight()
{
return 166;
}
@Override
protected void setupConfig()
{
@@ -58,14 +64,14 @@ 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++ )
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++ )
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" );
@@ -75,9 +81,9 @@ public class ContainerIOPort extends ContainerUpgradeable
}
@Override
protected int getHeight()
protected boolean supportCapacity()
{
return 166;
return false;
}
@Override
@@ -86,18 +92,12 @@ public class ContainerIOPort extends ContainerUpgradeable
return 3;
}
@Override
protected boolean supportCapacity()
{
return false;
}
@Override
public void detectAndSendChanges()
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.opMode = (OperationMode) this.upgradeable.getConfigManager().getSetting( Settings.OPERATION_MODE );
this.fMode = (FullnessMode) this.upgradeable.getConfigManager().getSetting( Settings.FULLNESS_MODE );
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
@@ -33,6 +34,7 @@ import appeng.recipes.handlers.Inscribe.InscriberRecipe;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider
{
@@ -42,13 +44,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
final Slot middle;
final Slot bottom;
@GuiSync(2)
@GuiSync( 2 )
public int maxProcessingTime = -1;
@GuiSync(3)
@GuiSync( 3 )
public int processingTime = -1;
public ContainerInscriber(InventoryPlayer ip, TileInscriber te)
public ContainerInscriber( InventoryPlayer ip, TileInscriber te )
{
super( ip, te );
this.ti = te;
@@ -60,7 +62,6 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
this.addSlotToContainer( new SlotOutput( this.ti, 3, 113, 40, -1 ) );
this.bindPlayerInventory( ip, 0, this.getHeight() - /* height of player inventory */82 );
}
@Override
@@ -70,9 +71,11 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
}
@Override
public int availableUpgrades()
/**
* Overridden super.setupConfig to prevent setting up the fake slots
*/ protected void setupConfig()
{
return 3;
this.setupUpgrades();
}
@Override
@@ -82,92 +85,9 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
}
@Override
/**
* Overridden super.setupConfig to prevent setting up the fake slots
*/
protected void setupConfig()
public int availableUpgrades()
{
this.setupUpgrades();
}
@Override
public boolean isValidForSlot(Slot s, ItemStack is)
{
ItemStack PlateA = this.ti.getStackInSlot( 0 );
ItemStack PlateB = this.ti.getStackInSlot( 1 );
if ( s == this.middle )
{
for (ItemStack i : Inscribe.PLATES )
{
if ( Platform.isSameItemPrecise( i, is ) )
return false;
}
boolean matches = false;
boolean found = false;
for (InscriberRecipe i : Inscribe.RECIPES )
{
boolean matchA = (PlateA == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateA, i.plateA )) && // and...
(PlateB == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateB, i.plateB ));
boolean matchB = (PlateB == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateB, i.plateA )) && // and...
(PlateA == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateA, i.plateB ));
if ( matchA || matchB )
{
matches = true;
for (ItemStack option : i.imprintable)
{
if ( Platform.isSameItemPrecise( is, option ) )
found = true;
}
}
}
if ( matches && !found )
return false;
}
if ( (s == this.top && PlateB != null) || (s == this.bottom && PlateA != null) )
{
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();
if ( namePress.isSameAs( otherSlot ) )
{
return namePress.isSameAs( is );
}
// everything else
for (InscriberRecipe i : Inscribe.RECIPES )
{
if ( Platform.isSameItemPrecise( i.plateA, otherSlot ) )
{
isValid = Platform.isSameItemPrecise( is, i.plateB );
}
else if ( Platform.isSameItemPrecise( i.plateB, otherSlot ) )
{
isValid = Platform.isSameItemPrecise( is, i.plateA );
}
if ( isValid )
break;
}
if ( !isValid )
return false;
}
return true;
return 3;
}
@Override
@@ -175,13 +95,92 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
{
this.standardDetectAndSendChanges();
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.maxProcessingTime = this.ti.maxProcessingTime;
this.processingTime = this.ti.processingTime;
}
}
@Override
public boolean isValidForSlot( Slot s, ItemStack is )
{
ItemStack PlateA = this.ti.getStackInSlot( 0 );
ItemStack PlateB = this.ti.getStackInSlot( 1 );
if( s == this.middle )
{
for( ItemStack i : Inscribe.PLATES )
{
if( Platform.isSameItemPrecise( i, is ) )
return false;
}
boolean matches = false;
boolean found = false;
for( InscriberRecipe i : Inscribe.RECIPES )
{
boolean matchA = ( PlateA == null && i.plateA == null ) || ( Platform.isSameItemPrecise( PlateA, i.plateA ) ) && // and...
( PlateB == null && i.plateB == null ) | ( Platform.isSameItemPrecise( PlateB, i.plateB ) );
boolean matchB = ( PlateB == null && i.plateA == null ) || ( Platform.isSameItemPrecise( PlateB, i.plateA ) ) && // and...
( PlateA == null && i.plateB == null ) | ( Platform.isSameItemPrecise( PlateA, i.plateB ) );
if( matchA || matchB )
{
matches = true;
for( ItemStack option : i.imprintable )
{
if( Platform.isSameItemPrecise( is, option ) )
found = true;
}
}
}
if( matches && !found )
return false;
}
if( ( s == this.top && PlateB != null ) || ( s == this.bottom && PlateA != null ) )
{
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();
if( namePress.isSameAs( otherSlot ) )
{
return namePress.isSameAs( is );
}
// everything else
for( InscriberRecipe i : Inscribe.RECIPES )
{
if( Platform.isSameItemPrecise( i.plateA, otherSlot ) )
{
isValid = Platform.isSameItemPrecise( is, i.plateB );
}
else if( Platform.isSameItemPrecise( i.plateB, otherSlot ) )
{
isValid = Platform.isSameItemPrecise( is, i.plateA );
}
if( isValid )
break;
}
if( !isValid )
return false;
}
return true;
}
@Override
public int getCurrentProgress()
{
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.config.SecurityPermissions;
@@ -31,31 +32,32 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
public class ContainerInterface extends ContainerUpgradeable
{
final DualityInterface myDuality;
@GuiSync(3)
@GuiSync( 3 )
public YesNo bMode = YesNo.NO;
@GuiSync(4)
@GuiSync( 4 )
public YesNo iTermMode = YesNo.YES;
public ContainerInterface(InventoryPlayer ip, IInterfaceHost te) {
public ContainerInterface( InventoryPlayer ip, IInterfaceHost te )
{
super( ip, te.getInterfaceDuality().getHost() );
this.myDuality = te.getInterfaceDuality();
for (int x = 0; x < 9; x++)
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++)
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++)
for( int x = 0; x < 8; x++ )
this.addSlotToContainer( new SlotNormal( this.myDuality.getStorage(), x, 17 + 18 * x, 35 + 18 ) );
}
@Override
@@ -70,13 +72,6 @@ public class ContainerInterface extends ContainerUpgradeable
this.setupUpgrades();
}
@Override
protected void loadSettingsFromHost(IConfigManager cm)
{
this.bMode = (YesNo) cm.getSetting( Settings.BLOCK );
this.iTermMode = (YesNo) cm.getSetting( Settings.INTERFACE_TERMINAL );
}
@Override
public int availableUpgrades()
{
@@ -89,4 +84,11 @@ public class ContainerInterface extends ContainerUpgradeable
this.verifyPermissions( SecurityPermissions.BUILD, false );
super.detectAndSendChanges();
}
@Override
protected void loadSettingsFromHost( IConfigManager cm )
{
this.bMode = (YesNo) cm.getSetting( Settings.BLOCK );
this.iTermMode = (YesNo) cm.getSetting( Settings.INTERFACE_TERMINAL );
}
}
@@ -53,6 +53,7 @@ import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.WrapperInvSlot;
public class ContainerInterfaceTerminal extends AEBaseContainer
{
@@ -61,61 +62,124 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
*/
static private long autoBase = Long.MIN_VALUE;
static class InvTracker
{
final long which = autoBase++;
final String unlocalizedName;
public InvTracker(DualityInterface dual, IInventory patterns, String unlocalizedName) {
this.server = patterns;
this.client = new AppEngInternalInventory( null, this.server.getSizeInventory() );
this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue();
}
final IInventory client;
final IInventory server;
public final long sortBy;
}
final Map<IInterfaceHost, InvTracker> diList = new HashMap<IInterfaceHost, InvTracker>();
final Map<Long, InvTracker> byId = new HashMap<Long, InvTracker>();
IGrid g;
NBTTagCompound data = new NBTTagCompound();
public ContainerInterfaceTerminal(InventoryPlayer ip, PartMonitor anchor) {
public ContainerInterfaceTerminal( InventoryPlayer ip, PartMonitor anchor )
{
super( ip, anchor );
if ( Platform.isServer() )
if( Platform.isServer() )
this.g = anchor.getActionableNode().getGrid();
this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 );
}
NBTTagCompound data = new NBTTagCompound();
static class PatternInvSlot extends WrapperInvSlot
@Override
public void detectAndSendChanges()
{
if( Platform.isClient() )
return;
public PatternInvSlot(IInventory inv) {
super( inv );
}
super.detectAndSendChanges();
@Override
public boolean isItemValid(ItemStack itemstack)
if( this.g == null )
return;
int total = 0;
boolean missing = false;
IActionHost host = this.getActionHost();
if( host != null )
{
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
IGridNode agn = host.getActionableNode();
if( agn != null && agn.isActive() )
{
for( IGridNode gn : this.g.getMachines( TileInterface.class ) )
{
if( gn.isActive() )
{
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++;
}
}
for( IGridNode gn : this.g.getMachines( PartInterface.class ) )
{
if( gn.isActive() )
{
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++;
}
}
}
}
if( total != this.diList.size() || missing )
this.regenList( this.data );
else
{
for( Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet() )
{
InvTracker inv = en.getValue();
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 );
}
}
}
if( !this.data.hasNoTags() )
{
try
{
NetworkHandler.instance.sendTo( new PacketCompressedNBT( this.data ), (EntityPlayerMP) this.getPlayerInv().player );
}
catch( IOException e )
{
// :P
}
this.data = new NBTTagCompound();
}
}
@Override
public void doAction(EntityPlayerMP player, InventoryAction action, int slot, long id)
public void doAction( EntityPlayerMP player, InventoryAction action, int slot, long id )
{
InvTracker inv = this.byId.get( id );
if ( inv != null )
if( inv != null )
{
ItemStack is = inv.server.getStackInSlot( slot );
boolean hasItemInHand = player.inventory.getItemStack() != null;
@@ -127,226 +191,117 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
IInventory theSlot = slotInv.getWrapper( slot );
InventoryAdaptor interfaceSlot = new AdaptorIInventory( theSlot );
switch (action)
switch( action )
{
case PICKUP_OR_SET_DOWN:
case PICKUP_OR_SET_DOWN:
if ( hasItemInHand )
{
ItemStack inSlot = theSlot.getStackInSlot( 0 );
if ( inSlot == null )
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
else
if( hasItemInHand )
{
inSlot = inSlot.copy();
ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents( 0, null );
player.inventory.setItemStack( null );
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
if ( player.inventory.getItemStack() == null )
player.inventory.setItemStack( inSlot );
ItemStack inSlot = theSlot.getStackInSlot( 0 );
if( inSlot == null )
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
else
{
player.inventory.setItemStack( inHand );
theSlot.setInventorySlotContents( 0, inSlot );
inSlot = inSlot.copy();
ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents( 0, null );
player.inventory.setItemStack( null );
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
if( player.inventory.getItemStack() == null )
player.inventory.setItemStack( inSlot );
else
{
player.inventory.setItemStack( inHand );
theSlot.setInventorySlotContents( 0, inSlot );
}
}
}
}
else
{
else
{
IInventory mySlot = slotInv.getWrapper( slot );
mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
}
break;
case SPLIT_OR_PLACE_SINGLE:
if( hasItemInHand )
{
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;
case SHIFT_CLICK:
IInventory mySlot = slotInv.getWrapper( slot );
mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
}
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
mySlot.setInventorySlotContents( 0, playerInv.addItems( mySlot.getStackInSlot( 0 ) ) );
break;
case SPLIT_OR_PLACE_SINGLE:
break;
case MOVE_REGION:
if ( hasItemInHand )
{
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 );
}
InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
for( int x = 0; x < inv.server.getSizeInventory(); x++ )
{
inv.server.setInventorySlotContents( x, playerInvAd.addItems( inv.server.getStackInSlot( x ) ) );
}
break;
case SHIFT_CLICK:
break;
case CREATIVE_DUPLICATE:
IInventory mySlot = slotInv.getWrapper( slot );
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
mySlot.setInventorySlotContents( 0, playerInv.addItems( mySlot.getStackInSlot( 0 ) ) );
if( player.capabilities.isCreativeMode && !hasItemInHand )
{
player.inventory.setItemStack( is == null ? null : is.copy() );
}
break;
case MOVE_REGION:
InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
for (int x = 0; x < inv.server.getSizeInventory(); x++)
{
inv.server.setInventorySlotContents( x, playerInvAd.addItems( inv.server.getStackInSlot( x ) ) );
}
break;
case CREATIVE_DUPLICATE:
if ( player.capabilities.isCreativeMode && !hasItemInHand )
{
player.inventory.setItemStack( is == null ? null : is.copy() );
}
break;
default:
return;
break;
default:
return;
}
this.updateHeld( player );
}
}
@Override
public void detectAndSendChanges()
{
if ( Platform.isClient() )
return;
super.detectAndSendChanges();
if ( this.g == null )
return;
int total = 0;
boolean missing = false;
IActionHost host = this.getActionHost();
if ( host != null )
{
IGridNode agn = host.getActionableNode();
if ( agn != null && agn.isActive() )
{
for (IGridNode gn : this.g.getMachines( TileInterface.class ))
{
if ( gn.isActive() )
{
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++;
}
}
for (IGridNode gn : this.g.getMachines( PartInterface.class ))
{
if ( gn.isActive() )
{
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++;
}
}
}
}
if ( total != this.diList.size() || missing )
this.regenList( this.data );
else
{
for (Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet())
{
InvTracker inv = en.getValue();
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 );
}
}
}
if ( !this.data.hasNoTags() )
{
try
{
NetworkHandler.instance.sendTo( new PacketCompressedNBT( this.data ), (EntityPlayerMP) this.getPlayerInv().player );
}
catch (IOException e)
{
// :P
}
this.data = new NBTTagCompound();
}
}
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 );
}
private void regenList(NBTTagCompound data)
private void regenList( NBTTagCompound data )
{
this.byId.clear();
this.diList.clear();
IActionHost host = this.getActionHost();
if ( host != null )
if( host != null )
{
IGridNode agn = host.getActionableNode();
if ( agn != null && agn.isActive() )
if( agn != null && agn.isActive() )
{
for (IGridNode gn : this.g.getMachines( TileInterface.class ))
for( IGridNode gn : this.g.getMachines( TileInterface.class ) )
{
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
DualityInterface dual = ih.getInterfaceDuality();
if ( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
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.g.getMachines( PartInterface.class ))
for( IGridNode gn : this.g.getMachines( PartInterface.class ) )
{
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
DualityInterface dual = ih.getInterfaceDuality();
if ( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
}
}
@@ -354,7 +309,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
data.setBoolean( "clear", true );
for (Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet())
for( Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet() )
{
InvTracker inv = en.getValue();
this.byId.put( inv.which, inv );
@@ -362,18 +317,29 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
}
}
private void addItems(NBTTagCompound data, InvTracker inv, int offset, int length)
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 );
}
private void addItems( NBTTagCompound data, InvTracker inv, int offset, int length )
{
String name = '=' + Long.toString( inv.which, Character.MAX_RADIX );
NBTTagCompound tag = data.getCompoundTag( name );
if ( tag.hasNoTags() )
if( tag.hasNoTags() )
{
tag.setLong( "sortBy", inv.sortBy );
tag.setString( "un", inv.unlocalizedName );
}
for (int x = 0; x < length; x++)
for( int x = 0; x < length; x++ )
{
NBTTagCompound itemNBT = new NBTTagCompound();
@@ -382,7 +348,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
// "update" client side.
inv.client.setInventorySlotContents( x + offset, is == null ? null : is.copy() );
if ( is != null )
if( is != null )
is.writeToNBT( itemNBT );
tag.setTag( Integer.toString( x + offset ), itemNBT );
@@ -390,4 +356,38 @@ public class ContainerInterfaceTerminal extends AEBaseContainer
data.setTag( name, tag );
}
static class InvTracker
{
public final long sortBy;
final long which = autoBase++;
final String unlocalizedName;
final IInventory client;
final IInventory server;
public InvTracker( DualityInterface dual, IInventory patterns, String unlocalizedName )
{
this.server = patterns;
this.client = new AppEngInternalInventory( null, this.server.getSizeInventory() );
this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue();
}
}
static class PatternInvSlot extends WrapperInvSlot
{
public PatternInvSlot( IInventory inv )
{
super( inv );
}
@Override
public boolean isItemValid( ItemStack itemstack )
{
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
}
}
}
@@ -39,40 +39,35 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.parts.automation.PartLevelEmitter;
import appeng.util.Platform;
public class ContainerLevelEmitter extends ContainerUpgradeable
{
final PartLevelEmitter lvlEmitter;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public GuiTextField textField;
@GuiSync( 2 )
public LevelType lvType;
@GuiSync( 3 )
public long EmitterValue = -1;
@GuiSync( 4 )
public YesNo cmType;
@SideOnly(Side.CLIENT)
public void setTextField(GuiTextField level)
public ContainerLevelEmitter( InventoryPlayer ip, PartLevelEmitter te )
{
super( ip, te );
this.lvlEmitter = te;
}
@SideOnly( Side.CLIENT )
public void setTextField( GuiTextField level )
{
this.textField = level;
this.textField.setText( String.valueOf( this.EmitterValue ) );
}
public ContainerLevelEmitter(InventoryPlayer ip, PartLevelEmitter te) {
super( ip, te );
this.lvlEmitter = te;
}
@Override
public int availableUpgrades()
{
return 1;
}
@Override
protected boolean supportCapacity()
{
return false;
}
public void setLevel(long l, EntityPlayer player)
public void setLevel( long l, EntityPlayer player )
{
this.lvlEmitter.setReportingValue( l );
this.EmitterValue = l;
@@ -85,34 +80,38 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
int y = 40;
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() );
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 ) );
}
@GuiSync(2)
public LevelType lvType;
@Override
protected boolean supportCapacity()
{
return false;
}
@GuiSync(3)
public long EmitterValue = -1;
@Override
public int availableUpgrades()
{
@GuiSync(4)
public YesNo cmType;
return 1;
}
@Override
public void detectAndSendChanges()
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.EmitterValue = this.lvlEmitter.getReportingValue();
this.cmType = (YesNo) this.upgradeable.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE );
@@ -125,13 +124,12 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue)
public void onUpdate( String field, Object oldValue, Object newValue )
{
if ( field.equals( "EmitterValue" ) )
if( field.equals( "EmitterValue" ) )
{
if ( this.textField != null )
if( this.textField != null )
this.textField.setText( String.valueOf( this.EmitterValue ) );
}
}
}
@@ -37,22 +37,39 @@ import appeng.items.misc.ItemEncodedPattern;
import appeng.tile.crafting.TileMolecularAssembler;
import appeng.util.Platform;
public class ContainerMAC extends ContainerUpgradeable implements IProgressProvider
{
final TileMolecularAssembler tma;
private static final int MAX_CRAFT_PROGRESS = 100;
final TileMolecularAssembler tma;
@GuiSync( 4 )
public int craftProgress = 0;
public ContainerMAC(InventoryPlayer ip, TileMolecularAssembler te)
public ContainerMAC( InventoryPlayer ip, TileMolecularAssembler te )
{
super( ip, te );
this.tma = te;
}
@Override
public int availableUpgrades()
public boolean isValidItemForSlot( int slotIndex, ItemStack i )
{
return 5;
IInventory mac = this.upgradeable.getInventoryByName( "mac" );
ItemStack is = mac.getStackInSlot( 10 );
if( is == null )
return false;
if( is.getItem() instanceof ItemEncodedPattern )
{
World w = this.getTileEntity().getWorldObj();
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
if( ph.isCraftable() )
return ph.isValidItemForSlot( slotIndex, i, w );
}
return false;
}
@Override
@@ -61,35 +78,6 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
return 197;
}
@Override
protected boolean supportCapacity()
{
return false;
}
@GuiSync(4)
public int craftProgress = 0;
public boolean isValidItemForSlot(int slotIndex, ItemStack i)
{
IInventory mac = this.upgradeable.getInventoryByName( "mac" );
ItemStack is = mac.getStackInSlot( 10 );
if ( is == null )
return false;
if ( is.getItem() instanceof ItemEncodedPattern )
{
World w = this.getTileEntity().getWorldObj();
ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem();
ICraftingPatternDetails ph = iep.getPatternForItem( is, w );
if ( ph.isCraftable() )
return ph.isValidItemForSlot( slotIndex, i, w );
}
return false;
}
@Override
protected void setupConfig()
{
@@ -98,8 +86,8 @@ 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++)
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 );
@@ -115,16 +103,23 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
offY = 17;
IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ))
.setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ))
.setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ))
.setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ))
.setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.invPlayer ))
.setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.invPlayer ) ).setNotDraggable() );
}
@Override
protected boolean supportCapacity()
{
return false;
}
@Override
public int availableUpgrades()
{
return 5;
}
@Override
@@ -132,7 +127,7 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.rsMode = (RedstoneMode) this.upgradeable.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
@@ -153,5 +148,4 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
{
return MAX_CRAFT_PROGRESS;
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import java.io.IOException;
import java.nio.BufferOverflowException;
@@ -66,33 +67,30 @@ import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{
public final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
final IMEMonitor<IAEItemStack> monitor;
final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
IConfigManager serverCM;
final IConfigManager clientCM;
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false;
public final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
public IConfigManagerHost gui;
private IGridNode networkNode;
private final ITerminalHost host;
@GuiSync( 99 )
public boolean canAccessViewCells = false;
@GuiSync( 98 )
public boolean hasPower = false;
public IConfigManagerHost gui;
IConfigManager serverCM;
private IGridNode networkNode;
public IGridNode getNetworkNode()
public ContainerMEMonitorable( InventoryPlayer ip, ITerminalHost monitorable )
{
return this.networkNode;
this( ip, monitorable, true );
}
protected ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory) {
protected ContainerMEMonitorable( InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory )
{
super( ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null );
this.host = monitorable;
@@ -102,29 +100,29 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if ( this.monitor != null )
if( this.monitor != null )
{
this.monitor.addListener( this, null );
this.cellInv = this.monitor;
if ( monitorable instanceof IPortableCell )
if( monitorable instanceof IPortableCell )
this.powerSrc = (IPortableCell) monitorable;
else if ( monitorable instanceof IMEChest )
else if( monitorable instanceof IMEChest )
this.powerSrc = (IMEChest) monitorable;
else if ( monitorable instanceof IGridHost )
else if( monitorable instanceof IGridHost )
{
IGridNode node = ((IGridHost) monitorable).getGridNode( ForgeDirection.UNKNOWN );
if ( node != null )
IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN );
if( node != null )
{
this.networkNode = node;
IGrid g = node.getGrid();
if ( g != null )
if( g != null )
this.powerSrc = new ChannelPowerSrc( this.networkNode, (IEnergyGrid) g.getCache( IEnergyGrid.class ) );
}
}
@@ -136,48 +134,48 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
this.monitor = null;
this.canAccessViewCells = false;
if ( monitorable instanceof IViewCellStorage )
if( monitorable instanceof IViewCellStorage )
{
for (int y = 0; y < 5; y++)
for( int y = 0; y < 5; y++ )
{
this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8,
this.invPlayer );
this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable ).getViewCellStorage(), y, 206, y * 18 + 8, this.invPlayer );
this.cellView[y].allowEdit = this.canAccessViewCells;
this.addSlotToContainer( this.cellView[y] );
}
}
if ( bindInventory )
if( bindInventory )
this.bindPlayerInventory( ip, 0, 0 );
}
public ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost monitorable) {
this( ip, monitorable, true );
public IGridNode getNetworkNode()
{
return this.networkNode;
}
@Override
public void detectAndSendChanges()
{
if ( Platform.isServer() )
if( Platform.isServer() )
{
if ( this.monitor != this.host.getItemInventory() )
if( this.monitor != this.host.getItemInventory() )
this.isContainerValid = false;
for (Settings set : this.serverCM.getSettings())
for( Settings set : this.serverCM.getSettings() )
{
Enum<?> sideLocal = this.serverCM.getSetting( set );
Enum<?> sideRemote = this.clientCM.getSetting( set );
if ( sideLocal != sideRemote )
if( sideLocal != sideRemote )
{
this.clientCM.putSetting( set, sideLocal );
for (Object crafter : this.crafters)
for( Object crafter : this.crafters )
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) crafter );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
@@ -185,7 +183,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
}
if ( !this.items.isEmpty() )
if( !this.items.isEmpty() )
{
try
{
@@ -193,10 +191,10 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
for (IAEItemStack is : this.items)
for( IAEItemStack is : this.items )
{
IAEItemStack send = monitorCache.findPrecise( is );
if ( send == null )
if( send == null )
{
is.setStackSize( 0 );
piu.appendItem( is );
@@ -205,18 +203,18 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
piu.appendItem( send );
}
if ( !piu.isEmpty() )
if( !piu.isEmpty() )
{
this.items.resetStatus();
for (Object c : this.crafters)
for( Object c : this.crafters )
{
if ( c instanceof EntityPlayer )
if( c instanceof EntityPlayer )
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
}
}
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
@@ -226,11 +224,11 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
boolean oldCanAccessViewCells = this.canAccessViewCells;
this.canAccessViewCells = this.hasAccess( SecurityPermissions.BUILD, false );
if ( this.canAccessViewCells != oldCanAccessViewCells )
if( this.canAccessViewCells != oldCanAccessViewCells )
{
for (int y = 0; y < 5; y++)
for( int y = 0; y < 5; y++ )
{
if ( this.cellView[y] != null )
if( this.cellView[y] != null )
this.cellView[y].allowEdit = this.canAccessViewCells;
}
}
@@ -243,42 +241,55 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
try
{
if ( this.networkNode != null )
if( this.networkNode != null )
this.hasPower = this.networkNode.isActive();
else if ( this.powerSrc instanceof IEnergyGrid )
this.hasPower = ((IEnergyGrid) this.powerSrc).isNetworkPowered();
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)
catch( Throwable t )
{
// :P
}
}
@Override
public void addCraftingToCrafters(ICrafting c)
public void onUpdate( String field, Object oldValue, Object newValue )
{
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 );
}
@Override
public void addCraftingToCrafters( ICrafting c )
{
super.addCraftingToCrafters( c );
this.queueInventory( c );
}
public void queueInventory(ICrafting c)
public void queueInventory( ICrafting c )
{
if ( Platform.isServer() && c instanceof EntityPlayer && this.monitor != null )
if( Platform.isServer() && c instanceof EntityPlayer && this.monitor != null )
{
try
{
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
for (IAEItemStack send : monitorCache)
for( IAEItemStack send : monitorCache )
{
try
{
piu.appendItem( send );
}
catch (BufferOverflowException boe)
catch( BufferOverflowException boe )
{
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
@@ -289,20 +300,49 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
}
catch (IOException e)
catch( IOException e )
{
AELog.error( e );
}
}
}
@Override
public void removeCraftingFromCrafters( ICrafting c )
{
super.removeCraftingFromCrafters( c );
if( this.crafters.isEmpty() && this.monitor != null )
this.monitor.removeListener( this );
}
@Override
public void onContainerClosed( EntityPlayer player )
{
super.onContainerClosed( player );
if( this.monitor != null )
this.monitor.removeListener( this );
}
@Override
public boolean isValid( Object verificationToken )
{
return true;
}
@Override
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source )
{
for( IAEItemStack is : change )
this.items.add( is );
}
@Override
public void onListUpdate()
{
for (Object c : this.crafters)
for( Object c : this.crafters )
{
if ( c instanceof ICrafting )
if( c instanceof ICrafting )
{
ICrafting cr = (ICrafting) c;
this.queueInventory( cr );
@@ -311,59 +351,16 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue)
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
{
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 );
}
@Override
public void onContainerClosed(EntityPlayer player)
{
super.onContainerClosed( player );
if ( this.monitor != null )
this.monitor.removeListener( this );
}
@Override
public void removeCraftingFromCrafters(ICrafting c)
{
super.removeCraftingFromCrafters( c );
if ( this.crafters.isEmpty() && this.monitor != null )
this.monitor.removeListener( this );
}
@Override
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source)
{
for (IAEItemStack is : change)
this.items.add( is );
}
@Override
public boolean isValid(Object verificationToken)
{
return true;
}
@Override
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
{
if ( this.gui != null )
if( this.gui != null )
this.gui.updateSetting( manager, settingName, newValue );
}
@Override
public IConfigManager getConfigManager()
{
if ( Platform.isServer() )
if( Platform.isServer() )
return this.serverCM;
return this.clientCM;
}
@@ -372,7 +369,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
{
ItemStack[] list = new ItemStack[this.cellView.length];
for (int x = 0; x < this.cellView.length; x++)
for( int x = 0; x < this.cellView.length; x++ )
list[x] = this.cellView[x].getStack();
return list;
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -26,33 +27,34 @@ import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.util.Platform;
public class ContainerMEPortableCell extends ContainerMEMonitorable
{
double powerMultiplier = 0.5;
final IPortableCell civ;
double powerMultiplier = 0.5;
int ticks = 0;
public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell monitorable) {
public ContainerMEPortableCell( InventoryPlayer ip, IPortableCell monitorable )
{
super( ip, monitorable, false );
this.lockPlayerInventorySlot( ip.currentItem );
this.civ = monitorable;
this.bindPlayerInventory( ip, 0, 0 );
}
int ticks = 0;
@Override
public void detectAndSendChanges()
{
ItemStack currentItem = this.getPlayerInv().getCurrentItem();
if ( this.civ != null )
if( this.civ != null )
{
if ( currentItem != this.civ.getItemStack() )
if( currentItem != this.civ.getItemStack() )
{
if ( currentItem != null )
if( currentItem != null )
{
if ( Platform.isSameItem( this.civ.getItemStack(), currentItem ) )
if( Platform.isSameItem( this.civ.getItemStack(), currentItem ) )
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() );
else
this.isContainerValid = false;
@@ -66,7 +68,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
// drain 1 ae t
this.ticks++;
if ( this.ticks > 10 )
if( this.ticks > 10 )
{
this.civ.extractAEPower( this.powerMultiplier * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.ticks = 0;
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
@@ -42,62 +43,62 @@ import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class ContainerNetworkStatus extends AEBaseContainer
{
@GuiSync( 0 )
public long avgAddition;
@GuiSync( 1 )
public long powerUsage;
@GuiSync( 2 )
public long currentPower;
@GuiSync( 3 )
public long maxPower;
IGrid network;
int delay = 40;
public ContainerNetworkStatus(InventoryPlayer ip, INetworkTool te) {
public ContainerNetworkStatus( InventoryPlayer ip, INetworkTool te )
{
super( ip, null, null );
IGridHost host = te.getGridHost();
if ( host != null )
if( host != null )
{
this.findNode( host, ForgeDirection.UNKNOWN );
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
this.findNode( host, d );
}
if ( this.network == null && Platform.isServer() )
if( this.network == null && Platform.isServer() )
this.isContainerValid = false;
}
private void findNode(IGridHost host, ForgeDirection d)
private void findNode( IGridHost host, ForgeDirection d )
{
if ( this.network == null )
if( this.network == null )
{
IGridNode node = host.getGridNode( d );
if ( node != null )
if( node != null )
this.network = node.getGrid();
}
}
int delay = 40;
@GuiSync(0)
public long avgAddition;
@GuiSync(1)
public long powerUsage;
@GuiSync(2)
public long currentPower;
@GuiSync(3)
public long maxPower;
@Override
public void detectAndSendChanges()
{
this.delay++;
if ( Platform.isServer() && this.delay > 15 && this.network != null )
if( Platform.isServer() && this.delay > 15 && this.network != null )
{
this.delay = 0;
IEnergyGrid eg = this.network.getCache( IEnergyGrid.class );
if ( eg != null )
if( eg != null )
{
this.avgAddition = (long) (100.0 * eg.getAvgPowerInjection());
this.powerUsage = (long) (100.0 * eg.getAvgPowerUsage());
this.currentPower = (long) (100.0 * eg.getStoredPower());
this.maxPower = (long) (100.0 * eg.getMaxStoredPower());
this.avgAddition = (long) ( 100.0 * eg.getAvgPowerInjection() );
this.powerUsage = (long) ( 100.0 * eg.getAvgPowerUsage() );
this.currentPower = (long) ( 100.0 * eg.getStoredPower() );
this.maxPower = (long) ( 100.0 * eg.getMaxStoredPower() );
}
PacketMEInventoryUpdate piu;
@@ -105,37 +106,36 @@ public class ContainerNetworkStatus extends AEBaseContainer
{
piu = new PacketMEInventoryUpdate();
for (Class<? extends IGridHost> machineClass : this.network.getMachinesClasses())
for( Class<? extends IGridHost> machineClass : this.network.getMachinesClasses() )
{
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
for (IGridNode machine : this.network.getMachines( machineClass ))
for( IGridNode machine : this.network.getMachines( machineClass ) )
{
IGridBlock blk = machine.getGridBlock();
ItemStack is = blk.getMachineRepresentation();
if ( is != null && is.getItem() != null )
if( is != null && is.getItem() != null )
{
IAEItemStack ais = AEItemStack.create( is );
ais.setStackSize( 1 );
ais.setCountRequestable( (long) (blk.getIdlePowerUsage() * 100.0) );
ais.setCountRequestable( (long) ( blk.getIdlePowerUsage() * 100.0 ) );
list.add( ais );
}
}
for (IAEItemStack ais : list)
for( IAEItemStack ais : list )
piu.appendItem( ais );
}
for (Object c : this.crafters)
for( Object c : this.crafters )
{
if ( c instanceof EntityPlayer )
if( c instanceof EntityPlayer )
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
}
}
catch (IOException e)
catch( IOException e )
{
// :P
}
}
super.detectAndSendChanges();
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -28,23 +29,25 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.util.Platform;
public class ContainerNetworkTool extends AEBaseContainer
{
final INetworkTool toolInv;
@GuiSync(1)
@GuiSync( 1 )
public boolean facadeMode;
public ContainerNetworkTool(InventoryPlayer ip, INetworkTool te) {
public ContainerNetworkTool( InventoryPlayer ip, INetworkTool te )
{
super( ip, null, null );
this.toolInv = te;
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 )) );
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 );
}
@@ -61,11 +64,11 @@ public class ContainerNetworkTool extends AEBaseContainer
{
ItemStack currentItem = this.getPlayerInv().getCurrentItem();
if ( currentItem != this.toolInv.getItemStack() )
if( currentItem != this.toolInv.getItemStack() )
{
if ( currentItem != null )
if( currentItem != null )
{
if ( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
{
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
}
@@ -76,7 +79,7 @@ public class ContainerNetworkTool extends AEBaseContainer
this.isContainerValid = false;
}
if ( this.isContainerValid )
if( this.isContainerValid )
{
NBTTagCompound data = Platform.openNbtData( currentItem );
this.facadeMode = data.getBoolean( "hideFacades" );
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import java.util.ArrayList;
import java.util.List;
@@ -65,23 +66,22 @@ import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.item.AEItemStack;
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket
{
public final PartPatternTerminal ct;
final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
final IInventory crafting;
final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
final SlotPatternTerm craftSlot;
final SlotRestrictedInput patternSlotIN;
final SlotRestrictedInput patternSlotOUT;
@GuiSync( 97 )
public boolean craftingMode = true;
public final PartPatternTerminal ct;
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost monitorable)
public ContainerPatternTerm( InventoryPlayer ip, ITerminalHost monitorable )
{
super( ip, monitorable, false );
this.ct = (PartPatternTerminal) monitorable;
@@ -90,14 +90,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
IInventory output = this.ct.getInventoryByName( "output" );
this.crafting = this.ct.getInventoryByName( "crafting" );
for (int y = 0; y < 3; y++)
for (int x = 0; x < 3; x++)
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;
for (int y = 0; y < 3; y++)
for( int y = 0; y < 3; y++ )
{
this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) );
this.outputSlots[y].renderDisabled = false;
@@ -115,31 +115,31 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
private void updateOrderOfOutputSlots()
{
if ( !this.craftingMode )
if( !this.craftingMode )
{
this.craftSlot.xDisplayPosition = -9000;
for (int y = 0; y < 3; y++)
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++)
for( int y = 0; y < 3; y++ )
this.outputSlots[y].xDisplayPosition = -9000;
}
}
@Override
public void putStackInSlot(int par1, ItemStack par2ItemStack)
public void putStackInSlot( int par1, ItemStack par2ItemStack )
{
super.putStackInSlot( par1, par2ItemStack );
this.getAndUpdateOutput();
}
@Override
public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack)
public void putStacksInSlots( ItemStack[] par1ArrayOfItemStack )
{
super.putStacksInSlots( par1ArrayOfItemStack );
this.getAndUpdateOutput();
@@ -148,7 +148,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
public ItemStack getAndUpdateOutput()
{
InventoryCrafting ic = new InventoryCrafting( this, 3, 3 );
for (int x = 0; x < ic.getSizeInventory(); x++)
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 );
@@ -156,41 +156,18 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
return is;
}
@GuiSync(97)
public boolean craftingMode = true;
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if ( Platform.isServer() )
{
if ( this.craftingMode != this.ct.isCraftingRecipe() )
{
this.craftingMode = this.ct.isCraftingRecipe();
this.updateOrderOfOutputSlots();
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue)
{
super.onUpdate( field, oldValue, newValue );
if ( field.equals( "craftingMode" ) )
{
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
@Override
public void saveChanges()
{
}
@Override
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
}
public void encode()
{
ItemStack output = this.patternSlotOUT.getStack();
@@ -199,27 +176,27 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if ( in == null || out == null )
if( in == null || out == null )
return;
// first check the output slots, should either be null, or a pattern
if ( output != null && !this.isPattern( output ) )
if( output != null && !this.isPattern( output ) )
return;
// if nothing is there we should snag a new pattern.
else if ( output == null )
// if nothing is there we should snag a new pattern.
else if( output == null )
{
output = this.patternSlotIN.getStack();
if ( output == null || !this.isPattern( output ) )
if( output == null || !this.isPattern( output ) )
return; // no blanks.
// remove one, and clear the input slot.
output.stackSize--;
if ( output.stackSize == 0 )
if( output.stackSize == 0 )
this.patternSlotIN.putStack( null );
// add a new encoded pattern.
for ( ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
for( ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
@@ -232,10 +209,10 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
NBTTagList tagIn = new NBTTagList();
NBTTagList tagOut = new NBTTagList();
for (ItemStack i : in)
for( ItemStack i : in )
tagIn.appendTag( this.createItemTag( i ) );
for (ItemStack i : out)
for( ItemStack i : out )
tagOut.appendTag( this.createItemTag( i ) );
encodedValue.setTag( "in", tagIn );
@@ -245,29 +222,19 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
output.setTagCompound( encodedValue );
}
private NBTBase createItemTag(ItemStack i)
{
NBTTagCompound c = new NBTTagCompound();
if ( i != null )
i.writeToNBT( c );
return c;
}
private ItemStack[] getInputs()
{
ItemStack[] input = new ItemStack[9];
boolean hasValue = false;
for (int x = 0; x < this.craftingSlots.length; x++)
for( int x = 0; x < this.craftingSlots.length; x++ )
{
input[x] = this.craftingSlots[x].getStack();
if ( input[x] != null )
if( input[x] != null )
hasValue = true;
}
if ( hasValue )
if( hasValue )
return input;
return null;
@@ -275,10 +242,10 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
private ItemStack[] getOutputs()
{
if ( this.craftingMode )
if( this.craftingMode )
{
ItemStack out = this.getAndUpdateOutput();
if ( out != null && out.stackSize > 0 )
if( out != null && out.stackSize > 0 )
return new ItemStack[] { out };
}
else
@@ -286,26 +253,26 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
List<ItemStack> list = new ArrayList<ItemStack>( 3 );
boolean hasValue = false;
for (OptionalSlotFake outputSlot : this.outputSlots)
for( OptionalSlotFake outputSlot : this.outputSlots )
{
ItemStack out = outputSlot.getStack();
if ( out != null && out.stackSize > 0 )
if( out != null && out.stackSize > 0 )
{
list.add( out );
hasValue = true;
}
}
if ( hasValue )
if( hasValue )
return list.toArray( new ItemStack[list.size()] );
}
return null;
}
private boolean isPattern(ItemStack output)
private boolean isPattern( ItemStack output )
{
if ( output == null )
if( output == null )
return false;
final IDefinitions definitions = AEApi.instance().definitions();
@@ -316,44 +283,48 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
return isPattern;
}
@Override
public boolean isSlotEnabled(int idx)
private NBTBase createItemTag( ItemStack i )
{
if ( idx == 1 )
NBTTagCompound c = new NBTTagCompound();
if( i != null )
i.writeToNBT( c );
return c;
}
@Override
public boolean isSlotEnabled( int idx )
{
if( idx == 1 )
return Platform.isServer() ? !this.ct.isCraftingRecipe() : !this.craftingMode;
else if ( idx == 2 )
else if( idx == 2 )
return Platform.isServer() ? this.ct.isCraftingRecipe() : this.craftingMode;
else
return false;
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
public void craftOrGetItem( PacketPatternSlot packetPatternSlot )
{
}
public void craftOrGetItem(PacketPatternSlot packetPatternSlot)
{
if ( packetPatternSlot.slotItem != null && this.cellInv != null )
if( packetPatternSlot.slotItem != null && this.cellInv != null )
{
IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player );
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, ForgeDirection.UNKNOWN );
if ( packetPatternSlot.shift )
if( packetPatternSlot.shift )
inv = playerInv;
if ( inv.simulateAdd( out.getItemStack() ) != null )
if( inv.simulateAdd( out.getItemStack() ) != null )
return;
IAEItemStack extracted = Platform.poweredExtraction( this.powerSrc, this.cellInv, out, this.mySrc );
EntityPlayer p = this.getPlayerInv().player;
if ( extracted != null )
if( extracted != null )
{
inv.addItems( extracted.getItemStack() );
if ( p instanceof EntityPlayerMP )
if( p instanceof EntityPlayerMP )
this.updateHeld( (EntityPlayerMP) p );
this.detectAndSendChanges();
return;
@@ -361,14 +332,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
InventoryCrafting real = new InventoryCrafting( new ContainerNull(), 3, 3 );
for (int x = 0; x < 9; x++)
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack() );
}
IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
if ( r == null )
if( r == null )
return;
IMEMonitor<IAEItemStack> storage = this.ct.getItemInventory();
@@ -376,68 +347,92 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
ItemStack is = r.getCraftingResult( ic );
for (int x = 0; x < ic.getSizeInventory(); x++)
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
if ( ic.getStackInSlot( x ) != null )
if( ic.getStackInSlot( x ) != null )
{
ItemStack pulled = Platform.extractItemsByRecipe( this.powerSrc, this.mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all,
Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) );
ItemStack pulled = Platform.extractItemsByRecipe( this.powerSrc, this.mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) );
real.setInventorySlotContents( x, pulled );
}
}
IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj );
if ( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
if( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
{
SlotCrafting sc = new SlotCrafting( p, real, this.cOut, 0, 0, 0 );
sc.onPickupFromSlot( p, is );
for (int x = 0; x < real.getSizeInventory(); x++)
for( int x = 0; x < real.getSizeInventory(); x++ )
{
ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) );
if ( failed != null )
if( failed != null )
p.dropPlayerItemWithRandomChoice( failed, false );
}
inv.addItems( is );
if ( p instanceof EntityPlayerMP )
if( p instanceof EntityPlayerMP )
this.updateHeld( (EntityPlayerMP) p );
this.detectAndSendChanges();
}
else
{
for (int x = 0; x < real.getSizeInventory(); x++)
for( int x = 0; x < real.getSizeInventory(); x++ )
{
ItemStack failed = real.getStackInSlot( x );
if ( failed != null )
if( failed != null )
{
this.cellInv.injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( this.ct ) );
}
}
}
}
}
@Override
public void onSlotChange(Slot s)
public void detectAndSendChanges()
{
if ( s == this.patternSlotOUT && Platform.isServer() )
super.detectAndSendChanges();
if( Platform.isServer() )
{
for (Object crafter : this.crafters)
if( this.craftingMode != this.ct.isCraftingRecipe() )
{
this.craftingMode = this.ct.isCraftingRecipe();
this.updateOrderOfOutputSlots();
}
}
}
@Override
public void onUpdate( String field, Object oldValue, Object newValue )
{
super.onUpdate( field, oldValue, newValue );
if( field.equals( "craftingMode" ) )
{
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
@Override
public void onSlotChange( Slot s )
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
for( Object crafter : this.crafters )
{
ICrafting icrafting = (ICrafting) crafter;
for (Object g : this.inventorySlots)
for( Object g : this.inventorySlots )
{
if ( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
{
Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false;
}
this.detectAndSendChanges();
}
@@ -445,10 +440,10 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
public void clear()
{
for (Slot s : this.craftingSlots)
for( Slot s : this.craftingSlots )
s.putStack( null );
for (Slot s : this.outputSlots)
for( Slot s : this.outputSlots )
s.putStack( null );
this.detectAndSendChanges();
@@ -456,9 +451,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
@Override
public IInventory getInventoryByName(String name)
public IInventory getInventoryByName( String name )
{
if (name.equals("player"))
if( name.equals( "player" ) )
{
return this.invPlayer;
}
@@ -34,30 +34,31 @@ import appeng.container.guisync.GuiSync;
import appeng.helpers.IPriorityHost;
import appeng.util.Platform;
public class ContainerPriority extends AEBaseContainer
{
final IPriorityHost priHost;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public GuiTextField textField;
@GuiSync( 2 )
public long PriorityValue = -1;
@SideOnly(Side.CLIENT)
public void setTextField(GuiTextField level)
public ContainerPriority( InventoryPlayer ip, IPriorityHost te )
{
super( ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
this.priHost = te;
}
@SideOnly( Side.CLIENT )
public void setTextField( GuiTextField level )
{
this.textField = level;
this.textField.setText( String.valueOf( this.PriorityValue ) );
}
public ContainerPriority(InventoryPlayer ip, IPriorityHost te) {
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
this.priHost = te;
}
@GuiSync(2)
public long PriorityValue = -1;
public void setPriority(int newValue, EntityPlayer player)
public void setPriority( int newValue, EntityPlayer player )
{
this.priHost.setPriority( newValue );
this.PriorityValue = newValue;
@@ -69,18 +70,18 @@ public class ContainerPriority extends AEBaseContainer
super.detectAndSendChanges();
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.PriorityValue = this.priHost.getPriority();
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue)
public void onUpdate( String field, Object oldValue, Object newValue )
{
if ( field.equals( "PriorityValue" ) )
if( field.equals( "PriorityValue" ) )
{
if ( this.textField != null )
if( this.textField != null )
this.textField.setText( String.valueOf( this.PriorityValue ) );
}
@@ -18,24 +18,26 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.qnb.TileQuantumBridge;
public class ContainerQNB extends AEBaseContainer
{
final TileQuantumBridge quantumBridge;
public ContainerQNB(InventoryPlayer ip, TileQuantumBridge quantumBridge) {
public ContainerQNB( InventoryPlayer ip, TileQuantumBridge quantumBridge )
{
super( ip, quantumBridge, null );
this.quantumBridge = quantumBridge;
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge, 0, 80, 37, this.invPlayer )).setStackLimit( 1 ) );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge, 0, 80, 37, this.invPlayer ) ).setStackLimit( 1 ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
@@ -36,6 +37,7 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngInventory, IInventory
{
@@ -46,12 +48,8 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
final QuartzKnifeOutput output;
String myName = "";
public void setName(String value)
public ContainerQuartzKnife( InventoryPlayer ip, QuartzKnifeObj te )
{
this.myName = value;
}
public ContainerQuartzKnife(InventoryPlayer ip, QuartzKnifeObj te) {
super( ip, null, null );
this.toolInv = te;
@@ -63,16 +61,21 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
this.bindPlayerInventory( ip, 0, 184 - /* height of player inventory */82 );
}
public void setName( String value )
{
this.myName = value;
}
@Override
public void detectAndSendChanges()
{
ItemStack currentItem = this.getPlayerInv().getCurrentItem();
if ( currentItem != this.toolInv.getItemStack() )
if( currentItem != this.toolInv.getItemStack() )
{
if ( currentItem != null )
if( currentItem != null )
{
if ( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) )
this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() );
else
this.isContainerValid = false;
@@ -85,9 +88,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public void onContainerClosed(EntityPlayer par1EntityPlayer)
public void onContainerClosed( EntityPlayer par1EntityPlayer )
{
if ( this.inSlot.getStackInSlot( 0 ) != null )
if( this.inSlot.getStackInSlot( 0 ) != null )
par1EntityPlayer.dropPlayerItemWithRandomChoice( this.inSlot.getStackInSlot( 0 ), false );
}
@@ -98,7 +101,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
}
@@ -110,17 +113,17 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public ItemStack getStackInSlot(int var1)
public ItemStack getStackInSlot( int var1 )
{
ItemStack input = this.inSlot.getStackInSlot( 0 );
if ( input == null )
if( input == null )
return null;
if ( SlotRestrictedInput.isMetalIngot( input ) )
if( SlotRestrictedInput.isMetalIngot( input ) )
{
if ( this.myName.length() > 0 )
if( this.myName.length() > 0 )
{
for ( ItemStack namePressStack : AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).asSet() )
for( ItemStack namePressStack : AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).asSet() )
{
final NBTTagCompound compound = Platform.openNbtData( namePressStack );
compound.setString( "InscribeName", this.myName );
@@ -134,12 +137,12 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public ItemStack decrStackSize(int var1, int var2)
public ItemStack decrStackSize( int var1, int var2 )
{
ItemStack is = this.getStackInSlot( 0 );
if ( is != null )
if( is != null )
{
if ( this.makePlate() )
if( this.makePlate() )
return is;
}
return null;
@@ -147,12 +150,12 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
private boolean makePlate()
{
if ( this.inSlot.decrStackSize( 0, 1 ) != null )
if( this.inSlot.decrStackSize( 0, 1 ) != null )
{
ItemStack item = this.toolInv.getItemStack();
item.damageItem( 1, this.getPlayerInv().player );
if ( item.stackSize == 0 )
if( item.stackSize == 0 )
{
this.getPlayerInv().mainInventory[this.getPlayerInv().currentItem] = null;
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( this.getPlayerInv().player, item ) );
@@ -164,15 +167,15 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public ItemStack getStackInSlotOnClosing(int var1)
public ItemStack getStackInSlotOnClosing( int var1 )
{
return null;
}
@Override
public void setInventorySlotContents(int var1, ItemStack var2)
public void setInventorySlotContents( int var1, ItemStack var2 )
{
if ( var2 == null && Platform.isServer() )
if( var2 == null && Platform.isServer() )
this.makePlate();
}
@@ -201,7 +204,7 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
public boolean isUseableByPlayer( EntityPlayer var1 )
{
return false;
}
@@ -219,9 +222,8 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2)
public boolean isItemValidForSlot( int var1, ItemStack var2 )
{
return false;
}
}
@@ -39,6 +39,7 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.misc.TileSecurity;
public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppEngInventory
{
@@ -50,8 +51,11 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
final SlotOutput wirelessOut;
final TileSecurity securityBox;
@GuiSync( 0 )
public int security = 0;
public ContainerSecurity(InventoryPlayer ip, ITerminalHost monitorable) {
public ContainerSecurity( InventoryPlayer ip, ITerminalHost monitorable )
{
super( ip, monitorable, false );
this.securityBox = (TileSecurity) monitorable;
@@ -64,38 +68,23 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
this.bindPlayerInventory( ip, 0, 0 );
}
@GuiSync(0)
public int security = 0;
@Override
public void onContainerClosed(EntityPlayer player)
{
super.onContainerClosed( player );
if ( this.wirelessIn.getHasStack() )
player.dropPlayerItemWithRandomChoice( this.wirelessIn.getStack(), false );
if ( this.wirelessOut.getHasStack() )
player.dropPlayerItemWithRandomChoice( this.wirelessOut.getStack(), false );
}
public void toggleSetting(String value, EntityPlayer player)
public void toggleSetting( String value, EntityPlayer player )
{
try
{
SecurityPermissions permission = SecurityPermissions.valueOf( value );
ItemStack a = this.configSlot.getStack();
if ( a != null && a.getItem() instanceof IBiometricCard )
if( a != null && a.getItem() instanceof IBiometricCard )
{
IBiometricCard bc = (IBiometricCard) a.getItem();
if ( bc.hasPermission( a, permission ) )
if( bc.hasPermission( a, permission ) )
bc.removePermission( a, permission );
else
bc.addPermission( a, permission );
}
}
catch (EnumConstantNotPresentException ex)
catch( EnumConstantNotPresentException ex )
{
// :(
}
@@ -109,11 +98,11 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
this.security = 0;
ItemStack a = this.configSlot.getStack();
if ( a != null && a.getItem() instanceof IBiometricCard )
if( a != null && a.getItem() instanceof IBiometricCard )
{
IBiometricCard bc = (IBiometricCard) a.getItem();
for (SecurityPermissions sp : bc.getPermissions( a ))
for( SecurityPermissions sp : bc.getPermissions( a ) )
this.security |= ( 1 << sp.ordinal() );
}
@@ -122,6 +111,18 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
super.detectAndSendChanges();
}
@Override
public void onContainerClosed( EntityPlayer player )
{
super.onContainerClosed( player );
if( this.wirelessIn.getHasStack() )
player.dropPlayerItemWithRandomChoice( this.wirelessIn.getStack(), false );
if( this.wirelessOut.getHasStack() )
player.dropPlayerItemWithRandomChoice( this.wirelessOut.getStack(), false );
}
@Override
public void saveChanges()
{
@@ -129,23 +130,23 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
{
if ( !this.wirelessOut.getHasStack() )
if( !this.wirelessOut.getHasStack() )
{
if ( this.wirelessIn.getHasStack() )
if( this.wirelessIn.getHasStack() )
{
ItemStack term = this.wirelessIn.getStack().copy();
INetworkEncodable networkEncodable = null;
if ( term.getItem() instanceof INetworkEncodable )
if( term.getItem() instanceof INetworkEncodable )
networkEncodable = (INetworkEncodable) term.getItem();
IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term );
if ( wTermHandler != null )
if( wTermHandler != null )
networkEncodable = wTermHandler;
if ( networkEncodable != null )
if( networkEncodable != null )
{
networkEncodable.setEncryptionKey( term, String.valueOf( this.securityBox.securityKey ), "" );
@@ -153,14 +154,13 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
this.wirelessOut.putStack( term );
// update the two slots in question...
for (Object crafter : this.crafters)
for( Object crafter : this.crafters )
{
ICrafting icrafting = (ICrafting) crafter;
icrafting.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() );
icrafting.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() );
}
}
}
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@@ -27,19 +28,21 @@ import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotNormal;
import appeng.tile.storage.TileSkyChest;
@ChestContainer
public class ContainerSkyChest extends AEBaseContainer
{
final TileSkyChest chest;
public ContainerSkyChest(InventoryPlayer ip, TileSkyChest chest) {
public ContainerSkyChest( InventoryPlayer ip, TileSkyChest chest )
{
super( ip, chest, null );
this.chest = chest;
for (int y = 0; y < 4; y++)
for( int y = 0; y < 4; y++ )
{
for (int x = 0; x < 9; x++)
for( int x = 0; x < 9; x++ )
{
this.addSlotToContainer( new SlotNormal( this.chest, y * 9 + x, 8 + 18 * x, 24 + 18 * y ) );
}
@@ -51,7 +54,7 @@ public class ContainerSkyChest extends AEBaseContainer
}
@Override
public void onContainerClosed(EntityPlayer par1EntityPlayer)
public void onContainerClosed( EntityPlayer par1EntityPlayer )
{
super.onContainerClosed( par1EntityPlayer );
this.chest.closeInventory();
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.common.util.ForgeDirection;
@@ -32,29 +33,28 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.spatial.TileSpatialIOPort;
import appeng.util.Platform;
public class ContainerSpatialIOPort extends AEBaseContainer
{
final TileSpatialIOPort spatialIOPort;
IGrid network;
@GuiSync(0)
@GuiSync( 0 )
public long currentPower;
@GuiSync(1)
@GuiSync( 1 )
public long maxPower;
@GuiSync(2)
@GuiSync( 2 )
public long reqPower;
@GuiSync(3)
@GuiSync( 3 )
public long eff;
IGrid network;
int delay = 40;
public ContainerSpatialIOPort(InventoryPlayer ip, TileSpatialIOPort spatialIOPort) {
public ContainerSpatialIOPort( InventoryPlayer ip, TileSpatialIOPort spatialIOPort )
{
super( ip, spatialIOPort, null );
this.spatialIOPort = spatialIOPort;
if ( Platform.isServer() )
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 ) );
@@ -68,21 +68,21 @@ public class ContainerSpatialIOPort extends AEBaseContainer
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.delay++;
if ( this.delay > 15 && this.network != null )
if( this.delay > 15 && this.network != null )
{
this.delay = 0;
IEnergyGrid eg = this.network.getCache( IEnergyGrid.class );
ISpatialCache sc = this.network.getCache( ISpatialCache.class );
if ( eg != null )
if( eg != null )
{
this.currentPower = (long) (100.0 * eg.getStoredPower());
this.maxPower = (long) (100.0 * eg.getMaxStoredPower());
this.reqPower = (long) (100.0 * sc.requiredPower());
this.eff = (long) (100.0f * sc.currentEfficiency());
this.currentPower = (long) ( 100.0 * eg.getStoredPower() );
this.maxPower = (long) ( 100.0 * eg.getMaxStoredPower() );
this.reqPower = (long) ( 100.0 * sc.requiredPower() );
this.eff = (long) ( 100.0f * sc.currentEfficiency() );
}
}
}
@@ -43,18 +43,20 @@ import appeng.parts.misc.PartStorageBus;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
public class ContainerStorageBus extends ContainerUpgradeable
{
final PartStorageBus storageBus;
@GuiSync(3)
@GuiSync( 3 )
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
@GuiSync(4)
@GuiSync( 4 )
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
public ContainerStorageBus(InventoryPlayer ip, PartStorageBus te) {
public ContainerStorageBus( InventoryPlayer ip, PartStorageBus te )
{
super( ip, te );
this.storageBus = te;
}
@@ -66,9 +68,29 @@ public class ContainerStorageBus extends ContainerUpgradeable
}
@Override
public int availableUpgrades()
protected void setupConfig()
{
return 5;
int xo = 8;
int yo = 23 + 6;
IInventory config = this.upgradeable.getInventoryByName( "config" );
for( int y = 0; y < 7; y++ )
{
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 ) );
}
}
IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ) ).setNotDraggable() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.invPlayer ) ).setNotDraggable() );
}
@Override
@@ -78,37 +100,9 @@ public class ContainerStorageBus extends ContainerUpgradeable
}
@Override
public boolean isSlotEnabled(int idx)
public int availableUpgrades()
{
int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY );
return upgrades > idx;
}
@Override
protected void setupConfig()
{
int xo = 8;
int yo = 23 + 6;
IInventory config = this.upgradeable.getInventoryByName( "config" );
for (int y = 0; y < 7; y++)
{
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 ) );
}
}
IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer )).setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer )).setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer )).setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer )).setNotDraggable() );
this.addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, this.invPlayer )).setNotDraggable() );
return 5;
}
@Override
@@ -116,7 +110,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.fzMode = (FuzzyMode) this.upgradeable.getConfigManager().getSetting( Settings.FUZZY_MODE );
this.rwMode = (AccessRestriction) this.upgradeable.getConfigManager().getSetting( Settings.ACCESS );
@@ -126,10 +120,18 @@ public class ContainerStorageBus extends ContainerUpgradeable
this.standardDetectAndSendChanges();
}
@Override
public boolean isSlotEnabled( int idx )
{
int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY );
return upgrades > idx;
}
public void clear()
{
IInventory inv = this.upgradeable.getInventoryByName( "config" );
for (int x = 0; x < inv.getSizeInventory(); x++)
for( int x = 0; x < inv.getSizeInventory(); x++ )
inv.setInventorySlotContents( x, null );
this.detectAndSendChanges();
}
@@ -141,15 +143,15 @@ public class ContainerStorageBus extends ContainerUpgradeable
IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler();
Iterator<IAEItemStack> i = new NullIterator<IAEItemStack>();
if ( cellInv != null )
if( cellInv != null )
{
IItemList<IAEItemStack> list = cellInv.getAvailableItems( AEApi.instance().storage().createItemList() );
i = list.iterator();
}
for (int x = 0; x < inv.getSizeInventory(); x++)
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
if ( i.hasNext() && this.isSlotEnabled( (x / 9) - 2 ) )
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
{
ItemStack g = i.next().getItemStack();
g.stackSize = 1;
@@ -161,5 +163,4 @@ public class ContainerStorageBus extends ContainerUpgradeable
this.detectAndSendChanges();
}
}
@@ -46,16 +46,23 @@ import appeng.items.tools.ToolNetworkTool;
import appeng.parts.automation.PartExportBus;
import appeng.util.Platform;
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
{
final IUpgradeableHost upgradeable;
@GuiSync( 0 )
public RedstoneMode rsMode = RedstoneMode.IGNORE;
@GuiSync( 1 )
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
@GuiSync( 5 )
public YesNo cMode = YesNo.NO;
int tbSlot;
NetworkToolViewer tbInventory;
public ContainerUpgradeable(InventoryPlayer ip, IUpgradeableHost te) {
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
public ContainerUpgradeable( InventoryPlayer ip, IUpgradeableHost te )
{
super( ip, (TileEntity) ( te instanceof TileEntity ? te : null ), (IPart) ( te instanceof IPart ? te : null ) );
this.upgradeable = te;
World w = null;
@@ -63,7 +70,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
int yCoord = 0;
int zCoord = 0;
if ( te instanceof TileEntity )
if( te instanceof TileEntity )
{
TileEntity myTile = (TileEntity) te;
w = myTile.getWorldObj();
@@ -72,7 +79,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
zCoord = myTile.zCoord;
}
if ( te instanceof IPart )
if( te instanceof IPart )
{
TileEntity mk = te.getTile();
w = mk.getWorldObj();
@@ -82,24 +89,23 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
}
IInventory pi = this.getPlayerInv();
for (int x = 0; x < pi.getSizeInventory(); x++)
for( int x = 0; x < pi.getSizeInventory(); x++ )
{
ItemStack pii = pi.getStackInSlot( x );
if ( pii != null && pii.getItem() instanceof ToolNetworkTool )
if( pii != null && pii.getItem() instanceof ToolNetworkTool )
{
this.lockPlayerInventorySlot( x );
this.tbSlot = x;
this.tbInventory = (NetworkToolViewer) ((ToolNetworkTool) pii.getItem()).getGuiObject( pii, w, xCoord, yCoord, zCoord );
this.tbInventory = (NetworkToolViewer) ( (ToolNetworkTool) pii.getItem() ).getGuiObject( pii, w, xCoord, yCoord, zCoord );
break;
}
}
if ( this.hasToolbox() )
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() );
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();
@@ -107,17 +113,14 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
this.bindPlayerInventory( ip, 0, this.getHeight() - /* height of player inventory */82 );
}
protected void setupUpgrades()
public boolean hasToolbox()
{
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() );
return this.tbInventory != null;
}
protected int getHeight()
{
return 184;
}
protected void setupConfig()
@@ -129,7 +132,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
IInventory inv = this.upgradeable.getInventoryByName( "config" );
this.addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
if ( this.supportCapacity() )
if( this.supportCapacity() )
{
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
this.addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
@@ -143,14 +146,17 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
}
}
protected int getHeight()
protected void setupUpgrades()
{
return 184;
}
public int availableUpgrades()
{
return 4;
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()
@@ -158,26 +164,56 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
return true;
}
@GuiSync(0)
public RedstoneMode rsMode = RedstoneMode.IGNORE;
public int availableUpgrades()
{
return 4;
}
@GuiSync(1)
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
@Override
public void detectAndSendChanges()
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
@GuiSync(5)
public YesNo cMode = YesNo.NO;
if( Platform.isServer() )
{
IConfigManager cm = this.upgradeable.getConfigManager();
this.loadSettingsFromHost( cm );
}
this.checkToolbox();
for( Object o : this.inventorySlots )
{
if( o instanceof OptionalSlotFake )
{
OptionalSlotFake fs = (OptionalSlotFake) o;
if( !fs.isEnabled() && fs.getDisplayStack() != null )
fs.clearStack();
}
}
this.standardDetectAndSendChanges();
}
protected void loadSettingsFromHost( IConfigManager cm )
{
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()
{
if ( this.hasToolbox() )
if( this.hasToolbox() )
{
ItemStack currentItem = this.getPlayerInv().getStackInSlot( this.tbSlot );
if ( currentItem != this.tbInventory.getItemStack() )
if( currentItem != this.tbInventory.getItemStack() )
{
if ( currentItem != null )
if( currentItem != null )
{
if ( Platform.isSameItem( this.tbInventory.getItemStack(), currentItem ) )
if( Platform.isSameItem( this.tbInventory.getItemStack(), currentItem ) )
this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() );
else
this.isContainerValid = false;
@@ -188,61 +224,21 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
}
}
@Override
public void detectAndSendChanges()
{
this.verifyPermissions( SecurityPermissions.BUILD, false );
if ( Platform.isServer() )
{
IConfigManager cm = this.upgradeable.getConfigManager();
this.loadSettingsFromHost( cm );
}
this.checkToolbox();
for (Object o : this.inventorySlots)
{
if ( o instanceof OptionalSlotFake )
{
OptionalSlotFake fs = (OptionalSlotFake) o;
if ( !fs.isEnabled() && fs.getDisplayStack() != null )
fs.clearStack();
}
}
this.standardDetectAndSendChanges();
}
protected void loadSettingsFromHost(IConfigManager cm)
{
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 );
}
protected void standardDetectAndSendChanges()
{
super.detectAndSendChanges();
}
public boolean hasToolbox()
{
return this.tbInventory != null;
}
@Override
public boolean isSlotEnabled(int idx)
public boolean isSlotEnabled( int idx )
{
int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY );
if ( idx == 1 && upgrades > 0 )
if( idx == 1 && upgrades > 0 )
return true;
if ( idx == 2 && upgrades > 1 )
if( idx == 2 && upgrades > 1 )
return true;
return false;
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
@@ -27,13 +28,20 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
public class ContainerVibrationChamber extends AEBaseContainer implements IProgressProvider
{
final TileVibrationChamber vibrationChamber;
private static final int MAX_BURN_TIME = 200;
public final int aePerTick = 5;
final TileVibrationChamber vibrationChamber;
@GuiSync( 0 )
public int burnProgress = 0;
@GuiSync( 1 )
public int burnSpeed = 100;
public ContainerVibrationChamber(InventoryPlayer ip, TileVibrationChamber vibrationChamber) {
public ContainerVibrationChamber( InventoryPlayer ip, TileVibrationChamber vibrationChamber )
{
super( ip, vibrationChamber, null );
this.vibrationChamber = vibrationChamber;
@@ -42,20 +50,12 @@ public class ContainerVibrationChamber extends AEBaseContainer implements IProgr
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
public final int aePerTick = 5;
@GuiSync(0)
public int burnProgress = 0;
@GuiSync(1)
public int burnSpeed = 100;
@Override
public void detectAndSendChanges()
{
if ( Platform.isServer() )
if( Platform.isServer() )
{
this.burnProgress = (int) (this.vibrationChamber.maxBurnTime <= 0 ? 0 : 12 * this.vibrationChamber.burnTime / this.vibrationChamber.maxBurnTime);
this.burnProgress = (int) ( this.vibrationChamber.maxBurnTime <= 0 ? 0 : 12 * this.vibrationChamber.burnTime / this.vibrationChamber.maxBurnTime );
this.burnSpeed = this.vibrationChamber.burnSpeed;
}
@@ -73,5 +73,4 @@ public class ContainerVibrationChamber extends AEBaseContainer implements IProgr
{
return MAX_BURN_TIME;
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
@@ -26,20 +27,19 @@ import appeng.container.slot.SlotRestrictedInput;
import appeng.core.AEConfig;
import appeng.tile.networking.TileWireless;
public class ContainerWireless extends AEBaseContainer
{
final TileWireless wirelessTerminal;
@GuiSync(1)
final SlotRestrictedInput boosterSlot;
@GuiSync( 1 )
public long range = 0;
@GuiSync(2)
@GuiSync( 2 )
public long drain = 0;
final SlotRestrictedInput boosterSlot;
public ContainerWireless(InventoryPlayer ip, TileWireless te) {
public ContainerWireless( InventoryPlayer ip, TileWireless te )
{
super( ip, te, null );
this.wirelessTerminal = te;
@@ -53,10 +53,9 @@ public class ContainerWireless extends AEBaseContainer
{
int boosters = this.boosterSlot.getStack() == null ? 0 : this.boosterSlot.getStack().stackSize;
this.range = (long) (10 * AEConfig.instance.wireless_getMaxRange( boosters ));
this.drain = (long) (100 * AEConfig.instance.wireless_getPowerDrain( boosters ));
this.range = (long) ( 10 * AEConfig.instance.wireless_getMaxRange( boosters ) );
this.drain = (long) ( 100 * AEConfig.instance.wireless_getPowerDrain( boosters ) );
super.detectAndSendChanges();
}
}
@@ -18,6 +18,7 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.core.AEConfig;
@@ -25,12 +26,14 @@ import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.Platform;
public class ContainerWirelessTerm extends ContainerMEPortableCell
{
final WirelessTerminalGuiObject wirelessTerminalGUIObject;
public ContainerWirelessTerm(InventoryPlayer ip, WirelessTerminalGuiObject wirelessTerminalGUIObject) {
public ContainerWirelessTerm( InventoryPlayer ip, WirelessTerminalGuiObject wirelessTerminalGUIObject )
{
super( ip, wirelessTerminalGUIObject );
this.wirelessTerminalGUIObject = wirelessTerminalGUIObject;
}
@@ -40,9 +43,9 @@ public class ContainerWirelessTerm extends ContainerMEPortableCell
{
super.detectAndSendChanges();
if ( !this.wirelessTerminalGUIObject.rangeCheck() )
if( !this.wirelessTerminalGUIObject.rangeCheck() )
{
if ( Platform.isServer() && this.isContainerValid )
if( Platform.isServer() && this.isContainerValid )
this.getPlayerInv().player.addChatMessage( PlayerMessages.OutOfRange.get() );
this.isContainerValid = false;
@@ -18,20 +18,21 @@
package appeng.container.implementations;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.util.ItemSorters;
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
{
public final String myName;
final ICraftingCPU cpu;
final long size;
final int processors;
public final String myName;
public CraftingCPURecord(long size, int coProcessors, ICraftingCPU server) {
public CraftingCPURecord( long size, int coProcessors, ICraftingCPU server )
{
this.size = size;
this.processors = coProcessors;
this.cpu = server;
@@ -39,12 +40,11 @@ public class CraftingCPURecord implements Comparable<CraftingCPURecord>
}
@Override
public int compareTo(CraftingCPURecord o)
public int compareTo( CraftingCPURecord o )
{
int a = ItemSorters.compareLong( o.processors, this.processors );
if ( a != 0 )
if( a != 0 )
return a;
return ItemSorters.compareLong( o.size, this.size );
}
}