aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_Workbench.java46
-rw-r--r--src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java48
-rw-r--r--src/Java/gtPlusPlus/core/item/ModItems.java53
-rw-r--r--src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java2
-rw-r--r--src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java164
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotBlueprint.java30
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotGeneric.java24
-rw-r--r--src/resources/assets/miscutils/textures/items/itemBlueprint.pngbin0 -> 3259 bytes
8 files changed, 308 insertions, 59 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_Workbench.java b/src/Java/gtPlusPlus/core/container/Container_Workbench.java
index d63133a01e..5ce6d0e1a2 100644
--- a/src/Java/gtPlusPlus/core/container/Container_Workbench.java
+++ b/src/Java/gtPlusPlus/core/container/Container_Workbench.java
@@ -1,15 +1,19 @@
package gtPlusPlus.core.container;
import gregtech.api.gui.GT_Slot_Holo;
-import gregtech.api.gui.GT_Slot_Output;
import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.interfaces.IItemBlueprint;
import gtPlusPlus.core.inventories.InventoryWorkbenchChest;
import gtPlusPlus.core.inventories.InventoryWorkbenchHoloCrafting;
import gtPlusPlus.core.inventories.InventoryWorkbenchHoloSlots;
import gtPlusPlus.core.inventories.InventoryWorkbenchTools;
+import gtPlusPlus.core.item.general.ItemBlueprint;
+import gtPlusPlus.core.slots.SlotBlueprint;
+import gtPlusPlus.core.slots.SlotGeneric;
import gtPlusPlus.core.slots.SlotGtTool;
-import gtPlusPlus.core.slots.SlotNoInput;
import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.item.UtilsItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -103,11 +107,11 @@ public class Container_Workbench extends Container {
int o=0;
//Output slot
- addSlotToContainer(new GT_Slot_Output(inventoryHolo, 0, 136, 64));
+ addSlotToContainer(new SlotGeneric(inventoryHolo, 0, 136, 64));
//Util Slots
- addSlotToContainer(new SlotNoInput(inventoryHolo, 1, 136, 28));
- addSlotToContainer(new SlotNoInput(inventoryHolo, 2, 154, 28));
- addSlotToContainer(new SlotNoInput(inventoryHolo, 3, 154, 64));
+ addSlotToContainer(new SlotBlueprint(inventoryHolo, 1, 136, 28)); //Blueprint
+ addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 2, 154, 28, false, false, 1)); //Hopper
+ addSlotToContainer(new SlotGeneric(inventoryHolo, 3, 154, 64)); //Parking
//Holo Slots
addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 4, 154, 46, false, false, 1));
addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 5, 136, 46, false, false, 1));
@@ -181,7 +185,7 @@ public class Container_Workbench extends Container {
}
-/* @Override
+ @Override
public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){
if (aSlotIndex == 999 || aSlotIndex == -999){
@@ -199,7 +203,32 @@ public class Container_Workbench extends Container {
Utils.LOG_INFO("Player Clicked Blueprint slot in the Holo Grid");
}
else if (x == 2){
- Utils.LOG_INFO("Player Clicked Right Arrow slot in the Holo Grid");
+ Utils.LOG_INFO("Player Clicked Right Arrow slot in the Holo Grid");
+ if (inventoryHolo.getStackInSlot(1) != null){
+ Utils.LOG_INFO("Found an ItemStack.");
+ if (inventoryHolo.getStackInSlot(1).getItem() instanceof IItemBlueprint){
+ Utils.LOG_INFO("Found a blueprint.");
+ ItemStack tempBlueprint = inventoryHolo.getStackInSlot(1);
+ ItemBlueprint tempItemBlueprint = (ItemBlueprint) tempBlueprint.getItem();
+ if (inventoryHolo.getStackInSlot(0) != null){
+ Utils.LOG_INFO("Output slot was not empty.");
+ Utils.LOG_INFO("Trying to manipulate NBT data on the blueprint stack, then replace it with the new one.");
+ tempItemBlueprint.setBlueprint(inventoryHolo.getStackInSlot(1), craftMatrix, inventoryHolo.getStackInSlot(0));
+ ItemStack newTempBlueprint = UtilsItems.getSimpleStack(tempItemBlueprint);
+ inventoryHolo.setInventorySlotContents(1, newTempBlueprint);
+ Utils.LOG_INFO(UtilsItems.getArrayStackNames(tempItemBlueprint.getBlueprint(newTempBlueprint)));
+ }
+ else {
+ Utils.LOG_INFO("Output slot was empty.");
+ }
+ }
+ else {
+ Utils.LOG_INFO("ItemStack found was not a blueprint.");
+ }
+ }
+ else {
+ Utils.LOG_INFO("No ItemStack found in Blueprint slot.");
+ }
}
else if (x == 3){
Utils.LOG_INFO("Player Clicked Big [P] slot in the Holo Grid");
@@ -231,7 +260,6 @@ public class Container_Workbench extends Container {
//Utils.LOG_INFO("Player Clicked slot "+aSlotIndex+" in the Grid");
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
-*/
@Override
public void onCraftMatrixChanged(IInventory par1IInventory){
diff --git a/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java b/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java
new file mode 100644
index 0000000000..f3f4e40b66
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/interfaces/IItemBlueprint.java
@@ -0,0 +1,48 @@
+package gtPlusPlus.core.interfaces;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+
+public interface IItemBlueprint {
+
+ /**
+ * The inventory size for the blueprint~
+ */
+ public int INV_SIZE = 9;
+
+ /**
+ * Meta Compatible function to allow meta items to be blueprints
+ * @param stack yourMetaItem
+ * @return true if it is a Blueprint
+ */
+ public boolean isBlueprint(ItemStack stack);
+
+ /**
+ * Sets the blueprint for this itemstack.
+ * @param stack yourMetaItem
+ * @return true if blueprint is set successfully
+ */
+ public boolean setBlueprint(ItemStack stack, IInventory craftingTable, ItemStack output);
+
+ /**
+ * Sets the name of the recipe/blueprint
+ * @param String Blueprint Name
+ * @return N/A
+ */
+ public void setBlueprintName(String name);
+
+ /**
+ * Does this itemstack hold a blueprint?
+ * @param stack yourMetaItem
+ * @return true if is holding a Blueprint
+ */
+ public boolean hasBlueprint(ItemStack stack);
+
+ /**
+ * Gets the recipe held by the item
+ * @param stack yourMetaItem
+ * @return the blueprints contents
+ */
+ public ItemStack[] getBlueprint(ItemStack stack);
+
+}
diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java
index 9ca49c8a51..b33a8b747f 100644
--- a/src/Java/gtPlusPlus/core/item/ModItems.java
+++ b/src/Java/gtPlusPlus/core/item/ModItems.java
@@ -15,6 +15,7 @@ import gtPlusPlus.core.item.base.ingots.BaseItemIngot;
import gtPlusPlus.core.item.base.plates.BaseItemPlate;
import gtPlusPlus.core.item.effects.RarityUncommon;
import gtPlusPlus.core.item.general.BufferCore;
+import gtPlusPlus.core.item.general.ItemBlueprint;
import gtPlusPlus.core.item.general.RF2EU_Battery;
import gtPlusPlus.core.item.general.fuelrods.FuelRod_Base;
import gtPlusPlus.core.item.init.ItemsFoods;
@@ -131,6 +132,8 @@ public final class ModItems {
public static BaseItemBackpack backpack_White;
public static Item dustLithiumCarbonate;
+
+ public static ItemBlueprint itemBlueprintBase;
//@SuppressWarnings("unused")
@@ -165,6 +168,8 @@ public final class ModItems {
backpack_Black = new BaseItemBackpack("backpackBlack", Utils.rgbtoHexValue(20, 20, 20));
backpack_White = new BaseItemBackpack("backpackWhite", Utils.rgbtoHexValue(240, 240, 240));
+ itemBlueprintBase = new ItemBlueprint("itemBlueprint");
+
//Start meta Item Generation
ItemsFoods.load();
@@ -239,54 +244,6 @@ public final class ModItems {
MS_GTMATERIAL = UtilsItems.generateMultiShovel(gtStyleTools, m);
}
-
- /*MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Wood);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Cobblestone);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Iron);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.WroughtIron);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.DarkIron);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Gold);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Silver);
-
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Diamond);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Emerald);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Ruby);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Sapphire);
-
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Cupronickel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Brass);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Bronze);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Steel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Lead);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Titanium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Tungsten);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Platinum);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Chrome);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.TungstenSteel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Aluminium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Thaumium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Cobalt);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Iridium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Ultimet);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Osmiridium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.NetherStar);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Naquadah);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.NaquadahAlloy);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.NaquadahEnriched);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Neutronium);
-
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Thorium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.DamascusSteel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Magnalium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.BlackSteel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Invar);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.MeteoricSteel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.StainlessSteel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.BlueSteel);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Neodymium);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Desh);
- MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.ElectrumFlux);*/
-
//EnderIO Resources
if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){
Utils.LOG_INFO("EnderIO Found - Loading Resources.");
diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java
index a6cc29497e..431f93b3e6 100644
--- a/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java
+++ b/src/Java/gtPlusPlus/core/item/base/BaseItemGeneric.java
@@ -8,7 +8,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.EnumChatFormatting;
public class BaseItemGeneric extends Item
{
@@ -24,7 +23,6 @@ public class BaseItemGeneric extends Item
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
- list.add(EnumChatFormatting.GOLD+"");
super.addInformation(stack, aPlayer, list, bool);
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
new file mode 100644
index 0000000000..a15616711d
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/item/general/ItemBlueprint.java
@@ -0,0 +1,164 @@
+package gtPlusPlus.core.item.general;
+
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.interfaces.IItemBlueprint;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.math.MathUtils;
+
+import java.util.List;
+
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+import cpw.mods.fml.common.registry.GameRegistry;
+
+public class ItemBlueprint extends Item implements IItemBlueprint{
+
+ protected String mName = "";
+ protected boolean mHasBlueprint = false;
+ private final int bpID;
+
+ /**
+ * The inventory of items the blueprint holds~
+ */
+ protected ItemStack[] blueprint = new ItemStack[9];
+
+ public ItemBlueprint(String unlocalizedName) {
+ this.setUnlocalizedName(unlocalizedName);
+ this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.setMaxStackSize(1);
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ this.bpID = MathUtils.randInt(0, 1000);
+ GameRegistry.registerItem(this, unlocalizedName);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
+ if (bpID >= 0){
+ list.add(EnumChatFormatting.GRAY+"Technical Document No. "+bpID);
+ }
+ if(mHasBlueprint){
+ list.add(EnumChatFormatting.BLUE+"Currently holding a blueprint for "+mName);
+ }
+ else {
+ list.add(EnumChatFormatting.RED+"Currently not holding a blueprint for anything.");
+ }
+ super.addInformation(stack, aPlayer, list, bool);
+ }
+
+ @Override
+ public String getItemStackDisplayName(ItemStack p_77653_1_) {
+ return "Blueprint";
+ }
+
+ @Override
+ public void onCreated(ItemStack itemStack, World world, EntityPlayer player) {
+ itemStack.stackTagCompound = new NBTTagCompound();
+ //this.inventory = null;
+ //itemStack.stackTagCompound.set("pos_x", bed_X); TODO
+ }
+
+ @Override
+ public void onUpdate(ItemStack itemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
+
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer par3Entity) {
+ //Let the player know what blueprint is held
+ Utils.messagePlayer(par3Entity, "This is a placeholder.");
+ return super.onItemRightClick(itemStack, world, par3Entity);
+ }
+
+ public void readFromNBT(NBTTagCompound nbt){
+ NBTTagList list = nbt.getTagList("Items", 10);
+ blueprint = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++)
+ {
+ NBTTagCompound data = list.getCompoundTagAt(i);
+ int slot = data.getInteger("Slot");
+ if(slot >= 0 && slot < INV_SIZE)
+ {
+ blueprint[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(NBTTagCompound nbt){
+ NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++)
+ {
+ ItemStack stack = blueprint[i];
+ if(stack != null)
+ {
+ NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public boolean isBlueprint(ItemStack stack) {
+ return true;
+ }
+
+ @Override
+ public boolean setBlueprint(ItemStack stack, IInventory craftingTable, ItemStack output) {
+ if (!mHasBlueprint){
+ try {
+ for (int o=0; o<craftingTable.getSizeInventory(); o++){
+ blueprint[o] = craftingTable.getStackInSlot(o);
+ if (blueprint[0] != null){
+ blueprint[0].stackSize = 0;
+ }
+ }
+ if (output != null){
+ setBlueprintName(output.getDisplayName());
+ return (mHasBlueprint = true);
+ }
+ return false;
+ } catch (Throwable t){
+ return false;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void setBlueprintName(String name) {
+ this.mName = name;
+ }
+
+ @Override
+ public boolean hasBlueprint(ItemStack stack) {
+ return mHasBlueprint;
+ }
+
+ @Override
+ public ItemStack[] getBlueprint(ItemStack stack) {
+ try {
+ ItemStack[] returnStack = new ItemStack[9];
+ for (int o=0; o<blueprint.length; o++){
+ returnStack[o] = blueprint[o];
+ if (returnStack[0] != null){
+ returnStack[0].stackSize = 1;
+ }
+ }
+ return returnStack;
+ } catch (Throwable t){
+ return null;
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java b/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java
new file mode 100644
index 0000000000..3c5c30966e
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotBlueprint.java
@@ -0,0 +1,30 @@
+package gtPlusPlus.core.slots;
+
+import gtPlusPlus.core.interfaces.IItemBlueprint;
+import gtPlusPlus.core.util.Utils;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class SlotBlueprint extends Slot{
+
+ public SlotBlueprint(IInventory inventory, int x, int y, int z) {
+ super(inventory, x, y, z);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack itemstack) {
+ if (itemstack.getItem() instanceof IItemBlueprint){
+ Utils.LOG_WARNING(itemstack.getDisplayName()+" is a valid Blueprint.");
+ return true;
+ }
+ Utils.LOG_WARNING(itemstack.getDisplayName()+" is not a valid Blueprint.");
+ return false;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/slots/SlotGeneric.java b/src/Java/gtPlusPlus/core/slots/SlotGeneric.java
new file mode 100644
index 0000000000..bf7dc1fff5
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotGeneric.java
@@ -0,0 +1,24 @@
+package gtPlusPlus.core.slots;
+
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class SlotGeneric extends Slot{
+
+ public SlotGeneric(IInventory inventory, int x, int y, int z) {
+ super(inventory, x, y, z);
+
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 64;
+ }
+
+}
diff --git a/src/resources/assets/miscutils/textures/items/itemBlueprint.png b/src/resources/assets/miscutils/textures/items/itemBlueprint.png
new file mode 100644
index 0000000000..7d60e0871b
--- /dev/null
+++ b/src/resources/assets/miscutils/textures/items/itemBlueprint.png
Binary files differ