This commit is contained in:
p455w0rd committed 2016-06-02 12:47:40 -04:00
1 parent a9c224824d
commit c27e5ee74e
7 files changed
+42 -9

No files matched your search

@@ -46,6 +46,7 @@ import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
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.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
@@ -194,8 +195,7 @@ public class ContainerWirelessCraftingTerminal extends Container implements ICon
this.obj = getGuiObject(containerstack, player, worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
this.civ = (IPortableCell) this.obj;
//final IGridNode node = ((IGridNode) ((IGrid) this.obj.getTargetGrid()).getPivot()).getMachine().getGridNode(ForgeDirection.UNKNOWN);
final IGridNode node = this.obj.getActionableNode(true);
final IGridNode node = ((IGridHost) this.obj).getGridNode(ForgeDirection.UNKNOWN);
this.networkNode = node;
this.prepareSync();
@@ -18,14 +18,20 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.ISecurityGrid;
@@ -86,6 +92,17 @@ public class PacketNEIRecipe extends WCTPacket
this.configureWrite( data );
}
private WirelessTerminalGuiObject getGuiObject(final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z) {
if (it != null) {
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
if (wh != null) {
return new WirelessTerminalGuiObject(wh, it, player, w, x, y, z);
}
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@@ -97,8 +114,13 @@ public class PacketNEIRecipe extends WCTPacket
if( con instanceof IContainerCraftingPacket )
{
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
final IGridNode node = cct.getNetworkNode();
if( node != null )
IGridNode node = cct.getNetworkNode();
if (node == null) {
WirelessTerminalGuiObject obj = getGuiObject(RandomUtils.getWirelessTerm(player.inventory), player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
node = obj.getActionableNode(true);
}
if ( node != null )
{
final IGrid grid = node.getGrid();
@@ -11,6 +11,7 @@ import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketOpenGui;
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class WCTInteractionHelper implements IWCTInteractionHelper {
@@ -27,7 +28,17 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
if (is == null) {
return;
}
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
if (is.hasTagCompound()) {
// Get the security terminal source key
String sourceKey = is.getTagCompound().getString(ItemWirelessCraftingTerminal.LINK_KEY_STRING);
// Ensure the source is not empty nor null
if ((sourceKey != null) && (!sourceKey.isEmpty())) {
// The terminal is linked.
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
}
}
}
public static boolean isTerminalLinked(final IWirelessCraftingTermHandler wirelessTerminal, final ItemStack wirelessTerminalItemstack) {
@@ -40,7 +40,7 @@ import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class ItemWirelessCraftingTerminal extends AERootPoweredItem implements IWirelessCraftingTerminalItem
{
private static final String LINK_KEY_STRING = "key";
public static final String LINK_KEY_STRING = "key";
public static double GLOBAL_POWER_MULTIPLIER = PowerMultiplier.CONFIG.multiplier;
private static final String POWER_NBT_KEY = "internalCurrentPower";
private static final String BOOSTER_SLOT_NBT = "BoosterSlot";