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