Wireless Terminal Gui Works, dose not support range, or WAPs
This commit is contained in:
parent
b7d90b989d
commit
8b81545abf
8 changed files with 121 additions and 36 deletions
|
@ -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 )
|
||||
|
|
|
@ -8,6 +8,7 @@ public class GuiWirelessTerm extends GuiMEPortableCell
|
|||
|
||||
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||
super( inventoryPlayer, te );
|
||||
maxRows = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,24 +40,29 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
if ( Platform.isServer() )
|
||||
{
|
||||
monitor = montiorable.getItemInventory();
|
||||
monitor.addListener( this, null );
|
||||
|
||||
cellInv = monitor;
|
||||
|
||||
if ( montiorable instanceof IPortableCell )
|
||||
powerSrc = (IPortableCell) montiorable;
|
||||
else if ( montiorable instanceof IMEChest )
|
||||
powerSrc = (IMEChest) montiorable;
|
||||
else if ( montiorable instanceof IGridHost )
|
||||
if ( monitor != null )
|
||||
{
|
||||
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( node != null )
|
||||
monitor.addListener( this, null );
|
||||
|
||||
cellInv = monitor;
|
||||
|
||||
if ( montiorable instanceof IPortableCell )
|
||||
powerSrc = (IPortableCell) montiorable;
|
||||
else if ( montiorable instanceof IMEChest )
|
||||
powerSrc = (IMEChest) montiorable;
|
||||
else if ( montiorable instanceof IGridHost )
|
||||
{
|
||||
IGrid g = node.getGrid();
|
||||
if ( g != null )
|
||||
powerSrc = g.getCache( IEnergyGrid.class );
|
||||
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
|
||||
if ( node != null )
|
||||
{
|
||||
IGrid g = node.getGrid();
|
||||
if ( g != null )
|
||||
powerSrc = g.getCache( IEnergyGrid.class );
|
||||
}
|
||||
}
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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,104 +40,156 @@ 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)
|
||||
{
|
||||
itemStorage.addListener( l, verificationToken );
|
||||
if ( itemStorage != null )
|
||||
itemStorage.addListener( l, verificationToken );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IMEMonitorHandlerReciever<IAEItemStack> l)
|
||||
{
|
||||
itemStorage.removeListener( l );
|
||||
if ( itemStorage != null )
|
||||
itemStorage.removeListener( l );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
return itemStorage.getAvailableItems( out );
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.getAvailableItems( out );
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList()
|
||||
{
|
||||
return itemStorage.getStorageList();
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.getStorageList();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getAccess()
|
||||
{
|
||||
return itemStorage.getAccess();
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.getAccess();
|
||||
return AccessRestriction.NO_ACCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized(IAEItemStack input)
|
||||
{
|
||||
return itemStorage.isPrioritized( input );
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.isPrioritized( input );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept(IAEItemStack input)
|
||||
{
|
||||
return itemStorage.canAccept( input );
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.canAccept( input );
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return itemStorage.getPriority();
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.getPriority();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot()
|
||||
{
|
||||
return itemStorage.getSlot();
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.getSlot();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
return itemStorage.injectItems( input, type, src );
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.injectItems( input, type, src );
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return itemStorage.extractItems( request, mode, src );
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.extractItems( request, mode, src );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return itemStorage.getChannel();
|
||||
if ( itemStorage != null )
|
||||
return itemStorage.getChannel();
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier)
|
||||
{
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
return wth.hasPower( myPlayer, amt, getItemStack() ) ? amt : 0;
|
||||
return wth.usePower( myPlayer, amt, getItemStack() ) ? amt : 0;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue