Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,309 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CopyMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.inventory.AppEngNullInventory;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
public class ContainerCellWorkbench extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
TileCellWorkbench workBench;
|
||||
AppEngNullInventory ni = new AppEngNullInventory();
|
||||
|
||||
public IInventory getCellUpgradeInventory()
|
||||
{
|
||||
IInventory ri = workBench.getCellUpgradeInventory();
|
||||
return ri == null ? ni : ri;
|
||||
}
|
||||
|
||||
public void setFuzzy(FuzzyMode valueOf)
|
||||
{
|
||||
ICellWorkbenchItem cwi = workBench.getCell();
|
||||
if ( cwi != null )
|
||||
cwi.setFuzzyMode( workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf );
|
||||
}
|
||||
|
||||
private FuzzyMode getFuzzyMode()
|
||||
{
|
||||
ICellWorkbenchItem cwi = workBench.getCell();
|
||||
if ( cwi != null )
|
||||
return cwi.getFuzzyMode( workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) );
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
|
||||
public void nextCopyMode()
|
||||
{
|
||||
workBench.getConfigManager().putSetting( Settings.COPY_MODE, Platform.nextEnum( getCopyMode() ) );
|
||||
}
|
||||
|
||||
public CopyMode getCopyMode()
|
||||
{
|
||||
return (CopyMode) workBench.getConfigManager().getSetting( Settings.COPY_MODE );
|
||||
}
|
||||
|
||||
class Upgrades implements IInventory
|
||||
{
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return getCellUpgradeInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
return getCellUpgradeInventory().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
{
|
||||
IInventory inv = getCellUpgradeInventory();
|
||||
ItemStack is = inv.decrStackSize( i, j );
|
||||
inv.markDirty();
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
IInventory inv = getCellUpgradeInventory();
|
||||
ItemStack is = inv.getStackInSlotOnClosing( i );
|
||||
inv.markDirty();
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
IInventory inv = getCellUpgradeInventory();
|
||||
inv.setInventorySlotContents( i, itemstack );
|
||||
inv.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "Upgrades";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return 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 );
|
||||
workBench = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
|
||||
if ( prevStack != is )
|
||||
{
|
||||
prevStack = is;
|
||||
return lastUpgrades = getCellUpgradeInventory().getSizeInventory();
|
||||
}
|
||||
return lastUpgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx)
|
||||
{
|
||||
return idx < availableUpgrades();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int x = 8;
|
||||
int y = 29;
|
||||
int offset = 0;
|
||||
|
||||
IInventory cell = myte.getInventoryByName( "cell" );
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, invPlayer ) );
|
||||
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
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++)
|
||||
addSlotToContainer( new SlotFakeTypeOnly( inv, offset++, x + z * 18, y + w * 18 ) );
|
||||
|
||||
for (int zz = 0; zz < 3; zz++)
|
||||
for (int z = 0; z < 8; z++)
|
||||
{
|
||||
int iSLot = zz * 8 + z;
|
||||
addSlotToContainer( new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, UpgradeInventoryWrapper, this, iSLot, 187 + zz * 18,
|
||||
8 + 18 * z, iSLot, 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" ) )
|
||||
workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.copyMode );
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
ItemStack is = workBench.getInventoryByName( "cell" ).getStackInSlot( 0 );
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||
|
||||
if ( prevStack != is )
|
||||
{
|
||||
// if the bars changed an item was probably made, so just send shit!
|
||||
for (Object s : inventorySlots)
|
||||
{
|
||||
if ( s instanceof OptionalSlotRestrictedInput )
|
||||
{
|
||||
OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
|
||||
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
|
||||
}
|
||||
}
|
||||
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.copyMode = getCopyMode();
|
||||
this.fzMode = (FuzzyMode) getFuzzyMode();
|
||||
}
|
||||
|
||||
prevStack = is;
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
inv.setInventorySlotContents( x, null );
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void partition()
|
||||
{
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
|
||||
IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell()
|
||||
.getCellInventory( myte.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 );
|
||||
}
|
||||
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
{
|
||||
|
||||
TileChest myte;
|
||||
|
||||
public ContainerChest(InventoryPlayer ip, TileChest te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, myte, 1, 80, 37, invPlayer ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerCondenser extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileCondenser myte;
|
||||
|
||||
public ContainerCondenser(InventoryPlayer ip, TileCondenser te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.TRASH, te, 0, 51, 52, ip ) );
|
||||
addSlotToContainer( new SlotOutput( te, 1, 105, 52, -1 ) );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, te.getInternalInventory(), 2, 101, 26, ip )).setStackLimit( 1 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 197 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
double maxStorage = this.myte.getStorage();
|
||||
double requiredEnergy = this.myte.getRequiredPower();
|
||||
int maxDisplay = requiredEnergy == 0 ? (int) maxStorage : (int) Math.min( requiredEnergy, maxStorage );
|
||||
|
||||
this.requiredEnergy = (int) maxDisplay;
|
||||
this.storedPower = (int) this.myte.storedPower;
|
||||
this.output = (CondenserOutput) this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT );
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@GuiSync(0)
|
||||
public long requiredEnergy = 0;
|
||||
|
||||
@GuiSync(1)
|
||||
public long storedPower = 0;
|
||||
|
||||
@GuiSync(2)
|
||||
public CondenserOutput output = CondenserOutput.TRASH;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public class ContainerCraftAmount extends AEBaseContainer
|
||||
{
|
||||
|
||||
ITerminalHost priHost;
|
||||
|
||||
public IAEItemStack whatToMake;
|
||||
public Slot craftingItem;
|
||||
|
||||
public ContainerCraftAmount(InventoryPlayer ip, ITerminalHost te) {
|
||||
super( ip, te );
|
||||
priHost = te;
|
||||
|
||||
craftingItem = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
|
||||
addSlotToContainer( craftingItem );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
IActionHost h = ((IActionHost) this.getTarget());
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return getPlayerInv().player.worldObj;
|
||||
}
|
||||
|
||||
public BaseActionSource getActionSrc()
|
||||
{
|
||||
return new PlayerSource( getPlayerInv().player, (IActionHost) getTarget() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public class ContainerCraftConfirm extends AEBaseContainer
|
||||
{
|
||||
|
||||
ITerminalHost priHost;
|
||||
public Future<ICraftingJob> job;
|
||||
public ICraftingJob result;
|
||||
|
||||
@GuiSync(0)
|
||||
public long bytesUsed;
|
||||
|
||||
@GuiSync(1)
|
||||
public long cpuBytesAvail;
|
||||
|
||||
@GuiSync(2)
|
||||
public int cpuCoProcessors;
|
||||
|
||||
@GuiSync(3)
|
||||
public boolean autoStart = false;
|
||||
|
||||
@GuiSync(4)
|
||||
public boolean simulation = true;
|
||||
|
||||
@GuiSync(5)
|
||||
public int selectedCpu = -1;
|
||||
|
||||
@GuiSync(6)
|
||||
public boolean noCPU = true;
|
||||
|
||||
@GuiSync(7)
|
||||
public String myName = "";
|
||||
|
||||
protected long cpuIdx = Long.MIN_VALUE;
|
||||
|
||||
public ArrayList<CraftingCPURecord> cpus = new ArrayList();
|
||||
|
||||
public ContainerCraftConfirm(InventoryPlayer ip, ITerminalHost te) {
|
||||
super( ip, te );
|
||||
priHost = te;
|
||||
}
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( cpus );
|
||||
|
||||
if ( selectedCpu >= cpus.size() )
|
||||
{
|
||||
selectedCpu = -1;
|
||||
cpuBytesAvail = 0;
|
||||
cpuCoProcessors = 0;
|
||||
myName = "";
|
||||
}
|
||||
else if ( selectedCpu != -1 )
|
||||
{
|
||||
myName = cpus.get( selectedCpu ).myName;
|
||||
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
||||
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
||||
}
|
||||
}
|
||||
|
||||
public void cycleCpu(boolean next)
|
||||
{
|
||||
if ( next )
|
||||
selectedCpu++;
|
||||
else
|
||||
selectedCpu--;
|
||||
|
||||
if ( selectedCpu < -1 )
|
||||
selectedCpu = cpus.size() - 1;
|
||||
else if ( selectedCpu >= cpus.size() )
|
||||
selectedCpu = -1;
|
||||
|
||||
if ( selectedCpu == -1 )
|
||||
{
|
||||
cpuBytesAvail = 0;
|
||||
cpuCoProcessors = 0;
|
||||
myName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
myName = cpus.get( selectedCpu ).myName;
|
||||
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
||||
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
ICraftingGrid cc = getGrid().getCache( ICraftingGrid.class );
|
||||
ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for (ICraftingCPU c : cpuSet)
|
||||
{
|
||||
boolean found = false;
|
||||
for (CraftingCPURecord ccr : cpus)
|
||||
if ( ccr.cpu == c )
|
||||
found = true;
|
||||
|
||||
boolean matched = cpuMatches( c );
|
||||
|
||||
if ( matched )
|
||||
matches++;
|
||||
|
||||
if ( !found != matched )
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if ( changed || cpus.size() != matches )
|
||||
{
|
||||
cpus.clear();
|
||||
for (ICraftingCPU c : cpuSet)
|
||||
{
|
||||
if ( cpuMatches( c ) )
|
||||
cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
|
||||
sendCPUs();
|
||||
}
|
||||
|
||||
noCPU = cpus.size() == 0;
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if ( job != null && job.isDone() )
|
||||
{
|
||||
try
|
||||
{
|
||||
result = job.get();
|
||||
|
||||
if ( !result.isSimulation() )
|
||||
{
|
||||
simulation = false;
|
||||
if ( autoStart )
|
||||
{
|
||||
startJob();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
simulation = true;
|
||||
|
||||
try
|
||||
{
|
||||
PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
|
||||
PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
|
||||
PacketMEInventoryUpdate c = result.isSimulation() ? new PacketMEInventoryUpdate( (byte) 2 ) : null;
|
||||
|
||||
IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
|
||||
result.populatePlan( plan );
|
||||
|
||||
bytesUsed = result.getByteTotal();
|
||||
|
||||
for (IAEItemStack out : plan)
|
||||
{
|
||||
IAEItemStack m = null;
|
||||
|
||||
IAEItemStack o = out.copy();
|
||||
o.reset();
|
||||
o.setStackSize( out.getStackSize() );
|
||||
|
||||
IAEItemStack p = out.copy();
|
||||
p.reset();
|
||||
p.setStackSize( out.getCountRequestable() );
|
||||
|
||||
IStorageGrid sg = getGrid().getCache( IStorageGrid.class );
|
||||
IMEInventory<IAEItemStack> items = sg.getItemInventory();
|
||||
|
||||
if ( c != null && result.isSimulation() )
|
||||
{
|
||||
m = o.copy();
|
||||
o = items.extractItems( o, Actionable.SIMULATE, mySrc );
|
||||
|
||||
if ( o == null )
|
||||
{
|
||||
o = m.copy();
|
||||
o.setStackSize( 0 );
|
||||
}
|
||||
|
||||
m.setStackSize( m.getStackSize() - o.getStackSize() );
|
||||
}
|
||||
|
||||
if ( o.getStackSize() > 0 )
|
||||
a.appendItem( o );
|
||||
|
||||
if ( p.getStackSize() > 0 )
|
||||
b.appendItem( p );
|
||||
|
||||
if ( c != null && m != null && m.getStackSize() > 0 )
|
||||
c.appendItem( m );
|
||||
}
|
||||
|
||||
for (Object g : this.crafters)
|
||||
{
|
||||
if ( g instanceof EntityPlayer )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
|
||||
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
|
||||
if ( c != null )
|
||||
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) );
|
||||
AELog.error( e );
|
||||
this.isContainerValid = false;
|
||||
result = null;
|
||||
}
|
||||
|
||||
job = null;
|
||||
}
|
||||
verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
|
||||
private boolean cpuMatches(ICraftingCPU c)
|
||||
{
|
||||
return c.getAvailableStorage() >= bytesUsed && !c.isBusy();
|
||||
}
|
||||
|
||||
public void startJob()
|
||||
{
|
||||
GuiBridge OriginalGui = null;
|
||||
|
||||
IActionHost ah = getActionHost();
|
||||
if ( ah instanceof WirelessTerminalGuiObject )
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
|
||||
if ( ah instanceof PartTerminal )
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
|
||||
if ( ah instanceof PartCraftingTerminal )
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
|
||||
if ( ah instanceof PartPatternTerminal )
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
|
||||
if ( result != null && simulation == false )
|
||||
{
|
||||
ICraftingGrid cc = getGrid().getCache( ICraftingGrid.class );
|
||||
ICraftingLink g = cc.submitJob( result, null, selectedCpu == -1 ? null : cpus.get( selectedCpu ).cpu, true, getActionSrc() );
|
||||
autoStart = false;
|
||||
if ( g != null && OriginalGui != null && openContext != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketSwitchGuis( OriginalGui ), (EntityPlayerMP) invPlayer.player );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// :(
|
||||
}
|
||||
|
||||
TileEntity te = openContext.getTile();
|
||||
Platform.openGUI( invPlayer.player, te, openContext.side, OriginalGui );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
super.onContainerClosed( par1EntityPlayer );
|
||||
if ( job != null )
|
||||
{
|
||||
job.cancel( true );
|
||||
job = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters(ICrafting c)
|
||||
{
|
||||
super.removeCraftingFromCrafters( c );
|
||||
if ( job != null )
|
||||
{
|
||||
job.cancel( true );
|
||||
job = null;
|
||||
}
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
{
|
||||
IActionHost h = ((IActionHost) this.getTarget());
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return getPlayerInv().player.worldObj;
|
||||
}
|
||||
|
||||
public BaseActionSource getActionSrc()
|
||||
{
|
||||
return new PlayerSource( getPlayerInv().player, (IActionHost) getTarget() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.CraftingItemList;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
|
||||
{
|
||||
|
||||
CraftingCPUCluster monitor = null;
|
||||
String cpuName = null;
|
||||
protected IGrid network;
|
||||
|
||||
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
|
||||
public ContainerCraftingCPU(InventoryPlayer ip, Object te) {
|
||||
super( ip, te );
|
||||
IGridHost host = (IGridHost) (te instanceof IGridHost ? te : null);
|
||||
|
||||
if ( host != null )
|
||||
{
|
||||
findNode( host, ForgeDirection.UNKNOWN );
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
|
||||
findNode( host, d );
|
||||
}
|
||||
|
||||
if ( te instanceof TileCraftingTile )
|
||||
setCPU( (ICraftingCPU) ((TileCraftingTile) te).getCluster() );
|
||||
|
||||
if ( network == null && Platform.isServer() )
|
||||
isContainerValid = false;
|
||||
}
|
||||
|
||||
protected void setCPU(ICraftingCPU c)
|
||||
{
|
||||
if ( c == monitor )
|
||||
return;
|
||||
|
||||
if ( monitor != null )
|
||||
monitor.removeListener( this );
|
||||
|
||||
for (Object g : this.crafters)
|
||||
{
|
||||
if ( g instanceof EntityPlayer )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (EntityPlayerMP) g );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( c instanceof CraftingCPUCluster )
|
||||
{
|
||||
cpuName = ((CraftingCPUCluster) c).getName();
|
||||
|
||||
monitor = (CraftingCPUCluster) c;
|
||||
if ( monitor != null )
|
||||
{
|
||||
list.resetStatus();
|
||||
monitor.getListOfItem( list, CraftingItemList.ALL );
|
||||
monitor.addListener( this, null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
monitor = null;
|
||||
cpuName = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelCrafting()
|
||||
{
|
||||
if ( monitor != null )
|
||||
{
|
||||
monitor.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void findNode(IGridHost host, ForgeDirection d)
|
||||
{
|
||||
if ( network == null )
|
||||
{
|
||||
IGridNode node = host.getGridNode( d );
|
||||
if ( node != null )
|
||||
network = node.getGrid();
|
||||
}
|
||||
}
|
||||
|
||||
int delay = 40;
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if ( monitor != null )
|
||||
monitor.removeListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters(ICrafting c)
|
||||
{
|
||||
super.removeCraftingFromCrafters( c );
|
||||
|
||||
if ( this.crafters.isEmpty() && monitor != null )
|
||||
monitor.removeListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isServer() && monitor != null && !list.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
|
||||
PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
|
||||
PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 );
|
||||
|
||||
for (IAEItemStack out : list)
|
||||
{
|
||||
a.appendItem( monitor.getItemStack( out, CraftingItemList.STORAGE ) );
|
||||
b.appendItem( monitor.getItemStack( out, CraftingItemList.ACTIVE ) );
|
||||
c.appendItem( monitor.getItemStack( out, CraftingItemList.PENDING ) );
|
||||
}
|
||||
|
||||
list.resetStatus();
|
||||
|
||||
for (Object g : this.crafters)
|
||||
{
|
||||
if ( g instanceof EntityPlayer )
|
||||
{
|
||||
if ( !a.isEmpty() )
|
||||
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
|
||||
|
||||
if ( !b.isEmpty() )
|
||||
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
|
||||
|
||||
if ( !c.isEmpty() )
|
||||
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource)
|
||||
{
|
||||
for (IAEItemStack is : change)
|
||||
{
|
||||
is = is.copy();
|
||||
is.setStackSize( 1 );
|
||||
list.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName()
|
||||
{
|
||||
return cpuName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return cpuName != null && cpuName.length() > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||
{
|
||||
|
||||
@GuiSync(5)
|
||||
public int selectedCpu = -1;
|
||||
|
||||
@GuiSync(6)
|
||||
public boolean noCPU = true;
|
||||
|
||||
@GuiSync(7)
|
||||
public String myName = "";
|
||||
|
||||
public ArrayList<CraftingCPURecord> cpus = new ArrayList();
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( cpus );
|
||||
|
||||
if ( selectedCpu >= cpus.size() )
|
||||
{
|
||||
selectedCpu = -1;
|
||||
myName = "";
|
||||
}
|
||||
else if ( selectedCpu != -1 )
|
||||
{
|
||||
myName = cpus.get( selectedCpu ).myName;
|
||||
}
|
||||
|
||||
if ( selectedCpu == -1 && cpus.size() > 0 )
|
||||
selectedCpu = 0;
|
||||
|
||||
if ( selectedCpu != -1 )
|
||||
{
|
||||
if ( cpus.get( selectedCpu ).cpu != monitor )
|
||||
setCPU( cpus.get( selectedCpu ).cpu );
|
||||
}
|
||||
else
|
||||
setCPU( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
ICraftingGrid cc = network.getCache( ICraftingGrid.class );
|
||||
ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for (ICraftingCPU c : cpuSet)
|
||||
{
|
||||
boolean found = false;
|
||||
for (CraftingCPURecord ccr : cpus)
|
||||
if ( ccr.cpu == c )
|
||||
found = true;
|
||||
|
||||
boolean matched = cpuMatches( c );
|
||||
|
||||
if ( matched )
|
||||
matches++;
|
||||
|
||||
if ( !found != matched )
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if ( changed || cpus.size() != matches )
|
||||
{
|
||||
cpus.clear();
|
||||
for (ICraftingCPU c : cpuSet)
|
||||
{
|
||||
if ( cpuMatches( c ) )
|
||||
cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
|
||||
sendCPUs();
|
||||
}
|
||||
|
||||
noCPU = cpus.size() == 0;
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
private boolean cpuMatches(ICraftingCPU c)
|
||||
{
|
||||
return c.isBusy();
|
||||
}
|
||||
|
||||
public ContainerCraftingStatus(InventoryPlayer ip, ITerminalHost te) {
|
||||
super( ip, te );
|
||||
}
|
||||
|
||||
public void cycleCpu(boolean next)
|
||||
{
|
||||
if ( next )
|
||||
selectedCpu++;
|
||||
else
|
||||
selectedCpu--;
|
||||
|
||||
if ( selectedCpu < -1 )
|
||||
selectedCpu = cpus.size() - 1;
|
||||
else if ( selectedCpu >= cpus.size() )
|
||||
selectedCpu = -1;
|
||||
|
||||
if ( selectedCpu == -1 && cpus.size() > 0 )
|
||||
selectedCpu = 0;
|
||||
|
||||
if ( selectedCpu == -1 )
|
||||
{
|
||||
myName = "";
|
||||
setCPU( null );
|
||||
}
|
||||
else
|
||||
{
|
||||
myName = cpus.get( selectedCpu ).myName;
|
||||
setCPU( cpus.get( selectedCpu ).cpu );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IContainerCraftingPacket
|
||||
{
|
||||
|
||||
AppEngInternalInventory output = new AppEngInternalInventory( this, 1 );
|
||||
|
||||
SlotCraftingMatrix craftingSlots[] = new SlotCraftingMatrix[9];
|
||||
SlotCraftingTerm outputSlot;
|
||||
|
||||
public PartCraftingTerminal ct;
|
||||
|
||||
/**
|
||||
* Callback for when the crafting matrix is changed.
|
||||
*/
|
||||
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, craftingSlots[x].getStack() );
|
||||
|
||||
outputSlot.putStack( CraftingManager.getInstance().findMatchingRecipe( ic, getPlayerInv().player.worldObj ) );
|
||||
}
|
||||
|
||||
public ContainerCraftingTerm(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super( ip, monitorable, false );
|
||||
ct = (PartCraftingTerminal) monitorable;
|
||||
|
||||
IInventory crafting = ct.getInventoryByName( "crafting" );
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 3; x++)
|
||||
addSlotToContainer( craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) );
|
||||
|
||||
addSlotToContainer( outputSlot = new SlotCraftingTerm( getPlayerInv().player, mySrc, powerSrc, monitorable, crafting, crafting, output, 131, -72 + 18, this ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
|
||||
onCraftMatrixChanged( crafting );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
return ct.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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
|
||||
{
|
||||
|
||||
TileDrive myte;
|
||||
|
||||
public ContainerDrive(InventoryPlayer ip, TileDrive te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
for (int y = 0; y < 5; y++)
|
||||
for (int x = 0; x < 2; x++)
|
||||
{
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, te, x + y * 2, 71 + x * 18, 14 + y * 18, invPlayer ) );
|
||||
}
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerFormationPlane extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
PartFormationPlane storageBus;
|
||||
|
||||
public ContainerFormationPlane(InventoryPlayer ip, PartFormationPlane te) {
|
||||
super( ip, te );
|
||||
storageBus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx)
|
||||
{
|
||||
int upgrades = myte.getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int xo = 8;
|
||||
int yo = 23 + 6;
|
||||
|
||||
IInventory config = myte.getInventoryByName( "config" );
|
||||
for (int y = 0; y < 7; y++)
|
||||
{
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
if ( y < 2 )
|
||||
addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
|
||||
else
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, invPlayer )).setNotDraggable() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
}
|
||||
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
|
||||
public class ContainerGrinder extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileGrinder myte;
|
||||
|
||||
public ContainerGrinder(InventoryPlayer ip, TileGrinder te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, te, 0, 12, 17, invPlayer ) );
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, te, 1, 12 + 18, 17, invPlayer ) );
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, te, 2, 12 + 36, 17, invPlayer ) );
|
||||
|
||||
addSlotToContainer( new SlotInaccessible( te, 6, 80, 40 ) );
|
||||
|
||||
addSlotToContainer( new SlotOutput( te, 3, 112, 63, 2 * 16 + 15 ) );
|
||||
addSlotToContainer( new SlotOutput( te, 4, 112 + 18, 63, 2 * 16 + 15 ) );
|
||||
addSlotToContainer( new SlotOutput( te, 5, 112 + 36, 63, 2 * 16 + 15 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 176 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerIOPort extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
TileIOPort ioPort;
|
||||
|
||||
@GuiSync(2)
|
||||
public FullnessMode fMode = FullnessMode.EMPTY;
|
||||
@GuiSync(3)
|
||||
public OperationMode opMode = OperationMode.EMPTY;
|
||||
|
||||
public ContainerIOPort(InventoryPlayer ip, TileIOPort te) {
|
||||
super( ip, te );
|
||||
ioPort = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int offx = 19;
|
||||
int offy = 17;
|
||||
|
||||
IInventory cells = myte.getInventoryByName( "cells" );
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 2; x++)
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells, x + y * 2, offx + x * 18, offy + y * 18, invPlayer ) );
|
||||
|
||||
offx = 122;
|
||||
offy = 17;
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 2; x++)
|
||||
addSlotToContainer( new SlotOutput( cells, 6 + x + y * 2, offx + x * 18, offy + y * 18, SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon ) );
|
||||
|
||||
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.opMode = (OperationMode) myte.getConfigManager().getSetting( Settings.OPERATION_MODE );
|
||||
this.fMode = (FullnessMode) this.myte.getConfigManager().getSetting( Settings.FULLNESS_MODE );
|
||||
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.recipes.handlers.Inscribe;
|
||||
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerInscriber extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileInscriber myte;
|
||||
|
||||
Slot top;
|
||||
Slot middle;
|
||||
Slot bottom;
|
||||
|
||||
@GuiSync(0)
|
||||
public int maxProcessingTime = -1;
|
||||
|
||||
@GuiSync(1)
|
||||
public int processingTime = -1;
|
||||
|
||||
public ContainerInscriber(InventoryPlayer ip, TileInscriber te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, myte, 0, 45, 16, invPlayer ) );
|
||||
addSlotToContainer( bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, myte, 1, 45, 62, invPlayer ) );
|
||||
addSlotToContainer( middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, myte, 2, 63, 39, invPlayer ) );
|
||||
|
||||
addSlotToContainer( new SlotOutput( myte, 3, 113, 40, -1 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 176 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
public boolean isValidForSlot(Slot s, ItemStack is)
|
||||
{
|
||||
ItemStack PlateA = myte.getStackInSlot( 0 );
|
||||
ItemStack PlateB = myte.getStackInSlot( 1 );
|
||||
|
||||
if ( s == 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 == false )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( (s == top && PlateB != null) || (s == bottom && PlateA != null) )
|
||||
{
|
||||
boolean isValid = false;
|
||||
ItemStack otherSlot = null;
|
||||
if ( s == top )
|
||||
otherSlot = bottom.getStack();
|
||||
else
|
||||
otherSlot = top.getStack();
|
||||
|
||||
// name presses
|
||||
if ( AEApi.instance().materials().materialNamePress.sameAsStack( otherSlot ) )
|
||||
return AEApi.instance().materials().materialNamePress.sameAsStack( 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 void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.maxProcessingTime = myte.maxProcessingTime;
|
||||
this.processingTime = myte.processingTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
|
||||
public class ContainerInterface extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
DualityInterface myDuality;
|
||||
|
||||
@GuiSync(3)
|
||||
public YesNo bMode = YesNo.NO;
|
||||
|
||||
@GuiSync(4)
|
||||
public YesNo iTermMode = YesNo.YES;
|
||||
|
||||
public ContainerInterface(InventoryPlayer ip, IInterfaceHost te) {
|
||||
super( ip, te.getInterfaceDuality().getHost() );
|
||||
|
||||
myDuality = te.getInterfaceDuality();
|
||||
|
||||
for (int x = 0; x < 9; x++)
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, myDuality.getPatterns(), x, 8 + 18 * x, 90 + 7, invPlayer ) );
|
||||
|
||||
for (int x = 0; x < 8; x++)
|
||||
addSlotToContainer( new SlotFake( myDuality.getConfig(), x, 17 + 18 * x, 35 ) );
|
||||
|
||||
for (int x = 0; x < 8; x++)
|
||||
addSlotToContainer( new SlotNormal( myDuality.getStorage(), x, 17 + 18 * x, 35 + 18 ) );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 211;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
setupUpgrades();
|
||||
}
|
||||
|
||||
protected void loadSettingsFromHost(IConfigManager cm)
|
||||
{
|
||||
this.bMode = (YesNo) cm.getSetting( Settings.BLOCK );
|
||||
this.iTermMode = (YesNo) cm.getSetting( Settings.INTERFACE_TERMINAL );
|
||||
}
|
||||
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.reporting.PartMonitor;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.inv.WrapperInvSlot;
|
||||
|
||||
public class ContainerInterfaceTerminal extends AEBaseContainer
|
||||
{
|
||||
|
||||
/**
|
||||
* this stuff is all server side..
|
||||
*/
|
||||
|
||||
static private long autoBase = Long.MIN_VALUE;
|
||||
|
||||
class InvTracker
|
||||
{
|
||||
|
||||
long which = autoBase++;
|
||||
String unlocalizedName;
|
||||
|
||||
public InvTracker(DualityInterface dual, IInventory patterns, String unlocalizedName) {
|
||||
server = patterns;
|
||||
client = new AppEngInternalInventory( null, server.getSizeInventory() );
|
||||
this.unlocalizedName = unlocalizedName;
|
||||
this.sortBy = dual.getSortValue();
|
||||
}
|
||||
|
||||
IInventory client;
|
||||
IInventory server;
|
||||
public long sortBy;
|
||||
|
||||
};
|
||||
|
||||
Map<IInterfaceHost, InvTracker> diList = new HashMap();
|
||||
Map<Long, InvTracker> byId = new HashMap();
|
||||
IGrid g;
|
||||
|
||||
public ContainerInterfaceTerminal(InventoryPlayer ip, PartMonitor anchor) {
|
||||
super( ip, anchor );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
g = anchor.getActionableNode().getGrid();
|
||||
|
||||
bindPlayerInventory( ip, 0, 222 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
class PatternInvSlot extends WrapperInvSlot
|
||||
{
|
||||
|
||||
public PatternInvSlot(IInventory inv) {
|
||||
super( inv );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemstack)
|
||||
{
|
||||
return itemstack != null && itemstack.getItem() instanceof ItemEncodedPattern;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public void doAction(EntityPlayerMP player, InventoryAction action, int slot, long id)
|
||||
{
|
||||
InvTracker inv = byId.get( id );
|
||||
if ( inv != null )
|
||||
{
|
||||
ItemStack is = inv.server.getStackInSlot( slot );
|
||||
boolean hasItemInHand = player.inventory.getItemStack() != null;
|
||||
|
||||
InventoryAdaptor playerHand = new AdaptorPlayerHand( player );
|
||||
|
||||
WrapperInvSlot slotInv = new PatternInvSlot( inv.server );
|
||||
|
||||
IInventory theSlot = slotInv.getWrapper( slot );
|
||||
InventoryAdaptor interfaceSlot = new AdaptorIInventory( theSlot );
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PICKUP_OR_SETDOWN:
|
||||
|
||||
if ( hasItemInHand )
|
||||
{
|
||||
ItemStack inSlot = theSlot.getStackInSlot( 0 );
|
||||
if ( inSlot == null )
|
||||
player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) );
|
||||
else
|
||||
{
|
||||
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
|
||||
{
|
||||
IInventory mySlot = slotInv.getWrapper( slot );
|
||||
mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
|
||||
}
|
||||
|
||||
break;
|
||||
case SPLIT_OR_PLACESINGLE:
|
||||
|
||||
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 );
|
||||
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
|
||||
mySlot.setInventorySlotContents( 0, playerInv.addItems( mySlot.getStackInSlot( 0 ) ) );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
updateHeld( player );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if ( g == null )
|
||||
return;
|
||||
|
||||
int total = 0;
|
||||
boolean missing = false;
|
||||
|
||||
IActionHost host = getActionHost();
|
||||
if ( host != null )
|
||||
{
|
||||
IGridNode agn = host.getActionableNode();
|
||||
if ( agn != null && agn.isActive() )
|
||||
{
|
||||
for (IGridNode gn : 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 = 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 : 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 = diList.get( ih );
|
||||
|
||||
if ( t == null )
|
||||
missing = true;
|
||||
else
|
||||
{
|
||||
DualityInterface dual = ih.getInterfaceDuality();
|
||||
if ( !t.unlocalizedName.equals( dual.getTermName() ) )
|
||||
missing = true;
|
||||
}
|
||||
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( total != diList.size() || missing )
|
||||
regenList( data );
|
||||
else
|
||||
{
|
||||
for (Entry<IInterfaceHost, InvTracker> en : diList.entrySet())
|
||||
{
|
||||
InvTracker inv = en.getValue();
|
||||
for (int x = 0; x < inv.server.getSizeInventory(); x++)
|
||||
{
|
||||
if ( isDifferent( inv.server.getStackInSlot( x ), inv.client.getStackInSlot( x ) ) )
|
||||
addItems( data, inv, x, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !data.hasNoTags() )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketCompressedNBT( data ), (EntityPlayerMP) getPlayerInv().player );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
byId.clear();
|
||||
diList.clear();
|
||||
|
||||
IActionHost host = getActionHost();
|
||||
if ( host != null )
|
||||
{
|
||||
IGridNode agn = host.getActionableNode();
|
||||
if ( agn != null && agn.isActive() )
|
||||
{
|
||||
for (IGridNode gn : g.getMachines( TileInterface.class ))
|
||||
{
|
||||
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
DualityInterface dual = ih.getInterfaceDuality();
|
||||
if ( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
|
||||
diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
|
||||
}
|
||||
|
||||
for (IGridNode gn : g.getMachines( PartInterface.class ))
|
||||
{
|
||||
IInterfaceHost ih = (IInterfaceHost) gn.getMachine();
|
||||
DualityInterface dual = ih.getInterfaceDuality();
|
||||
if ( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES )
|
||||
diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.setBoolean( "clear", true );
|
||||
|
||||
for (Entry<IInterfaceHost, InvTracker> en : diList.entrySet())
|
||||
{
|
||||
InvTracker inv = en.getValue();
|
||||
byId.put( inv.which, inv );
|
||||
addItems( data, inv, 0, inv.server.getSizeInventory() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addItems(NBTTagCompound data, InvTracker inv, int offset, int length)
|
||||
{
|
||||
String name = "=" + Long.toString( inv.which, Character.MAX_RADIX );
|
||||
NBTTagCompound invv = data.getCompoundTag( name );
|
||||
|
||||
if ( invv.hasNoTags() )
|
||||
{
|
||||
invv.setLong( "sortBy", inv.sortBy );
|
||||
invv.setString( "un", inv.unlocalizedName );
|
||||
}
|
||||
|
||||
for (int x = 0; x < length; x++)
|
||||
{
|
||||
NBTTagCompound itemNBT = new NBTTagCompound();
|
||||
|
||||
ItemStack is = inv.server.getStackInSlot( x + offset );
|
||||
|
||||
// "update" client side.
|
||||
inv.client.setInventorySlotContents( x + offset, is == null ? null : is.copy() );
|
||||
|
||||
if ( is != null )
|
||||
is.writeToNBT( itemNBT );
|
||||
|
||||
invv.setTag( Integer.toString( x + offset ), itemNBT );
|
||||
}
|
||||
|
||||
data.setTag( name, invv );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerLevelEmitter extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
PartLevelEmitter lvlEmitter;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiTextField textField;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setTextField(GuiTextField level)
|
||||
{
|
||||
textField = level;
|
||||
textField.setText( "" + EmitterValue );
|
||||
}
|
||||
|
||||
public ContainerLevelEmitter(InventoryPlayer ip, PartLevelEmitter te) {
|
||||
super( ip, te );
|
||||
lvlEmitter = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLevel(long l, EntityPlayer player)
|
||||
{
|
||||
lvlEmitter.setReportingValue( l );
|
||||
EmitterValue = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int x = 80 + 44;
|
||||
int y = 40;
|
||||
|
||||
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||
if ( availableUpgrades() > 0 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
||||
if ( availableUpgrades() > 1 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
||||
if ( availableUpgrades() > 2 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
||||
if ( availableUpgrades() > 3 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
|
||||
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
|
||||
}
|
||||
|
||||
@GuiSync(2)
|
||||
public LevelType lvType;
|
||||
|
||||
@GuiSync(3)
|
||||
public long EmitterValue = -1;
|
||||
|
||||
@GuiSync(4)
|
||||
public YesNo cmType;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.EmitterValue = lvlEmitter.getReportingValue();
|
||||
this.cmType = (YesNo) this.myte.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE );
|
||||
this.lvType = (LevelType) this.myte.getConfigManager().getSetting( Settings.LEVEL_TYPE );
|
||||
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_EMITTER );
|
||||
}
|
||||
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
public void onUpdate(String field, Object oldValue, Object newValue)
|
||||
{
|
||||
if ( field.equals( "EmitterValue" ) )
|
||||
{
|
||||
if ( textField != null )
|
||||
textField.setText( "" + EmitterValue );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotMACPattern;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMAC extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
TileMolecularAssembler tma;
|
||||
|
||||
public ContainerMAC(InventoryPlayer ip, TileMolecularAssembler te) {
|
||||
super( ip, te );
|
||||
tma = te;
|
||||
}
|
||||
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@GuiSync(4)
|
||||
public int craftProgress = 0;
|
||||
|
||||
public boolean isValidItemForSlot(int slotIndex, ItemStack i)
|
||||
{
|
||||
IInventory mac = myte.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()
|
||||
{
|
||||
int offx = 29;
|
||||
int offy = 30;
|
||||
|
||||
IInventory mac = myte.getInventoryByName( "mac" );
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
SlotMACPattern s = new SlotMACPattern( this, mac, x + y * 3, offx + x * 18, offy + y * 18 );
|
||||
addSlotToContainer( s );
|
||||
}
|
||||
|
||||
offx = 126;
|
||||
offy = 16;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_CRAFTING_PATTERN, mac, 10, offx, offy, invPlayer ) );
|
||||
addSlotToContainer( new SlotOutput( mac, 9, offx, offy + 32, -1 ) );
|
||||
|
||||
offx = 122;
|
||||
offy = 17;
|
||||
|
||||
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, invPlayer )).setNotDraggable() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
craftProgress = this.tma.getCraftingProgress();
|
||||
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,356 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
|
||||
{
|
||||
|
||||
final IMEMonitor<IAEItemStack> monitor;
|
||||
final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
|
||||
|
||||
IConfigManager serverCM;
|
||||
IConfigManager clientCM;
|
||||
|
||||
@GuiSync(99)
|
||||
public boolean canAccessViewCells = false;
|
||||
|
||||
@GuiSync(98)
|
||||
public boolean hasPower = false;
|
||||
|
||||
public SlotRestrictedInput cellView[] = new SlotRestrictedInput[5];
|
||||
|
||||
public IConfigManagerHost gui;
|
||||
private IGridNode networkNode;
|
||||
|
||||
public IGridNode getNetworkNode()
|
||||
{
|
||||
return networkNode;
|
||||
}
|
||||
|
||||
protected ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost monitorable, boolean bindInventory) {
|
||||
super( ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null );
|
||||
|
||||
clientCM = new ConfigManager( this );
|
||||
|
||||
clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
serverCM = monitorable.getConfigManager();
|
||||
|
||||
monitor = monitorable.getItemInventory();
|
||||
if ( monitor != null )
|
||||
{
|
||||
monitor.addListener( this, null );
|
||||
|
||||
cellInv = monitor;
|
||||
|
||||
if ( monitorable instanceof IPortableCell )
|
||||
powerSrc = (IPortableCell) monitorable;
|
||||
else if ( monitorable instanceof IMEChest )
|
||||
powerSrc = (IMEChest) monitorable;
|
||||
else if ( monitorable instanceof IGridHost )
|
||||
{
|
||||
IGridNode node = ((IGridHost) monitorable).getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( node != null )
|
||||
{
|
||||
networkNode = node;
|
||||
IGrid g = node.getGrid();
|
||||
if ( g != null )
|
||||
powerSrc = new ChannelPowerSrc( networkNode, (IEnergyGrid) g.getCache( IEnergyGrid.class ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
monitor = null;
|
||||
|
||||
canAccessViewCells = false;
|
||||
if ( monitorable instanceof IViewCellStorage )
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEWCELL, ((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8,
|
||||
invPlayer );
|
||||
cellView[y].allowEdit = canAccessViewCells;
|
||||
addSlotToContainer( cellView[y] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bindInventory )
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
|
||||
public ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
this( ip, monitorable, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (Enum set : serverCM.getSettings())
|
||||
{
|
||||
Enum sideLocal = serverCM.getSetting( set );
|
||||
Enum sideRemote = clientCM.getSetting( set );
|
||||
|
||||
if ( sideLocal != sideRemote )
|
||||
{
|
||||
clientCM.putSetting( set, sideLocal );
|
||||
for (int j = 0; j < this.crafters.size(); ++j)
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) this.crafters.get( j ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !items.isEmpty() )
|
||||
{
|
||||
try
|
||||
{
|
||||
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
|
||||
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
|
||||
for (IAEItemStack is : items)
|
||||
{
|
||||
IAEItemStack send = monitorCache.findPrecise( is );
|
||||
if ( send == null )
|
||||
{
|
||||
is.setStackSize( 0 );
|
||||
piu.appendItem( is );
|
||||
}
|
||||
else
|
||||
piu.appendItem( send );
|
||||
}
|
||||
|
||||
if ( !piu.isEmpty() )
|
||||
{
|
||||
items.resetStatus();
|
||||
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
if ( c instanceof EntityPlayer )
|
||||
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
updatePowerStatus();
|
||||
|
||||
boolean oldCanAccessViewCells = canAccessViewCells;
|
||||
canAccessViewCells = hasAccess( SecurityPermissions.BUILD, false );
|
||||
if ( canAccessViewCells != oldCanAccessViewCells )
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
if ( cellView[y] != null )
|
||||
cellView[y].allowEdit = canAccessViewCells;
|
||||
}
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updatePowerStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( networkNode != null )
|
||||
hasPower = networkNode.isActive();
|
||||
else if ( powerSrc instanceof IEnergyGrid )
|
||||
hasPower = ((IEnergyGrid) powerSrc).isNetworkPowered();
|
||||
else
|
||||
hasPower = powerSrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting c)
|
||||
{
|
||||
super.addCraftingToCrafters( c );
|
||||
queueInventory( c );
|
||||
}
|
||||
|
||||
public void queueInventory(ICrafting c)
|
||||
{
|
||||
if ( Platform.isServer() && c instanceof EntityPlayer && monitor != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
|
||||
|
||||
for (IAEItemStack send : monitorCache)
|
||||
{
|
||||
try
|
||||
{
|
||||
piu.appendItem( send );
|
||||
}
|
||||
catch (BufferOverflowException boe)
|
||||
{
|
||||
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
||||
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
piu.appendItem( send );
|
||||
}
|
||||
}
|
||||
|
||||
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
if ( c instanceof ICrafting )
|
||||
{
|
||||
ICrafting cr = (ICrafting) c;
|
||||
queueInventory( cr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(String field, Object oldValue, Object newValue)
|
||||
{
|
||||
if ( field.equals( "canAccessViewCells" ) )
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
if ( cellView[y] != null )
|
||||
cellView[y].allowEdit = canAccessViewCells;
|
||||
}
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
if ( monitor != null )
|
||||
monitor.removeListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters(ICrafting c)
|
||||
{
|
||||
super.removeCraftingFromCrafters( c );
|
||||
|
||||
if ( this.crafters.isEmpty() && monitor != null )
|
||||
monitor.removeListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource source)
|
||||
{
|
||||
for (IAEItemStack is : change)
|
||||
items.add( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
if ( gui != null )
|
||||
gui.updateSetting( manager, settingName, newValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return serverCM;
|
||||
return clientCM;
|
||||
}
|
||||
|
||||
public ItemStack[] getViewCells()
|
||||
{
|
||||
ItemStack[] list = new ItemStack[cellView.length];
|
||||
|
||||
for (int x = 0; x < cellView.length; x++)
|
||||
list[x] = cellView[x].getStack();
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable
|
||||
{
|
||||
|
||||
double powerMultiplier = 0.5;
|
||||
IPortableCell civ;
|
||||
|
||||
public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell monitorable) {
|
||||
super( ip, (ITerminalHost) monitorable, false );
|
||||
lockPlayerInventorySlot( ip.currentItem );
|
||||
civ = monitorable;
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
|
||||
int ticks = 0;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
ItemStack currentItem = getPlayerInv().getCurrentItem();
|
||||
|
||||
if ( civ != null )
|
||||
{
|
||||
if ( currentItem != civ.getItemStack() )
|
||||
{
|
||||
if ( currentItem != null )
|
||||
{
|
||||
if ( Platform.isSameItem( civ.getItemStack(), currentItem ) )
|
||||
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, civ.getItemStack() );
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
|
||||
// drain 1 ae t
|
||||
ticks++;
|
||||
if ( ticks > 10 )
|
||||
{
|
||||
civ.extractAEPower( powerMultiplier * (double) ticks, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
ticks = 0;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridBlock;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class ContainerNetworkStatus extends AEBaseContainer
|
||||
{
|
||||
|
||||
IGrid network;
|
||||
|
||||
public ContainerNetworkStatus(InventoryPlayer ip, INetworkTool te) {
|
||||
super( ip, null, null );
|
||||
IGridHost host = te.getGridHost();
|
||||
|
||||
if ( host != null )
|
||||
{
|
||||
findNode( host, ForgeDirection.UNKNOWN );
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
|
||||
findNode( host, d );
|
||||
}
|
||||
|
||||
if ( network == null && Platform.isServer() )
|
||||
isContainerValid = false;
|
||||
}
|
||||
|
||||
private void findNode(IGridHost host, ForgeDirection d)
|
||||
{
|
||||
if ( network == null )
|
||||
{
|
||||
IGridNode node = host.getGridNode( d );
|
||||
if ( node != null )
|
||||
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()
|
||||
{
|
||||
delay++;
|
||||
if ( Platform.isServer() && delay > 15 && network != null )
|
||||
{
|
||||
delay = 0;
|
||||
|
||||
IEnergyGrid eg = network.getCache( IEnergyGrid.class );
|
||||
if ( eg != null )
|
||||
{
|
||||
avgAddition = (long) (100.0 * eg.getAvgPowerInjection());
|
||||
powerUsage = (long) (100.0 * eg.getAvgPowerUsage());
|
||||
currentPower = (long) (100.0 * eg.getStoredPower());
|
||||
maxPower = (long) (100.0 * eg.getMaxStoredPower());
|
||||
}
|
||||
|
||||
PacketMEInventoryUpdate piu;
|
||||
try
|
||||
{
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
|
||||
for (Class<? extends IGridHost> machineClass : network.getMachinesClasses())
|
||||
{
|
||||
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
for (IGridNode machine : network.getMachines( machineClass ))
|
||||
{
|
||||
IGridBlock blk = machine.getGridBlock();
|
||||
ItemStack is = blk.getMachineRepresentation();
|
||||
if ( is != null && is.getItem() != null )
|
||||
{
|
||||
IAEItemStack ais = AEItemStack.create( is );
|
||||
ais.setStackSize( 1 );
|
||||
ais.setCountRequestable( (long) (blk.getIdlePowerUsage() * 100.0) );
|
||||
list.add( ais );
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack ais : list)
|
||||
piu.appendItem( ais );
|
||||
}
|
||||
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
if ( c instanceof EntityPlayer )
|
||||
NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerNetworkTool extends AEBaseContainer
|
||||
{
|
||||
|
||||
INetworkTool toolInv;
|
||||
|
||||
@GuiSync(1)
|
||||
public boolean facadeMode;
|
||||
|
||||
public ContainerNetworkTool(InventoryPlayer ip, INetworkTool te) {
|
||||
super( ip, null, null );
|
||||
toolInv = te;
|
||||
|
||||
lockPlayerInventorySlot( ip.currentItem );
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 3; x++)
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te, y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, invPlayer )) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
public void toggleFacadeMode()
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( toolInv.getItemStack() );
|
||||
data.setBoolean( "hideFacades", !data.getBoolean( "hideFacades" ) );
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
ItemStack currentItem = getPlayerInv().getCurrentItem();
|
||||
|
||||
if ( currentItem != toolInv.getItemStack() )
|
||||
{
|
||||
if ( currentItem != null )
|
||||
{
|
||||
if ( Platform.isSameItem( toolInv.getItemStack(), currentItem ) )
|
||||
{
|
||||
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, toolInv.getItemStack() );
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
|
||||
if ( isContainerValid )
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( currentItem );
|
||||
facadeMode = data.getBoolean( "hideFacades" );
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket
|
||||
{
|
||||
|
||||
AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
|
||||
IInventory crafting;
|
||||
|
||||
SlotFakeCraftingMatrix craftingSlots[] = new SlotFakeCraftingMatrix[9];
|
||||
OptionalSlotFake outputSlots[] = new OptionalSlotFake[3];
|
||||
|
||||
SlotPatternTerm craftSlot;
|
||||
|
||||
SlotRestrictedInput patternSlotIN;
|
||||
SlotRestrictedInput patternSlotOUT;
|
||||
|
||||
public PartPatternTerminal ct;
|
||||
|
||||
public ContainerPatternTerm(InventoryPlayer ip, ITerminalHost monitorable)
|
||||
{
|
||||
super( ip, monitorable, false );
|
||||
ct = (PartPatternTerminal) monitorable;
|
||||
|
||||
IInventory patternInv = ct.getInventoryByName( "pattern" );
|
||||
IInventory output = ct.getInventoryByName( "output" );
|
||||
crafting = ct.getInventoryByName( "crafting" );
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 3; x++)
|
||||
addSlotToContainer( craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
|
||||
|
||||
addSlotToContainer( craftSlot = new SlotPatternTerm( ip.player, mySrc, powerSrc, monitorable, crafting, patternInv, cOut, 110, -76 + 18, this, 2, this ) );
|
||||
craftSlot.IIcon = -1;
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
{
|
||||
addSlotToContainer( outputSlots[y] = new SlotPatternOutputs( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) );
|
||||
outputSlots[y].renderDisabled = false;
|
||||
outputSlots[y].IIcon = -1;
|
||||
}
|
||||
|
||||
addSlotToContainer( patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, invPlayer ) );
|
||||
addSlotToContainer( patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, invPlayer ) );
|
||||
|
||||
patternSlotOUT.setStackLimit( 1 );
|
||||
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
private void updateOrderOfOutputSlots()
|
||||
{
|
||||
if ( !craftingMode )
|
||||
{
|
||||
craftSlot.xDisplayPosition = -9000;
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
outputSlots[y].xDisplayPosition = outputSlots[y].defX;
|
||||
}
|
||||
else
|
||||
{
|
||||
craftSlot.xDisplayPosition = craftSlot.defX;
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
outputSlots[y].xDisplayPosition = -9000;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
super.putStackInSlot( par1, par2ItemStack );
|
||||
getAndUpdateOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack)
|
||||
{
|
||||
super.putStacksInSlots( par1ArrayOfItemStack );
|
||||
getAndUpdateOutput();
|
||||
}
|
||||
|
||||
public ItemStack getAndUpdateOutput()
|
||||
{
|
||||
InventoryCrafting ic = new InventoryCrafting( this, 3, 3 );
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++)
|
||||
ic.setInventorySlotContents( x, crafting.getStackInSlot( x ) );
|
||||
|
||||
ItemStack is = CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj );
|
||||
cOut.setInventorySlotContents( 0, is );
|
||||
return is;
|
||||
}
|
||||
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
if ( craftingMode != ct.isCraftingRecipe() )
|
||||
{
|
||||
craftingMode = ct.isCraftingRecipe();
|
||||
updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(String field, Object oldValue, Object newValue)
|
||||
{
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
|
||||
if ( field.equals( "craftingMode" ) )
|
||||
{
|
||||
getAndUpdateOutput();
|
||||
updateOrderOfOutputSlots();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void encode()
|
||||
{
|
||||
ItemStack output = patternSlotOUT.getStack();
|
||||
|
||||
ItemStack[] in = getInputs();
|
||||
ItemStack[] out = getOutputs();
|
||||
|
||||
// if theres no input, this would be silly.
|
||||
if ( in == null || out == null )
|
||||
return;
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if ( output != null && !isPattern( output ) )
|
||||
return;
|
||||
|
||||
// if nothing is there we should snag a new pattern.
|
||||
else if ( output == null )
|
||||
{
|
||||
output = patternSlotIN.getStack();
|
||||
if ( output == null || !isPattern( output ) )
|
||||
return; // no blanks.
|
||||
|
||||
// remove one, and clear the input slot.
|
||||
output.stackSize--;
|
||||
if ( output.stackSize == 0 )
|
||||
patternSlotIN.putStack( null );
|
||||
|
||||
// add a new encoded pattern.
|
||||
patternSlotOUT.putStack( output = AEApi.instance().items().itemEncodedPattern.stack( 1 ) );
|
||||
}
|
||||
|
||||
// encode the slot.
|
||||
NBTTagCompound encodedValue = new NBTTagCompound();
|
||||
|
||||
NBTTagList tagIn = new NBTTagList();
|
||||
NBTTagList tagOut = new NBTTagList();
|
||||
|
||||
for (ItemStack i : in)
|
||||
tagIn.appendTag( createItemTag( i ) );
|
||||
|
||||
for (ItemStack i : out)
|
||||
tagOut.appendTag( createItemTag( i ) );
|
||||
|
||||
encodedValue.setTag( "in", tagIn );
|
||||
encodedValue.setTag( "out", tagOut );
|
||||
encodedValue.setBoolean( "crafting", craftingMode );
|
||||
|
||||
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 < craftingSlots.length; x++)
|
||||
{
|
||||
input[x] = craftingSlots[x].getStack();
|
||||
if ( input[x] != null )
|
||||
hasValue = true;
|
||||
}
|
||||
|
||||
if ( hasValue )
|
||||
return input;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack[] getOutputs()
|
||||
{
|
||||
if ( craftingMode )
|
||||
{
|
||||
ItemStack out = getAndUpdateOutput();
|
||||
if ( out != null && out.stackSize > 0 )
|
||||
return new ItemStack[] { out };
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ItemStack> list = new ArrayList( 3 );
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < outputSlots.length; x++)
|
||||
{
|
||||
ItemStack out = outputSlots[x].getStack();
|
||||
if ( out != null && out.stackSize > 0 )
|
||||
{
|
||||
list.add( out );
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasValue )
|
||||
return list.toArray( new ItemStack[list.size()] );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPattern(ItemStack output)
|
||||
{
|
||||
if ( output == null )
|
||||
return false;
|
||||
|
||||
return AEApi.instance().items().itemEncodedPattern.sameAsStack( output ) || AEApi.instance().materials().materialBlankPattern.sameAsStack( output );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx)
|
||||
{
|
||||
if ( idx == 1 )
|
||||
return Platform.isServer() ? ct.isCraftingRecipe() == false : craftingMode == false;
|
||||
if ( idx == 2 )
|
||||
return Platform.isServer() ? ct.isCraftingRecipe() == true : craftingMode == true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void craftOrGetItem(PacketPatternSlot packetPatternSlot)
|
||||
{
|
||||
if ( packetPatternSlot.slotItem != null && cellInv != null )
|
||||
{
|
||||
IAEItemStack out = packetPatternSlot.slotItem.copy();
|
||||
|
||||
InventoryAdaptor inv = new AdaptorPlayerHand( getPlayerInv().player );
|
||||
InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( getPlayerInv().player, ForgeDirection.UNKNOWN );
|
||||
if ( packetPatternSlot.shift )
|
||||
inv = playerInv;
|
||||
|
||||
if ( inv.simulateAdd( out.getItemStack() ) != null )
|
||||
return;
|
||||
|
||||
IAEItemStack extracted = Platform.poweredExtraction( powerSrc, cellInv, out, mySrc );
|
||||
EntityPlayer p = getPlayerInv().player;
|
||||
|
||||
if ( extracted != null )
|
||||
{
|
||||
inv.addItems( extracted.getItemStack() );
|
||||
if ( p instanceof EntityPlayerMP )
|
||||
updateHeld( (EntityPlayerMP) p );
|
||||
detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
InventoryCrafting real = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
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 )
|
||||
return;
|
||||
|
||||
IMEMonitor<IAEItemStack> storage = ct.getItemInventory();
|
||||
IItemList<IAEItemStack> all = storage.getStorageList();
|
||||
|
||||
ItemStack is = r.getCraftingResult( ic );
|
||||
|
||||
if ( r != null && inv != null )
|
||||
{
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++)
|
||||
{
|
||||
if ( ic.getStackInSlot( x ) != null )
|
||||
{
|
||||
ItemStack pulled = Platform.extractItemsByRecipe( powerSrc, mySrc, storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all,
|
||||
Actionable.MODULATE, ItemViewCell.createFilter( getViewCells() ) );
|
||||
real.setInventorySlotContents( x, pulled );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj );
|
||||
|
||||
if ( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
|
||||
{
|
||||
SlotCrafting sc = new SlotCrafting( p, real, cOut, 0, 0, 0 );
|
||||
sc.onPickupFromSlot( p, is );
|
||||
|
||||
for (int x = 0; x < real.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) );
|
||||
if ( failed != null )
|
||||
p.dropPlayerItemWithRandomChoice( failed, false );
|
||||
}
|
||||
|
||||
inv.addItems( is );
|
||||
if ( p instanceof EntityPlayerMP )
|
||||
updateHeld( (EntityPlayerMP) p );
|
||||
detectAndSendChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < real.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack failed = real.getStackInSlot( x );
|
||||
if ( failed != null )
|
||||
{
|
||||
cellInv.injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( ct ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(Slot s)
|
||||
{
|
||||
if ( s == patternSlotOUT && Platform.isServer() )
|
||||
{
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||
|
||||
for (Object g : inventorySlots)
|
||||
{
|
||||
if ( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
|
||||
{
|
||||
Slot sri = (Slot) g;
|
||||
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
|
||||
}
|
||||
}
|
||||
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
|
||||
}
|
||||
detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
for (Slot s : craftingSlots)
|
||||
s.putStack( null );
|
||||
|
||||
for (Slot s : outputSlots)
|
||||
s.putStack( null );
|
||||
|
||||
detectAndSendChanges();
|
||||
getAndUpdateOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name)
|
||||
{
|
||||
return ct.getInventoryByName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerPriority extends AEBaseContainer
|
||||
{
|
||||
|
||||
IPriorityHost priHost;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiTextField textField;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setTextField(GuiTextField level)
|
||||
{
|
||||
textField = level;
|
||||
textField.setText( "" + PriorityValue );
|
||||
}
|
||||
|
||||
public ContainerPriority(InventoryPlayer ip, IPriorityHost te) {
|
||||
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
|
||||
priHost = te;
|
||||
}
|
||||
|
||||
@GuiSync(2)
|
||||
public long PriorityValue = -1;
|
||||
|
||||
public void setPriority(int newValue, EntityPlayer player)
|
||||
{
|
||||
priHost.setPriority( newValue );
|
||||
PriorityValue = newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.PriorityValue = priHost.getPriority();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(String field, Object oldValue, Object newValue)
|
||||
{
|
||||
if ( field.equals( "PriorityValue" ) )
|
||||
{
|
||||
if ( textField != null )
|
||||
textField.setText( "" + PriorityValue );
|
||||
}
|
||||
|
||||
super.onUpdate( field, oldValue, newValue );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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
|
||||
{
|
||||
|
||||
TileQuantumBridge myte;
|
||||
|
||||
public ContainerQNB(InventoryPlayer ip, TileQuantumBridge te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, te, 0, 80, 37, invPlayer )).setStackLimit( 1 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.QuartzKnifeOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngInventory, IInventory
|
||||
{
|
||||
|
||||
QuartzKnifeObj toolInv;
|
||||
|
||||
AppEngInternalInventory inSlot = new AppEngInternalInventory( this, 1 );
|
||||
SlotRestrictedInput metals;
|
||||
QuartzKnifeOutput output;
|
||||
String myName = "";
|
||||
|
||||
public void setName(String value)
|
||||
{
|
||||
myName = value;
|
||||
}
|
||||
|
||||
public ContainerQuartzKnife(InventoryPlayer ip, QuartzKnifeObj te) {
|
||||
super( ip, null, null );
|
||||
toolInv = te;
|
||||
|
||||
addSlotToContainer( metals = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.METAL_INGOTS, inSlot, 0, 94, 44, ip ) );
|
||||
addSlotToContainer( output = new QuartzKnifeOutput( this, 0, 134, 44, -1 ) );
|
||||
|
||||
lockPlayerInventorySlot( ip.currentItem );
|
||||
|
||||
bindPlayerInventory( ip, 0, 184 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
ItemStack currentItem = getPlayerInv().getCurrentItem();
|
||||
|
||||
if ( currentItem != toolInv.getItemStack() )
|
||||
{
|
||||
if ( currentItem != null )
|
||||
{
|
||||
if ( Platform.isSameItem( toolInv.getItemStack(), currentItem ) )
|
||||
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, toolInv.getItemStack() );
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
if ( inSlot.getStackInSlot( 0 ) != null )
|
||||
par1EntityPlayer.dropPlayerItemWithRandomChoice( inSlot.getStackInSlot( 0 ), false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1)
|
||||
{
|
||||
ItemStack input = inSlot.getStackInSlot( 0 );
|
||||
if ( input == null )
|
||||
return null;
|
||||
|
||||
if ( SlotRestrictedInput.isMetalIngot( input ) )
|
||||
{
|
||||
if ( myName.length() > 0 )
|
||||
{
|
||||
ItemStack name = AEApi.instance().materials().materialNamePress.stack( 1 );
|
||||
NBTTagCompound c = Platform.openNbtData( name );
|
||||
c.setString( "InscribeName", myName );
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int var1, int var2)
|
||||
{
|
||||
ItemStack is = getStackInSlot( 0 );
|
||||
if ( is != null )
|
||||
{
|
||||
if ( makePlate() )
|
||||
return is;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean makePlate()
|
||||
{
|
||||
if ( inSlot.decrStackSize( 0, 1 ) != null )
|
||||
{
|
||||
ItemStack item = toolInv.getItemStack();
|
||||
item.damageItem( 1, getPlayerInv().player );
|
||||
|
||||
if ( item.stackSize == 0 )
|
||||
{
|
||||
getPlayerInv().mainInventory[getPlayerInv().currentItem] = null;
|
||||
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( getPlayerInv().player, item ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int var1, ItemStack var2)
|
||||
{
|
||||
if ( var2 == null && Platform.isServer() )
|
||||
makePlate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "Quartz Knife Output";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack var2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.features.INetworkEncodable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
|
||||
public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppEngInventory
|
||||
{
|
||||
|
||||
SlotRestrictedInput configSlot;
|
||||
|
||||
AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory( this, 2 );
|
||||
|
||||
SlotRestrictedInput wirelessIn;
|
||||
SlotOutput wirelessOut;
|
||||
|
||||
TileSecurity securityBox;
|
||||
|
||||
public ContainerSecurity(InventoryPlayer ip, ITerminalHost monitorable) {
|
||||
super( ip, monitorable, false );
|
||||
|
||||
securityBox = (TileSecurity) monitorable;
|
||||
|
||||
addSlotToContainer( configSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, securityBox.configSlot, 0, 37, -33, ip ) );
|
||||
|
||||
addSlotToContainer( wirelessIn = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODEABLE_ITEM, wirelessEncoder, 0, 212, 10, ip ) );
|
||||
addSlotToContainer( wirelessOut = new SlotOutput( wirelessEncoder, 1, 212, 68, -1 ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
|
||||
@GuiSync(0)
|
||||
public int security = 0;
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
super.onContainerClosed( player );
|
||||
|
||||
if ( wirelessIn.getHasStack() )
|
||||
player.dropPlayerItemWithRandomChoice( wirelessIn.getStack(), false );
|
||||
|
||||
if ( wirelessOut.getHasStack() )
|
||||
player.dropPlayerItemWithRandomChoice( wirelessOut.getStack(), false );
|
||||
}
|
||||
|
||||
public void toggleSetting(String value, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
SecurityPermissions permission = SecurityPermissions.valueOf( value );
|
||||
|
||||
ItemStack a = configSlot.getStack();
|
||||
if ( a != null && a.getItem() instanceof IBiometricCard )
|
||||
{
|
||||
IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
if ( bc.hasPermission( a, permission ) )
|
||||
bc.removePermission( a, permission );
|
||||
else
|
||||
bc.addPermission( a, permission );
|
||||
}
|
||||
}
|
||||
catch (EnumConstantNotPresentException ex)
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.SECURITY, false );
|
||||
|
||||
security = 0;
|
||||
|
||||
ItemStack a = configSlot.getStack();
|
||||
if ( a != null && a.getItem() instanceof IBiometricCard )
|
||||
{
|
||||
IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
|
||||
for (SecurityPermissions sp : bc.getPermissions( a ))
|
||||
security = security | (1 << sp.ordinal());
|
||||
}
|
||||
|
||||
updatePowerStatus();
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges()
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
||||
{
|
||||
if ( !wirelessOut.getHasStack() )
|
||||
{
|
||||
if ( wirelessIn.getHasStack() )
|
||||
{
|
||||
ItemStack term = wirelessIn.getStack().copy();
|
||||
INetworkEncodable netEncodeable = null;
|
||||
|
||||
if ( term.getItem() instanceof INetworkEncodable )
|
||||
netEncodeable = (INetworkEncodable) term.getItem();
|
||||
|
||||
IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term );
|
||||
if ( wTermHandler != null )
|
||||
netEncodeable = wTermHandler;
|
||||
|
||||
if ( netEncodeable != null )
|
||||
{
|
||||
netEncodeable.setEncryptionKey( term, "" + securityBox.securityKey, "" );
|
||||
|
||||
wirelessIn.putStack( null );
|
||||
wirelessOut.putStack( term );
|
||||
|
||||
// update the two slots in question...
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get( i );
|
||||
((EntityPlayerMP) icrafting).sendSlotContents( this, wirelessIn.slotNumber, wirelessIn.getStack() );
|
||||
((EntityPlayerMP) icrafting).sendSlotContents( this, wirelessOut.slotNumber, wirelessOut.getStack() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import invtweaks.api.container.ChestContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
@ChestContainer
|
||||
public class ContainerSkyChest extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileSkyChest myte;
|
||||
|
||||
public ContainerSkyChest(InventoryPlayer ip, TileSkyChest te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
for (int y = 0; y < 4; y++)
|
||||
{
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
addSlotToContainer( new SlotNormal( myte, y * 9 + x, 8 + 18 * x, 24 + 18 * y ) );
|
||||
}
|
||||
}
|
||||
|
||||
myte.openInventory();
|
||||
|
||||
bindPlayerInventory( ip, 0, 195 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
super.onContainerClosed( par1EntityPlayer );
|
||||
myte.closeInventory();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerSpatialIOPort extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileSpatialIOPort myte;
|
||||
|
||||
IGrid network;
|
||||
|
||||
@GuiSync(0)
|
||||
public long currentPower;
|
||||
@GuiSync(1)
|
||||
public long maxPower;
|
||||
@GuiSync(2)
|
||||
public long reqPower;
|
||||
@GuiSync(3)
|
||||
public long eff;
|
||||
|
||||
int delay = 40;
|
||||
|
||||
public ContainerSpatialIOPort(InventoryPlayer ip, TileSpatialIOPort te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
if ( Platform.isServer() )
|
||||
network = te.getGridNode( ForgeDirection.UNKNOWN ).getGrid();
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, te, 0, 52, 48, invPlayer ) );
|
||||
addSlotToContainer( new SlotOutput( te, 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 197 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
delay++;
|
||||
if ( delay > 15 && network != null )
|
||||
{
|
||||
delay = 0;
|
||||
|
||||
IEnergyGrid eg = network.getCache( IEnergyGrid.class );
|
||||
ISpatialCache sc = network.getCache( ISpatialCache.class );
|
||||
if ( eg != null )
|
||||
{
|
||||
currentPower = (long) (100.0 * eg.getStoredPower());
|
||||
maxPower = (long) (100.0 * eg.getMaxStoredPower());
|
||||
reqPower = (long) (100.0 * sc.requiredPower());
|
||||
eff = (long) (100.0f * sc.currentEfficiency());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
public class ContainerStorageBus extends ContainerUpgradeable
|
||||
{
|
||||
|
||||
PartStorageBus storageBus;
|
||||
|
||||
@GuiSync(3)
|
||||
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
|
||||
|
||||
@GuiSync(4)
|
||||
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
|
||||
|
||||
public ContainerStorageBus(InventoryPlayer ip, PartStorageBus te) {
|
||||
super( ip, te );
|
||||
storageBus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getHeight()
|
||||
{
|
||||
return 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx)
|
||||
{
|
||||
int upgrades = myte.getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
return upgrades > idx;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupConfig()
|
||||
{
|
||||
int xo = 8;
|
||||
int yo = 23 + 6;
|
||||
|
||||
IInventory config = myte.getInventoryByName( "config" );
|
||||
for (int y = 0; y < 7; y++)
|
||||
{
|
||||
for (int x = 0; x < 9; x++)
|
||||
{
|
||||
if ( y < 2 )
|
||||
addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) );
|
||||
else
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 4, 187, 8 + 18 * 4, invPlayer )).setNotDraggable() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.fzMode = (FuzzyMode) this.myte.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||
this.rwMode = (AccessRestriction) this.myte.getConfigManager().getSetting( Settings.ACCESS );
|
||||
this.storageFilter = (StorageFilter) this.myte.getConfigManager().getSetting( Settings.STORAGE_FILTER );
|
||||
}
|
||||
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
inv.setInventorySlotContents( x, null );
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
public void partition()
|
||||
{
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
|
||||
IMEInventory<IAEItemStack> cellInv = storageBus.getInternalHandler();
|
||||
|
||||
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() && isSlotEnabled( (x / 9) - 2 ) )
|
||||
{
|
||||
ItemStack g = i.next().getItemStack();
|
||||
g.stackSize = 1;
|
||||
inv.setInventorySlotContents( x, g );
|
||||
}
|
||||
else
|
||||
inv.setInventorySlotContents( x, null );
|
||||
}
|
||||
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.items.contents.NetworkToolViewer;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSlotHost
|
||||
{
|
||||
|
||||
IUpgradeableHost myte;
|
||||
|
||||
int tbslot;
|
||||
NetworkToolViewer tbinv;
|
||||
|
||||
public ContainerUpgradeable(InventoryPlayer ip, IUpgradeableHost te) {
|
||||
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
|
||||
myte = te;
|
||||
|
||||
World w = null;
|
||||
int xCoor = 0, yCoor = 0, zCoor = 0;
|
||||
|
||||
if ( te instanceof TileEntity )
|
||||
{
|
||||
TileEntity myTile = (TileEntity) te;
|
||||
w = myTile.getWorldObj();
|
||||
xCoor = myTile.xCoord;
|
||||
yCoor = myTile.yCoord;
|
||||
zCoor = myTile.zCoord;
|
||||
}
|
||||
|
||||
if ( te instanceof IPart )
|
||||
{
|
||||
IUpgradeableHost myTile = (IUpgradeableHost) te;
|
||||
TileEntity mk = myTile.getTile();
|
||||
w = mk.getWorldObj();
|
||||
xCoor = mk.xCoord;
|
||||
yCoor = mk.yCoord;
|
||||
zCoor = mk.zCoord;
|
||||
}
|
||||
|
||||
IInventory pi = getPlayerInv();
|
||||
for (int x = 0; x < pi.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack pii = pi.getStackInSlot( x );
|
||||
if ( pii != null && pii.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
lockPlayerInventorySlot( x );
|
||||
tbslot = x;
|
||||
tbinv = (NetworkToolViewer) ((ToolNetworkTool) pii.getItem()).getGuiObject( pii, w, xCoor, yCoor, zCoor );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasToolbox() )
|
||||
{
|
||||
for (int v = 0; v < 3; v++)
|
||||
for (int u = 0; u < 3; u++)
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, tbinv, u + v * 3, 186 + u * 18, getHeight() - 82 + v * 18,
|
||||
invPlayer )).setPlayerSide() );
|
||||
}
|
||||
|
||||
setupConfig();
|
||||
|
||||
bindPlayerInventory( ip, 0, getHeight() - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
protected void setupUpgrades()
|
||||
{
|
||||
IInventory upgrades = myte.getInventoryByName( "upgrades" );
|
||||
if ( availableUpgrades() > 0 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8 + 18 * 0, invPlayer )).setNotDraggable() );
|
||||
if ( availableUpgrades() > 1 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18 * 1, invPlayer )).setNotDraggable() );
|
||||
if ( availableUpgrades() > 2 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, invPlayer )).setNotDraggable() );
|
||||
if ( availableUpgrades() > 3 )
|
||||
addSlotToContainer( (new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, invPlayer )).setNotDraggable() );
|
||||
}
|
||||
|
||||
protected void setupConfig()
|
||||
{
|
||||
int x = 80;
|
||||
int y = 40;
|
||||
setupUpgrades();
|
||||
|
||||
IInventory inv = myte.getInventoryByName( "config" );
|
||||
addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
|
||||
|
||||
if ( supportCapacity() )
|
||||
{
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
|
||||
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
|
||||
addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected int getHeight()
|
||||
{
|
||||
return 184;
|
||||
}
|
||||
|
||||
public int availableUpgrades()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
protected boolean supportCapacity()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@GuiSync(0)
|
||||
public RedstoneMode rsMode = RedstoneMode.IGNORE;
|
||||
|
||||
@GuiSync(1)
|
||||
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
|
||||
|
||||
@GuiSync(5)
|
||||
public YesNo cMode = YesNo.NO;
|
||||
|
||||
public void checkToolbox()
|
||||
{
|
||||
if ( hasToolbox() )
|
||||
{
|
||||
ItemStack currentItem = getPlayerInv().getStackInSlot( tbslot );
|
||||
|
||||
if ( currentItem != tbinv.getItemStack() )
|
||||
{
|
||||
if ( currentItem != null )
|
||||
{
|
||||
if ( Platform.isSameItem( tbinv.getItemStack(), currentItem ) )
|
||||
getPlayerInv().setInventorySlotContents( tbslot, tbinv.getItemStack() );
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
isContainerValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
verifyPermissions( SecurityPermissions.BUILD, false );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
IConfigManager cm = this.myte.getConfigManager();
|
||||
loadSettingsFromHost( cm );
|
||||
}
|
||||
|
||||
checkToolbox();
|
||||
|
||||
for (Object o : inventorySlots)
|
||||
{
|
||||
if ( o instanceof OptionalSlotFake )
|
||||
{
|
||||
OptionalSlotFake fs = (OptionalSlotFake) o;
|
||||
if ( !fs.isEnabled() && fs.getDisplayStack() != null )
|
||||
((OptionalSlotFake) fs).clearStack();
|
||||
}
|
||||
}
|
||||
|
||||
standardDetectAndSendChanges();
|
||||
}
|
||||
|
||||
protected void loadSettingsFromHost(IConfigManager cm)
|
||||
{
|
||||
this.fzMode = (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE );
|
||||
this.rsMode = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
if ( myte instanceof PartExportBus )
|
||||
this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY );
|
||||
}
|
||||
|
||||
protected void standardDetectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
public boolean hasToolbox()
|
||||
{
|
||||
return tbinv != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx)
|
||||
{
|
||||
int upgrades = myte.getInstalledUpgrades( Upgrades.CAPACITY );
|
||||
|
||||
if ( idx == 1 && upgrades > 0 )
|
||||
return true;
|
||||
if ( idx == 2 && upgrades > 1 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerVibrationChamber extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileVibrationChamber myte;
|
||||
|
||||
public ContainerVibrationChamber(InventoryPlayer ip, TileVibrationChamber te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.FUEL, te, 0, 80, 37, invPlayer ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
public int aePerTick = 5;
|
||||
|
||||
@GuiSync(0)
|
||||
public int burnProgress = 0;
|
||||
|
||||
@GuiSync(1)
|
||||
public int burnSpeed = 100;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
this.burnProgress = (int) (this.myte.maxBurnTime <= 0 ? 0 : 12 * this.myte.burnTime / this.myte.maxBurnTime);
|
||||
this.burnSpeed = this.myte.burnSpeed;
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
public class ContainerWireless extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileWireless myte;
|
||||
|
||||
@GuiSync(1)
|
||||
public long range = 0;
|
||||
|
||||
@GuiSync(2)
|
||||
public long drain = 0;
|
||||
|
||||
SlotRestrictedInput boosterSlot;
|
||||
|
||||
public ContainerWireless(InventoryPlayer ip, TileWireless te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
|
||||
addSlotToContainer( boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, myte, 0, 80, 47, invPlayer ) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
int boosters = boosterSlot.getStack() == null ? 0 : boosterSlot.getStack().stackSize;
|
||||
|
||||
range = (long) (10 * AEConfig.instance.wireless_getMaxRange( boosters ));
|
||||
drain = (long) (100 * AEConfig.instance.wireless_getPowerDrain( boosters ));
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerWirelessTerm extends ContainerMEPortableCell
|
||||
{
|
||||
|
||||
WirelessTerminalGuiObject wtgo;
|
||||
|
||||
public ContainerWirelessTerm(InventoryPlayer ip, WirelessTerminalGuiObject monitorable) {
|
||||
super( ip, monitorable );
|
||||
wtgo = monitorable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if ( !wtgo.rangeCheck() )
|
||||
{
|
||||
if ( Platform.isServer() && isContainerValid )
|
||||
getPlayerInv().player.addChatMessage( PlayerMessages.OutOfRange.get() );
|
||||
|
||||
isContainerValid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
powerMultiplier = AEConfig.instance.wireless_getDrainRate( wtgo.getRange() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||
{
|
||||
|
||||
ICraftingCPU cpu;
|
||||
|
||||
long size;
|
||||
int processors;
|
||||
|
||||
public String myName;
|
||||
|
||||
public CraftingCPURecord(long size, int proc, ICraftingCPU server) {
|
||||
this.size = size;
|
||||
this.processors = proc;
|
||||
this.cpu = server;
|
||||
myName = server.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CraftingCPURecord o)
|
||||
{
|
||||
int a = ItemSorters.compareLong( o.processors, processors );
|
||||
if ( a != 0 )
|
||||
return a;
|
||||
return ItemSorters.compareLong( o.size, size );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user