diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftConfirm.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftConfirm.java index bf91443..975382f 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftConfirm.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftConfirm.java @@ -1,12 +1,9 @@ package net.p455w0rd.wirelesscraftingterminal.client.gui; import appeng.api.storage.ITerminalHost; -import appeng.core.localization.GuiText; -import net.minecraft.client.gui.GuiButton; 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.helpers.WirelessTerminalGuiObject; import net.p455w0rd.wirelesscraftingterminal.reference.Reference; public class GuiCraftConfirm extends appeng.client.gui.implementations.GuiCraftConfirm { diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftingStatus.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftingStatus.java index 1c56db6..41661ed 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftingStatus.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiCraftingStatus.java @@ -57,6 +57,8 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf @Override public void initGui() { super.initGui(); + // Hide "go back to wireless terminal" button as it opens the wrong GUI + this.buttonList.remove(this.buttonList.size() - 1); if (this.myIcon != null) { this.buttonList.add( diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiWirelessCraftingTerminal.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiWirelessCraftingTerminal.java index d10eb52..13abe91 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiWirelessCraftingTerminal.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/gui/GuiWirelessCraftingTerminal.java @@ -15,6 +15,11 @@ import appeng.client.gui.widgets.GuiScrollbar; import appeng.client.gui.widgets.ISortSource; import appeng.client.me.InternalSlotME; import appeng.client.me.ItemRepo; +import appeng.client.me.SlotME; +import appeng.container.AEBaseContainer; +import appeng.container.slot.AppEngSlot; +import appeng.container.slot.SlotCraftingMatrix; +import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.core.AEConfig; import appeng.core.CommonHelper; import appeng.core.localization.ButtonToolTips; @@ -25,9 +30,16 @@ import appeng.util.Platform; import codechicken.nei.TextField; import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.ReflectionHelper; +import java.io.IOException; +import java.lang.reflect.Field; +import java.text.NumberFormat; +import java.util.List; +import java.util.Locale; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -35,11 +47,7 @@ import net.minecraft.util.ResourceLocation; import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton; import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTrashButton; import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.MEGuiTextField; -import net.p455w0rd.wirelesscraftingterminal.client.me.SlotME; import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.AppEngSlot; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingMatrix; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotFakeCraftingMatrix; import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotTrash; import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog; import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler; @@ -52,35 +60,29 @@ import net.p455w0rd.wirelesscraftingterminal.reference.Reference; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.io.IOException; -import java.lang.reflect.Field; -import java.text.NumberFormat; -import java.util.List; -import java.util.Locale; - public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSource, IConfigManagerHost { private float xSize_lo; private float ySize_lo; public static int tick = 0, - GUI_HEIGHT = 240, - GUI_WIDTH = 230, - AE_ROW_HEIGHT = 18, - AE_NUM_ROWS = 0, - GUI_UPPER_HEIGHT = 35, - GUI_SEARCH_ROW = 35, - SEARCH_X = 81, - SEARCH_Y = 5, - SEARCH_WIDTH = 88, - SEARCH_HEIGHT = 12, - SEARCH_MAXCHARS = 15, - GUI_LOWER_HEIGHT, - AE_TOTAL_ROWS_HEIGHT, - BUTTON_SEARCH_MODE_POS_X = -18, - BUTTON_SEARCH_MODE_POS_Y = 68, - BUTTON_SIZE = 16, - NEI_EXTRA_SPACE = 30, - slotYOffset; + GUI_HEIGHT = 240, + GUI_WIDTH = 230, + AE_ROW_HEIGHT = 18, + AE_NUM_ROWS = 0, + GUI_UPPER_HEIGHT = 35, + GUI_SEARCH_ROW = 35, + SEARCH_X = 81, + SEARCH_Y = 5, + SEARCH_WIDTH = 88, + SEARCH_HEIGHT = 12, + SEARCH_MAXCHARS = 15, + GUI_LOWER_HEIGHT, + AE_TOTAL_ROWS_HEIGHT, + BUTTON_SEARCH_MODE_POS_X = -18, + BUTTON_SEARCH_MODE_POS_Y = 68, + BUTTON_SIZE = 16, + NEI_EXTRA_SPACE = 30, + slotYOffset; protected static final int BUTTON_SEARCH_MODE_ID = 5; protected static final long TOOLTIP_UPDATE_INTERVAL = 3000L; private int currScreenWidth, currScreenHeight; @@ -147,8 +149,8 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc private void setScrollBar() { this.getScrollBar().setTop(18).setLeft(174).setHeight(this.rows * 18 - 2); this.getScrollBar() - .setRange( - 0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6)); + .setRange( + 0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6)); } @SuppressWarnings("rawtypes") @@ -165,7 +167,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc if (iBtn.getSetting() != Settings.ACTIONS) { final Enum cv = iBtn.getCurrentValue(); final Enum next = - Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues()); + Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues()); if (btn == this.terminalStyleBox) { AEConfig.instance.settings.putSetting(iBtn.getSetting(), next); @@ -177,7 +179,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc } else { try { NetworkHandler.instance.sendToServer( - new PacketValueConfig(iBtn.getSetting().name(), next.name())); + new PacketValueConfig(iBtn.getSetting().name(), next.name())); } catch (final IOException e) { WCTLog.debug(e.getMessage()); } @@ -200,7 +202,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc if (s != null) { final PacketInventoryAction p = - new PacketInventoryAction(InventoryAction.MOVE_REGION, s.slotNumber, 0); + new PacketInventoryAction(InventoryAction.MOVE_REGION, s.slotNumber, 0); NetworkHandler.instance.sendToServer(p); } } @@ -225,6 +227,47 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc } } + @Override + protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int mouseButton) { + // Handle autocraft requests ourselves to spawn the right GUI classes + final EntityPlayer player = Minecraft.getMinecraft().thePlayer; + + if (slot instanceof SlotME) { + InventoryAction action = null; + IAEItemStack stack = null; + + switch (mouseButton) { + case 0: // pickup / set-down. + action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; + stack = ((SlotME) slot).getAEStack(); + + if (stack != null + && action == InventoryAction.PICKUP_OR_SET_DOWN + && stack.getStackSize() == 0 + && player.inventory.getItemStack() == null) { + action = InventoryAction.AUTO_CRAFT; + } + + break; + case 3: // creative dupe: + stack = ((SlotME) slot).getAEStack(); + if (stack != null && stack.isCraftable()) { + action = InventoryAction.AUTO_CRAFT; + } + break; + default: + } + if (action == InventoryAction.AUTO_CRAFT) { + ((AEBaseContainer) this.inventorySlots).setTargetStack(stack); + final PacketInventoryAction p = + new PacketInventoryAction(action, this.inventorySlots.inventorySlots.size(), 0); + NetworkHandler.instance.sendToServer(p); + } + return; + } + super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton); + } + private void reinitalize() { this.buttonList.clear(); this.initGui(); @@ -257,8 +300,8 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc Keyboard.enableRepeatEvents(true); this.maxRows = this.getMaxRows(); this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL - ? 9 - : 9 + ((this.width - this.standardSize) / 18); + ? 9 + : 9 + ((this.width - this.standardSize) / 18); this.isNEIEnabled = Loader.isModLoaded("NotEnoughItems"); int top = isNEIEnabled ? 22 : 0; final int magicNumber = 114 + 1; @@ -281,7 +324,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc for (int y = 0; y < this.rows; y++) { for (int x = 0; x < this.perRow; x++) { this.getMeSlots() - .add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18)); + .add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18)); } } if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) { @@ -298,52 +341,52 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc this.buttonList.clear(); this.buttonList.add( - this.clearBtn = new GuiImgButton( - this.guiLeft + 134, this.guiTop + this.ySize - 160, Settings.ACTIONS, ActionItems.STASH)); + this.clearBtn = new GuiImgButton( + this.guiLeft + 134, this.guiTop + this.ySize - 160, Settings.ACTIONS, ActionItems.STASH)); this.buttonList.add(this.trashBtn = new GuiTrashButton(this.guiLeft + 98, this.guiTop + this.ySize - 104)); this.clearBtn.setHalfSize(true); if (this.customSortOrder) { this.buttonList.add( - this.SortByBox = new GuiImgButton( - this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY))); + this.SortByBox = new GuiImgButton( + this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY))); offset += 20; } this.buttonList.add( - this.ViewBox = new GuiImgButton( - this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting(Settings.VIEW_MODE))); + this.ViewBox = new GuiImgButton( + this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting(Settings.VIEW_MODE))); offset += 20; this.buttonList.add( - this.SortDirBox = new GuiImgButton( - this.guiLeft - 18, - offset, - Settings.SORT_DIRECTION, - this.configSrc.getSetting(Settings.SORT_DIRECTION))); + this.SortDirBox = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.SORT_DIRECTION, + this.configSrc.getSetting(Settings.SORT_DIRECTION))); offset += 20; this.buttonList.add( - this.searchBoxSettings = new GuiImgButton( - this.guiLeft - 18, - offset, - Settings.SEARCH_MODE, - AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE))); + this.searchBoxSettings = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.SEARCH_MODE, + AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE))); offset += 20; this.buttonList.add( - this.searchStringSave = new GuiImgButton( - this.guiLeft - 18, - offset, - Settings.SAVE_SEARCH, - AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO)); + this.searchStringSave = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.SAVE_SEARCH, + AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO)); offset += 20; this.buttonList.add( - this.terminalStyleBox = new GuiImgButton( - this.guiLeft - 18, - offset, - Settings.TERMINAL_STYLE, - AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE))); + this.terminalStyleBox = new GuiImgButton( + this.guiLeft - 18, + offset, + Settings.TERMINAL_STYLE, + AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE))); this.searchField = new MEGuiTextField(this.fontRendererObj, SEARCH_X, SEARCH_Y, SEARCH_WIDTH, SEARCH_HEIGHT); @@ -354,12 +397,12 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc this.searchField.setEnabled(true); this.buttonList.add( - this.craftingStatusBtn = new GuiTabButton( - this.guiLeft + 169, - this.guiTop - 4, - 2 + 11 * 16, - GuiText.CraftingStatus.getLocal(), - itemRender)); + this.craftingStatusBtn = new GuiTabButton( + this.guiLeft + 169, + this.guiTop - 4, + 2 + 11 * 16, + GuiText.CraftingStatus.getLocal(), + itemRender)); this.craftingStatusBtn.setHideEdge(13); final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); @@ -398,8 +441,8 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc int getMaxRows() { return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL - ? 6 - : Integer.MAX_VALUE; + ? 6 + : Integer.MAX_VALUE; } protected void repositionSlot(final AppEngSlot s) { @@ -466,8 +509,8 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc */ private boolean hasScreenResChanged() { if ((this.currScreenWidth != this.mc.displayWidth) - || (this.currScreenHeight != this.mc.displayHeight) - || (this.isFullScreen != this.mc.isFullScreen())) { + || (this.currScreenHeight != this.mc.displayHeight) + || (this.isFullScreen != this.mc.isFullScreen())) { this.currScreenWidth = this.mc.displayWidth; this.currScreenHeight = this.mc.displayHeight; this.isFullScreen = this.mc.isFullScreen(); @@ -511,12 +554,12 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc // draw player inv this.drawTexturedModalRect( - offsetX, - offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, - 0, - 106 - 18 - 18, - x_width, - 99 + this.reservedSpace - this.lowerTextureOffset); + offsetX, + offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, + 0, + 106 - 18 - 18, + x_width, + 99 + this.reservedSpace - this.lowerTextureOffset); // draw view cells this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 32, 104); @@ -525,12 +568,12 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc this.drawTexturedModalRect(this.guiLeft + 132, (this.guiTop + this.rows * 18) + 83, 237, 237, 19, 19); } GuiInventory.func_147046_a( - this.guiLeft + 51, - (this.guiTop + this.rows * 18) + 94, - 32, - (float) (this.guiLeft + 51) - this.xSize_lo, - (float) ((this.guiTop + this.rows * 18) + 50) - this.ySize_lo, - this.mc.thePlayer); + this.guiLeft + 51, + (this.guiTop + this.rows * 18) + 94, + 32, + (float) (this.guiLeft + 51) - this.xSize_lo, + (float) ((this.guiTop + this.rows * 18) + 50) - this.ySize_lo, + this.mc.thePlayer); boolean update = false; for (int i = 0; i < 5; i++) { @@ -598,7 +641,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc } final boolean mouseInGui = - this.isPointInRegion(0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY); + this.isPointInRegion(0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY); if (this.isAutoFocus && !this.searchField.isFocused() && mouseInGui) { this.searchField.setFocused(true); } @@ -623,7 +666,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc } public List handleItemTooltip( - final ItemStack stack, final int mouseX, final int mouseY, final List currentToolTip) { + final ItemStack stack, final int mouseX, final int mouseY, final List currentToolTip) { if (stack != null) { final Slot s = this.getSlot(mouseX, mouseY); if (s instanceof SlotME) { @@ -641,7 +684,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc if (myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged())) { final String local = ButtonToolTips.ItemsStored.getLocal(); final String formattedAmount = - NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize()); + NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize()); final String format = String.format(local, formattedAmount); currentToolTip.add("\u00a77" + format); @@ -650,7 +693,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc if (myStack.getCountRequestable() > 0) { final String local = ButtonToolTips.ItemsRequestable.getLocal(); final String formattedAmount = - NumberFormat.getNumberInstance(Locale.US).format(myStack.getCountRequestable()); + NumberFormat.getNumberInstance(Locale.US).format(myStack.getCountRequestable()); final String format = String.format(local, formattedAmount); currentToolTip.add("\u00a77" + format); @@ -658,7 +701,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc } else if (stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged())) { final String local = ButtonToolTips.ItemsStored.getLocal(); final String formattedAmount = - NumberFormat.getNumberInstance(Locale.US).format(stack.stackSize); + NumberFormat.getNumberInstance(Locale.US).format(stack.stackSize); final String format = String.format(local, formattedAmount); currentToolTip.add("\u00a77" + format); @@ -685,23 +728,23 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc if (myStack != null) { final List currentToolTip = - stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); + stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); if (myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged())) { currentToolTip.add("Items Stored: " - + NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize())); + + NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize())); } if (myStack.getCountRequestable() > 0) { currentToolTip.add("Items Requestable: " - + NumberFormat.getNumberInstance(Locale.US).format(myStack.getCountRequestable())); + + NumberFormat.getNumberInstance(Locale.US).format(myStack.getCountRequestable())); } this.drawTooltip(x, y, 0, join(currentToolTip, "\n")); } else if (stack.stackSize > BigNumber) { final List var4 = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips); var4.add("Items Stored: " - + NumberFormat.getNumberInstance(Locale.US).format(stack.stackSize)); + + NumberFormat.getNumberInstance(Locale.US).format(stack.stackSize)); this.drawTooltip(x, y, 0, join(var4, "\n")); return; } @@ -772,9 +815,9 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc pointX -= i; pointY -= j; return pointX >= rectX - 1 - && pointX < rectX + rectWidth + 1 - && pointY >= rectY - 1 - && pointY < rectY + rectHeight + 1; + && pointX < rectX + rectWidth + 1 + && pointY >= rectY - 1 + && pointY < rectY + rectHeight + 1; } private boolean isNEIFocused() { @@ -783,7 +826,7 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc } try { final Class c = - ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager"); + ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager"); final Field fldSearchField = c.getField("searchField"); final TextField searchField = (TextField) fldSearchField.get(c); return searchField.focused(); diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/ClientDCInternalInv.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/ClientDCInternalInv.java deleted file mode 100644 index dfc6634..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/ClientDCInternalInv.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.me; - -import appeng.tile.inventory.AppEngInternalInventory; -import appeng.util.ItemSorters; -import javax.annotation.Nonnull; -import net.minecraft.util.StatCollector; - -public class ClientDCInternalInv implements Comparable { - - private final String unlocalizedName; - private final AppEngInternalInventory inventory; - - private final long id; - private final long sortBy; - - public ClientDCInternalInv(final int size, final long id, final long sortBy, final String unlocalizedName) { - this.inventory = new AppEngInternalInventory(null, size); - this.unlocalizedName = unlocalizedName; - this.id = id; - this.sortBy = sortBy; - } - - public String getName() { - final String s = StatCollector.translateToLocal(this.unlocalizedName + ".name"); - if (s.equals(this.unlocalizedName + ".name")) { - return StatCollector.translateToLocal(this.unlocalizedName); - } - return s; - } - - @Override - public int compareTo(@Nonnull final ClientDCInternalInv o) { - return ItemSorters.compareLong(this.sortBy, o.sortBy); - } - - public AppEngInternalInventory getInventory() { - return this.inventory; - } - - public long getId() { - return this.id; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/InternalSlotME.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/InternalSlotME.java deleted file mode 100644 index ef8e492..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/InternalSlotME.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.me; - -import appeng.api.storage.data.IAEItemStack; -import net.minecraft.item.ItemStack; - -public class InternalSlotME { - - private final int offset; - private final int xPos; - private final int yPos; - private final ItemRepo repo; - - public InternalSlotME(final ItemRepo def, final int offset, final int displayX, final int displayY) { - this.repo = def; - this.offset = offset; - this.xPos = displayX; - this.yPos = displayY; - } - - ItemStack getStack() { - return this.repo.getItem(this.offset); - } - - IAEItemStack getAEStack() { - return this.repo.getReferenceItem(this.offset); - } - - boolean hasPower() { - return this.repo.hasPower(); - } - - int getxPosition() { - return this.xPos; - } - - int getyPosition() { - return this.yPos; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/ItemRepo.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/ItemRepo.java deleted file mode 100644 index 8bf0a1e..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/ItemRepo.java +++ /dev/null @@ -1,240 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.me; - -import appeng.api.AEApi; -import appeng.api.config.SearchBoxMode; -import appeng.api.config.Settings; -import appeng.api.config.SortOrder; -import appeng.api.config.ViewItems; -import appeng.api.config.YesNo; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.client.gui.widgets.IScrollSource; -import appeng.client.gui.widgets.ISortSource; -import appeng.core.AEConfig; -import appeng.items.storage.ItemViewCell; -import appeng.util.ItemSorters; -import appeng.util.Platform; -import appeng.util.prioitylist.IPartitionList; -import cpw.mods.fml.relauncher.ReflectionHelper; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.regex.Pattern; -import javax.annotation.Nonnull; -import net.minecraft.item.ItemStack; - -public class ItemRepo { - - private final IItemList list = AEApi.instance().storage().createItemList(); - private final ArrayList view = new ArrayList(); - private final ArrayList dsp = new ArrayList(); - private final IScrollSource src; - private final ISortSource sortSrc; - - private int rowSize = 9; - - private String searchString = ""; - private IPartitionList myPartitionList; - private String innerSearch = ""; - private String NEIWord = null; - private boolean hasPower; - - public ItemRepo(final IScrollSource src, final ISortSource sortSrc) { - this.src = src; - this.sortSrc = sortSrc; - } - - public IAEItemStack getReferenceItem(int idx) { - idx += this.src.getCurrentScroll() * this.rowSize; - - if (idx >= this.view.size()) { - return null; - } - return this.view.get(idx); - } - - public ItemStack getItem(int idx) { - idx += this.src.getCurrentScroll() * this.rowSize; - - if (idx >= this.dsp.size()) { - return null; - } - return this.dsp.get(idx); - } - - void setSearch(final String search) { - this.searchString = search == null ? "" : search; - } - - public void postUpdate(final IAEItemStack is) { - final IAEItemStack st = this.list.findPrecise(is); - - if (st != null) { - st.reset(); - st.add(is); - } else { - this.list.add(is); - } - } - - public void setViewCell(final ItemStack[] list) { - this.myPartitionList = ItemViewCell.createFilter(list); - this.updateView(); - } - - @SuppressWarnings("rawtypes") - public void updateView() { - this.view.clear(); - this.dsp.clear(); - - this.view.ensureCapacity(this.list.size()); - this.dsp.ensureCapacity(this.list.size()); - - final Enum viewMode = this.sortSrc.getSortDisplay(); - final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE); - if (searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH) { - this.updateNEI(this.searchString); - } - - this.innerSearch = this.searchString; - final boolean terminalSearchToolTips = - AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO; - // boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO; - - boolean searchMod = false; - if (this.innerSearch.startsWith("@")) { - searchMod = true; - this.innerSearch = this.innerSearch.substring(1); - } - - Pattern m = null; - try { - m = Pattern.compile(this.innerSearch.toLowerCase(), Pattern.CASE_INSENSITIVE); - } catch (final Throwable ignore) { - try { - m = Pattern.compile(Pattern.quote(this.innerSearch.toLowerCase()), Pattern.CASE_INSENSITIVE); - } catch (final Throwable __) { - return; - } - } - - boolean notDone = false; - for (IAEItemStack is : this.list) { - if (this.myPartitionList != null) { - if (!this.myPartitionList.isListed(is)) { - continue; - } - } - - if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) { - continue; - } - - if (viewMode == ViewItems.CRAFTABLE) { - is = is.copy(); - is.setStackSize(0); - } - - if (viewMode == ViewItems.STORED && is.getStackSize() == 0) { - continue; - } - - final String dspName = searchMod ? Platform.getModId(is) : Platform.getItemDisplayName(is); - notDone = true; - - if (m.matcher(dspName.toLowerCase()).find()) { - this.view.add(is); - notDone = false; - } - - if (terminalSearchToolTips && notDone) { - for (final Object lp : Platform.getTooltip(is)) { - if (lp instanceof String && m.matcher((CharSequence) lp).find()) { - this.view.add(is); - notDone = false; - break; - } - } - } - - /* - * if ( terminalSearchMods && notDone ) { if ( m.matcher( Platform.getMod( is.getItemStack() ) ).find() ) { - * view.add( is ); notDone = false; } } - */ - } - - final Enum SortBy = this.sortSrc.getSortBy(); - final Enum SortDir = this.sortSrc.getSortDir(); - - ItemSorters.setDirection((appeng.api.config.SortDir) SortDir); - ItemSorters.init(); - - if (SortBy == SortOrder.MOD) { - Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD); - } else if (SortBy == SortOrder.AMOUNT) { - Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE); - } else if (SortBy == SortOrder.INVTWEAKS) { - Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS); - } else { - Collections.sort(this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME); - } - - for (final IAEItemStack is : this.view) { - this.dsp.add(is.getItemStack()); - } - } - - @SuppressWarnings("rawtypes") - private void updateNEI(final String filter) { - try { - if (this.NEIWord == null || !this.NEIWord.equals(filter)) { - final Class c = - ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager"); - final Field fldSearchField = c.getField("searchField"); - final Object searchField = fldSearchField.get(c); - - final Method a = searchField.getClass().getMethod("setText", String.class); - final Method b = searchField.getClass().getMethod("onTextChange", String.class); - - this.NEIWord = filter; - a.invoke(searchField, filter); - b.invoke(searchField, ""); - } - } catch (final Throwable ignore) { - - } - } - - public int size() { - return this.view.size(); - } - - public void clear() { - this.list.resetStatus(); - } - - public boolean hasPower() { - return this.hasPower; - } - - public void setPower(final boolean hasPower) { - this.hasPower = hasPower; - } - - public int getRowSize() { - return this.rowSize; - } - - public void setRowSize(final int rowSize) { - this.rowSize = rowSize; - } - - public String getSearchString() { - return this.searchString; - } - - public void setSearchString(@Nonnull final String searchString) { - this.searchString = searchString; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/SlotDisconnected.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/SlotDisconnected.java deleted file mode 100644 index 46059fc..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/SlotDisconnected.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.me; - -import appeng.items.misc.ItemEncodedPattern; -import appeng.util.Platform; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.AppEngSlot; - -public class SlotDisconnected extends AppEngSlot { - - private final ClientDCInternalInv mySlot; - - public SlotDisconnected(final ClientDCInternalInv me, final int which, final int x, final int y) { - super(me.getInventory(), which, x, y); - this.mySlot = me; - } - - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } - - @Override - public void putStack(final ItemStack par1ItemStack) {} - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } - - @Override - public ItemStack getDisplayStack() { - if (Platform.isClient()) { - final ItemStack is = super.getStack(); - if (is != null && is.getItem() instanceof ItemEncodedPattern) { - final ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); - final ItemStack out = iep.getOutput(is); - if (out != null) { - return out; - } - } - } - return super.getStack(); - } - - @Override - public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {} - - @Override - public boolean getHasStack() { - return this.getStack() != null; - } - - @Override - public int getSlotStackLimit() { - return 0; - } - - @Override - public ItemStack decrStackSize(final int par1) { - return null; - } - - @Override - public boolean isSlotInInventory(final IInventory par1iInventory, final int par2) { - return false; - } - - public ClientDCInternalInv getSlot() { - return this.mySlot; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/SlotME.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/SlotME.java deleted file mode 100644 index d12e1ca..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/SlotME.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.me; - -import appeng.api.storage.data.IAEItemStack; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class SlotME extends Slot { - - private final InternalSlotME mySlot; - - public SlotME(final InternalSlotME me) { - super(null, 0, me.getxPosition(), me.getyPosition()); - this.mySlot = me; - } - - public IAEItemStack getAEStack() { - if (this.mySlot.hasPower()) { - return this.mySlot.getAEStack(); - } - return null; - } - - @Override - public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {} - - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } - - @Override - public ItemStack getStack() { - if (this.mySlot.hasPower()) { - return this.mySlot.getStack(); - } - return null; - } - - @Override - public boolean getHasStack() { - if (this.mySlot.hasPower()) { - return this.getStack() != null; - } - return false; - } - - @Override - public void putStack(final ItemStack par1ItemStack) {} - - @Override - public int getSlotStackLimit() { - return 0; - } - - @Override - public ItemStack decrStackSize(final int par1) { - return null; - } - - @Override - public boolean isSlotInInventory(final IInventory par1iInventory, final int par2) { - return false; - } - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/WCTRenderItem.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/WCTRenderItem.java deleted file mode 100644 index b7dd950..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/me/WCTRenderItem.java +++ /dev/null @@ -1,147 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.me; - -import appeng.api.storage.data.IAEItemStack; -import appeng.core.AEConfig; -import appeng.core.localization.GuiText; -import appeng.util.ISlimReadableNumberConverter; -import appeng.util.IWideReadableNumberConverter; -import appeng.util.ReadableNumberConverter; -import javax.annotation.Nonnull; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; - -/** - * @author AlgorithmX2 - * @author thatsIch - * @version rv2 - * @since rv0 - */ -public class WCTRenderItem extends RenderItem { - private static final ISlimReadableNumberConverter SLIM_CONVERTER = ReadableNumberConverter.INSTANCE; - private static final IWideReadableNumberConverter WIDE_CONVERTER = ReadableNumberConverter.INSTANCE; - boolean useLg = AEConfig.instance.useTerminalUseLargeFont(); - private IAEItemStack aeStack = null; - - @Override - public void renderItemOverlayIntoGUI( - final FontRenderer fontRenderer, - final TextureManager textureManager, - final ItemStack is, - final int par4, - final int par5, - final String par6Str) { - if (is != null) { - final float scaleFactor = useLg ? 0.85f : 0.5f; - final float inverseScaleFactor = 1.0f / scaleFactor; - final int offset = useLg ? 0 : -1; - - final boolean unicodeFlag = fontRenderer.getUnicodeFlag(); - fontRenderer.setUnicodeFlag(false); - - if (is.getItem().showDurabilityBar(is)) { - final double health = is.getItem().getDurabilityForDisplay(is); - final int j1 = (int) Math.round(13.0D - health * 13.0D); - final int k = (int) Math.round(255.0D - health * 255.0D); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glDisable(GL11.GL_BLEND); - - final Tessellator tessellator = Tessellator.instance; - final int l = 255 - k << 16 | k << 8; - final int i1 = (255 - k) / 4 << 16 | 16128; - - this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); - this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1); - this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l); - - GL11.glEnable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - - if (is.stackSize == 0) { - final String craftLabelText = - useLg ? GuiText.LargeFontCraft.getLocal() : GuiText.SmallFontCraft.getLocal(); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glScaled(scaleFactor, scaleFactor, scaleFactor); - - final int X = (int) - (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(craftLabelText) * scaleFactor) - * inverseScaleFactor); - final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); - fontRenderer.drawStringWithShadow(craftLabelText, X, Y, 16777215); - - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize; - - if (amount != 0) { - final String stackSize = this.getToBeRenderedStackSize(amount); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glScaled(scaleFactor, scaleFactor, scaleFactor); - - final int X = - (int) (((float) par4 + offset + 16.0f - fontRenderer.getStringWidth(stackSize) * scaleFactor) - * inverseScaleFactor); - final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor); - fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215); - - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - fontRenderer.setUnicodeFlag(unicodeFlag); - } - } - - private void renderQuad( - final Tessellator par1Tessellator, - final int par2, - final int par3, - final int par4, - final int par5, - final int par6) { - par1Tessellator.startDrawingQuads(); - par1Tessellator.setColorOpaque_I(par6); - par1Tessellator.addVertex(par2, par3, 0.0D); - par1Tessellator.addVertex(par2, par3 + par5, 0.0D); - par1Tessellator.addVertex(par2 + par4, par3 + par5, 0.0D); - par1Tessellator.addVertex(par2 + par4, par3, 0.0D); - par1Tessellator.draw(); - } - - private String getToBeRenderedStackSize(final long originalSize) { - if (AEConfig.instance.useTerminalUseLargeFont()) { - return SLIM_CONVERTER.toSlimReadableForm(originalSize); - } else { - return WIDE_CONVERTER.toWideReadableForm(originalSize); - } - } - - public IAEItemStack getAeStack() { - return this.aeStack; - } - - public void setAeStack(@Nonnull final IAEItemStack aeStack) { - this.aeStack = aeStack; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/textures/IStateIconTexture.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/textures/IStateIconTexture.java deleted file mode 100644 index 6d24ee8..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/textures/IStateIconTexture.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.textures; - -import javax.annotation.Nonnull; -import net.minecraft.util.ResourceLocation; - -/** - * Icon from a state texture. - * - * @author Nividica - * - */ -public interface IStateIconTexture { - /** - * Height of the icon. - * - * @return - */ - int getHeight(); - - /** - * Texture the icon is in. - * - * @return - */ - @Nonnull - ResourceLocation getTexture(); - - /** - * U coordinate of the icon. - * - * @return - */ - int getU(); - - /** - * V coordinate of the icon. - * - * @return - */ - int getV(); - - /** - * Width of the icon. - * - * @return - */ - int getWidth(); -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/textures/WCTStateIconsEnum.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/textures/WCTStateIconsEnum.java deleted file mode 100644 index 2272b03..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/client/textures/WCTStateIconsEnum.java +++ /dev/null @@ -1,150 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.client.textures; - -import net.minecraft.util.ResourceLocation; - -/** - * Icons stored in the AE2's "states" texture. - * - * @author Nividica - * - */ -public enum WCTStateIconsEnum implements IStateIconTexture { - - // Redstone modes - REDSTONE_LOW(0, 0), - REDSTONE_HIGH(16, 0), - REDSTONE_PULSE(32, 0), - REDSTONE_IGNORE(48, 0), - - // Slot backgrounds - VIEW_CELL_BACKGROUND(224, 64), - UPGRADE_CARD_BACKGROUND(240, 208), - ME_CELL_BACKGROUND(240, 0), - PATTERN_CELL_BACKGROUND(240, 128), - - // Buttons - REGULAR_BUTTON(240, 240), - TAB_BUTTON(208, 0, 22, 22), - - // Sorting modes - SORT_MODE_ALPHABETIC(0, 64), - SORT_MODE_AMOUNT(16, 64), - SORT_MODE_MOD(80, 64), - SORT_MODE_INVTWEAK(64, 64), - - // Sorting directions - SORT_DIR_ASC(0, 48), - SORT_DIR_DEC(16, 48), - - // View types - VIEW_TYPE_STORED(0, 16), - VIEW_TYPE_ALL(32, 16), - VIEW_TYPE_CRAFT(48, 16), - - // Terminal styles - TERM_STYLE_TALL(0, 208), - TERM_STYLE_SMALL(16, 208), - - // Search modes - SEARCH_MODE_AUTO(48, 32), - SEARCH_MODE_MANUAL(64, 32), - SEARCH_MODE_NEI_AUTO(80, 32), - SEARCH_MODE_NEI_MANUAL(96, 32), - - // Misc - WRENCH(32, 64), - DISABLED(0, 128), - ENABLED(16, 128), - SAVE(0, 176), - DELETE(0, 192), - CLEAR_GRID(96, 0), - ARROW_DOWN(128, 0); - - /** - * Location of the AE states texture - */ - public static final ResourceLocation AE_STATES_TEXTURE = - new ResourceLocation("appliedenergistics2", "textures/guis/states.png"); - - /** - * Width and height of standard icons. - */ - public static final int STANDARD_ICON_SIZE = 16; - - /** - * X position in the texture this icon is located at. - */ - private int minU; - - /** - * Y position in the texture this icon is located at. - */ - private int minV; - - /** - * Width of the icon - */ - private int width; - - /** - * Height of the icon - */ - private int height; - - /** - * Standard icon constructor - * - * @param u - * @param v - */ - private WCTStateIconsEnum(final int u, final int v) { - this(u, v, STANDARD_ICON_SIZE, STANDARD_ICON_SIZE); - } - - /** - * Icon constructor - * - * @param u - * @param v - * @param width - * @param height - */ - private WCTStateIconsEnum(final int u, final int v, final int width, final int height) { - // Set the u - this.minU = u; - - // Set the v - this.minV = v; - - // Set width - this.width = width; - - // Set height - this.height = height; - } - - @Override - public int getHeight() { - return this.height; - } - - @Override - public ResourceLocation getTexture() { - return WCTStateIconsEnum.AE_STATES_TEXTURE; - } - - @Override - public int getU() { - return this.minU; - } - - @Override - public int getV() { - return this.minV; - } - - @Override - public int getWidth() { - return this.width; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java index 822e2ca..7550361 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/WCTGuiHandler.java @@ -63,24 +63,12 @@ public class WCTGuiHandler implements IGuiHandler { if (guiId == Reference.GUI_CRAFT_AMOUNT) { return updateGui( - new ContainerCraftAmount(player, terminal), - world, - x, - y, - z, - ForgeDirection.UNKNOWN, - obj); + new ContainerCraftAmount(player, terminal), world, x, y, z, ForgeDirection.UNKNOWN, obj); } if (guiId == Reference.GUI_CRAFT_CONFIRM) { return updateGui( - new ContainerCraftConfirm(player, terminal), - world, - x, - y, - z, - ForgeDirection.UNKNOWN, - obj); + new ContainerCraftConfirm(player, terminal), world, x, y, z, ForgeDirection.UNKNOWN, obj); } } } diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftAmount.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftAmount.java index de4ca3f..4d41719 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftAmount.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftAmount.java @@ -2,11 +2,8 @@ package net.p455w0rd.wirelesscraftingterminal.common.container; import appeng.api.implementations.guiobjects.IPortableCell; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler; -import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler; -import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis; import net.p455w0rd.wirelesscraftingterminal.reference.Reference; public class ContainerCraftAmount extends appeng.container.implementations.ContainerCraftAmount { diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftConfirm.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftConfirm.java index 63b0242..59522c3 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftConfirm.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerCraftConfirm.java @@ -2,10 +2,7 @@ package net.p455w0rd.wirelesscraftingterminal.common.container; import appeng.api.implementations.guiobjects.IPortableCell; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler; -import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler; -import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis; import net.p455w0rd.wirelesscraftingterminal.reference.Reference; public class ContainerCraftConfirm extends appeng.container.implementations.ContainerCraftConfirm { diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java index 0fb14f5..f6d8e20 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/ContainerWirelessCraftingTerminal.java @@ -27,7 +27,16 @@ import appeng.client.me.InternalSlotME; import appeng.client.me.SlotME; import appeng.container.AEBaseContainer; import appeng.container.ContainerNull; +import appeng.container.slot.AppEngCraftingSlot; import appeng.container.slot.AppEngSlot; +import appeng.container.slot.NullSlot; +import appeng.container.slot.SlotCraftingMatrix; +import appeng.container.slot.SlotCraftingTerm; +import appeng.container.slot.SlotDisabled; +import appeng.container.slot.SlotFake; +import appeng.container.slot.SlotInaccessible; +import appeng.container.slot.SlotPlayerHotBar; +import appeng.container.slot.SlotPlayerInv; import appeng.core.AEConfig; import appeng.core.localization.PlayerMessages; import appeng.helpers.IContainerCraftingPacket; @@ -40,6 +49,12 @@ import appeng.util.IConfigManagerHost; import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.inv.AdaptorPlayerHand; +import java.io.IOException; +import java.nio.BufferOverflowException; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -59,18 +74,9 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler; import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTerminalItem; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.AppEngCraftingSlot; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.NullSlot; import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotArmor; import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotBooster; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingMatrix; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingTerm; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotDisabled; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotFake; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotInaccessible; import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotMagnet; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotPlayerHotBar; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotPlayerInv; import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotTrash; import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotViewCell; import net.p455w0rd.wirelesscraftingterminal.common.inventory.WCTInventoryBooster; @@ -89,20 +95,13 @@ import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster; import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet; import net.p455w0rd.wirelesscraftingterminal.reference.Reference; -import javax.annotation.Nonnull; -import java.io.IOException; -import java.nio.BufferOverflowException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - public class ContainerWirelessCraftingTerminal extends AEBaseContainer - implements IConfigManagerHost, - IConfigurableObject, - IMEMonitorHandlerReceiver, - IAEAppEngInventory, - IContainerCraftingPacket, - IViewCellStorage { + implements IConfigManagerHost, + IConfigurableObject, + IMEMonitorHandlerReceiver, + IAEAppEngInventory, + IContainerCraftingPacket, + IViewCellStorage { private final ItemStack containerstack; public final WCTInventoryCrafting craftingGrid; @@ -115,18 +114,18 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer private final World worldObj; private final EntityPlayer player; private static final int HOTBAR_START = 1, - HOTBAR_END = HOTBAR_START + 8, - INV_START = HOTBAR_END + 1, - INV_END = INV_START + 26, - ARMOR_START = INV_END + 1, - ARMOR_END = ARMOR_START + 3, - CRAFT_GRID_START = ARMOR_END + 1, - CRAFT_GRID_END = CRAFT_GRID_START + 8, - CRAFT_RESULT = CRAFT_GRID_END + 1, - VIEW_CELL_START = CRAFT_RESULT + 1, - VIEW_CELL_END = VIEW_CELL_START + 4, - BOOSTER_INDEX = 0, - MAGNET_INDEX = VIEW_CELL_END + 1; + HOTBAR_END = HOTBAR_START + 8, + INV_START = HOTBAR_END + 1, + INV_END = INV_START + 26, + ARMOR_START = INV_END + 1, + ARMOR_END = ARMOR_START + 3, + CRAFT_GRID_START = ARMOR_END + 1, + CRAFT_GRID_END = CRAFT_GRID_START + 8, + CRAFT_RESULT = CRAFT_GRID_END + 1, + VIEW_CELL_START = CRAFT_RESULT + 1, + VIEW_CELL_END = VIEW_CELL_START + 4, + BOOSTER_INDEX = 0, + MAGNET_INDEX = VIEW_CELL_END + 1; public static int CRAFTING_SLOT_X_POS = 80, CRAFTING_SLOT_Y_POS = 83; private SlotBooster boosterSlot; private final SlotMagnet magnetSlot; @@ -161,7 +160,15 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer * @author p455w0rd */ public ContainerWirelessCraftingTerminal(EntityPlayer player, InventoryPlayer inventoryPlayer) { - super(inventoryPlayer, getGuiObject(RandomUtils.getWirelessTerm(inventoryPlayer), player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ)); + super( + inventoryPlayer, + getGuiObject( + RandomUtils.getWirelessTerm(inventoryPlayer), + player, + player.worldObj, + (int) player.posX, + (int) player.posY, + (int) player.posZ)); this.clientCM = new ConfigManager(this); this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME); this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL); @@ -186,7 +193,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer viewCellSlot = new SlotViewCell[5]; this.obj = - getGuiObject(containerstack, player, worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); + getGuiObject(containerstack, player, worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); this.civ = this.obj; final IGridNode node = ((IGridHost) this.obj).getGridNode(ForgeDirection.UNKNOWN); this.networkNode = node; @@ -242,7 +249,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { craftMatrixSlot[k] = - new SlotCraftingMatrix(this, this.craftingGrid, j + i * 3, 80 + j * 18, (i * 18) - 76); + new SlotCraftingMatrix(this, this.craftingGrid, j + i * 3, 80 + j * 18, (i * 18) - 76); this.addSlotToContainer(craftMatrixSlot[k]); if (k == 0) { this.firstCraftingSlotNumber = craftMatrixSlot[k].slotNumber; @@ -253,22 +260,22 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer this.lastCraftingSlotNumber = craftMatrixSlot[8].slotNumber; craftingSlot = new SlotCraftingTerm( - this.getPlayerInv().player, - this.getActionSource(), - this.getPowerSource(), - this.obj, - this.craftingGrid, - this.craftingGrid, - this.output, - 174, - -58, - this); + this.getPlayerInv().player, + this.getActionSource(), + this.getPowerSource(), + this.obj, + this.craftingGrid, + this.craftingGrid, + this.output, + 174, + -58, + this); // Add crafting result slot this.addSlotToContainer(craftingSlot); // Add view cell slots for (int i = 0; i < 5; i++) { - viewCellSlot[i] = new SlotViewCell(getViewCellStorage(), i, 207, (i * 18) + 8); + viewCellSlot[i] = new SlotViewCell(getViewCellStorage(), i, 207, (i * 18) + 8, inventoryPlayer); addSlotToContainer(viewCellSlot[i]); } @@ -293,7 +300,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer return super.addSlotToContainer(newSlot); } else { throw new IllegalArgumentException( - "Invalid Slot [" + newSlot + "] for WCT Container instead of AppEngSlot."); + "Invalid Slot [" + newSlot + "] for WCT Container instead of AppEngSlot."); } } @@ -436,7 +443,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer } ais = Platform.poweredExtraction( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais != null) { adp.addItems(ais.getItemStack()); } @@ -456,14 +463,14 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer final IAEItemStack extracted = ais.copy(); ais = Platform.poweredInsert( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais == null) { final InventoryAdaptor ia = new AdaptorPlayerHand(player); final ItemStack fail = ia.removeItems(1, extracted.getItemStack(), null); if (fail == null) { this.getCellInventory() - .extractItems(extracted, Actionable.MODULATE, this.getActionSource()); + .extractItems(extracted, Actionable.MODULATE, this.getActionSource()); } this.updateHeld(player); @@ -494,7 +501,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer IAEItemStack ais = slotItem.copy(); ais.setStackSize(1); ais = Platform.poweredExtraction( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais != null) { final InventoryAdaptor ia = new AdaptorPlayerHand(player); @@ -518,7 +525,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer IAEItemStack ais = slotItem.copy(); ais.setStackSize(ais.getItemStack().getMaxStackSize()); ais = Platform.poweredExtraction( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais != null) { player.inventory.setItemStack(ais.getItemStack()); } else { @@ -529,7 +536,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer } else { IAEItemStack ais = AEApi.instance().storage().createItemStack(player.inventory.getItemStack()); ais = Platform.poweredInsert( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais != null) { player.inventory.setItemStack(ais.getItemStack()); } else { @@ -555,7 +562,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer final long stackSize = Math.min(maxSize, ais.getStackSize()); ais.setStackSize((stackSize + 1) >> 1); ais = Platform.poweredExtraction( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); } if (ais != null) { @@ -569,7 +576,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer IAEItemStack ais = AEApi.instance().storage().createItemStack(player.inventory.getItemStack()); ais.setStackSize(1); ais = Platform.poweredInsert( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais == null) { final ItemStack is = player.inventory.getItemStack(); is.stackSize--; @@ -611,7 +618,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer } ais = Platform.poweredExtraction( - this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); + this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource()); if (ais != null) { adp.addItems(ais.getItemStack()); } else { @@ -644,11 +651,11 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer @Override public void onChangeInventory( - final IInventory inv, - final int slot, - final InvOperation mc, - final ItemStack removedStack, - final ItemStack newStack) { + final IInventory inv, + final int slot, + final InvOperation mc, + final ItemStack removedStack, + final ItemStack newStack) { // <3 } @@ -694,10 +701,10 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer } public static WirelessTerminalGuiObject getGuiObject( - final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z) { + 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); + AEApi.instance().registries().wireless().getWirelessTerminalHandler(it); if (wh != null) { return new WirelessTerminalGuiObject(wh, it, player, w, x, y, z); } @@ -713,7 +720,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer if (this.ticks > 10) { if (!isBoosterInstalled() || !Reference.WCT_BOOSTER_ENABLED) { this.civ.extractAEPower( - this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG); + this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG); } else { this.civ.extractAEPower((int) (0.5 * this.ticks), Actionable.MODULATE, PowerMultiplier.CONFIG); } @@ -734,7 +741,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer for (final Object crafter : this.crafters) { try { NetworkHandler.instance.sendTo( - new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter); + new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter); } catch (final IOException e) { WCTLog.debug(e.getMessage()); } @@ -782,14 +789,14 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer if (!networkIsPowered()) { if (this.isValidContainer()) { this.getPlayerInv() - .player - .addChatMessage(new ChatComponentText(LocaleHandler.NoNetworkPower.getLocal())); + .player + .addChatMessage(new ChatComponentText(LocaleHandler.NoNetworkPower.getLocal())); } this.setValidContainer(false); } } else if (!hasAccess(SecurityPermissions.CRAFT, true) - || !hasAccess(SecurityPermissions.EXTRACT, true) - || !hasAccess(SecurityPermissions.INJECT, true)) { + || !hasAccess(SecurityPermissions.EXTRACT, true) + || !hasAccess(SecurityPermissions.INJECT, true)) { if (this.isValidContainer()) { this.getPlayerInv().player.addChatMessage(PlayerMessages.CommunicationError.get()); } @@ -807,11 +814,11 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer return false; } boolean hasStack = - getSlotFromInventory(this.boosterInventory, BOOSTER_INDEX).getHasStack(); + getSlotFromInventory(this.boosterInventory, BOOSTER_INDEX).getHasStack(); if (hasStack) { Item boosterSlotContents = getSlotFromInventory(this.boosterInventory, BOOSTER_INDEX) - .getStack() - .getItem(); + .getStack() + .getItem(); return boosterSlotContents instanceof ItemInfinityBooster; } return false; @@ -823,11 +830,11 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer return false; } boolean hasStack = - getSlotFromInventory(this.magnetInventory, MAGNET_INDEX).getHasStack(); + getSlotFromInventory(this.magnetInventory, MAGNET_INDEX).getHasStack(); if (hasStack) { Item magnetSlotContents = getSlotFromInventory(this.magnetInventory, MAGNET_INDEX) - .getStack() - .getItem(); + .getStack() + .getItem(); return magnetSlotContents instanceof ItemMagnet; } return false; @@ -885,9 +892,9 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer @Override public void postChange( - final IBaseMonitor monitor, - final Iterable change, - final BaseActionSource source) { + final IBaseMonitor monitor, + final Iterable change, + final BaseActionSource source) { for (final IAEItemStack is : change) { this.items.add(is); } @@ -1251,7 +1258,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer @SuppressWarnings("unused") private boolean isCraftMatrixSlot(AppEngSlot cs) { return (cs.getSlotIndex() >= this.firstCraftingSlotNumber) - && !(cs.getSlotIndex() <= this.lastCraftingSlotNumber); + && !(cs.getSlotIndex() <= this.lastCraftingSlotNumber); } private void updateSlot(final Slot clickSlot) { @@ -1263,10 +1270,10 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer return input; } final IAEItemStack ais = Platform.poweredInsert( - this.getPowerSource(), - this.civ, - AEApi.instance().storage().createItemStack(input), - this.getActionSource()); + this.getPowerSource(), + this.civ, + AEApi.instance().storage().createItemStack(input), + this.getActionSource()); if (ais == null) { return null; } @@ -1310,8 +1317,8 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { try { if (slot >= 0 - && getSlot(slot) != null - && getSlot(slot).getStack() == RandomUtils.getWirelessTerm(player.inventory)) { + && getSlot(slot) != null + && getSlot(slot).getStack() == RandomUtils.getWirelessTerm(player.inventory)) { return null; } return super.slotClick(slot, button, flag, player); @@ -1342,9 +1349,9 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer } if (itemstack1 != null - && itemstack1.getItem() == stack.getItem() - && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) - && ItemStack.areItemStackTagsEqual(stack, itemstack1)) { + && itemstack1.getItem() == stack.getItem() + && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) + && ItemStack.areItemStackTagsEqual(stack, itemstack1)) { int l = itemstack1.stackSize + stack.stackSize; if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) { @@ -1384,7 +1391,7 @@ public class ContainerWirelessCraftingTerminal extends AEBaseContainer break; } else { putStackInSlot( - k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage())); + k, new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage())); stack.stackSize -= slot.getSlotStackLimit(); boosterInventory.markDirty(); flag1 = true; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/AppEngCraftingSlot.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/AppEngCraftingSlot.java deleted file mode 100644 index 95b990d..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/AppEngCraftingSlot.java +++ /dev/null @@ -1,161 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import cpw.mods.fml.common.FMLCommonHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemHoe; -import net.minecraft.item.ItemPickaxe; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.item.ItemTool; -import net.minecraft.stats.AchievementList; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; - -public class AppEngCraftingSlot extends AppEngSlot { - - /** - * The craft matrix inventory linked to this result slot. - */ - private final IInventory craftMatrix; - - /** - * The player that is using the GUI where this slot resides. - */ - private final EntityPlayer thePlayer; - - /** - * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. - */ - private int amountCrafted; - - public AppEngCraftingSlot( - final EntityPlayer par1EntityPlayer, - final IInventory par2IInventory, - final IInventory par3IInventory, - final int par4, - final int par5, - final int par6) { - super(par3IInventory, par4, par5, par6); - this.thePlayer = par1EntityPlayer; - this.craftMatrix = par2IInventory; - } - - /** - * Check if the stack is a valid item for this slot. Always true beside for the armor slots. - */ - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an - * internal count then calls onCrafting(item). - */ - @Override - protected void onCrafting(final ItemStack par1ItemStack, final int par2) { - this.amountCrafted += par2; - this.onCrafting(par1ItemStack); - } - - /** - * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. - */ - @Override - protected void onCrafting(final ItemStack par1ItemStack) { - par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); - this.amountCrafted = 0; - - if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { - this.thePlayer.addStat(AchievementList.buildWorkBench, 1); - } - - if (par1ItemStack.getItem() instanceof ItemPickaxe) { - this.thePlayer.addStat(AchievementList.buildPickaxe, 1); - } - - if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.furnace)) { - this.thePlayer.addStat(AchievementList.buildFurnace, 1); - } - - if (par1ItemStack.getItem() instanceof ItemHoe) { - this.thePlayer.addStat(AchievementList.buildHoe, 1); - } - - if (par1ItemStack.getItem() == Items.bread) { - this.thePlayer.addStat(AchievementList.makeBread, 1); - } - - if (par1ItemStack.getItem() == Items.cake) { - this.thePlayer.addStat(AchievementList.bakeCake, 1); - } - - if (par1ItemStack.getItem() instanceof ItemPickaxe - && ((ItemTool) par1ItemStack.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { - this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); - } - - if (par1ItemStack.getItem() instanceof ItemSword) { - this.thePlayer.addStat(AchievementList.buildSword, 1); - } - - if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { - this.thePlayer.addStat(AchievementList.enchantments, 1); - } - - if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { - this.thePlayer.addStat(AchievementList.bookcase, 1); - } - } - - @Override - public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) { - FMLCommonHandler.instance().firePlayerCraftingEvent(par1EntityPlayer, par2ItemStack, this.craftMatrix); - this.onCrafting(par2ItemStack); - - for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { - final ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); - - if (itemstack1 != null) { - this.craftMatrix.decrStackSize(i, 1); - - if (itemstack1.getItem().hasContainerItem(itemstack1)) { - final ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); - - if (itemstack2 != null - && itemstack2.isItemStackDamageable() - && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(this.thePlayer, itemstack2)); - continue; - } - - if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) - || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { - if (this.craftMatrix.getStackInSlot(i) == null) { - this.craftMatrix.setInventorySlotContents(i, itemstack2); - } else { - this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); - } - } - } - } - } - } - - /** - * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new - * stack. - */ - @Override - public ItemStack decrStackSize(final int par1) { - if (this.getHasStack()) { - this.amountCrafted += Math.min(par1, this.getStack().stackSize); - } - - return super.decrStackSize(par1); - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/AppEngSlot.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/AppEngSlot.java deleted file mode 100644 index 0c0dccf..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/AppEngSlot.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.inventory.IInventory; - -public class AppEngSlot extends appeng.container.slot.AppEngSlot { - - public AppEngSlot(final IInventory inv, final int idx, final int x, final int y) { - super(inv, idx, x, y); - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/NullSlot.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/NullSlot.java deleted file mode 100644 index 0c1c8aa..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/NullSlot.java +++ /dev/null @@ -1,59 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class NullSlot extends AppEngSlot { - - public NullSlot() { - super(null, 0, 0, 0); - } - - @Override - public void onSlotChange(final ItemStack par1ItemStack, final ItemStack par2ItemStack) {} - - @Override - public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {} - - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } - - @Override - public ItemStack getStack() { - return null; - } - - @Override - public void putStack(final ItemStack par1ItemStack) {} - - @Override - public void onSlotChanged() {} - - @Override - public int getSlotStackLimit() { - return 0; - } - - @Override - public ItemStack decrStackSize(final int par1) { - return null; - } - - @Override - public boolean isSlotInInventory(final IInventory par1IInventory, final int par2) { - return false; - } - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } - - @Override - public int getSlotIndex() { - return 0; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/OptionalSlotFake.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/OptionalSlotFake.java index d095c35..31d3ef2 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/OptionalSlotFake.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/OptionalSlotFake.java @@ -1,5 +1,6 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot; +import appeng.container.slot.SlotFake; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotArmor.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotArmor.java index 2ba394f..4706b52 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotArmor.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotArmor.java @@ -9,7 +9,7 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class SlotArmor extends AppEngSlot { +public class SlotArmor extends appeng.container.slot.AppEngSlot { /* * The armor type that can be placed on that slot, it uses the same values diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotBooster.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotBooster.java index 6860223..8c90c94 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotBooster.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotBooster.java @@ -9,7 +9,7 @@ import net.minecraft.util.IIcon; import net.p455w0rd.wirelesscraftingterminal.items.ItemBoosterBGIcon; import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster; -public class SlotBooster extends AppEngSlot { +public class SlotBooster extends appeng.container.slot.AppEngSlot { /** * Custom slot for infinity booster card diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotCraftingMatrix.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotCraftingMatrix.java deleted file mode 100644 index a95827d..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotCraftingMatrix.java +++ /dev/null @@ -1,40 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotCraftingMatrix extends AppEngSlot { - - private final Container c; - - public SlotCraftingMatrix( - final Container c, final IInventory par1iInventory, final int par2, final int par3, final int par4) { - super(par1iInventory, par2, par3, par4); - this.c = c; - } - - @Override - public void clearStack() { - super.clearStack(); - this.c.onCraftMatrixChanged(this.inventory); - } - - @Override - public void putStack(final ItemStack par1ItemStack) { - super.putStack(par1ItemStack); - this.c.onCraftMatrixChanged(this.inventory); - } - - @Override - public boolean isPlayerSide() { - return true; - } - - @Override - public ItemStack decrStackSize(final int par1) { - final ItemStack is = super.decrStackSize(par1); - this.c.onCraftMatrixChanged(this.inventory); - return is; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotCraftingTerm.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotCraftingTerm.java deleted file mode 100644 index 8dd1cf8..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotCraftingTerm.java +++ /dev/null @@ -1,243 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import appeng.api.config.Actionable; -import appeng.api.networking.energy.IEnergySource; -import appeng.api.networking.security.BaseActionSource; -import appeng.api.storage.IMEMonitor; -import appeng.api.storage.IStorageMonitorable; -import appeng.api.storage.data.IAEItemStack; -import appeng.api.storage.data.IItemList; -import appeng.container.ContainerNull; -import appeng.helpers.IContainerCraftingPacket; -import appeng.helpers.InventoryAction; -import appeng.util.InventoryAdaptor; -import appeng.util.Platform; -import appeng.util.inv.AdaptorPlayerHand; -import appeng.util.item.AEItemStack; -import java.util.ArrayList; -import java.util.List; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; - -public class SlotCraftingTerm extends AppEngCraftingSlot { - - private final IInventory craftInv; - private final IInventory pattern; - - private final BaseActionSource mySrc; - private final IEnergySource energySrc; - private final IStorageMonitorable storage; - - public SlotCraftingTerm( - final EntityPlayer player, - final BaseActionSource mySrc, - final IEnergySource energySrc, - final IStorageMonitorable storage, - final IInventory cMatrix, - final IInventory secondMatrix, - final IInventory output, - final int x, - final int y, - final IContainerCraftingPacket ccp) { - super(player, cMatrix, output, 0, x, y); - this.energySrc = energySrc; - this.storage = storage; - this.mySrc = mySrc; - this.pattern = cMatrix; - this.craftInv = secondMatrix; - } - - public IInventory getCraftingMatrix() { - return this.craftInv; - } - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } - - @Override - public void onPickupFromSlot(final EntityPlayer p, final ItemStack is) {} - - public void doClick(final InventoryAction action, final EntityPlayer who) { - if (this.getStack() == null) { - return; - } - if (Platform.isClient()) { - return; - } - - final IMEMonitor inv = this.storage.getItemInventory(); - final int howManyPerCraft = this.getStack().stackSize; - int maxTimesToCraft = 0; - - InventoryAdaptor ia = null; - if (action == InventoryAction.CRAFT_SHIFT) // craft into player - // inventory... - { - ia = InventoryAdaptor.getAdaptor(who, null); - maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft); - } else if (action == InventoryAction.CRAFT_STACK) // craft into hand, - // full stack - { - ia = new AdaptorPlayerHand(who); - maxTimesToCraft = (int) Math.floor((double) this.getStack().getMaxStackSize() / (double) howManyPerCraft); - } else - // pick up what was crafted... - { - ia = new AdaptorPlayerHand(who); - maxTimesToCraft = 1; - } - - maxTimesToCraft = this.capCraftingAttempts(maxTimesToCraft); - - if (ia == null) { - return; - } - - final ItemStack rs = Platform.cloneItemStack(this.getStack()); - if (rs == null) { - return; - } - - for (int x = 0; x < maxTimesToCraft; x++) { - if (ia.simulateAdd(rs) == null) { - final IItemList all = inv.getStorageList(); - final ItemStack extra = ia.addItems(this.craftItem(who, rs, inv, all)); - if (extra != null) { - final List drops = new ArrayList(); - drops.add(extra); - Platform.spawnDrops(who.worldObj, (int) who.posX, (int) who.posY, (int) who.posZ, drops); - return; - } - } - } - } - - private int capCraftingAttempts(final int maxTimesToCraft) { - return maxTimesToCraft; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private ItemStack craftItem( - final EntityPlayer p, final ItemStack request, final IMEMonitor inv, final IItemList all) { - // update crafting matrix... - ItemStack is = this.getStack(); - - if (is != null && Platform.isSameItem(request, is)) { - final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()]; - - // add one of each item to the items on the board... - if (Platform.isServer()) { - final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3); - for (int x = 0; x < 9; x++) { - ic.setInventorySlotContents(x, this.getPattern().getStackInSlot(x)); - } - - final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj); - - if (r == null) { - final Item target = request.getItem(); - if (target.isDamageable() && target.isRepairable()) { - boolean isBad = false; - for (int x = 0; x < ic.getSizeInventory(); x++) { - final ItemStack pis = ic.getStackInSlot(x); - if (pis == null) { - continue; - } - if (pis.getItem() != target) { - isBad = true; - } - } - if (!isBad) { - super.onPickupFromSlot(p, is); - // actually necessary to cleanup this case... - p.openContainer.onCraftMatrixChanged(this.craftInv); - return request; - } - } - return null; - } - - is = r.getCraftingResult(ic); - - if (inv != null) { - for (int x = 0; x < this.getPattern().getSizeInventory(); x++) { - if (this.getPattern().getStackInSlot(x) != null) { - set[x] = Platform.extractItemsByRecipe( - this.energySrc, - this.mySrc, - inv, - p.worldObj, - r, - is, - ic, - this.getPattern().getStackInSlot(x), - x, - all, - Actionable.MODULATE, - null); - ic.setInventorySlotContents(x, set[x]); - } - } - } - } - - if (this.preCraft(p, inv, set, is)) { - this.makeItem(p, is); - - this.postCraft(p, inv, set, is); - } - - // shouldn't be necessary... - p.openContainer.onCraftMatrixChanged(this.craftInv); - - return is; - } - - return null; - } - - private boolean preCraft( - final EntityPlayer p, final IMEMonitor inv, final ItemStack[] set, final ItemStack result) { - return true; - } - - private void makeItem(final EntityPlayer p, final ItemStack is) { - super.onPickupFromSlot(p, is); - } - - private void postCraft( - final EntityPlayer p, final IMEMonitor inv, final ItemStack[] set, final ItemStack result) { - final List drops = new ArrayList(); - - // add one of each item to the items on the board... - if (Platform.isServer()) { - // set new items onto the crafting table... - for (int x = 0; x < this.craftInv.getSizeInventory(); x++) { - if (this.craftInv.getStackInSlot(x) == null) { - this.craftInv.setInventorySlotContents(x, set[x]); - } else if (set[x] != null) { - // eek! put it back! - final IAEItemStack fail = - inv.injectItems(AEItemStack.create(set[x]), Actionable.MODULATE, this.mySrc); - if (fail != null) { - drops.add(fail.getItemStack()); - } - } - } - } - - if (drops.size() > 0) { - Platform.spawnDrops(p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops); - } - } - - IInventory getPattern() { - return this.pattern; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotDisabled.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotDisabled.java deleted file mode 100644 index b021815..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotDisabled.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotDisabled extends AppEngSlot { - - public SlotDisabled(final IInventory par1iInventory, final int slotIndex, final int x, final int y) { - super(par1iInventory, slotIndex, x, y); - } - - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotFake.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotFake.java deleted file mode 100644 index c4dbc8d..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotFake.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotFake extends AppEngSlot { - - public SlotFake(final IInventory inv, final int idx, final int x, final int y) { - super(inv, idx, x, y); - } - - @Override - public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {} - - @Override - public ItemStack decrStackSize(final int par1) { - return null; - } - - @Override - public boolean isItemValid(final ItemStack par1ItemStack) { - return false; - } - - @Override - public void putStack(ItemStack is) { - if (is != null) { - is = is.copy(); - } - - super.putStack(is); - } - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotFakeCraftingMatrix.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotFakeCraftingMatrix.java deleted file mode 100644 index 66b648e..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotFakeCraftingMatrix.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.inventory.IInventory; - -public class SlotFakeCraftingMatrix extends SlotFake { - - public SlotFakeCraftingMatrix(final IInventory inv, final int idx, final int x, final int y) { - super(inv, idx, x, y); - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotInaccessible.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotInaccessible.java deleted file mode 100644 index 3a53579..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotInaccessible.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotInaccessible extends AppEngSlot { - - private ItemStack dspStack = null; - - public SlotInaccessible(final IInventory i, final int slotIdx, final int x, final int y) { - super(i, slotIdx, x, y); - } - - @Override - public boolean isItemValid(final ItemStack i) { - return false; - } - - @Override - public void onSlotChanged() { - super.onSlotChanged(); - this.dspStack = null; - } - - @Override - public boolean canTakeStack(final EntityPlayer par1EntityPlayer) { - return false; - } - - @Override - public ItemStack getDisplayStack() { - if (this.dspStack == null) { - final ItemStack dsp = super.getDisplayStack(); - if (dsp != null) { - this.dspStack = dsp.copy(); - } - } - return this.dspStack; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotMagnet.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotMagnet.java index c047a91..40d381b 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotMagnet.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotMagnet.java @@ -4,7 +4,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.p455w0rd.wirelesscraftingterminal.items.ItemMagnet; -public class SlotMagnet extends AppEngSlot { +public class SlotMagnet extends appeng.container.slot.AppEngSlot { public SlotMagnet(IInventory inv, int xPos, int yPos) { super(inv, 0, xPos, yPos); diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotOutput.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotOutput.java deleted file mode 100644 index bc744af..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotOutput.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; - -public class SlotOutput extends AppEngSlot { - - public SlotOutput(final IInventory a, final int b, final int c, final int d, final int i) { - super(a, b, c, d); - this.setIIcon(i); - } - - @Override - public boolean isItemValid(final ItemStack i) { - return false; - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotPlayerHotBar.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotPlayerHotBar.java deleted file mode 100644 index 81e7f56..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotPlayerHotBar.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.inventory.IInventory; - -public class SlotPlayerHotBar extends appeng.container.slot.SlotPlayerHotBar { - - public SlotPlayerHotBar(final IInventory par1iInventory, final int par2, final int par3, final int par4) { - super(par1iInventory, par2, par3, par4); - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotPlayerInv.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotPlayerInv.java deleted file mode 100644 index 9ed4abd..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotPlayerInv.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.container.slot; - -import net.minecraft.inventory.IInventory; - -// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot. - -public class SlotPlayerInv extends appeng.container.slot.SlotPlayerInv { - - public SlotPlayerInv(final IInventory par1iInventory, final int par2, final int par3, final int par4) { - super(par1iInventory, par2, par3, par4); - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotTrash.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotTrash.java index ae33744..3cbbff3 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotTrash.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotTrash.java @@ -7,7 +7,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils; -public class SlotTrash extends AppEngSlot { +public class SlotTrash extends appeng.container.slot.AppEngSlot { private final EntityPlayer entityPlayer; private ItemStack itemStack; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotViewCell.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotViewCell.java index a481e8a..52b821e 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotViewCell.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/container/slot/SlotViewCell.java @@ -1,20 +1,12 @@ package net.p455w0rd.wirelesscraftingterminal.common.container.slot; -import appeng.api.AEApi; +import appeng.container.slot.SlotRestrictedInput; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -public class SlotViewCell extends AppEngSlot { +public class SlotViewCell extends SlotRestrictedInput { - public SlotViewCell(IInventory inv, int index, int xPos, int yPos) { - super(inv, index, xPos, yPos); - } - - @Override - public boolean isItemValid(ItemStack is) { - if (is == null || is.getItem() == null) { - return false; - } - return AEApi.instance().definitions().items().viewCell().isSameAs(is); + public SlotViewCell(IInventory inv, int index, int xPos, int yPos, InventoryPlayer playerInv) { + super(PlacableItemType.VIEW_CELL, inv, index, xPos, yPos, playerInv); } } diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/registries/EnumCache.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/registries/EnumCache.java deleted file mode 100644 index de0a755..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/registries/EnumCache.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.registries; - -import appeng.api.config.SortDir; -import appeng.api.config.SortOrder; -import appeng.api.config.ViewItems; - -public class EnumCache { - /** - * SortDir - */ - public static final SortDir[] AE_SORT_DIRECTIONS = SortDir.values(); - - /** - * SortOrder - */ - public static final SortOrder[] AE_SORT_ORDERS = SortOrder.values(); - - /** - * ViewItems - */ - public static final ViewItems[] AE_VIEW_ITEMS = ViewItems.values(); -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/utils/ReflectionUtils.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/utils/ReflectionUtils.java deleted file mode 100644 index 666b1b6..0000000 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/common/utils/ReflectionUtils.java +++ /dev/null @@ -1,61 +0,0 @@ -package net.p455w0rd.wirelesscraftingterminal.common.utils; - -import cpw.mods.fml.relauncher.ReflectionHelper; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -public class ReflectionUtils { - /** - * Get a {@link MethodHandle} for a method. - * - * @param clazz The class - * @param methodNames The possible names of the method - * @param methodTypes The argument types of the method - * @param The class - * @return The MethodHandle - */ - public static MethodHandle findMethod(Class clazz, String[] methodNames, Class... methodTypes) { - final Method method = ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes); - try { - return MethodHandles.lookup().unreflect(method); - } catch (IllegalAccessException e) { - throw new ReflectionHelper.UnableToFindMethodException(methodNames, e); - } - } - - /** - * Get a {@link MethodHandle} for a field's getter. - * - * @param clazz The class - * @param fieldNames The possible names of the field - * @return The MethodHandle - */ - public static MethodHandle findFieldGetter(Class clazz, String... fieldNames) { - final Field field = ReflectionHelper.findField(clazz, fieldNames); - - try { - return MethodHandles.lookup().unreflectGetter(field); - } catch (IllegalAccessException e) { - throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e); - } - } - - /** - * Get a {@link MethodHandle} for a field's setter. - * - * @param clazz The class - * @param fieldNames The possible names of the field - * @return The MethodHandle - */ - public static MethodHandle findFieldSetter(Class clazz, String... fieldNames) { - final Field field = ReflectionHelper.findField(clazz, fieldNames); - - try { - return MethodHandles.lookup().unreflectSetter(field); - } catch (IllegalAccessException e) { - throw new ReflectionHelper.UnableToAccessFieldException(fieldNames, e); - } - } -} diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketInventoryAction.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketInventoryAction.java index c1b0ca0..aca26fc 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketInventoryAction.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketInventoryAction.java @@ -99,7 +99,6 @@ public class PacketInventoryAction extends WCTPacket { context = ((AEBaseContainer) baseContainer).getOpenContext(); } - if (this.action == InventoryAction.AUTO_CRAFT) { // if( context != null ) // { diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketNEIRecipe.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketNEIRecipe.java index 3c27778..ed49e5a 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketNEIRecipe.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketNEIRecipe.java @@ -1,6 +1,5 @@ package net.p455w0rd.wirelesscraftingterminal.core.sync.packets; -import appeng.api.AEApi; import appeng.api.config.Actionable; import appeng.api.config.FuzzyMode; import appeng.api.config.SecurityPermissions; @@ -35,10 +34,8 @@ 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.container.ContainerWirelessCraftingTerminal; import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils; import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketValueConfig.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketValueConfig.java index e09728a..f4a7641 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketValueConfig.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/core/sync/packets/PacketValueConfig.java @@ -15,7 +15,6 @@ 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.container.ContainerWirelessCraftingTerminal; import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils; import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket; import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/helpers/WirelessTerminalGuiObject.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/helpers/WirelessTerminalGuiObject.java index 9f7c68d..779a8a5 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/helpers/WirelessTerminalGuiObject.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/helpers/WirelessTerminalGuiObject.java @@ -34,7 +34,8 @@ import net.minecraftforge.common.util.ForgeDirection; import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTerminalItem; import net.p455w0rd.wirelesscraftingterminal.api.networking.security.WCTIActionHost; -public class WirelessTerminalGuiObject implements IActionHost, IPortableCell, IInventorySlotAware, WCTIActionHost, IGuiItemObject { +public class WirelessTerminalGuiObject + implements IActionHost, IPortableCell, IInventorySlotAware, WCTIActionHost, IGuiItemObject { private final ItemStack effectiveItem; private final IWirelessTermHandler wth; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEI.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEI.java index bcaed4e..32e7048 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEI.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEI.java @@ -2,6 +2,8 @@ package net.p455w0rd.wirelesscraftingterminal.integration.modules; import appeng.api.AEApi; import appeng.api.storage.data.IAEItemStack; +import appeng.container.slot.SlotCraftingMatrix; +import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.integration.modules.NEIHelpers.NEIAEShapelessRecipeHandler; import appeng.util.Platform; import codechicken.nei.PositionedStack; @@ -24,8 +26,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal; import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingMatrix; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotFakeCraftingMatrix; import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler; import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketNEIRecipe; import net.p455w0rd.wirelesscraftingterminal.helpers.Reflected; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEIHelpers/NEICraftingHandler.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEIHelpers/NEICraftingHandler.java index ec278bf..444246e 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEIHelpers/NEICraftingHandler.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/integration/modules/NEIHelpers/NEICraftingHandler.java @@ -1,5 +1,7 @@ package net.p455w0rd.wirelesscraftingterminal.integration.modules.NEIHelpers; +import appeng.container.slot.SlotCraftingMatrix; +import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.util.Platform; import codechicken.nei.PositionedStack; import codechicken.nei.api.IOverlayHandler; @@ -12,8 +14,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotCraftingMatrix; -import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotFakeCraftingMatrix; import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler; import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketNEIRecipe; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemMagnet.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemMagnet.java index 626c350..339a9c1 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemMagnet.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemMagnet.java @@ -1,6 +1,5 @@ package net.p455w0rd.wirelesscraftingterminal.items; -import appeng.api.AEApi; import appeng.api.config.SecurityPermissions; import appeng.api.implementations.guiobjects.IPortableCell; import appeng.api.networking.IGrid; @@ -30,7 +29,6 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.oredict.OreDictionary; -import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler; import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTerminalItem; import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler; import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils; diff --git a/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemWirelessCraftingTerminal.java b/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemWirelessCraftingTerminal.java index e8a2159..c3b71d8 100644 --- a/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemWirelessCraftingTerminal.java +++ b/src/main/java/net/p455w0rd/wirelesscraftingterminal/items/ItemWirelessCraftingTerminal.java @@ -33,7 +33,8 @@ import net.p455w0rd.wirelesscraftingterminal.integration.EnderIO; import net.p455w0rd.wirelesscraftingterminal.reference.Reference; import org.lwjgl.input.Keyboard; -public class ItemWirelessCraftingTerminal extends AERootPoweredItem implements IWirelessCraftingTerminalItem, IWirelessTermHandler, IBauble { +public class ItemWirelessCraftingTerminal extends AERootPoweredItem + implements IWirelessCraftingTerminalItem, IWirelessTermHandler, IBauble { public static final String LINK_KEY_STRING = "key"; public static double GLOBAL_POWER_MULTIPLIER = PowerMultiplier.CONFIG.multiplier;