Wireless Terminal Gui Works, dose not support range, or WAPs

This commit is contained in:
AlgorithmX2 2014-02-02 23:02:54 -06:00
parent b7d90b989d
commit 8b81545abf
8 changed files with 121 additions and 36 deletions

View file

@ -19,6 +19,7 @@ import appeng.container.implementations.ContainerMEMonitorable;
import appeng.container.slot.AppEngSlot;
import appeng.core.Configuration;
import appeng.core.localization.GuiText;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.PartTerminal;
import appeng.tile.misc.TileSecurity;
import appeng.util.Platform;
@ -52,6 +53,8 @@ public class GuiMEMonitorable extends AEBaseMEGui
if ( te instanceof TileSecurity )
myName = GuiText.Security;
else if ( te instanceof WirelessTerminalGuiObject )
myName = GuiText.WirelessTerminal;
else if ( te instanceof IPortableCell )
myName = GuiText.PortableCell;
else if ( te instanceof IMEChest )

View file

@ -8,6 +8,7 @@ public class GuiWirelessTerm extends GuiMEPortableCell
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
super( inventoryPlayer, te );
maxRows = Integer.MAX_VALUE;
}
}

View file

@ -40,6 +40,8 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
if ( Platform.isServer() )
{
monitor = montiorable.getItemInventory();
if ( monitor != null )
{
monitor.addListener( this, null );
cellInv = monitor;
@ -59,6 +61,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
}
}
}
else
ip.player.closeScreen();
}
else
monitor = null;
@ -122,7 +127,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
{
super.addCraftingToCrafters( c );
if ( Platform.isServer() && c instanceof Player )
if ( Platform.isServer() && c instanceof Player && monitor != null )
{
try
{
@ -168,7 +173,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
{
super.removeCraftingFromCrafters( c );
if ( this.crafters.isEmpty() )
if ( this.crafters.isEmpty() && monitor != null )
monitor.removeListener( this );
}

View file

@ -1,13 +1,28 @@
package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.WirelessTerminalGuiObject;
public class ContainerWirelessTerm extends ContainerMEPortableCell
{
public ContainerWirelessTerm(InventoryPlayer ip, IPortableCell montiorable) {
WirelessTerminalGuiObject wtgo;
public ContainerWirelessTerm(InventoryPlayer ip, WirelessTerminalGuiObject montiorable) {
super( ip, montiorable );
wtgo = montiorable;
}
@Override
public void detectAndSendChanges()
{
super.detectAndSendChanges();
if ( !wtgo.rangeCheck() )
{
getPlayerInv().player.closeScreen();
getPlayerInv().player.sendChatToPlayer( PlayerMessages.OutOfRange.get() );
}
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistery;
import appeng.core.localization.PlayerMessages;
import appeng.core.sync.GuiBridge;
import appeng.util.Platform;
@ -66,6 +67,8 @@ public class WirelessRegistry implements IWirelessTermRegistery
{
Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM );
}
else
player.sendChatToPlayer( PlayerMessages.DeviceNotPowered.get() );
}

View file

@ -21,7 +21,7 @@ public enum GuiText
StorageBus, Priority, Security, Encoded, Blank, Unlinked, Linked,
SecurityCardEditor, NoPermissions,
SecurityCardEditor, NoPermissions, WirelessTerminal,
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel;

View file

@ -5,7 +5,9 @@ import appeng.core.AELog;
public enum PlayerMessages
{
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered, isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError;
ChestCannotReadStorageCell, InvalidMachine, LoadedSettings, SavedSettings, MachineNotPowered,
isNowLocked, isNowUnlocked, AmmoDepleted, CommunicationError, OutOfRange, DeviceNotPowered;
private PlayerMessages() {
AELog.localization( "chat", getName() );

View file

@ -3,12 +3,16 @@ package appeng.helpers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
@ -36,34 +40,62 @@ public class WirelessTerminalGuiObject implements IPortableCell
effectiveItem = is;
myPlayer = ep;
wth = wh;
long encKey = Long.parseLong( encryptionKey );
Object obj = AEApi.instance().registries().locateable().findLocateableBySerial( encKey );
if ( obj instanceof IGridHost )
{
IGridNode n = ((IGridHost) obj).getGridNode( ForgeDirection.UNKNOWN );
if ( n != null )
{
targetGrid = n.getGrid();
if ( targetGrid != null )
{
sg = targetGrid.getCache( IStorageGrid.class );
if ( sg != null )
itemStorage = sg.getItemInventory();
}
}
}
}
boolean rangeCheck()
public boolean rangeCheck()
{
if ( targetGrid != null && itemStorage != null )
{
return true;
}
return false;
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
{
if ( sg == null )
return null;
return sg.getItemInventory();
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
if ( sg == null )
return null;
return sg.getFluidInventory();
}
@Override
public void addListener(IMEMonitorHandlerReciever<IAEItemStack> l, Object verificationToken)
{
if ( itemStorage != null )
itemStorage.addListener( l, verificationToken );
}
@Override
public void removeListener(IMEMonitorHandlerReciever<IAEItemStack> l)
{
if ( itemStorage != null )
itemStorage.removeListener( l );
}
@ -71,70 +103,94 @@ public class WirelessTerminalGuiObject implements IPortableCell
@Override
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
{
if ( itemStorage != null )
return itemStorage.getAvailableItems( out );
return out;
}
@Override
public IItemList<IAEItemStack> getStorageList()
{
if ( itemStorage != null )
return itemStorage.getStorageList();
return null;
}
@Override
public AccessRestriction getAccess()
{
if ( itemStorage != null )
return itemStorage.getAccess();
return AccessRestriction.NO_ACCESS;
}
@Override
public boolean isPrioritized(IAEItemStack input)
{
if ( itemStorage != null )
return itemStorage.isPrioritized( input );
return false;
}
@Override
public boolean canAccept(IAEItemStack input)
{
if ( itemStorage != null )
return itemStorage.canAccept( input );
return false;
}
@Override
public int getPriority()
{
if ( itemStorage != null )
return itemStorage.getPriority();
return 0;
}
@Override
public int getSlot()
{
if ( itemStorage != null )
return itemStorage.getSlot();
return 0;
}
@Override
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
{
if ( itemStorage != null )
return itemStorage.injectItems( input, type, src );
return input;
}
@Override
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
{
if ( itemStorage != null )
return itemStorage.extractItems( request, mode, src );
return null;
}
@Override
public StorageChannel getChannel()
{
if ( itemStorage != null )
return itemStorage.getChannel();
return StorageChannel.ITEMS;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier)
{
if ( wth != null && effectiveItem != null )
{
if ( mode == Actionable.SIMULATE )
return wth.hasPower( myPlayer, amt, getItemStack() ) ? amt : 0;
return wth.usePower( myPlayer, amt, getItemStack() ) ? amt : 0;
}
return 0.0;
}
@Override
public ItemStack getItemStack()