Some work on the P Stone portable crafting and Minium Stone durability.

Much more work to be done.
This commit is contained in:
pahimar 2012-07-04 15:56:15 -04:00
parent dc9285c192
commit 68c5051d50
10 changed files with 142 additions and 11 deletions

View File

@ -4,14 +4,14 @@
<property file="build.properties" />
<target name="clean">
<delete file="..\mcp\src\minecraft\mod_EE3.info" />
<delete file="..\mcp\src\minecraft\net\minecraft\src\mod_EE3.java" />
<delete dir="..\mcp\src\minecraft\ee3" />
<delete dir="..\mcp\src\minecraft\codechicken" />
<delete file="..\mcp\src\minecraft_server\mod_EE3.info" />
<delete file="..\mcp\src\minecraft_server\net\minecraft\src\mod_EE3.java" />
<delete file="..\mcp\src\minecraft_server\net\minecraft\src\EnumRarity.java" />
<delete dir="..\mcp\src\minecraft_server\ee3" />
<delete file="${dir.development}\mcp\src\minecraft\mod_EE3.info" />
<delete file="${dir.development}\mcp\src\minecraft\net\minecraft\src\mod_EE3.java" />
<delete dir="${dir.development}\mcp\src\minecraft\ee3" />
<delete dir="${dir.development}\mcp\src\minecraft\codechicken" />
<delete file="${dir.development}\mcp\src\minecraft_server\mod_EE3.info" />
<delete file="${dir.development}\mcp\src\minecraft_server\net\minecraft\src\mod_EE3.java" />
<delete file="${dir.development}\mcp\src\minecraft_server\net\minecraft\src\EnumRarity.java" />
<delete dir="${dir.development}\mcp\src\minecraft_server\ee3" />
</target>
<target name="integrate-nei">

View File

@ -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);
}
}

View File

@ -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");
}
}
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -49,4 +49,7 @@ public interface IProxy {
public abstract void addCustomEnumRarityTypes();
public abstract EnumRarity getCustomEnumRarityType(String custom);
public abstract boolean isPortableCraftingGUIOpen();
}

View File

@ -6,5 +6,5 @@ package ee3.lib;
*
*/
public class GuiIds {
public static int PORTABLE_CRAFTING = 1;
}

View File

@ -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;
}
}