AE2 First Commit, the dawn of 1.7 hast arrived.

This commit is contained in:
algorithmx2
2013-12-27 16:59:59 -06:00
commit e9acdcbee2
468 changed files with 47440 additions and 0 deletions
+434
View File
@@ -0,0 +1,434 @@
package appeng.container;
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.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.InternalSlotME;
import appeng.client.me.SlotME;
import appeng.container.slot.ISlotPlayerSide;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.container.slot.SlotDisabled;
import appeng.container.slot.SlotFake;
import appeng.container.slot.SlotInaccessable;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.helpers.InventoryAction;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
public abstract class AEBaseContainer extends Container
{
final InventoryPlayer invPlayer;
final TileEntity tileEntity;
protected IMEInventoryHandler<IAEItemStack> cellInv;
protected IEnergySource powerSrc;
public AEBaseContainer(InventoryPlayer ip, TileEntity te) {
invPlayer = ip;
tileEntity = te;
}
public TileEntity getTileEntity()
{
return tileEntity;
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
if ( tileEntity instanceof IInventory )
return ((IInventory) tileEntity).isUseableByPlayer( entityplayer );
return true;
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p, int idx)
{
if ( Platform.isClient() )
return null;
boolean hasMETiles = false;
for (Object is : this.inventorySlots)
{
if ( is instanceof InternalSlotME )
{
hasMETiles = true;
break;
}
}
if ( hasMETiles && Platform.isClient() )
{
return null;
}
ItemStack tis = null;
Slot clickSlot = (Slot) this.inventorySlots.get( idx );
if ( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessable )
return null;
if ( clickSlot != null && clickSlot.getHasStack() )
{
tis = clickSlot.getStack();
if ( tis == null )
return null;
List<Slot> selectedSlots = new ArrayList<Slot>();
/**
* Gather a list of valid destinations.
*/
if ( clickSlot instanceof ISlotPlayerSide )
{
tis = shiftStoreItem( tis );
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
{
Slot cs = (Slot) this.inventorySlots.get( x );
if ( !(cs instanceof ISlotPlayerSide) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
{
if ( cs.isItemValid( tis ) )
selectedSlots.add( cs );
}
}
}
else
{
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
{
Slot cs = (Slot) this.inventorySlots.get( x );
if ( (cs instanceof ISlotPlayerSide) && !(cs instanceof SlotFake) && !(cs instanceof SlotCraftingMatrix) )
{
if ( cs.isItemValid( tis ) )
selectedSlots.add( cs );
}
}
}
/**
* Handle Fake Slot Shift clicking.
*/
if ( selectedSlots.isEmpty() && clickSlot instanceof ISlotPlayerSide )
{
if ( tis != null )
{
// target slots in the container...
for (int x = 0; x < this.inventorySlots.size(); x++)
{
Slot cs = (Slot) this.inventorySlots.get( x );
ItemStack dest = cs.getStack();
if ( !(cs instanceof ISlotPlayerSide) && cs instanceof SlotFake )
{
if ( Platform.isSameItem( dest, tis ) )
return null;
else if ( dest == null )
{
cs.putStack( tis != null ? tis.copy() : null );
cs.onSlotChanged();
updateSlot( cs );
return null;
}
}
}
}
}
if ( tis != null )
{
// find partials..
for (Slot d : selectedSlots)
{
if ( d instanceof SlotDisabled || d instanceof SlotME )
continue;
if ( d.isItemValid( tis ) && tis != null )
{
if ( d.getHasStack() )
{
ItemStack t = d.getStack();
if ( tis != null && Platform.isSameItem( tis, t ) ) // t.isItemEqual(tis))
{
int maxSize = t.getMaxStackSize();
if ( maxSize > d.getSlotStackLimit() )
maxSize = d.getSlotStackLimit();
int placeAble = maxSize - t.stackSize;
if ( tis.stackSize < placeAble )
{
placeAble = tis.stackSize;
}
t.stackSize += placeAble;
tis.stackSize -= placeAble;
if ( tis.stackSize <= 0 )
{
clickSlot.putStack( null );
d.onSlotChanged();
// if ( hasMETiles ) updateClient();
updateSlot( clickSlot );
updateSlot( d );
return null;
}
else
updateSlot( d );
}
}
}
}
// any match..
for (Slot d : selectedSlots)
{
if ( d instanceof SlotDisabled || d instanceof SlotME )
continue;
if ( d.isItemValid( tis ) && tis != null )
{
if ( d.getHasStack() )
{
ItemStack t = d.getStack();
if ( tis != null && Platform.isSameItem( t, tis ) )
{
int maxSize = t.getMaxStackSize();
if ( d.getSlotStackLimit() < maxSize )
maxSize = d.getSlotStackLimit();
int placeAble = maxSize - t.stackSize;
if ( tis.stackSize < placeAble )
{
placeAble = tis.stackSize;
}
t.stackSize += placeAble;
tis.stackSize -= placeAble;
if ( tis.stackSize <= 0 )
{
clickSlot.putStack( null );
d.onSlotChanged();
// if ( worldEntity != null )
// worldEntity.onInventoryChanged();
// if ( hasMETiles ) updateClient();
updateSlot( clickSlot );
updateSlot( d );
return null;
}
else
updateSlot( d );
}
}
else
{
int maxSize = tis.getMaxStackSize();
if ( maxSize > d.getSlotStackLimit() )
maxSize = d.getSlotStackLimit();
ItemStack tmp = tis.copy();
if ( tmp.stackSize > maxSize )
tmp.stackSize = maxSize;
tis.stackSize -= tmp.stackSize;
d.putStack( tmp );
if ( tis.stackSize <= 0 )
{
clickSlot.putStack( null );
d.onSlotChanged();
// if ( worldEntity != null )
// worldEntity.onInventoryChanged();
// if ( hasMETiles ) updateClient();
updateSlot( clickSlot );
updateSlot( d );
return null;
}
else
updateSlot( d );
}
}
}
}
clickSlot.putStack( tis != null ? tis.copy() : null );
}
updateSlot( clickSlot );
return null;
}
private void updateSlot(Slot clickSlot)
{
detectAndSendChanges();
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer, int offset_x, int offset_y)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer( new SlotPlayerInv( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) );
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
}
}
public ItemStack shiftStoreItem(ItemStack input)
{
if ( powerSrc == null || cellInv == null )
return input;
IAEItemStack ais = Platform.poweredInsert( powerSrc, cellInv, AEApi.instance().storage().createItemStack( input ) );
if ( ais == null )
return null;
return ais.getItemStack();
}
public void doAction(EntityPlayerMP player, InventoryAction action, int slot, IAEItemStack slotItem)
{
/*
* boolean isValidSlot = true;
*
* if ( slot < 0 || slot >= inventorySlots.size() ) isValidSlot = false;
*/
switch (action)
{
case SHIFT_CLICK:
if ( powerSrc == null || cellInv == null )
return;
if ( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
ItemStack myItem = ais.getItemStack();
ais.setStackSize( myItem.getMaxStackSize() );
InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player.inventory, ForgeDirection.UNKNOWN );
myItem.stackSize = (int) ais.getStackSize();
myItem = adp.simulateAdd( myItem );
if ( myItem != null )
ais.setStackSize( ais.getStackSize() - myItem.stackSize );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais );
if ( ais != null )
adp.addItems( ais.getItemStack() );
}
break;
case PICKUP_OR_SETDOWN:
if ( powerSrc == null || cellInv == null )
return;
if ( player.inventory.getItemStack() == null )
{
if ( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
ais.setStackSize( ais.getItemStack().getMaxStackSize() );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais );
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else
player.inventory.setItemStack( null );
player.updateHeldItem();
}
}
else
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
ais = Platform.poweredInsert( powerSrc, cellInv, ais );
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else
player.inventory.setItemStack( null );
player.updateHeldItem();
}
break;
case SPLIT_OR_PLACESINGLE:
if ( powerSrc == null || cellInv == null )
return;
if ( player.inventory.getItemStack() == null )
{
if ( slotItem != null )
{
IAEItemStack ais = slotItem.copy();
long stackSize = Math.min( ais.getItemStack().getMaxStackSize(), ais.getStackSize() );
ais.setStackSize( (stackSize + 1) >> 1 );
ais = Platform.poweredExtraction( powerSrc, cellInv, ais );
if ( ais != null )
player.inventory.setItemStack( ais.getItemStack() );
else
player.inventory.setItemStack( null );
player.updateHeldItem();
}
}
else
{
IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() );
ais.setStackSize( 1 );
ais = Platform.poweredInsert( powerSrc, cellInv, ais );
if ( ais == null )
{
ItemStack is = player.inventory.getItemStack();
is.stackSize--;
if ( is.stackSize <= 0 )
player.inventory.setItemStack( null );
player.updateHeldItem();
}
}
break;
case CREATIVE_DUPLICATE:
if ( player.capabilities.isCreativeMode && slotItem != null )
{
ItemStack is = slotItem.getItemStack();
is.stackSize = is.getMaxStackSize();
player.inventory.setItemStack( is );
player.updateHeldItem();
}
break;
case MOVE_REGION:
break;
default:
break;
}
}
}
+18
View File
@@ -0,0 +1,18 @@
package appeng.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
/*
* Totaly useless container that does nothing.
*/
public class ContainerNull extends Container
{
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return false;
}
}
@@ -0,0 +1,23 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.storage.TileChest;
public class ContainerChest extends AEBaseContainer
{
TileChest myte;
public ContainerChest(InventoryPlayer ip, TileChest te) {
super( ip, te );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, myte, 1, 80, 37 ) );
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
}
}
@@ -0,0 +1,106 @@
package appeng.container.implementations;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import appeng.api.config.CondenserOuput;
import appeng.api.config.Settings;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.misc.TileCondenser;
import appeng.util.Platform;
import buildcraft.core.gui.slots.SlotOutput;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerCondenser extends AEBaseContainer
{
TileCondenser myte;
public ContainerCondenser(InventoryPlayer ip, TileCondenser te) {
super( ip, te );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.TRASH, te, 0, 51, 52 ) );
addSlotToContainer( new SlotOutput( te, 1, 105, 52 ) );
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.STORAGE_COMPONENT, te.getInternalInventory(), 2, 101, 26 )).setStackLimit( 1 ) );
bindPlayerInventory( ip, 0, 197 - /* height of playerinventory */82 );
}
public int requiredEnergy = 0;
public int storedPower = 0;
public CondenserOuput output = CondenserOuput.TRASH;
@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 );
for (int i = 0; i < this.crafters.size(); ++i)
{
boolean changed = false;
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.requiredEnergy != maxDisplay )
{
icrafting.sendProgressBarUpdate( this, 0, (int) maxDisplay );
changed = true;
}
if ( this.storedPower != this.myte.storedPower )
{
icrafting.sendProgressBarUpdate( this, 1, (int) this.myte.storedPower );
changed = true;
}
if ( this.output != this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT ) )
{
icrafting.sendProgressBarUpdate( this, 2, (int) this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT ).ordinal() );
changed = true;
}
if ( changed )
{
// if the bars changed an item was probably made, so just send shit!
((EntityPlayerMP) icrafting).playerInventoryBeingManipulated = false;
}
}
this.requiredEnergy = (int) maxDisplay;
this.storedPower = (int) this.myte.storedPower;
this.output = (CondenserOuput) this.myte.getConfigManager().getSetting( Settings.CONDENSER_OUTPUT );
}
super.detectAndSendChanges();
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int idx, int value)
{
if ( idx == 0 )
{
this.requiredEnergy = value;
}
if ( idx == 1 )
{
this.storedPower = value;
}
if ( idx == 2 )
{
this.output = CondenserOuput.values()[value];
}
}
}
@@ -0,0 +1,27 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.storage.TileDrive;
public class ContainerDrive extends AEBaseContainer
{
TileDrive myte;
public ContainerDrive(InventoryPlayer ip, TileDrive te) {
super( ip, te );
myte = te;
for (int y = 0; y < 5; y++)
for (int x = 0; x < 2; x++)
{
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.STORAGE_CELLS, te, x + y * 2, 71 + x * 18, 14 + y * 18 ) );
}
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
}
}
@@ -0,0 +1,33 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotInaccessable;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.grindstone.TileGrinder;
public class ContainerGrinder extends AEBaseContainer
{
TileGrinder myte;
public ContainerGrinder(InventoryPlayer ip, TileGrinder te) {
super( ip, te );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ORE, te, 0, 12, 17 ) );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ORE, te, 1, 12 + 18, 17 ) );
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ORE, te, 2, 12 + 36, 17 ) );
addSlotToContainer( new SlotInaccessable( 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,23 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.parts.automation.PartLevelEmitter;
public class ContainerLevelEmitter extends AEBaseContainer
{
PartLevelEmitter myte;
public ContainerLevelEmitter(InventoryPlayer ip, PartLevelEmitter te) {
super( ip, te.getHost().getTile() );
myte = te;
// addSlotToContainer( new SlotRestrictedInput(
// PlaceableItemType.WIRELESS_TERMINAL, te, 0, 71, 14 ) );
// addSlotToContainer( new SlotOutput( te, 1, 71, 14,
// PlaceableItemType.WIRELESS_TERMINAL.icon ) );
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
}
}
@@ -0,0 +1,166 @@
package appeng.container.implementations;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import appeng.api.implementations.IMEChest;
import appeng.api.implementations.IStorageMonitorable;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMontorHandlerReciever;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.util.Platform;
import appeng.util.item.ItemList;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
public class ContainerMEMonitorable extends AEBaseContainer implements IMEMontorHandlerReciever<IAEItemStack>
{
final IMEMonitor<IAEItemStack> monitor;
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>();
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null );
if ( Platform.isServer() )
{
monitor = montiorable.getItemInventory();
monitor.addListener( this, null );
cellInv = monitor;
if ( montiorable instanceof IMEChest )
powerSrc = (IMEChest) montiorable;
else if ( montiorable instanceof IGridHost )
{
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
if ( node != null )
{
IGrid g = node.getGrid();
if ( g != null )
powerSrc = g.getCache( IEnergyGrid.class );
}
}
}
else
monitor = null;
bindPlayerInventory( ip, 0, 0 );
}
@Override
public void detectAndSendChanges()
{
if ( Platform.isServer() )
{
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() )
{
Packet p = piu.getPacket();
items.resetStatus();
for (Object c : this.crafters)
{
if ( c instanceof Player )
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
super.detectAndSendChanges();
}
}
@Override
public void addCraftingToCrafters(ICrafting c)
{
super.addCraftingToCrafters( c );
if ( Platform.isServer() && c instanceof Player )
{
try
{
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
IItemList<IAEItemStack> monitorCache = monitor.getStorageList();
for (IAEItemStack send : monitorCache)
{
piu.appendItem( send );
}
Packet p = piu.getPacket();
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
@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.removeListener( this );
}
@Override
public void postChange(IAEItemStack change)
{
items.add( change );
}
@Override
public boolean isValid(Object verificationToken)
{
return true;
}
}
@@ -0,0 +1,24 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.tileentity.TileEntity;
import appeng.container.AEBaseContainer;
public class ContainerNetworkStatus extends AEBaseContainer
{
TileEntity myte;
public ContainerNetworkStatus(InventoryPlayer ip, TileEntity te) {
super( ip, (TileEntity) te );
myte = te;
// addSlotToContainer( new SlotRestrictedInput(
// PlaceableItemType.WIRELESS_TERMINAL, te, 0, 71, 14 ) );
// addSlotToContainer( new SlotOutput( te, 1, 71, 14,
// PlaceableItemType.WIRELESS_TERMINAL.icon ) );
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
}
}
@@ -0,0 +1,25 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.spatial.TileSpatialIOPort;
public class ContainerSpatialIOPort extends AEBaseContainer
{
TileSpatialIOPort myte;
public ContainerSpatialIOPort(InventoryPlayer ip, TileSpatialIOPort te) {
super( ip, te );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.SPATIAL_STORAGE_CELLS, te, 0, 71, 14 ) );
addSlotToContainer( new SlotOutput( te, 1, 71, 14, PlaceableItemType.SPATIAL_STORAGE_CELLS.icon ) );
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
}
}
@@ -0,0 +1,78 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.core.AELog;
import appeng.tile.misc.TileVibrationChamber;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ContainerVibrationChamber extends AEBaseContainer
{
TileVibrationChamber myte;
public ContainerVibrationChamber(InventoryPlayer ip, TileVibrationChamber te) {
super( ip, te );
myte = te;
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.FUEL, te, 0, 80, 37 ) );
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
}
public int aePerTick = 5;
public int burnSpeed = 100;
public int burnProgress = 0;
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if ( Platform.isServer() )
{
int burnProgress = (int) (this.myte.maxBurnTime <= 0 ? 0 : 12 * this.myte.burnTime / this.myte.maxBurnTime);
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
if ( this.burnProgress != burnProgress )
{
icrafting.sendProgressBarUpdate( this, 0, (int) burnProgress );
}
if ( this.burnSpeed != this.myte.burnSpeed )
{
AELog.info( "" + this.myte.burnSpeed );
icrafting.sendProgressBarUpdate( this, 1, this.myte.burnSpeed );
}
}
this.burnProgress = burnProgress;
this.burnSpeed = this.myte.burnSpeed;
}
}
@Override
@SideOnly(Side.CLIENT)
public void updateProgressBar(int idx, int value)
{
if ( idx == 0 )
{
this.burnProgress = value;
}
if ( idx == 1 )
{
this.burnSpeed = value;
}
}
}
+15
View File
@@ -0,0 +1,15 @@
package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.SlotCrafting;
public class AppEngCraftingSlot extends SlotCrafting
{
public AppEngCraftingSlot(EntityPlayer par1EntityPlayer, IInventory par2iInventory, IInventory par3iInventory, int par4,
int par5, int par6) {
super( par1EntityPlayer, par2iInventory, par3iInventory, par4, par5, par6 );
}
}
+71
View File
@@ -0,0 +1,71 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class AppEngSlot extends Slot
{
public enum hasCalculatedValidness
{
NotAvailable, Valid, Invalid
};
public int icon = -1;
public hasCalculatedValidness isValid;
public int defX, defY;
public String getTooltip()
{
return null;
}
@Override
public void onSlotChanged()
{
super.onSlotChanged();
isValid = hasCalculatedValidness.NotAvailable;
}
public AppEngSlot(IInventory inv, int idx, int x, int y) {
super( inv, idx, x, y );
defX = x;
defY = y;
isValid = hasCalculatedValidness.NotAvailable;
}
public boolean isDisplay = false;
@Override
public ItemStack getStack()
{
if ( isDisplay )
{
isDisplay = false;
return getDisplayStack();
}
return super.getStack();
}
public ItemStack getDisplayStack()
{
return super.getStack();
}
public float getOpacityOfIcon()
{
return 0.4f;
}
public boolean renderIconWithItem()
{
return false;
}
public int getIcon()
{
return icon;
}
}
+8
View File
@@ -0,0 +1,8 @@
package appeng.container.slot;
// anything that implements this interface is treated as being part of the players interface, rather then the chests...
public interface ISlotPlayerSide
{
}
+80
View File
@@ -0,0 +1,80 @@
package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class NullSlot extends Slot
{
public NullSlot() {
super( null, 0, 0, 0 );
}
@Override
public void onSlotChange(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
}
@Override
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
@Override
public ItemStack getStack()
{
return null;
}
@Override
public void putStack(ItemStack par1ItemStack)
{
}
@Override
public void onSlotChanged()
{
}
@Override
public int getSlotStackLimit()
{
return 0;
}
@Override
public ItemStack decrStackSize(int par1)
{
return null;
}
@Override
public boolean isSlotInInventory(IInventory par1IInventory, int par2)
{
return false;
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return false;
}
@Override
public int getSlotIndex()
{
return 0;
}
}
+12
View File
@@ -0,0 +1,12 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
public class SlotCraftingMatrix extends AppEngSlot
{
public SlotCraftingMatrix(IInventory par1iInventory, int par2, int par3, int par4) {
super( par1iInventory, par2, par3, par4 );
}
}
+25
View File
@@ -0,0 +1,25 @@
package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotDisabled extends AppEngSlot
{
public SlotDisabled(IInventory par1iInventory, int slotIndex, int x, int y) {
super( par1iInventory, slotIndex, x, y );
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return false;
}
}
+85
View File
@@ -0,0 +1,85 @@
package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.util.Platform;
public class SlotFake extends AppEngSlot
{
int invSlot;
public SlotFake(IInventory inv, int idx, int x, int y) {
super( inv, idx, x, y );
invSlot = idx;
}
public void addToInv(ItemStack is)
{
if ( is != null )
{
ItemStack current = this.inventory.getStackInSlot( invSlot );
if ( current != null && Platform.isSameItem( current, is ) )
{
current.stackSize += is.stackSize;
if ( current.stackSize > inventory.getInventoryStackLimit() )
current.stackSize = inventory.getInventoryStackLimit();
} else
{
current = is.copy();
if ( current.stackSize > inventory.getInventoryStackLimit() )
current.stackSize = inventory.getInventoryStackLimit();
this.inventory.setInventorySlotContents( invSlot, current );
}
} else
{
this.inventory.setInventorySlotContents( invSlot, null );
}
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return false;
}
@Override
public ItemStack decrStackSize(int par1)
{
ItemStack current = this.inventory.getStackInSlot( invSlot );
if ( current != null )
{
current.stackSize--;
if ( current.stackSize <= 0 )
{
this.inventory.setInventorySlotContents( invSlot, null );
}
}
return null;
}
@Override
public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack)
{
}
@Override
public void putStack(ItemStack par1ItemStack)
{
this.inventory.setInventorySlotContents( invSlot, par1ItemStack );
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return true;
}
}
+34
View File
@@ -0,0 +1,34 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
public class SlotFakeBlacklist extends SlotFakeTypeOnly
{
public SlotFakeBlacklist(IInventory inv, int idx, int x, int y) {
super( inv, idx, x, y );
}
@Override
public boolean renderIconWithItem()
{
return true;
}
@Override
public float getOpacityOfIcon()
{
return 0.8f;
}
@Override
public int getIcon()
{
if ( getHasStack() )
{
return getStack().stackSize > 0 ? 16 + 14 : 14;
}
return -1;
}
}
+39
View File
@@ -0,0 +1,39 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotFakeTypeOnly extends SlotFake
{
public SlotFakeTypeOnly(IInventory inv, int idx, int x, int y) {
super( inv, idx, x, y );
}
@Override
public void addToInv(ItemStack is)
{
if ( is != null )
{
is = is.copy();
is.stackSize = 1;
}
super.putStack( is );
}
@Override
public void putStack(ItemStack is)
{
if ( is != null )
{
is = is.copy();
if ( is.stackSize > 1 )
is.stackSize = 1;
else if ( is.stackSize < -1 )
is.stackSize = -1;
}
super.putStack( is );
}
}
+47
View File
@@ -0,0 +1,47 @@
package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotInaccessable extends AppEngSlot
{
public SlotInaccessable(IInventory i, int slotIdx, int x, int y) {
super( i, slotIdx, x, y );
}
ItemStack dspStack = null;
@Override
public ItemStack getDisplayStack()
{
if ( dspStack == null )
{
ItemStack dsp = super.getDisplayStack();
if ( dsp != null )
dspStack = dsp.copy();
}
return dspStack;
}
@Override
public void onSlotChanged()
{
super.onSlotChanged();
dspStack = null;
}
@Override
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return false;
}
@Override
public boolean isItemValid(ItemStack i)
{
return false;
}
}
+12
View File
@@ -0,0 +1,12 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
public class SlotInaccessableHD extends SlotInaccessable
{
public SlotInaccessableHD(IInventory i, int slotIdx, int x, int y) {
super( i, slotIdx, x, y );
}
}
+14
View File
@@ -0,0 +1,14 @@
package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
public class SlotNormal extends AppEngSlot
{
public SlotNormal(Container _c, EntityPlayer _p, IInventory par1iInventory, int par2, int par3, int par4) {
super( par1iInventory, par2, par3, par4 );
}
}
+19
View File
@@ -0,0 +1,19 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public class SlotOutput extends AppEngSlot
{
public SlotOutput(IInventory a, int b, int c, int d, int i) {
super( a, b, c, d );
icon = i;
}
@Override
public boolean isItemValid(ItemStack i)
{
return false;
}
}
+11
View File
@@ -0,0 +1,11 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
public class SlotPlayerHotBar extends AppEngSlot implements ISlotPlayerSide
{
public SlotPlayerHotBar(IInventory par1iInventory, int par2, int par3, int par4) {
super( par1iInventory, par2, par3, par4 );
}
}
+13
View File
@@ -0,0 +1,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
public class SlotPlayerInv extends AppEngSlot implements ISlotPlayerSide
{
public SlotPlayerInv(IInventory par1iInventory, int par2, int par3, int par4) {
super( par1iInventory, par2, par3, par4 );
}
}
+140
View File
@@ -0,0 +1,140 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.IAppEngApi;
import appeng.api.crafting.ICraftingPatternMAC;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.ISpatialStorageCell;
import appeng.api.implementations.IStorageComponent;
import appeng.util.Platform;
public class SlotRestrictedInput extends AppEngSlot
{
public enum PlaceableItemType
{
STORAGE_CELLS(15), ORE(1 * 16 + 15), STORAGE_COMPONENT(3 * 16 + 15), WIRELESS_TERMINAL(4 * 16 + 15), TRASH(5 * 16 + 15), VALID_ENCODED_PATTERN_W_OUPUT(7 * 16 + 15), ENCODED_PATTERN_W_OUTPUT(
7 * 16 + 15), ENCODED_PATTERN(7 * 16 + 15), BLANK_PATTERN(8 * 16 + 15), POWERED_TOOL(9 * 16 + 15), RANGE_BOOSTER(6 * 16 + 15), QE_SINGULARTIY(10 * 16 + 15), SPATIAL_STORAGE_CELLS(
11 * 16 + 15), FUEL(12 * 16 + 15);
public final int icon;
private PlaceableItemType(int o) {
icon = o;
}
};
@Override
public int getSlotStackLimit()
{
if ( stackLimit != -1 )
return stackLimit;
return super.getSlotStackLimit();
}
public boolean isValid(ItemStack is, World theWorld)
{
if ( which == PlaceableItemType.VALID_ENCODED_PATTERN_W_OUPUT )
{
ICraftingPatternMAC ap = is.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) is.getItem()).getPatternForItem( is ) : null;
if ( ap != null && ap.isEncoded() && ap.isCraftable( theWorld ) )
return true;
return false;
}
return true;
}
public PlaceableItemType which;
public int stackLimit = -1;
public Slot setStackLimit(int i)
{
stackLimit = i;
return this;
}
public SlotRestrictedInput(PlaceableItemType valid, IInventory i, int slotnum, int x, int y) {
super( i, slotnum, x, y );
which = valid;
icon = valid.icon;
}
@Override
public ItemStack getDisplayStack()
{
if ( Platform.isClient() && (which == PlaceableItemType.VALID_ENCODED_PATTERN_W_OUPUT || which == PlaceableItemType.ENCODED_PATTERN_W_OUTPUT) )
{
ItemStack is = super.getStack();
if ( is != null )
{
ICraftingPatternMAC ap = is.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) is.getItem()).getPatternForItem( is ) : null;
if ( ap != null )
{
return ap.getOutput().getItemStack();
}
}
}
return super.getStack();
}
@Override
public boolean isItemValid(ItemStack i)
{
if ( i == null )
return false;
if ( i.getItem() == null )
return false;
IAppEngApi api = AEApi.instance();
switch (which)
{
case VALID_ENCODED_PATTERN_W_OUPUT:
case ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN: {
ICraftingPatternMAC pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) i.getItem()).getPatternForItem( i ) : null;
if ( pattern != null )
return pattern.isEncoded();
return false;
}
case BLANK_PATTERN: {
ICraftingPatternMAC pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) i.getItem()).getPatternForItem( i ) : null;
if ( pattern != null )
return !pattern.isEncoded();
return false;
}
case ORE:
return appeng.api.AEApi.instance().registries().grinder().getRecipeForInput( i ) != null;
case FUEL:
return TileEntityFurnace.getItemBurnTime( i ) > 0;
case POWERED_TOOL:
return Platform.isChargeable( i );
case QE_SINGULARTIY:
return api.materials().materialQESingularity.sameAs( i );
case RANGE_BOOSTER:
return api.materials().materialWirelessBooster.sameAs( i );
case SPATIAL_STORAGE_CELLS:
return i.getItem() instanceof ISpatialStorageCell && ((ISpatialStorageCell) i.getItem()).isSpatialStorage( i );
case STORAGE_CELLS:
return AEApi.instance().registries().cell().isCellHandled( i );
case STORAGE_COMPONENT:
boolean isComp = i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i );
return isComp;
case TRASH:
if ( AEApi.instance().registries().cell().isCellHandled( i ) )
return false;
if ( i.getItem() instanceof IStorageComponent && ((IStorageComponent) i.getItem()).isStorageComponent( i ) )
return false;
return true;
case WIRELESS_TERMINAL:
return AEApi.instance().registries().wireless().isWirelessTerminal( i );
}
return false;
}
}