Begin work on Wireless Terminal Gui.
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
|
|
||||||
|
public class GuiWirelessTerm extends GuiMEPortableCell
|
||||||
|
{
|
||||||
|
|
||||||
|
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||||
|
super( inventoryPlayer, te );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package appeng.container.implementations;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||||
|
|
||||||
|
public class ContainerWirelessTerm extends ContainerMEPortableCell
|
||||||
|
{
|
||||||
|
|
||||||
|
public ContainerWirelessTerm(InventoryPlayer ip, IPortableCell montiorable) {
|
||||||
|
super( ip, montiorable );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,8 +8,8 @@ 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.sync.GuiBridge;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.network.Player;
|
|
||||||
|
|
||||||
public class WirelessRegistry implements IWirelessTermRegistery
|
public class WirelessRegistry implements IWirelessTermRegistery
|
||||||
{
|
{
|
||||||
@@ -62,9 +62,9 @@ public class WirelessRegistry implements IWirelessTermRegistery
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( handler.usePower( (Player) player, 10.0f, item ) )
|
if ( handler.hasPower( player, 0.5, item ) )
|
||||||
{
|
{
|
||||||
|
Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
package appeng.core.features.registries.entries;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import appeng.api.AEApi;
|
|
||||||
import appeng.api.features.IWirelessTermHandler;
|
|
||||||
import appeng.util.Platform;
|
|
||||||
import cpw.mods.fml.common.network.Player;
|
|
||||||
|
|
||||||
public class BasicTerminalHandler implements IWirelessTermHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canHandle(ItemStack is)
|
|
||||||
{
|
|
||||||
if ( is == null )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( AEApi.instance().items().itemWirelessTerminal.sameAs( is ) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean usePower(Player player, float amount, ItemStack is)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPower(Player player, ItemStack is)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEncryptionKey(ItemStack i)
|
|
||||||
{
|
|
||||||
if ( i == null )
|
|
||||||
return null;
|
|
||||||
NBTTagCompound tag = Platform.openNbtData( i );
|
|
||||||
if ( tag != null )
|
|
||||||
{
|
|
||||||
return tag.getString( "encKey" );
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setEncryptionKey(ItemStack i, String encKey, String name)
|
|
||||||
{
|
|
||||||
if ( i == null )
|
|
||||||
return;
|
|
||||||
NBTTagCompound tag = Platform.openNbtData( i );
|
|
||||||
if ( tag != null )
|
|
||||||
{
|
|
||||||
tag.setString( "encKey", encKey );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+29
-12
@@ -8,8 +8,10 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import appeng.api.AEApi;
|
||||||
import appeng.api.config.SecurityPermissions;
|
import appeng.api.config.SecurityPermissions;
|
||||||
import appeng.api.exceptions.AppEngException;
|
import appeng.api.exceptions.AppEngException;
|
||||||
|
import appeng.api.features.IWirelessTermHandler;
|
||||||
import appeng.api.implementations.IUpgradeableHost;
|
import appeng.api.implementations.IUpgradeableHost;
|
||||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||||
@@ -44,8 +46,10 @@ import appeng.container.implementations.ContainerSecurity;
|
|||||||
import appeng.container.implementations.ContainerStorageBus;
|
import appeng.container.implementations.ContainerStorageBus;
|
||||||
import appeng.container.implementations.ContainerUpgradeable;
|
import appeng.container.implementations.ContainerUpgradeable;
|
||||||
import appeng.container.implementations.ContainerVibrationChamber;
|
import appeng.container.implementations.ContainerVibrationChamber;
|
||||||
|
import appeng.container.implementations.ContainerWirelessTerm;
|
||||||
import appeng.helpers.IInterfaceHost;
|
import appeng.helpers.IInterfaceHost;
|
||||||
import appeng.helpers.IPriorityHost;
|
import appeng.helpers.IPriorityHost;
|
||||||
|
import appeng.helpers.WirelessTerminalGuiObject;
|
||||||
import appeng.parts.automation.PartLevelEmitter;
|
import appeng.parts.automation.PartLevelEmitter;
|
||||||
import appeng.parts.misc.PartStorageBus;
|
import appeng.parts.misc.PartStorageBus;
|
||||||
import appeng.server.AccessType;
|
import appeng.server.AccessType;
|
||||||
@@ -76,6 +80,8 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
|
|
||||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, true, null),
|
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, true, null),
|
||||||
|
|
||||||
|
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, true, null),
|
||||||
|
|
||||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, true, null),
|
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, true, null),
|
||||||
|
|
||||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, true, null),
|
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, true, null),
|
||||||
@@ -211,12 +217,9 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
if ( ID.isItem() )
|
if ( ID.isItem() )
|
||||||
{
|
{
|
||||||
ItemStack it = player.inventory.getCurrentItem();
|
ItemStack it = player.inventory.getCurrentItem();
|
||||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||||
{
|
if ( myItem != null && ID.CorrectTileOrPart( myItem ) )
|
||||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
return updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side );
|
||||||
if ( ID.CorrectTileOrPart( myItem ) )
|
|
||||||
return updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -238,6 +241,23 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
return new ContainerNull();
|
return new ContainerNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Object getGuiObject(ItemStack it, EntityPlayer player, World w, int x, int y, int z)
|
||||||
|
{
|
||||||
|
if ( it != null )
|
||||||
|
{
|
||||||
|
if ( it.getItem() instanceof IGuiItem )
|
||||||
|
{
|
||||||
|
return ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||||
|
}
|
||||||
|
|
||||||
|
IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it );
|
||||||
|
if ( wh != null )
|
||||||
|
return new WirelessTerminalGuiObject( wh, it, player, w, x, y, z );
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isItem()
|
public boolean isItem()
|
||||||
{
|
{
|
||||||
return isItem;
|
return isItem;
|
||||||
@@ -252,12 +272,9 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
if ( ID.isItem() )
|
if ( ID.isItem() )
|
||||||
{
|
{
|
||||||
ItemStack it = player.inventory.getCurrentItem();
|
ItemStack it = player.inventory.getCurrentItem();
|
||||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
Object myItem = getGuiObject( it, player, w, x, y, z );
|
||||||
{
|
if ( ID.CorrectTileOrPart( myItem ) )
|
||||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
return ID.ConstructGui( player.inventory, side, myItem );
|
||||||
if ( ID.CorrectTileOrPart( myItem ) )
|
|
||||||
return ID.ConstructGui( player.inventory, side, myItem );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
package appeng.helpers;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
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.security.BaseActionSource;
|
||||||
|
import appeng.api.networking.storage.IStorageGrid;
|
||||||
|
import appeng.api.storage.IMEMonitor;
|
||||||
|
import appeng.api.storage.IMEMonitorHandlerReciever;
|
||||||
|
import appeng.api.storage.StorageChannel;
|
||||||
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
|
import appeng.api.storage.data.IItemList;
|
||||||
|
|
||||||
|
public class WirelessTerminalGuiObject implements IPortableCell
|
||||||
|
{
|
||||||
|
|
||||||
|
IWirelessTermHandler wth;
|
||||||
|
String encryptionKey;
|
||||||
|
|
||||||
|
IGrid targetGrid;
|
||||||
|
IStorageGrid sg;
|
||||||
|
IMEMonitor<IAEItemStack> itemStorage;
|
||||||
|
|
||||||
|
EntityPlayer myPlayer;
|
||||||
|
public ItemStack effectiveItem;
|
||||||
|
|
||||||
|
public WirelessTerminalGuiObject(IWirelessTermHandler wh, ItemStack is, EntityPlayer ep, World w, int x, int y, int z) {
|
||||||
|
encryptionKey = wh.getEncryptionKey( is );
|
||||||
|
effectiveItem = is;
|
||||||
|
myPlayer = ep;
|
||||||
|
wth = wh;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean rangeCheck()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMEMonitor<IAEItemStack> getItemInventory()
|
||||||
|
{
|
||||||
|
return sg.getItemInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMEMonitor<IAEFluidStack> getFluidInventory()
|
||||||
|
{
|
||||||
|
return sg.getFluidInventory();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addListener(IMEMonitorHandlerReciever<IAEItemStack> l, Object verificationToken)
|
||||||
|
{
|
||||||
|
itemStorage.addListener( l, verificationToken );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeListener(IMEMonitorHandlerReciever<IAEItemStack> l)
|
||||||
|
{
|
||||||
|
itemStorage.removeListener( l );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||||
|
{
|
||||||
|
return itemStorage.getAvailableItems( out );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IItemList<IAEItemStack> getStorageList()
|
||||||
|
{
|
||||||
|
return itemStorage.getStorageList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AccessRestriction getAccess()
|
||||||
|
{
|
||||||
|
return itemStorage.getAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPrioritized(IAEItemStack input)
|
||||||
|
{
|
||||||
|
return itemStorage.isPrioritized( input );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAccept(IAEItemStack input)
|
||||||
|
{
|
||||||
|
return itemStorage.canAccept( input );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriority()
|
||||||
|
{
|
||||||
|
return itemStorage.getPriority();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlot()
|
||||||
|
{
|
||||||
|
return itemStorage.getSlot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
|
||||||
|
{
|
||||||
|
return itemStorage.injectItems( input, type, src );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||||
|
{
|
||||||
|
return itemStorage.extractItems( request, mode, src );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StorageChannel getChannel()
|
||||||
|
{
|
||||||
|
return itemStorage.getChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemStack()
|
||||||
|
{
|
||||||
|
return effectiveItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,7 +14,6 @@ import appeng.core.features.AEFeature;
|
|||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import cpw.mods.fml.common.network.Player;
|
|
||||||
|
|
||||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
||||||
{
|
{
|
||||||
@@ -63,15 +62,15 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean usePower(Player player, float amount, ItemStack is)
|
public boolean usePower(EntityPlayer player, double amount, ItemStack is)
|
||||||
{
|
{
|
||||||
return this.extractAEPower( is, amount ) >= amount - 0.5;
|
return this.extractAEPower( is, amount ) >= amount - 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPower(Player player, ItemStack is)
|
public boolean hasPower(EntityPlayer player, double amt, ItemStack is)
|
||||||
{
|
{
|
||||||
return getAECurrentPower( is ) > 0.5;
|
return getAECurrentPower( is ) >= amt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user