diff --git a/src/main/java/appeng/client/ClientHelper.java b/src/main/java/appeng/client/ClientHelper.java index 91af9bd96..a09e1a270 100644 --- a/src/main/java/appeng/client/ClientHelper.java +++ b/src/main/java/appeng/client/ClientHelper.java @@ -35,6 +35,7 @@ import appeng.core.Api; import appeng.core.AppEng; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketAssemblerAnimation; +import appeng.core.sync.packets.PacketTerminalUse; import appeng.core.sync.packets.PacketValueConfig; import appeng.entity.EntityFloatingItem; import appeng.entity.EntityTinyTNTPrimed; @@ -44,6 +45,8 @@ import appeng.helpers.HighlighterHandler; import appeng.helpers.IMouseWheelItem; import appeng.hooks.TickHandler; import appeng.hooks.TickHandler.PlayerColor; +import appeng.items.tools.powered.Terminal; +import appeng.items.tools.powered.ToolWirelessTerminal; import appeng.server.ServerHelper; import appeng.util.Platform; import net.minecraft.client.Minecraft; @@ -59,12 +62,19 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.client.event.*; import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.client.settings.KeyConflictContext; +import net.minecraftforge.client.settings.KeyModifier; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import java.io.IOException; @@ -73,11 +83,17 @@ import java.util.EnumMap; import java.util.List; import java.util.Random; +import static appeng.client.KeyBindings.WCT; +import static appeng.client.KeyBindings.WFT; +import static appeng.client.KeyBindings.WPT; +import static appeng.client.KeyBindings.WT; + public class ClientHelper extends ServerHelper { - private final static String KEY_CATEGORY = "key.appliedenergistics2.category"; + public final static String KEY_CATEGORY = "key.appliedenergistics2.category"; private final EnumMap bindings = new EnumMap<>(ActionKey.class); + private final List keyBindings = new ArrayList<>(); @Override public void preinit() { @@ -99,6 +115,11 @@ public class ClientHelper extends ServerHelper { this.bindings.put(key, binding); } + for (KeyBindings k : KeyBindings.values()) { + ClientRegistry.registerKeyBinding(k.getKeyBinding()); + this.keyBindings.add(k.getKeyBinding()); + } + Api.INSTANCE.definitions().items().encodedPattern().maybeItem().ifPresent(pattern -> Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ItemEncodedPatternBakedModel.PATTERN_ITEM_COLOR_HANDLER, pattern)); } @@ -319,6 +340,23 @@ public class ClientHelper extends ServerHelper { } } + @SubscribeEvent(priority = EventPriority.HIGHEST) + public void onInputEvent(final InputEvent.KeyInputEvent event) { + for (KeyBinding k : keyBindings) { + if (k.isPressed()) { + if (k == WT.getKeyBinding()) { + NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_TERMINAL)); + } else if (k == WCT.getKeyBinding()) { + NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_CRAFTING_TERMINAL)); + } else if (k == WPT.getKeyBinding()) { + NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_PATTERN_TERMINAL)); + } else if (k == WFT.getKeyBinding()) { + NetworkHandler.instance().sendToServer(new PacketTerminalUse(Terminal.WIRELESS_FLUID_TERMINAL)); + } + } + } + } + @SubscribeEvent public void onTextureStitch(final TextureStitchEvent.Pre event) { ParticleTextures.registerSprite(event); diff --git a/src/main/java/appeng/client/KeyBindings.java b/src/main/java/appeng/client/KeyBindings.java new file mode 100644 index 000000000..6dd711313 --- /dev/null +++ b/src/main/java/appeng/client/KeyBindings.java @@ -0,0 +1,28 @@ +package appeng.client; + +import net.minecraft.client.settings.KeyBinding; +import net.minecraftforge.client.settings.KeyConflictContext; +import net.minecraftforge.client.settings.KeyModifier; +import org.lwjgl.input.Keyboard; + +import static appeng.client.ClientHelper.KEY_CATEGORY; + + +public enum KeyBindings { + WT(new KeyBinding("open_wireless_terminal", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_T, KEY_CATEGORY)), + WCT(new KeyBinding("open_wireless_crafting_terminal", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_E, KEY_CATEGORY)), + WPT(new KeyBinding("open_wireless_pattern_terminal", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_R, KEY_CATEGORY)), + WFT(new KeyBinding("open_wireless_fluid_terminal", KeyConflictContext.UNIVERSAL, KeyModifier.SHIFT, Keyboard.KEY_F, KEY_CATEGORY)); + + private KeyBinding keyBinding; + + KeyBindings(KeyBinding keyBinding) { + this.keyBinding = keyBinding; + } + + ; + + public KeyBinding getKeyBinding() { + return keyBinding; + } +} diff --git a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java index 215281f79..525db0fe3 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java +++ b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java @@ -35,6 +35,7 @@ import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.Platform; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; +import baubles.api.BaublesApi; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; @@ -56,7 +57,9 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I super(ip, monitorable, bindInventory); if (monitorable != null) { final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot(); - this.lockPlayerInventorySlot(slotIndex); + if (!((IInventorySlotAware) monitorable).isBaubleSlot()) { + this.lockPlayerInventorySlot(slotIndex); + } this.slot = slotIndex; } else { this.slot = -1; @@ -76,9 +79,14 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable implements I public void detectAndSendChanges() { if (Platform.isServer()) { - final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); + final ItemStack currentItem; + if (wirelessTerminalGUIObject.isBaubleSlot()) { + currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot); + } else { + currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); + } - if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) { + if (currentItem.isEmpty()) { this.setValidContainer(false); } else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) { if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) { diff --git a/src/main/java/appeng/container/implementations/ContainerWirelessPatternTerminal.java b/src/main/java/appeng/container/implementations/ContainerWirelessPatternTerminal.java index 289d62a82..23753b534 100644 --- a/src/main/java/appeng/container/implementations/ContainerWirelessPatternTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerWirelessPatternTerminal.java @@ -25,6 +25,7 @@ import appeng.api.implementations.ICraftingPatternItem; import appeng.api.implementations.IUpgradeableCellContainer; import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.data.IAEItemStack; +import appeng.container.interfaces.IInventorySlotAware; import appeng.container.slot.OptionalSlotFake; import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.container.slot.SlotPatternOutputs; @@ -38,6 +39,7 @@ import appeng.tile.inventory.AppEngInternalInventory; import appeng.util.Platform; import appeng.util.helpers.ItemHandlerUtil; import appeng.util.inv.InvOperation; +import baubles.api.BaublesApi; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -69,7 +71,9 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im if (gui != null) { final int slotIndex = gui.getInventorySlot(); - this.lockPlayerInventorySlot(slotIndex); + if (!((IInventorySlotAware) gui).isBaubleSlot()) { + this.lockPlayerInventorySlot(slotIndex); + } this.slot = slotIndex; } else { this.slot = -1; @@ -116,9 +120,14 @@ public class ContainerWirelessPatternTerminal extends ContainerPatternEncoder im public void detectAndSendChanges() { if (Platform.isServer()) { - final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); + final ItemStack currentItem; + if (wirelessTerminalGUIObject.isBaubleSlot()) { + currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot); + } else { + currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); + } - if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) { + if (currentItem.isEmpty()) { this.setValidContainer(false); } else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) { if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) { diff --git a/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java b/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java index 3a2ba0a4d..cd9eae785 100644 --- a/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java @@ -28,11 +28,8 @@ import net.minecraft.entity.player.InventoryPlayer; public class ContainerWirelessTerm extends ContainerMEPortableCell { - private final WirelessTerminalGuiObject wirelessTerminalGUIObject; - public ContainerWirelessTerm(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) { super(ip, gui, true); - this.wirelessTerminalGUIObject = gui; } @Override diff --git a/src/main/java/appeng/container/interfaces/IInventorySlotAware.java b/src/main/java/appeng/container/interfaces/IInventorySlotAware.java index 1af2a7be7..1471e9118 100644 --- a/src/main/java/appeng/container/interfaces/IInventorySlotAware.java +++ b/src/main/java/appeng/container/interfaces/IInventorySlotAware.java @@ -1,35 +1,39 @@ -/* - * This file is part of Applied Energistics 2. - * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. - * - * Applied Energistics 2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Applied Energistics 2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Applied Energistics 2. If not, see . - */ - -package appeng.container.interfaces; - - -/** - * Any item providing a GUI and depending on an exact inventory slot. - *

- * This interface is likely a volatile one until a general GUI refactoring occurred. - * Use it with care and expect changes. - */ -public interface IInventorySlotAware { - /** - * This is needed to select the correct slot index. - * - * @return the inventory index of this portable cell. - */ - int getInventorySlot(); -} +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.container.interfaces; + + +/** + * Any item providing a GUI and depending on an exact inventory slot. + *

+ * This interface is likely a volatile one until a general GUI refactoring occurred. + * Use it with care and expect changes. + */ +public interface IInventorySlotAware { + /** + * This is needed to select the correct slot index. + * + * @return the inventory index of this portable cell. + */ + int getInventorySlot(); + + default boolean isBaubleSlot() { + return false; + } +} diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 25ef37615..2297041d6 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -414,8 +414,7 @@ final class Registration { iids.add(items.wirelessTerminal()); iids.add(items.wirelessCraftingTerminal()); iids.add(items.wirelessPatternTerminal()); - iids.add(items.wirelessFluidTerminal()); - + for (IItemDefinition id : iids) { id.maybeItem().ifPresent(terminal -> { registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal); @@ -423,6 +422,10 @@ final class Registration { Upgrades.MAGNET.registerItem(id, 1); }); } + items.wirelessFluidTerminal().maybeItem().ifPresent(terminal -> { + registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal); + Upgrades.QUANTUM_LINK.registerItem(items.wirelessFluidTerminal(), 1); + }); // Charge Rates items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d)); diff --git a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java index 5738fb18c..6e7065161 100644 --- a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java +++ b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java @@ -84,7 +84,9 @@ public class AppEngPacketHandlerBase { PACKET_INFORM_PLAYER(PacketInformPlayer.class), - PACKET_CRAFTING_CPUS_UPDATE(PacketCraftingCPUsUpdate.class); + PACKET_CRAFTING_CPUS_UPDATE(PacketCraftingCPUsUpdate.class), + + PACKET_TERMINAL_KEYBIND(PacketTerminalUse.class); private final Class packetClass; diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index 1a519cc0c..748f27532 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -71,6 +71,7 @@ import appeng.tile.storage.TileDrive; import appeng.tile.storage.TileIOPort; import appeng.tile.storage.TileSkyChest; import appeng.util.Platform; +import baubles.api.BaublesApi; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -233,10 +234,14 @@ public enum GuiBridge implements IGuiHandler { final boolean stem = ((ordinal >> 3) & 1) == 1; if (ID.type.isItem()) { ItemStack it = ItemStack.EMPTY; - if (stem) { - it = player.inventory.getCurrentItem(); - } else if (x >= 0 && x < player.inventory.mainInventory.size()) { - it = player.inventory.getStackInSlot(x); + if (y == 0) { + if (stem) { + it = player.inventory.getCurrentItem(); + } else if (x >= 0 && x < player.inventory.mainInventory.size()) { + it = player.inventory.getStackInSlot(x); + } + } else { + it = BaublesApi.getBaublesHandler(player).getStackInSlot(x); } final Object myItem = this.getGuiObject(it, player, w, x, y, z); if (myItem != null && ID.CorrectTileOrPart(myItem)) { @@ -344,10 +349,14 @@ public enum GuiBridge implements IGuiHandler { final boolean stem = ((ordinal >> 3) & 1) == 1; if (ID.type.isItem()) { ItemStack it = ItemStack.EMPTY; - if (stem) { - it = player.inventory.getCurrentItem(); - } else if (x >= 0 && x < player.inventory.mainInventory.size()) { - it = player.inventory.getStackInSlot(x); + if (y == 0) { + if (stem) { + it = player.inventory.getCurrentItem(); + } else if (x >= 0 && x < player.inventory.mainInventory.size()) { + it = player.inventory.getStackInSlot(x); + } + } else { + it = BaublesApi.getBaublesHandler(player).getStackInSlot(x); } final Object myItem = this.getGuiObject(it, player, w, x, y, z); if (myItem != null && ID.CorrectTileOrPart(myItem)) { diff --git a/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java b/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java new file mode 100644 index 000000000..2a932a423 --- /dev/null +++ b/src/main/java/appeng/core/sync/packets/PacketTerminalUse.java @@ -0,0 +1,53 @@ +package appeng.core.sync.packets; + +import appeng.core.sync.AppEngPacket; +import appeng.core.sync.network.INetworkInfo; +import appeng.items.tools.powered.Terminal; +import appeng.util.Platform; +import baubles.api.BaublesApi; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +public class PacketTerminalUse extends AppEngPacket { + Terminal terminal; + + public PacketTerminalUse(final ByteBuf stream) { + this.terminal = Terminal.values()[stream.readInt()]; + } + + public PacketTerminalUse(Enum terminal) { + + final ByteBuf data = Unpooled.buffer(); + + data.writeInt(this.getPacketID()); + data.writeInt(terminal.ordinal()); + + this.configureWrite(data); + } + + @Override + public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) { + NonNullList mainInventory = player.inventory.mainInventory; + for (int i = 0; i < mainInventory.size(); i++) { + ItemStack is = mainInventory.get(i); + if (is.isItemEqual(terminal.getItemDefinition().maybeStack(1).get())) { + Platform.openGUI(player, i, terminal.getBridge(), false); + return; + } + } + for (int i = 0; i < BaublesApi.getBaublesHandler(player).getSlots(); i++) { + ItemStack is = BaublesApi.getBaublesHandler(player).getStackInSlot(i); + if (is.isItemEqual(terminal.getItemDefinition().maybeStack(1).get())) { + Platform.openGUI(player, i, terminal.getBridge(), true); + break; + } + } + } + + enum a { + + } +} diff --git a/src/main/java/appeng/fluids/container/ContainerMEPortableFluidCell.java b/src/main/java/appeng/fluids/container/ContainerMEPortableFluidCell.java index 0f7574b97..785db70e8 100644 --- a/src/main/java/appeng/fluids/container/ContainerMEPortableFluidCell.java +++ b/src/main/java/appeng/fluids/container/ContainerMEPortableFluidCell.java @@ -48,6 +48,7 @@ import appeng.util.IConfigManagerHost; import appeng.util.Platform; import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.InvOperation; +import baubles.api.BaublesApi; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -66,7 +67,7 @@ import java.nio.BufferOverflowException; public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAEAppEngInventory, IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver, IUpgradeableCellContainer { - private final WirelessTerminalGuiObject wirelessTerminalGUIObject; + protected final WirelessTerminalGuiObject wirelessTerminalGUIObject; private final IConfigManager clientCM; private final IMEMonitor monitor; @@ -129,7 +130,9 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE if (monitorable != null) { final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot(); - this.lockPlayerInventorySlot(slotIndex); + if (!((IInventorySlotAware) monitorable).isBaubleSlot()) { + this.lockPlayerInventorySlot(slotIndex); + } this.slot = slotIndex; } else { this.slot = -1; @@ -149,9 +152,13 @@ public class ContainerMEPortableFluidCell extends AEBaseContainer implements IAE @Override public void detectAndSendChanges() { if (Platform.isServer()) { - final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); - - if (this.wirelessTerminalGUIObject == null || currentItem.isEmpty()) { + final ItemStack currentItem; + if (wirelessTerminalGUIObject.isBaubleSlot()) { + currentItem = BaublesApi.getBaublesHandler(this.getPlayerInv().player).getStackInSlot(this.slot); + } else { + currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem() : this.getPlayerInv().getStackInSlot(this.slot); + } + if (currentItem.isEmpty()) { this.setValidContainer(false); } else if (!this.wirelessTerminalGUIObject.getItemStack().isEmpty() && currentItem != this.wirelessTerminalGUIObject.getItemStack()) { if (ItemStack.areItemsEqual(this.wirelessTerminalGUIObject.getItemStack(), currentItem)) { diff --git a/src/main/java/appeng/fluids/container/ContainerWirelessFluidTerminal.java b/src/main/java/appeng/fluids/container/ContainerWirelessFluidTerminal.java index c2ce18046..8f903aa67 100644 --- a/src/main/java/appeng/fluids/container/ContainerWirelessFluidTerminal.java +++ b/src/main/java/appeng/fluids/container/ContainerWirelessFluidTerminal.java @@ -19,36 +19,14 @@ package appeng.fluids.container; -import appeng.core.AEConfig; -import appeng.core.localization.PlayerMessages; import appeng.helpers.WirelessTerminalGuiObject; -import appeng.util.Platform; import net.minecraft.entity.player.InventoryPlayer; public class ContainerWirelessFluidTerminal extends ContainerMEPortableFluidCell { - private final WirelessTerminalGuiObject wirelessTerminalGUIObject; public ContainerWirelessFluidTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) { super(ip, gui); - this.wirelessTerminalGUIObject = gui; - } - - @Override - public void detectAndSendChanges() { - if (Platform.isServer()) { - super.detectAndSendChanges(); - - if (!this.wirelessTerminalGUIObject.rangeCheck()) { - if (Platform.isServer() && this.isValidContainer()) { - this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get()); - } - - this.setValidContainer(false); - } else { - this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange())); - } - } } } diff --git a/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java b/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java index f797315e9..60e7ea433 100644 --- a/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java +++ b/src/main/java/appeng/helpers/WirelessTerminalGuiObject.java @@ -67,6 +67,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II private final IWirelessTermHandler wth; private final String encryptionKey; private final EntityPlayer myPlayer; + private final boolean isBaubleSlot; private IGrid targetGrid; private IStorageGrid sg; private IMEMonitor itemStorage; @@ -86,6 +87,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II this.myPlayer = ep; this.wth = wh; this.inventorySlot = x; + this.isBaubleSlot = y == 1; ILocatable obj = null; @@ -327,6 +329,11 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II return this.inventorySlot; } + @Override + public boolean isBaubleSlot() { + return isBaubleSlot; + } + @Override public IItemHandler getViewCellStorage() { NBTTagCompound data = effectiveItem.getTagCompound(); diff --git a/src/main/java/appeng/items/tools/powered/Terminal.java b/src/main/java/appeng/items/tools/powered/Terminal.java new file mode 100644 index 000000000..0b94857c9 --- /dev/null +++ b/src/main/java/appeng/items/tools/powered/Terminal.java @@ -0,0 +1,28 @@ +package appeng.items.tools.powered; + +import appeng.api.AEApi; +import appeng.api.definitions.IItemDefinition; +import appeng.core.sync.GuiBridge; + +public enum Terminal { + WIRELESS_TERMINAL(AEApi.instance().definitions().items().wirelessTerminal(), GuiBridge.GUI_WIRELESS_TERM), + WIRELESS_CRAFTING_TERMINAL(AEApi.instance().definitions().items().wirelessCraftingTerminal(), GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL), + WIRELESS_PATTERN_TERMINAL(AEApi.instance().definitions().items().wirelessPatternTerminal(), GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL), + WIRELESS_FLUID_TERMINAL(AEApi.instance().definitions().items().wirelessFluidTerminal(), GuiBridge.GUI_WIRELESS_FLUID_TERMINAL); + + final GuiBridge bridge; + final IItemDefinition itemDefinition; + + Terminal(IItemDefinition itemDefinition, GuiBridge guiBridge) { + this.itemDefinition = itemDefinition; + this.bridge = guiBridge; + } + + public GuiBridge getBridge() { + return bridge; + } + + public IItemDefinition getItemDefinition() { + return itemDefinition; + } +} diff --git a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java index 48430ac6d..4e7235831 100644 --- a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java +++ b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java @@ -26,6 +26,9 @@ import appeng.api.util.IConfigManager; import appeng.core.AEConfig; import appeng.core.localization.GuiText; import appeng.core.sync.GuiBridge; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketCraftRequest; +import appeng.core.sync.packets.PacketTerminalUse; import appeng.items.contents.CellConfig; import appeng.items.contents.CellUpgrades; import appeng.items.materials.ItemMaterial; @@ -34,6 +37,7 @@ import appeng.util.ConfigManager; import appeng.util.Platform; import baubles.api.BaubleType; import baubles.api.IBauble; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -48,11 +52,16 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; +import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.fml.common.Optional; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent; import net.minecraftforge.fml.common.network.IGuiHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.ItemStackHandler; +import org.lwjgl.input.Keyboard; import java.util.List; diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index f81f132b0..7992bb4ba 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -342,6 +342,18 @@ public class Platform { } } + public static void openGUI(@Nonnull final EntityPlayer p, int i, @Nonnull final GuiBridge type, boolean isBauble) { + if (isClient()) { + return; + } + + if (type.getType().isItem()) { + if (type.getType() == GuiHostType.ITEM) { + p.openGui(AppEng.instance(), type.ordinal() << 4, p.getEntityWorld(), i, isBauble ? 1 : 0, 0); + } + } + } + /* * returns true if the code is on the client. */