Wireless block no uses placed side to orient, this is more natural for it instead of the place based version.

Added Wireless Encoder Gui to the Security Term
Security Term now only accepts Biometric Cards in the config slot.
Added Wireless Block.
Added Wireless Terminal.
Fixed Crash when loading world settings.
Configure slot of Security Block now drops on destruction.
This commit is contained in:
AlgorithmX2
2014-02-02 01:32:10 -06:00
parent 2d61ca3fd0
commit af8e356bec
12 changed files with 202 additions and 44 deletions
@@ -1,31 +1,62 @@
package appeng.container.implementations;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.items.IBiometricCard;
import appeng.api.storage.IStorageMonitorable;
import appeng.container.slot.SlotNormal;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.misc.TileSecurity;
import appeng.util.Platform;
public class ContainerSecurity extends ContainerMEMonitorable
public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppEngInventory
{
SlotNormal configSlot;
SlotRestrictedInput configSlot;
AppEngInternalInventory wirelessEncoder = new AppEngInternalInventory( this, 2 );
SlotRestrictedInput wirelessIn;
SlotOutput wirelessOut;
TileSecurity securityBox;
public ContainerSecurity(InventoryPlayer ip, IStorageMonitorable montiorable) {
super( ip, montiorable, false );
addSlotToContainer( configSlot = new SlotNormal( ((TileSecurity) montiorable).configSlot, 0, 37, -32 ) );
securityBox = (TileSecurity) montiorable;
addSlotToContainer( configSlot = new SlotRestrictedInput( PlaceableItemType.BIOMETRIC_CARD, securityBox.configSlot, 0, 37, -32 ) );
addSlotToContainer( wirelessIn = new SlotRestrictedInput( PlaceableItemType.WIRELESS_TERMINAL, wirelessEncoder, 0, 212, 10 ) );
addSlotToContainer( wirelessOut = new SlotOutput( wirelessEncoder, 1, 212, 68, -1 ) );
bindPlayerInventory( ip, 0, 0 );
}
public int security = 0;
@Override
public void onContainerClosed(EntityPlayer player)
{
if ( wirelessIn.getHasStack() )
player.dropPlayerItem( wirelessIn.getStack() );
if ( wirelessOut.getHasStack() )
player.dropPlayerItem( wirelessOut.getStack() );
}
public void toggleSetting(String value, EntityPlayer player)
{
try
@@ -89,4 +120,39 @@ public class ContainerSecurity extends ContainerMEMonitorable
super.detectAndSendChanges();
}
@Override
public void saveChanges()
{
// :P
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
{
if ( !wirelessOut.getHasStack() )
{
if ( wirelessIn.getHasStack() )
{
ItemStack term = wirelessIn.getStack().copy();
IWirelessTermHandler h = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term );
if ( h != null )
{
h.setEncryptionKey( term, "" + securityBox.securityKey, "" );
wirelessIn.putStack( null );
wirelessOut.putStack( term );
// update the two slots in question...
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get( i );
((EntityPlayerMP) icrafting).sendSlotContents( this, wirelessIn.slotNumber, wirelessIn.getStack() );
((EntityPlayerMP) icrafting).sendSlotContents( this, wirelessOut.slotNumber, wirelessOut.getStack() );
}
}
}
}
}
}