diff --git a/build.xml b/build.xml index cd7e1ebb..b4722a58 100644 --- a/build.xml +++ b/build.xml @@ -4,14 +4,14 @@ - - - - - - - - + + + + + + + + diff --git a/ee3_client/ee3/client/EEProxy.java b/ee3_client/ee3/client/EEProxy.java index ebc30682..6577b350 100644 --- a/ee3_client/ee3/client/EEProxy.java +++ b/ee3_client/ee3/client/EEProxy.java @@ -7,8 +7,10 @@ import cpw.mods.fml.common.ReflectionHelper; import ee3.client.core.KeyBindingHandler; import ee3.client.core.SoundHandler; +import ee3.client.gui.GuiPortableCrafting; import ee3.core.mod_EE3; import ee3.core.interfaces.IProxy; +import ee3.lib.GuiIds; import static ee3.lib.CustomItemRarity.*; import net.minecraft.client.Minecraft; import net.minecraft.src.EntityPlayer; @@ -77,8 +79,11 @@ public class EEProxy implements IProxy { } @Override - // TODO Client side: Handle GUI call public Object handleGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + if (ID == GuiIds.PORTABLE_CRAFTING) { + return new GuiPortableCrafting(player.inventory); + } + return null; } @@ -113,5 +118,10 @@ public class EEProxy implements IProxy { public void keyBindingEvent(Object event) { KeyBindingHandler.keyboardEvent((KeyBinding)event); } + + @Override + public boolean isPortableCraftingGUIOpen() { + return (ModLoader.getMinecraftInstance().currentScreen instanceof GuiPortableCrafting); + } } diff --git a/ee3_client/ee3/client/core/KeyBindingHandler.java b/ee3_client/ee3/client/core/KeyBindingHandler.java index adec9f91..535542aa 100644 --- a/ee3_client/ee3/client/core/KeyBindingHandler.java +++ b/ee3_client/ee3/client/core/KeyBindingHandler.java @@ -3,9 +3,14 @@ package ee3.client.core; import org.lwjgl.input.Keyboard; import ee3.core.mod_EE3; +import ee3.item.ModItems; +import ee3.lib.GuiIds; +import net.minecraft.src.EntityPlayerSP; +import net.minecraft.src.Item; import net.minecraft.src.KeyBinding; import net.minecraft.src.ModLoader; +import net.minecraft.src.World; /** * TODO Class Description @@ -32,7 +37,31 @@ public class KeyBindingHandler { } public static void keyboardEvent(KeyBinding event) { - System.out.println(event.keyDescription); + // We only care about keybinding events that happen when the game is "in play" + if (!ModLoader.getMinecraftInstance().isGamePaused) { + + EntityPlayerSP thePlayer = ModLoader.getMinecraftInstance().thePlayer; + World theWorld = ModLoader.getMinecraftInstance().theWorld; + + if (event.equals(Extra)) { + if (thePlayer.inventory.getCurrentItem() != null) { + Item currentItem = thePlayer.inventory.getCurrentItem().getItem(); + if ((currentItem.shiftedIndex == ModItems.miniumStone.shiftedIndex) || (currentItem.shiftedIndex == ModItems.philStone.shiftedIndex)) { + thePlayer.openGui(mod_EE3.instance(), GuiIds.PORTABLE_CRAFTING, theWorld, (int)thePlayer.posX, (int)thePlayer.posY, (int)thePlayer.posZ); + } + } + } + else if (event.equals(Charge)) { + // Check to see if the player is sneaking + System.out.println("Charge Key Pressed"); + } + else if (event.equals(Toggle)) { + System.out.println("Toggle Key Pressed"); + } + else if (event.equals(Release)) { + System.out.println("Release Key Pressed"); + } + } } } diff --git a/ee3_client/ee3/client/gui/GuiPortableCrafting.java b/ee3_client/ee3/client/gui/GuiPortableCrafting.java new file mode 100644 index 00000000..bae50413 --- /dev/null +++ b/ee3_client/ee3/client/gui/GuiPortableCrafting.java @@ -0,0 +1,34 @@ +package ee3.client.gui; + +import org.lwjgl.opengl.GL11; + +import ee3.container.ContainerPortableCrafting; + +import net.minecraft.src.GuiContainer; +import net.minecraft.src.InventoryPlayer; + +public class GuiPortableCrafting extends GuiContainer { + + public GuiPortableCrafting(InventoryPlayer inventoryPlayer) { + super(new ContainerPortableCrafting(inventoryPlayer, inventoryPlayer.player.worldObj, (int)inventoryPlayer.player.posX, (int)inventoryPlayer.player.posY, (int)inventoryPlayer.player.posZ)); + } + + public void onGuiClosed() { + super.onGuiClosed(); + } + + protected void drawGuiContainerForegroundLayer() { + fontRenderer.drawString("Crafting", 28, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + } + + protected void drawGuiContainerBackgroundLayer(float f, int l, int m) { + int i = mc.renderEngine.getTexture("/gui/crafting.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(i); + int j = (width - xSize) / 2; + int k = (height - ySize) / 2; + drawTexturedModalRect(j, k, 0, 0, xSize, ySize); + } + +} diff --git a/ee3_common/ee3/addons/ForestryAddon.java b/ee3_common/ee3/addons/ForestryAddon.java index 4d94827c..20c1b399 100644 --- a/ee3_common/ee3/addons/ForestryAddon.java +++ b/ee3_common/ee3/addons/ForestryAddon.java @@ -3,6 +3,7 @@ package ee3.addons; import ee3.core.helper.Helper; import net.minecraft.src.Block; import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; import net.minecraft.src.ModLoader; /** @@ -48,4 +49,16 @@ public class ForestryAddon extends EEAddon { e.printStackTrace(System.err); } } + + public static Item getModItem(String fieldItemName, String modClassName) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException, ClassNotFoundException { + return (Item)Class.forName(modClassName).getField(fieldItemName).get(null); + } + + public static Block getModBlock(String fieldBlockName, String modClassName) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException, ClassNotFoundException { + return (Block)Class.forName(modClassName).getField(fieldBlockName).get(null); + } + + public static ItemStack getModItemStack(String fieldItemName, String modClassName) throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException, ClassNotFoundException { + return new ItemStack(getModItem(fieldItemName, modClassName)); + } } diff --git a/ee3_common/ee3/container/ContainerPortableCrafting.java b/ee3_common/ee3/container/ContainerPortableCrafting.java new file mode 100644 index 00000000..8fca8e5e --- /dev/null +++ b/ee3_common/ee3/container/ContainerPortableCrafting.java @@ -0,0 +1,25 @@ +package ee3.container; + +import ee3.item.ModItems; +import net.minecraft.src.ContainerWorkbench; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.IInventory; +import net.minecraft.src.InventoryCraftResult; +import net.minecraft.src.InventoryCrafting; +import net.minecraft.src.InventoryPlayer; +import net.minecraft.src.Slot; +import net.minecraft.src.SlotCrafting; +import net.minecraft.src.World; + +public class ContainerPortableCrafting extends ContainerWorkbench { + + public ContainerPortableCrafting(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { + super(par1InventoryPlayer, par2World, par3, par4, par5); + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return true; + } + +} diff --git a/ee3_common/ee3/core/CraftingHandler.java b/ee3_common/ee3/core/CraftingHandler.java index b578453d..182947ca 100644 --- a/ee3_common/ee3/core/CraftingHandler.java +++ b/ee3_common/ee3/core/CraftingHandler.java @@ -1,16 +1,22 @@ package ee3.core; +import ee3.core.interfaces.IProxy; import ee3.item.ItemPhilosopherStone; import ee3.item.ModItems; import net.minecraft.src.EntityPlayer; import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; +import net.minecraft.src.ModLoader; import net.minecraft.src.forge.ICraftingHandler; public class CraftingHandler implements ICraftingHandler { @Override public void onTakenFromCrafting(EntityPlayer player, ItemStack stack, IInventory craftMatrix) { + if (mod_EE3.proxy.isPortableCraftingGUIOpen()) { + player.inventory.getCurrentItem().damageItem(1, player); + } + ItemStack currentItemStack; for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { currentItemStack = craftMatrix.getStackInSlot(i); diff --git a/ee3_common/ee3/core/interfaces/IProxy.java b/ee3_common/ee3/core/interfaces/IProxy.java index e34dfa81..a880e4b1 100644 --- a/ee3_common/ee3/core/interfaces/IProxy.java +++ b/ee3_common/ee3/core/interfaces/IProxy.java @@ -49,4 +49,7 @@ public interface IProxy { public abstract void addCustomEnumRarityTypes(); public abstract EnumRarity getCustomEnumRarityType(String custom); + + public abstract boolean isPortableCraftingGUIOpen(); + } diff --git a/ee3_common/ee3/lib/GuiIds.java b/ee3_common/ee3/lib/GuiIds.java index 5bae0bc6..f21b320b 100644 --- a/ee3_common/ee3/lib/GuiIds.java +++ b/ee3_common/ee3/lib/GuiIds.java @@ -6,5 +6,5 @@ package ee3.lib; * */ public class GuiIds { - + public static int PORTABLE_CRAFTING = 1; } diff --git a/ee3_server/ee3/server/EEProxy.java b/ee3_server/ee3/server/EEProxy.java index 93b12cf9..c50083ff 100644 --- a/ee3_server/ee3/server/EEProxy.java +++ b/ee3_server/ee3/server/EEProxy.java @@ -11,7 +11,9 @@ import net.minecraft.src.EnumRarity; import net.minecraft.src.ModLoader; import net.minecraft.src.NetworkManager; import net.minecraft.src.World; +import ee3.container.ContainerPortableCrafting; import ee3.core.interfaces.IProxy; +import ee3.lib.GuiIds; /** * TODO Class Description @@ -70,6 +72,10 @@ public class EEProxy implements IProxy { @Override // TODO Server side: Handle GUI call public Object handleGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + if (ID == GuiIds.PORTABLE_CRAFTING) { + return new ContainerPortableCrafting(player.inventory, world, x, y, z); + } + return null; } @@ -90,4 +96,9 @@ public class EEProxy implements IProxy { @Override public void keyBindingEvent(Object event) { } + @Override + public boolean isPortableCraftingGUIOpen() { + return false; + } + }