Wireless Terminal Gui Works, dose not support range, or WAPs
This commit is contained in:
@@ -19,6 +19,7 @@ import appeng.container.implementations.ContainerMEMonitorable;
|
|||||||
import appeng.container.slot.AppEngSlot;
|
import appeng.container.slot.AppEngSlot;
|
||||||
import appeng.core.Configuration;
|
import appeng.core.Configuration;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
|
import appeng.helpers.WirelessTerminalGuiObject;
|
||||||
import appeng.parts.reporting.PartTerminal;
|
import appeng.parts.reporting.PartTerminal;
|
||||||
import appeng.tile.misc.TileSecurity;
|
import appeng.tile.misc.TileSecurity;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
@@ -52,6 +53,8 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||||||
|
|
||||||
if ( te instanceof TileSecurity )
|
if ( te instanceof TileSecurity )
|
||||||
myName = GuiText.Security;
|
myName = GuiText.Security;
|
||||||
|
else if ( te instanceof WirelessTerminalGuiObject )
|
||||||
|
myName = GuiText.WirelessTerminal;
|
||||||
else if ( te instanceof IPortableCell )
|
else if ( te instanceof IPortableCell )
|
||||||
myName = GuiText.PortableCell;
|
myName = GuiText.PortableCell;
|
||||||
else if ( te instanceof IMEChest )
|
else if ( te instanceof IMEChest )
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class GuiWirelessTerm extends GuiMEPortableCell
|
|||||||
|
|
||||||
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||||
super( inventoryPlayer, te );
|
super( inventoryPlayer, te );
|
||||||
|
maxRows = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,24 +40,29 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||||||
if ( Platform.isServer() )
|
if ( Platform.isServer() )
|
||||||
{
|
{
|
||||||
monitor = montiorable.getItemInventory();
|
monitor = montiorable.getItemInventory();
|
||||||
monitor.addListener( this, null );
|
if ( monitor != null )
|
||||||
|
|
||||||
cellInv = monitor;
|
|
||||||
|
|
||||||
if ( montiorable instanceof IPortableCell )
|
|
||||||
powerSrc = (IPortableCell) montiorable;
|
|
||||||
else if ( montiorable instanceof IMEChest )
|
|
||||||
powerSrc = (IMEChest) montiorable;
|
|
||||||
else if ( montiorable instanceof IGridHost )
|
|
||||||
{
|
{
|
||||||
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
|
monitor.addListener( this, null );
|
||||||
if ( node != 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();
|
IGridNode node = ((IGridHost) montiorable).getGridNode( ForgeDirection.UNKNOWN );
|
||||||
if ( g != null )
|
if ( node != null )
|
||||||
powerSrc = g.getCache( IEnergyGrid.class );
|
{
|
||||||
|
IGrid g = node.getGrid();
|
||||||
|
if ( g != null )
|
||||||
|
powerSrc = g.getCache( IEnergyGrid.class );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
ip.player.closeScreen();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
monitor = null;
|
monitor = null;
|
||||||
@@ -122,7 +127,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||||||
{
|
{
|
||||||
super.addCraftingToCrafters( c );
|
super.addCraftingToCrafters( c );
|
||||||
|
|
||||||
if ( Platform.isServer() && c instanceof Player )
|
if ( Platform.isServer() && c instanceof Player && monitor != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -168,7 +173,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||||||
{
|
{
|
||||||
super.removeCraftingFromCrafters( c );
|
super.removeCraftingFromCrafters( c );
|
||||||
|
|
||||||
if ( this.crafters.isEmpty() )
|
if ( this.crafters.isEmpty() && monitor != null )
|
||||||
monitor.removeListener( this );
|
monitor.removeListener( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,28 @@
|
|||||||
package appeng.container.implementations;
|
package appeng.container.implementations;
|
||||||
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
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 class ContainerWirelessTerm extends ContainerMEPortableCell
|
||||||
{
|
{
|
||||||
|
|
||||||
public ContainerWirelessTerm(InventoryPlayer ip, IPortableCell montiorable) {
|
WirelessTerminalGuiObject wtgo;
|
||||||
|
|
||||||
|
public ContainerWirelessTerm(InventoryPlayer ip, WirelessTerminalGuiObject montiorable) {
|
||||||
super( ip, 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 net.minecraft.world.World;
|
||||||
import appeng.api.features.IWirelessTermHandler;
|
import appeng.api.features.IWirelessTermHandler;
|
||||||
import appeng.api.features.IWirelessTermRegistery;
|
import appeng.api.features.IWirelessTermRegistery;
|
||||||
|
import appeng.core.localization.PlayerMessages;
|
||||||
import appeng.core.sync.GuiBridge;
|
import appeng.core.sync.GuiBridge;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
@@ -66,6 +67,8 @@ public class WirelessRegistry implements IWirelessTermRegistery
|
|||||||
{
|
{
|
||||||
Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM );
|
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,
|
StorageBus, Priority, Security, Encoded, Blank, Unlinked, Linked,
|
||||||
|
|
||||||
SecurityCardEditor, NoPermissions,
|
SecurityCardEditor, NoPermissions, WirelessTerminal,
|
||||||
|
|
||||||
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel;
|
METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import appeng.core.AELog;
|
|||||||
|
|
||||||
public enum PlayerMessages
|
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() {
|
private PlayerMessages() {
|
||||||
AELog.localization( "chat", getName() );
|
AELog.localization( "chat", getName() );
|
||||||
|
|||||||
@@ -3,12 +3,16 @@ package appeng.helpers;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
import appeng.api.config.PowerMultiplier;
|
import appeng.api.config.PowerMultiplier;
|
||||||
import appeng.api.features.IWirelessTermHandler;
|
import appeng.api.features.IWirelessTermHandler;
|
||||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
import appeng.api.networking.IGrid;
|
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.security.BaseActionSource;
|
||||||
import appeng.api.networking.storage.IStorageGrid;
|
import appeng.api.networking.storage.IStorageGrid;
|
||||||
import appeng.api.storage.IMEMonitor;
|
import appeng.api.storage.IMEMonitor;
|
||||||
@@ -36,104 +40,156 @@ public class WirelessTerminalGuiObject implements IPortableCell
|
|||||||
effectiveItem = is;
|
effectiveItem = is;
|
||||||
myPlayer = ep;
|
myPlayer = ep;
|
||||||
wth = wh;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEMonitor<IAEItemStack> getItemInventory()
|
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||||
{
|
{
|
||||||
|
if ( sg == null )
|
||||||
|
return null;
|
||||||
return sg.getItemInventory();
|
return sg.getItemInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||||
{
|
{
|
||||||
|
if ( sg == null )
|
||||||
|
return null;
|
||||||
return sg.getFluidInventory();
|
return sg.getFluidInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(IMEMonitorHandlerReciever<IAEItemStack> l, Object verificationToken)
|
public void addListener(IMEMonitorHandlerReciever<IAEItemStack> l, Object verificationToken)
|
||||||
{
|
{
|
||||||
itemStorage.addListener( l, verificationToken );
|
if ( itemStorage != null )
|
||||||
|
itemStorage.addListener( l, verificationToken );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeListener(IMEMonitorHandlerReciever<IAEItemStack> l)
|
public void removeListener(IMEMonitorHandlerReciever<IAEItemStack> l)
|
||||||
{
|
{
|
||||||
itemStorage.removeListener( l );
|
if ( itemStorage != null )
|
||||||
|
itemStorage.removeListener( l );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||||
{
|
{
|
||||||
return itemStorage.getAvailableItems( out );
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.getAvailableItems( out );
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemList<IAEItemStack> getStorageList()
|
public IItemList<IAEItemStack> getStorageList()
|
||||||
{
|
{
|
||||||
return itemStorage.getStorageList();
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.getStorageList();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccessRestriction getAccess()
|
public AccessRestriction getAccess()
|
||||||
{
|
{
|
||||||
return itemStorage.getAccess();
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.getAccess();
|
||||||
|
return AccessRestriction.NO_ACCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPrioritized(IAEItemStack input)
|
public boolean isPrioritized(IAEItemStack input)
|
||||||
{
|
{
|
||||||
return itemStorage.isPrioritized( input );
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.isPrioritized( input );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAccept(IAEItemStack input)
|
public boolean canAccept(IAEItemStack input)
|
||||||
{
|
{
|
||||||
return itemStorage.canAccept( input );
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.canAccept( input );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority()
|
public int getPriority()
|
||||||
{
|
{
|
||||||
return itemStorage.getPriority();
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.getPriority();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlot()
|
public int getSlot()
|
||||||
{
|
{
|
||||||
return itemStorage.getSlot();
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.getSlot();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
|
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
|
@Override
|
||||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
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
|
@Override
|
||||||
public StorageChannel getChannel()
|
public StorageChannel getChannel()
|
||||||
{
|
{
|
||||||
return itemStorage.getChannel();
|
if ( itemStorage != null )
|
||||||
|
return itemStorage.getChannel();
|
||||||
|
return StorageChannel.ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier)
|
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier)
|
||||||
{
|
{
|
||||||
if ( mode == Actionable.SIMULATE )
|
if ( wth != null && effectiveItem != null )
|
||||||
return wth.hasPower( myPlayer, amt, getItemStack() ) ? amt : 0;
|
{
|
||||||
return wth.usePower( myPlayer, amt, getItemStack() ) ? amt : 0;
|
if ( mode == Actionable.SIMULATE )
|
||||||
|
return wth.hasPower( myPlayer, amt, getItemStack() ) ? amt : 0;
|
||||||
|
return wth.usePower( myPlayer, amt, getItemStack() ) ? amt : 0;
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user