Applied-Energistics-2-tiler.../container/slot/SlotPatternTerm.java

57 lines
1.4 KiB
Java
Raw Normal View History

2014-04-08 02:43:57 +02:00
package appeng.container.slot;
2014-04-17 06:38:43 +02:00
import java.io.IOException;
2014-04-08 02:43:57 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
2014-04-17 06:38:43 +02:00
import appeng.api.AEApi;
2014-04-11 05:43:18 +02:00
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IStorageMonitorable;
2014-04-17 06:38:43 +02:00
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.packets.PacketPatternSlot;
2014-04-08 02:43:57 +02:00
2014-04-11 05:43:18 +02:00
public class SlotPatternTerm extends SlotCraftingTerm
2014-04-08 02:43:57 +02:00
{
2014-04-11 05:43:18 +02:00
int groupNum;
IOptionalSlotHost host;
public SlotPatternTerm(EntityPlayer player, BaseActionSource mySrc, IEnergySource energySrc, IStorageMonitorable storage, IInventory cMatrix,
IInventory secondMatrix, IInventory output, int x, int y, IOptionalSlotHost h, int grpnum) {
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y );
host = h;
groupNum = grpnum;
2014-04-08 02:43:57 +02:00
}
@Override
2014-04-11 05:43:18 +02:00
public ItemStack getStack()
2014-04-08 02:43:57 +02:00
{
2014-04-11 05:43:18 +02:00
if ( !isEnabled() )
{
if ( getDisplayStack() != null )
clearStack();
}
return super.getStack();
2014-04-08 02:43:57 +02:00
}
@Override
2014-04-11 05:43:18 +02:00
public boolean isEnabled()
2014-04-08 02:43:57 +02:00
{
2014-04-11 05:43:18 +02:00
if ( host == null )
return false;
return host.isSlotEnabled( groupNum );
2014-04-08 02:43:57 +02:00
}
2014-04-17 06:38:43 +02:00
public AppEngPacket getRequest(boolean shift) throws IOException
{
return new PacketPatternSlot( this.pattern, AEApi.instance().storage().createItemStack( getStack() ), shift );
}
2014-04-08 02:43:57 +02:00
}