mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-13 00:47:32 +00:00
Delete unused things
This commit is contained in:
17 files changed
+10
-1127
No files matched your search
@@ -1,73 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.helpers.Reflected;
|
||||
|
||||
public class GuiCraftAmount extends appeng.client.gui.implementations.GuiCraftAmount {
|
||||
|
||||
private GuiTabButton originalGuiBtn;
|
||||
|
||||
private ItemStack myIcon;
|
||||
|
||||
private int originalGui;
|
||||
|
||||
@Reflected
|
||||
public GuiCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
|
||||
myIcon = is;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "unused" })
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
// Remove the autogenerated button which takes you to the AE2 wireless terminal GUI
|
||||
if (this.buttonList.get(this.buttonList.size() - 1) instanceof GuiTabButton) {
|
||||
this.buttonList.remove(this.buttonList.size() - 1);
|
||||
}
|
||||
|
||||
final Object target = ((ContainerCraftAmount) this.inventorySlots).getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
|
||||
if (this.originalGui > 0 && myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 154,
|
||||
this.guiTop - 4,
|
||||
myIcon,
|
||||
myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
|
||||
public class GuiCraftConfirm extends appeng.client.gui.implementations.GuiCraftConfirm {
|
||||
|
||||
public GuiCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchToOriginalGUI() {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(Reference.GUI_WCT));
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
|
||||
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {
|
||||
|
||||
private GuiTabButton originalGuiBtn;
|
||||
private int originalGui;
|
||||
private ItemStack myIcon = null;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public GuiCraftingStatus(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te);
|
||||
|
||||
ContainerCraftingStatus status = (ContainerCraftingStatus) this.inventorySlots;
|
||||
final Object target = status.getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
for (final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack(1).asSet()) {
|
||||
this.myIcon = wirelessTerminalStack;
|
||||
}
|
||||
|
||||
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
|
||||
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
|
||||
myIcon = is;
|
||||
|
||||
this.originalGui = Reference.GUI_WCT;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
if (this.myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 213,
|
||||
this.guiTop - 4,
|
||||
this.myIcon,
|
||||
this.myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftAmount;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftingStatus;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiMagnet;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftAmount;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftConfirm;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerMagnet;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
@@ -18,10 +13,8 @@ import net.p455w0rd.wirelesscraftingterminal.helpers.WTCGuiObject;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class WCTGuiHandler implements IGuiHandler {
|
||||
@@ -58,31 +51,6 @@ public class WCTGuiHandler implements IGuiHandler {
|
||||
z,
|
||||
ForgeDirection.UNKNOWN,
|
||||
term);
|
||||
case Reference.GUI_CRAFTING_STATUS -> updateGui(
|
||||
new ContainerCraftingStatus(player.inventory, term),
|
||||
world,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
ForgeDirection.UNKNOWN,
|
||||
term);
|
||||
|
||||
case Reference.GUI_CRAFT_AMOUNT -> updateGui(
|
||||
new ContainerCraftAmount(player, term),
|
||||
world,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
ForgeDirection.UNKNOWN,
|
||||
term);
|
||||
case Reference.GUI_CRAFT_CONFIRM -> updateGui(
|
||||
new ContainerCraftConfirm(player, term),
|
||||
world,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
ForgeDirection.UNKNOWN,
|
||||
term);
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
@@ -91,7 +59,7 @@ public class WCTGuiHandler implements IGuiHandler {
|
||||
public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) {
|
||||
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless()
|
||||
.getWirelessTerminalHandler(RandomUtils.getWirelessTerm(player.inventory));
|
||||
if (wh != null) {
|
||||
if (wh != null && guiId == Reference.GUI_WCT) {
|
||||
final WTCGuiObject obj = new WTCGuiObject(
|
||||
wh,
|
||||
RandomUtils.getWirelessTerm(player.inventory),
|
||||
@@ -100,25 +68,7 @@ public class WCTGuiHandler implements IGuiHandler {
|
||||
x,
|
||||
y,
|
||||
z);
|
||||
if (obj != null) {
|
||||
final IPortableCell terminal = obj;
|
||||
|
||||
if (guiId == Reference.GUI_WCT) {
|
||||
return new GuiWirelessCraftingTerminal(player.inventory, obj);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFTING_STATUS) {
|
||||
return new GuiCraftingStatus(player.inventory, terminal);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFT_AMOUNT) {
|
||||
return new GuiCraftAmount(player.inventory, terminal);
|
||||
}
|
||||
|
||||
if (guiId == Reference.GUI_CRAFT_CONFIRM) {
|
||||
return new GuiCraftConfirm(player.inventory, terminal);
|
||||
}
|
||||
}
|
||||
return new GuiWirelessCraftingTerminal(player.inventory, obj);
|
||||
}
|
||||
if (guiId == Reference.GUI_MAGNET) {
|
||||
return new GuiMagnet(new ContainerMagnet(player, player.inventory));
|
||||
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
|
||||
public class ContainerCraftAmount extends appeng.container.implementations.ContainerCraftAmount {
|
||||
|
||||
public ContainerCraftAmount(EntityPlayer player, IPortableCell terminal) {
|
||||
super(player.inventory, terminal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openConfirmationGUI(EntityPlayer player, TileEntity te) {
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_CONFIRM, player, player.worldObj, x, y, z);
|
||||
setupConfirmationGUI(player);
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
|
||||
public class ContainerCraftConfirm extends appeng.container.implementations.ContainerCraftConfirm {
|
||||
|
||||
private final EntityPlayer player;
|
||||
|
||||
public ContainerCraftConfirm(EntityPlayer player, IPortableCell terminal) {
|
||||
super(player.inventory, terminal);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchToOriginalGUI() {
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
WCTGuiHandler.launchGui(Reference.GUI_WCT, player, player.worldObj, x, y, z);
|
||||
}
|
||||
}
|
||||
-27
@@ -7,7 +7,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
@@ -324,32 +323,6 @@ public class ContainerWirelessCraftingTerminal extends ContainerMEMonitorable
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isBoosterInstalled() {
|
||||
Slot slot = getSlotFromInventory(this.boosterInventory, 0);
|
||||
if (slot == null) {
|
||||
return false;
|
||||
}
|
||||
boolean hasStack = getSlotFromInventory(this.boosterInventory, 0).getHasStack();
|
||||
if (hasStack) {
|
||||
Item boosterSlotContents = getSlotFromInventory(this.boosterInventory, 0).getStack().getItem();
|
||||
return boosterSlotContents instanceof ItemInfinityBooster;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMagnetInstalled() {
|
||||
Slot slot = getSlotFromInventory(this.magnetInventory, MAGNET_INDEX);
|
||||
if (slot == null) {
|
||||
return false;
|
||||
}
|
||||
boolean hasStack = getSlotFromInventory(this.magnetInventory, MAGNET_INDEX).getHasStack();
|
||||
if (hasStack) {
|
||||
Item magnetSlotContents = getSlotFromInventory(this.magnetInventory, MAGNET_INDEX).getStack().getItem();
|
||||
return magnetSlotContents instanceof ItemMagnet;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPowered() {
|
||||
double pwr = this.thisItem.getAECurrentPower(this.containerstack);
|
||||
return (pwr > 0.0);
|
||||
|
||||
-12
@@ -6,16 +6,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketConfigSync;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketCraftRequest;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketEmptyTrash;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketInventoryAction;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMagnetFilter;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketNEIRecipe;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketOpenGui;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSetMagnet;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.handler.codec.DecoderException;
|
||||
@@ -28,16 +24,8 @@ public class WCTPacketHandlerBase {
|
||||
|
||||
PACKET_INVENTORY_ACTION(PacketInventoryAction.class),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE(PacketMEInventoryUpdate.class),
|
||||
|
||||
PACKET_VALUE_CONFIG(PacketValueConfig.class),
|
||||
|
||||
PACKET_SWITCH_GUIS(PacketSwitchGuis.class),
|
||||
|
||||
PACKET_RECIPE_NEI(PacketNEIRecipe.class),
|
||||
|
||||
PACKET_CRAFTING_REQUEST(PacketCraftRequest.class),
|
||||
|
||||
PACKET_MAGNETFILTER_MODE(PacketMagnetFilter.class),
|
||||
|
||||
PACKET_OPENWIRELESSTERM(PacketOpenGui.class),
|
||||
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.core.sync.packets;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PacketCraftRequest extends WCTPacket {
|
||||
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
|
||||
public PacketCraftRequest(final ByteBuf stream) {
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
}
|
||||
|
||||
public PacketCraftRequest(final int craftAmt, final boolean shift) {
|
||||
this.amount = craftAmt;
|
||||
this.heldShift = shift;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeBoolean(shift);
|
||||
data.writeLong(this.amount);
|
||||
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
if (player.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) player.openContainer;
|
||||
final Object target = cca.getTarget();
|
||||
if (target instanceof IGridHost) {
|
||||
final IGrid g = cca.getGrid();
|
||||
if (g == null || cca.getItemToCraft() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
cca.getItemToCraft().setStackSize(this.amount);
|
||||
|
||||
Future<ICraftingJob> futureJob = null;
|
||||
try {
|
||||
final ICraftingGrid cg = g.getCache(ICraftingGrid.class);
|
||||
futureJob = cg.beginCraftingJob(
|
||||
cca.getWorld(),
|
||||
cca.getGrid(),
|
||||
cca.getActionSrc(),
|
||||
cca.getItemToCraft(),
|
||||
null);
|
||||
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
|
||||
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_CONFIRM, player, player.worldObj, x, y, z);
|
||||
|
||||
if (player.openContainer instanceof ContainerCraftConfirm) {
|
||||
final ContainerCraftConfirm ccc = (ContainerCraftConfirm) player.openContainer;
|
||||
ccc.setItemToCraft(cca.getItemToCraft());
|
||||
ccc.setAutoStart(this.heldShift);
|
||||
ccc.setJob(futureJob);
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
if (futureJob != null) {
|
||||
futureJob.cancel(true);
|
||||
}
|
||||
// WCTLog.debug(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-37
@@ -5,17 +5,14 @@ import java.io.IOException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
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.reference.Reference;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -96,41 +93,15 @@ public class PacketInventoryAction extends WCTPacket {
|
||||
final EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
Container baseContainer = sender.openContainer;
|
||||
|
||||
if (this.action == InventoryAction.AUTO_CRAFT) {
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
|
||||
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_AMOUNT, player, player.worldObj, x, y, z);
|
||||
|
||||
if (sender.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
|
||||
if (baseContainer instanceof ContainerWirelessCraftingTerminal container) {
|
||||
if (container.getTargetStack() != null) {
|
||||
cca.setItemToCraft(container.getTargetStack());
|
||||
}
|
||||
}
|
||||
|
||||
if (baseContainer instanceof AEBaseContainer container) {
|
||||
if (container.getTargetStack() != null) {
|
||||
cca.setItemToCraft(container.getTargetStack());
|
||||
}
|
||||
}
|
||||
|
||||
cca.detectAndSendChanges();
|
||||
}
|
||||
} else {
|
||||
if (baseContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
if (RandomUtils.getWirelessTerm(player.inventory) == null)
|
||||
((ContainerWirelessCraftingTerminal) baseContainer).setValidContainer(false);
|
||||
else((ContainerWirelessCraftingTerminal) baseContainer)
|
||||
.doAction(sender, this.action, this.slot, this.id);
|
||||
}
|
||||
if (baseContainer instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) baseContainer).doAction(sender, this.action, this.slot, this.id);
|
||||
}
|
||||
if (baseContainer instanceof ContainerWirelessCraftingTerminal) {
|
||||
if (RandomUtils.getWirelessTerm(player.inventory) == null)
|
||||
((ContainerWirelessCraftingTerminal) baseContainer).setValidContainer(false);
|
||||
else((ContainerWirelessCraftingTerminal) baseContainer).doAction(sender, this.action, this.slot, this.id);
|
||||
}
|
||||
if (baseContainer instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) baseContainer).doAction(sender, this.action, this.slot, this.id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-162
@@ -1,162 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.core.sync.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PacketMEInventoryUpdate extends WCTPacket {
|
||||
|
||||
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
|
||||
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
|
||||
private static final int TEMP_BUFFER_SIZE = 1024;
|
||||
private static final int STREAM_MASK = 0xff;
|
||||
|
||||
// input.
|
||||
@Nullable
|
||||
private final List<IAEItemStack> list;
|
||||
// output...
|
||||
private final byte ref;
|
||||
|
||||
@Nullable
|
||||
private final ByteBuf data;
|
||||
|
||||
@Nullable
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
// automatic.
|
||||
public PacketMEInventoryUpdate(final ByteBuf stream) throws IOException {
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
this.list = new LinkedList<IAEItemStack>();
|
||||
this.ref = stream.readByte();
|
||||
|
||||
final GZIPInputStream gzReader = new GZIPInputStream(new InputStream() {
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (stream.readableBytes() <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return stream.readByte() & STREAM_MASK;
|
||||
}
|
||||
});
|
||||
|
||||
final ByteBuf uncompressed = Unpooled.buffer(stream.readableBytes());
|
||||
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
|
||||
while (gzReader.available() != 0) {
|
||||
final int bytes = gzReader.read(tmp);
|
||||
if (bytes > 0) {
|
||||
uncompressed.writeBytes(tmp, 0, bytes);
|
||||
}
|
||||
}
|
||||
gzReader.close();
|
||||
|
||||
while (uncompressed.readableBytes() > 0) {
|
||||
this.list.add(AEItemStack.loadItemStackFromPacket(uncompressed));
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate() throws IOException {
|
||||
this((byte) 0);
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate(final byte ref) throws IOException {
|
||||
this.ref = ref;
|
||||
this.data = Unpooled.buffer(OPERATION_BYTE_LIMIT);
|
||||
this.data.writeInt(this.getPacketID());
|
||||
this.data.writeByte(this.ref);
|
||||
|
||||
this.compressFrame = new GZIPOutputStream(new OutputStream() {
|
||||
|
||||
@Override
|
||||
public void write(final int value) throws IOException {
|
||||
PacketMEInventoryUpdate.this.data.writeByte(value);
|
||||
}
|
||||
});
|
||||
|
||||
this.list = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
if (gs instanceof GuiCraftConfirm) {
|
||||
((GuiCraftConfirm) gs).postUpdate(this.list, this.ref);
|
||||
}
|
||||
|
||||
if (gs instanceof GuiWirelessCraftingTerminal) {
|
||||
((GuiWirelessCraftingTerminal) gs).postUpdate(this.list);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FMLProxyPacket getProxy() {
|
||||
try {
|
||||
this.compressFrame.close();
|
||||
|
||||
this.configureWrite(this.data);
|
||||
return super.getProxy();
|
||||
} catch (final IOException e) {
|
||||
WCTLog.debug(e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void appendItem(final IAEItemStack is) throws IOException, BufferOverflowException {
|
||||
final ByteBuf tmp = Unpooled.buffer(OPERATION_BYTE_LIMIT);
|
||||
is.writeToPacket(tmp);
|
||||
|
||||
this.compressFrame.flush();
|
||||
if (this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT) {
|
||||
throw new BufferOverflowException();
|
||||
} else {
|
||||
this.writtenBytes += tmp.readableBytes();
|
||||
this.compressFrame.write(tmp.array(), 0, tmp.readableBytes());
|
||||
this.empty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.data.readableBytes();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.empty;
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.core.sync.packets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
|
||||
import appeng.util.Platform;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PacketSwitchGuis extends WCTPacket {
|
||||
|
||||
private final int newGui;
|
||||
|
||||
// automatic.
|
||||
public PacketSwitchGuis(final ByteBuf stream) {
|
||||
this.newGui = stream.readInt();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketSwitchGuis(final int newGui) {
|
||||
this.newGui = newGui;
|
||||
|
||||
if (Platform.isClient()) {
|
||||
GuiWirelessCraftingTerminal.setSwitchingGuis(true);
|
||||
}
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeInt(newGui);
|
||||
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
World world = player.worldObj;
|
||||
int x = (int) player.posX;
|
||||
int y = (int) player.posY;
|
||||
int z = (int) player.posZ;
|
||||
WCTGuiHandler.launchGui(newGui, player, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
GuiWirelessCraftingTerminal.setSwitchingGuis(true);
|
||||
}
|
||||
}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.helpers.IMouseWheelItem;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PacketValueConfig extends WCTPacket {
|
||||
|
||||
private final String Name;
|
||||
private final String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig(final ByteBuf stream) throws IOException {
|
||||
final DataInputStream dis = new DataInputStream(
|
||||
new ByteArrayInputStream(stream.array(), stream.readerIndex(), stream.readableBytes()));
|
||||
this.Name = dis.readUTF();
|
||||
this.Value = dis.readUTF();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketValueConfig(final String name, final String value) throws IOException {
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final DataOutputStream dos = new DataOutputStream(bos);
|
||||
dos.writeUTF(name);
|
||||
dos.writeUTF(value);
|
||||
data.writeBytes(bos.toByteArray());
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if (this.Name.equals("Item") && RandomUtils.getWirelessTerm(player.inventory) != null
|
||||
&& RandomUtils.getWirelessTerm(player.inventory).getItem() instanceof IMouseWheelItem) {
|
||||
final ItemStack is = RandomUtils.getWirelessTerm(player.inventory);
|
||||
final IMouseWheelItem si = (IMouseWheelItem) is.getItem();
|
||||
si.onWheel(is, this.Value.equals("WheelUp"));
|
||||
} else if (c instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (final Settings e : cm.getSettings()) {
|
||||
if (e.name().equals(this.Name)) {
|
||||
final Enum<?> def = cm.getSetting(e);
|
||||
|
||||
try {
|
||||
cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value));
|
||||
} catch (final IllegalArgumentException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if (this.Name.equals("CustomName")) {
|
||||
if (c instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) c).setCustomName(this.Value);
|
||||
}
|
||||
} else if (this.Name.startsWith("SyncDat.")) {
|
||||
if (c instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value);
|
||||
}
|
||||
} else if (c instanceof IConfigurableObject) {
|
||||
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
|
||||
|
||||
for (final Settings e : cm.getSettings()) {
|
||||
if (e.name().equals(this.Name)) {
|
||||
final Enum<?> def = cm.getSetting(e);
|
||||
|
||||
try {
|
||||
cm.putSetting(e, Enum.valueOf(def.getClass(), this.Value));
|
||||
} catch (final IllegalArgumentException err) {
|
||||
// :P
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-339
@@ -1,339 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.helpers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTerminalItem;
|
||||
import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionHost;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IWirelessAccessPoint;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IMachineSet;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
public class WirelessTerminalGuiObject
|
||||
implements IActionHost, IPortableCell, IInventorySlotAware, WCTIActionHost, IGuiItemObject {
|
||||
|
||||
private final ItemStack effectiveItem;
|
||||
private final IWirelessTermHandler wth;
|
||||
private final String encryptionKey;
|
||||
private final EntityPlayer myPlayer;
|
||||
private IGrid targetGrid;
|
||||
private IStorageGrid sg;
|
||||
private IMEMonitor<IAEItemStack> itemStorage;
|
||||
private IWirelessAccessPoint myWap;
|
||||
private double sqRange = Double.MAX_VALUE;
|
||||
private double myRange = Double.MAX_VALUE;
|
||||
private final int inventorySlot;
|
||||
|
||||
public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep,
|
||||
final World w, final int x, final int y, final int z) {
|
||||
this.encryptionKey = wh.getEncryptionKey(is);
|
||||
this.effectiveItem = is;
|
||||
this.myPlayer = ep;
|
||||
this.wth = wh;
|
||||
this.inventorySlot = x;
|
||||
ILocatable obj = null;
|
||||
try {
|
||||
final long encKey = Long.parseLong(this.encryptionKey);
|
||||
obj = AEApi.instance().registries().locatable().getLocatableBy(encKey);
|
||||
} catch (final NumberFormatException err) {
|
||||
// :P
|
||||
}
|
||||
|
||||
if (obj instanceof IGridHost) {
|
||||
final IGridNode n = ((IGridHost) obj).getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (n != null) {
|
||||
this.targetGrid = n.getGrid();
|
||||
if (this.targetGrid != null) {
|
||||
this.sg = this.targetGrid.getCache(IStorageGrid.class);
|
||||
if (this.sg != null) {
|
||||
this.itemStorage = this.sg.getItemInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether an infinity booster card is installed on the WCT.
|
||||
*/
|
||||
private boolean checkForBooster() {
|
||||
if (effectiveItem != null && effectiveItem.getItem() instanceof IWirelessCraftingTerminalItem) {
|
||||
IWirelessCraftingTerminalItem wct = (IWirelessCraftingTerminalItem) effectiveItem.getItem();
|
||||
return wct.checkForBooster(effectiveItem);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public IGrid getTargetGrid() {
|
||||
return this.targetGrid;
|
||||
}
|
||||
|
||||
public double getRange() {
|
||||
return this.myRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
if (this.sg == null) {
|
||||
return null;
|
||||
}
|
||||
return this.sg.getItemInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
if (this.sg == null) {
|
||||
return null;
|
||||
}
|
||||
return this.sg.getFluidInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final IMEMonitorHandlerReceiver<IAEItemStack> l, final Object verificationToken) {
|
||||
if (this.itemStorage != null) {
|
||||
this.itemStorage.addListener(l, verificationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(final IMEMonitorHandlerReceiver<IAEItemStack> l) {
|
||||
if (this.itemStorage != null) {
|
||||
this.itemStorage.removeListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(final IItemList out, int iteration) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getAvailableItems(out, iteration);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getStorageList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getAccess() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getAccess();
|
||||
}
|
||||
return AccessRestriction.NO_ACCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized(final IAEItemStack input) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.isPrioritized(input);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept(final IAEItemStack input) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.canAccept(input);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getPriority();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getSlot();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validForPass(final int i) {
|
||||
return this.itemStorage.validForPass(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(final IAEItemStack input, final Actionable type, final BaseActionSource src) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.injectItems(input, type, src);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(final IAEItemStack request, final Actionable mode, final BaseActionSource src) {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.extractItems(request, mode, src);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel() {
|
||||
if (this.itemStorage != null) {
|
||||
return this.itemStorage.getChannel();
|
||||
}
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier usePowerMultiplier) {
|
||||
if (this.wth != null && this.effectiveItem != null) {
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return this.wth.hasPower(this.myPlayer, amt, this.effectiveItem) ? amt : 0;
|
||||
}
|
||||
return this.wth.usePower(this.myPlayer, amt, this.effectiveItem) ? amt : 0;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.effectiveItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return this.wth.getConfigManager(this.effectiveItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(final ForgeDirection dir) {
|
||||
return this.getActionableNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(final ForgeDirection dir) {
|
||||
return AECableType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {}
|
||||
|
||||
@Override
|
||||
public IGridNode getActionableNode() {
|
||||
return getActionableNode(checkForBooster());
|
||||
}
|
||||
|
||||
public IGridNode getActionableNode(boolean ignoreRange) {
|
||||
this.rangeCheck(ignoreRange);
|
||||
if (this.myWap != null) {
|
||||
// return this.getTargetGrid().getPivot();
|
||||
return this.myWap.getActionableNode();
|
||||
} else {
|
||||
if (ignoreRange && this.getTargetGrid() != null) {
|
||||
return this.getTargetGrid().getPivot();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean rangeCheck() {
|
||||
return rangeCheck(checkForBooster());
|
||||
}
|
||||
|
||||
public boolean rangeCheck(boolean ignoreRange) {
|
||||
this.sqRange = this.myRange = Double.MAX_VALUE;
|
||||
|
||||
if (this.targetGrid != null && this.itemStorage != null) {
|
||||
if (this.myWap != null) {
|
||||
if (this.myWap.getGrid() == this.targetGrid) {
|
||||
if (this.testWap(this.myWap)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final IMachineSet tw = this.targetGrid.getMachines(TileWireless.class);
|
||||
|
||||
this.myWap = null;
|
||||
|
||||
for (final IGridNode n : tw) {
|
||||
final IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine();
|
||||
if (this.testWap(wap, ignoreRange)) {
|
||||
this.myWap = wap;
|
||||
}
|
||||
}
|
||||
|
||||
return this.myWap != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean testWap(final IWirelessAccessPoint wap) {
|
||||
return testWap(wap, checkForBooster());
|
||||
}
|
||||
|
||||
private boolean testWap(final IWirelessAccessPoint wap, boolean ignoreRange) {
|
||||
double rangeLimit = wap.getRange();
|
||||
rangeLimit *= rangeLimit;
|
||||
|
||||
final DimensionalCoord dc = wap.getLocation();
|
||||
|
||||
if (dc.getWorld() == this.myPlayer.worldObj) {
|
||||
final double offX = dc.x - this.myPlayer.posX;
|
||||
final double offY = dc.y - this.myPlayer.posY;
|
||||
final double offZ = dc.z - this.myPlayer.posZ;
|
||||
|
||||
final double r = offX * offX + offY * offY + offZ * offZ;
|
||||
if (r < rangeLimit && this.sqRange > r && !ignoreRange) {
|
||||
if (wap.isActive()) {
|
||||
this.sqRange = r;
|
||||
this.myRange = Math.sqrt(r);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (wap.isActive() && ignoreRange) {
|
||||
this.sqRange = r;
|
||||
this.myRange = Math.sqrt(r);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventorySlot() {
|
||||
return this.inventorySlot;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import net.p455w0rd.wirelesscraftingterminal.integration.IIntegrationModule;
|
||||
import net.p455w0rd.wirelesscraftingterminal.integration.IntegrationHelper;
|
||||
import net.p455w0rd.wirelesscraftingterminal.integration.abstraction.INEI;
|
||||
import net.p455w0rd.wirelesscraftingterminal.integration.modules.NEIHelpers.NEIAEShapedRecipeHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.integration.modules.NEIHelpers.NEIGUIHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -72,7 +71,6 @@ public class NEI implements INEI, IContainerTooltipHandler, IIntegrationModule {
|
||||
"crafting");
|
||||
API.registerRecipeHandler(new NEIAEShapedRecipeHandler());
|
||||
API.registerRecipeHandler(new NEIAEShapelessRecipeHandler());
|
||||
API.registerNEIGuiHandler(new NEIGUIHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.integration.modules.NEIHelpers;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
|
||||
|
||||
import codechicken.nei.api.INEIGuiAdapter;
|
||||
|
||||
public class NEIGUIHandler extends INEIGuiAdapter {
|
||||
|
||||
protected Pattern SPECIAL_REGEX_CHARS = Pattern.compile("[{}()\\[\\].+*?^$\\\\|]");
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) {
|
||||
if (gui instanceof GuiWirelessCraftingTerminal && draggedStack != null && draggedStack.getItem() != null) {
|
||||
GuiWirelessCraftingTerminal gmm = (GuiWirelessCraftingTerminal) gui;
|
||||
if (gmm.isOverSearchField(mousex, mousey)) {
|
||||
gmm.setSearchString(SPECIAL_REGEX_CHARS.matcher(draggedStack.getDisplayName()).replaceAll("\\\\$0"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.handleDragNDrop(gui, mousex, mousey, draggedStack, button);
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,5 @@ public class Reference {
|
||||
|
||||
// Gui IDs
|
||||
public static final int GUI_WCT = 0;
|
||||
public static final int GUI_CRAFTING_STATUS = 1;
|
||||
public static final int GUI_CRAFT_AMOUNT = 2;
|
||||
public static final int GUI_CRAFT_CONFIRM = 3;
|
||||
public static final int GUI_MAGNET = 4;
|
||||
}
|
||||
Reference in new issue
Block a user