2013-12-27 23:59:59 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-03-06 06:45:14 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.config.SecurityPermissions;
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.api.networking.IGrid;
|
|
|
|
import appeng.api.networking.energy.IEnergyGrid;
|
|
|
|
import appeng.api.networking.spatial.ISpatialCache;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.container.AEBaseContainer;
|
2014-05-07 07:22:42 +02:00
|
|
|
import appeng.container.guisync.GuiSync;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.container.slot.SlotOutput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
|
|
|
import appeng.tile.spatial.TileSpatialIOPort;
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class ContainerSpatialIOPort extends AEBaseContainer
|
|
|
|
{
|
|
|
|
|
|
|
|
TileSpatialIOPort myte;
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
IGrid network;
|
|
|
|
|
2014-05-07 07:22:42 +02:00
|
|
|
@GuiSync(0)
|
2014-03-06 06:45:14 +01:00
|
|
|
public long currentPower;
|
2014-05-07 07:22:42 +02:00
|
|
|
@GuiSync(1)
|
2014-03-06 06:45:14 +01:00
|
|
|
public long maxPower;
|
2014-05-07 07:22:42 +02:00
|
|
|
@GuiSync(2)
|
|
|
|
public long reqPower;
|
|
|
|
@GuiSync(3)
|
2014-03-06 06:45:14 +01:00
|
|
|
public long eff;
|
|
|
|
|
|
|
|
int delay = 40;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public ContainerSpatialIOPort(InventoryPlayer ip, TileSpatialIOPort te) {
|
2014-01-02 06:51:41 +01:00
|
|
|
super( ip, te, null );
|
2013-12-27 23:59:59 +01:00
|
|
|
myte = te;
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
if ( Platform.isServer() )
|
|
|
|
network = te.getGridNode( ForgeDirection.UNKNOWN ).getGrid();
|
|
|
|
|
|
|
|
addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.SPATIAL_STORAGE_CELLS, te, 0, 52, 48 ) );
|
|
|
|
addSlotToContainer( new SlotOutput( te, 1, 113, 48, PlaceableItemType.SPATIAL_STORAGE_CELLS.IIcon ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-03-05 08:27:42 +01:00
|
|
|
bindPlayerInventory( ip, 0, 197 - /* height of playerinventory */82 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
|
|
|
verifyPermissions( SecurityPermissions.BUILD, false );
|
|
|
|
|
2014-03-06 06:45:14 +01:00
|
|
|
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.currentEffiency());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
super.detectAndSendChanges();
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|