Applied-Energistics-2-tiler.../container/implementations/ContainerMEPortableCell.java

59 lines
1.5 KiB
Java
Raw Normal View History

2014-01-20 17:41:37 +01:00
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;
2014-01-23 20:02:48 +01:00
import appeng.api.implementations.guiobjects.IPortableCell;
2014-02-17 01:50:25 +01:00
import appeng.api.storage.ITerminalHost;
2014-01-20 17:41:37 +01:00
import appeng.util.Platform;
public class ContainerMEPortableCell extends ContainerMEMonitorable
{
double powerMultiplier = 0.5;
2014-01-23 20:02:48 +01:00
IPortableCell civ;
2014-01-20 17:41:37 +01:00
2014-01-23 20:02:48 +01:00
public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell montiorable) {
2014-02-17 01:50:25 +01:00
super( ip, (ITerminalHost) montiorable, false );
2014-01-23 17:28:12 +01:00
lockPlayerInventorySlot( ip.currentItem );
2014-01-20 17:41:37 +01:00
civ = montiorable;
bindPlayerInventory( ip, 0, 0 );
2014-01-20 17:41:37 +01:00
}
int ticks = 0;
@Override
public void detectAndSendChanges()
{
ItemStack currentItem = getPlayerInv().getCurrentItem();
if ( civ != null )
2014-01-20 17:41:37 +01:00
{
if ( currentItem != civ.getItemStack() )
2014-01-20 17:41:37 +01:00
{
if ( currentItem != null )
{
if ( Platform.isSameItem( civ.getItemStack(), currentItem ) )
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, civ.getItemStack() );
else
2014-02-09 02:34:52 +01:00
isContainerValid = false;
}
2014-01-20 17:41:37 +01:00
else
2014-02-09 02:34:52 +01:00
isContainerValid = false;
2014-01-20 17:41:37 +01:00
}
}
else
2014-02-09 02:34:52 +01:00
isContainerValid = false;
2014-01-20 17:41:37 +01:00
// drain 1 ae t
ticks++;
if ( ticks > 10 )
{
civ.extractAEPower( powerMultiplier * (double) ticks, Actionable.MODULATE, PowerMultiplier.CONFIG );
2014-01-20 17:41:37 +01:00
ticks = 0;
}
super.detectAndSendChanges();
}
}