aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/container
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/core/container')
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_BackpackBase.java231
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_Charger.java71
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_NHG.java104
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_Workbench.java581
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_WorkbenchAdvanced.java512
5 files changed, 761 insertions, 738 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java b/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java
index e3d936a315..f156f6dcaf 100644
--- a/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java
+++ b/src/Java/gtPlusPlus/core/container/Container_BackpackBase.java
@@ -8,188 +8,179 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
-public class Container_BackpackBase extends Container {
- /**
- * Using these will make transferStackInSlot easier to understand and
- * implement INV_START is the index of the first slot in the Player's
- * Inventory, so our BaseInventoryBackpack's number of slots (e.g. 5 slots
- * is array indices 0-4, so start at 5) Notice how we don't have to remember
- * how many slots we made? We can just use BaseInventoryBackpack.INV_SIZE
- * and if we ever change it, the Container updates automatically.
- */
- private static final int INV_START = BaseInventoryBackpack.INV_SIZE,
- INV_END = Container_BackpackBase.INV_START + 26, HOTBAR_START = Container_BackpackBase.INV_END + 1,
- HOTBAR_END = Container_BackpackBase.HOTBAR_START + 8;
-
- /**
- * The Item Inventory for this Container, only needed if you want to
- * reference isUseableByPlayer
- */
- public final BaseInventoryBackpack inventory;
+public class Container_BackpackBase extends Container
+{
+ /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */
+ public final BaseInventoryBackpack inventory;
+
+ /** Using these will make transferStackInSlot easier to understand and implement
+ * INV_START is the index of the first slot in the Player's Inventory, so our
+ * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5)
+ * Notice how we don't have to remember how many slots we made? We can just use
+ * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */
+ private static final int INV_START = BaseInventoryBackpack.INV_SIZE, INV_END = INV_START+26,
+ HOTBAR_START = INV_END+1, HOTBAR_END = HOTBAR_START+8;
// If you're planning to add armor slots, put those first like this:
// ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3,
// INV_START = ARMOR_END+1, and then carry on like above.
- public Container_BackpackBase(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer,
- final BaseInventoryBackpack inventoryItem) {
+ public Container_BackpackBase(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, BaseInventoryBackpack inventoryItem)
+ {
this.inventory = inventoryItem;
int i;
- // ITEM INVENTORY - you'll need to adjust the slot locations to match
- // your texture file
- // I have them set vertically in columns of 4 to the right of the player
- // model
- for (i = 0; i < BaseInventoryBackpack.INV_SIZE; ++i) {
+ // ITEM INVENTORY - you'll need to adjust the slot locations to match your texture file
+ // I have them set vertically in columns of 4 to the right of the player model
+ for (i = 0; i < BaseInventoryBackpack.INV_SIZE; ++i)
+ {
// You can make a custom Slot if you need different behavior,
// such as only certain item types can be put into this slot
// We made a custom slot to prevent our inventory-storing item
- // from being stored within itself, but if you want to allow that
- // and
+ // from being stored within itself, but if you want to allow that and
// you followed my advice at the end of the above step, then you
// could get away with using the vanilla Slot class
- this.addSlotToContainer(new SlotItemBackpackInv(this.inventory, i, 80 + 18 * (i / 4), 8 + 18 * (i % 4)));
+ this.addSlotToContainer(new SlotItemBackpackInv(this.inventory, i, 80 + (18 * (int)(i/4)), 8 + (18*(i%4))));
}
// If you want, you can add ARMOR SLOTS here as well, but you need to
- // make a public version of SlotArmor. I won't be doing that in this
- // tutorial.
+ // make a public version of SlotArmor. I won't be doing that in this tutorial.
/*
- * for (i = 0; i < 4; ++i) { // These are the standard positions for
- * survival inventory layout this.addSlotToContainer(new
- * SlotArmor(this.player, inventoryPlayer,
- * inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); }
- */
-
- // PLAYER INVENTORY - uses default locations for standard inventory
- // texture file
- for (i = 0; i < 3; ++i) {
- for (int j = 0; j < 9; ++j) {
+ for (i = 0; i < 4; ++i)
+ {
+ // These are the standard positions for survival inventory layout
+ this.addSlotToContainer(new SlotArmor(this.player, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i));
+ }
+ */
+
+ // PLAYER INVENTORY - uses default locations for standard inventory texture file
+ for (i = 0; i < 3; ++i)
+ {
+ for (int j = 0; j < 9; ++j)
+ {
this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
- // PLAYER ACTION BAR - uses default locations for standard action bar
- // texture file
- for (i = 0; i < 9; ++i) {
+ // PLAYER ACTION BAR - uses default locations for standard action bar texture file
+ for (i = 0; i < 9; ++i)
+ {
this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
- public boolean canInteractWith(final EntityPlayer entityplayer) {
+ public boolean canInteractWith(EntityPlayer entityplayer)
+ {
// be sure to return the inventory's isUseableByPlayer method
// if you defined special behavior there:
- return this.inventory.isUseableByPlayer(entityplayer);
- }
-
- /**
- * You should override this method to prevent the player from moving the
- * stack that opened the inventory, otherwise if the player moves it, the
- * inventory will not be able to save properly
- */
- @Override
- public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) {
- // this will prevent the player from interacting with the item that
- // opened the inventory:
- if (slot >= 0 && this.getSlot(slot) != null && this.getSlot(slot).getStack() == player.getHeldItem()) {
- return null;
- }
- return super.slotClick(slot, button, flag, player);
+ return inventory.isUseableByPlayer(entityplayer);
}
/**
- * Called when a player shift-clicks on a slot. You must override this or
- * you will crash when someone does that.
+ * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
*/
- @Override
- public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) {
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int index)
+ {
ItemStack itemstack = null;
- final Slot slot = (Slot) this.inventorySlots.get(index);
+ Slot slot = (Slot) this.inventorySlots.get(index);
- if (slot != null && slot.getHasStack()) {
- final ItemStack itemstack1 = slot.getStack();
+ if (slot != null && slot.getHasStack())
+ {
+ ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
// If item is in our custom Inventory or armor slot
- if (index < Container_BackpackBase.INV_START) {
+ if (index < INV_START)
+ {
// try to place in player inventory / action bar
- if (!this.mergeItemStack(itemstack1, Container_BackpackBase.INV_START,
- Container_BackpackBase.HOTBAR_END + 1, true)) {
+ if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true))
+ {
return null;
}
slot.onSlotChange(itemstack1, itemstack);
}
- // Item is in inventory / hotbar, try to place in custom inventory
- // or armor slots
- else {
+ // Item is in inventory / hotbar, try to place in custom inventory or armor slots
+ else
+ {
/*
- * If your inventory only stores certain instances of Items, you
- * can implement shift-clicking to your inventory like this:
- *
- * // Check that the item is the right type if
- * (itemstack1.getItem() instanceof ItemCustom) { // Try to
- * merge into your custom inventory slots // We use
- * 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in
- * case // you also add armor or other custom slots if
- * (!this.mergeItemStack(itemstack1, 0,
- * BaseInventoryBackpack.INV_SIZE, false)) { return null; } } //
- * If you added armor slots, check them here as well: // Item
- * being shift-clicked is armor - try to put in armor slot if
- * (itemstack1.getItem() instanceof ItemArmor) { int type =
- * ((ItemArmor) itemstack1.getItem()).armorType; if
- * (!this.mergeItemStack(itemstack1, ARMOR_START + type,
- * ARMOR_START + type + 1, false)) { return null; } } Otherwise,
- * you have basically 2 choices: 1. shift-clicking between
- * player inventory and custom inventory 2. shift-clicking
- * between action bar and inventory
- *
- * Be sure to choose only ONE of the following
- * implementations!!!
- */
+ If your inventory only stores certain instances of Items,
+ you can implement shift-clicking to your inventory like this:
+
+ // Check that the item is the right type
+ if (itemstack1.getItem() instanceof ItemCustom)
+ {
+ // Try to merge into your custom inventory slots
+ // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case
+ // you also add armor or other custom slots
+ if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false))
+ {
+ return null;
+ }
+ }
+ // If you added armor slots, check them here as well:
+ // Item being shift-clicked is armor - try to put in armor slot
+ if (itemstack1.getItem() instanceof ItemArmor)
+ {
+ int type = ((ItemArmor) itemstack1.getItem()).armorType;
+ if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false))
+ {
+ return null;
+ }
+ }
+ Otherwise, you have basically 2 choices:
+ 1. shift-clicking between player inventory and custom inventory
+ 2. shift-clicking between action bar and inventory
+
+ Be sure to choose only ONE of the following implementations!!!
+ */
/**
- * Implementation number 1: Shift-click into your custom
- * inventory
+ * Implementation number 1: Shift-click into your custom inventory
*/
- if (index >= Container_BackpackBase.INV_START) {
+ if (index >= INV_START)
+ {
// place in custom inventory
- if (!this.mergeItemStack(itemstack1, 0, Container_BackpackBase.INV_START, false)) {
+ if (!this.mergeItemStack(itemstack1, 0, INV_START, false))
+ {
return null;
}
}
-
+
/**
- * Implementation number 2: Shift-click items between action bar
- * and inventory
+ * Implementation number 2: Shift-click items between action bar and inventory
*/
// item is in player's inventory, but not in action bar
- if (index >= Container_BackpackBase.INV_START && index < Container_BackpackBase.HOTBAR_START) {
+ if (index >= INV_START && index < HOTBAR_START)
+ {
// place in action bar
- if (!this.mergeItemStack(itemstack1, Container_BackpackBase.HOTBAR_START,
- Container_BackpackBase.HOTBAR_END + 1, false)) {
+ if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false))
+ {
return null;
}
}
// item in action bar - place in player inventory
- else if (index >= Container_BackpackBase.HOTBAR_START
- && index < Container_BackpackBase.HOTBAR_END + 1) {
- if (!this.mergeItemStack(itemstack1, Container_BackpackBase.INV_START,
- Container_BackpackBase.INV_END + 1, false)) {
+ else if (index >= HOTBAR_START && index < HOTBAR_END+1)
+ {
+ if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false))
+ {
return null;
}
}
}
- if (itemstack1.stackSize == 0) {
+ if (itemstack1.stackSize == 0)
+ {
slot.putStack((ItemStack) null);
}
- else {
+ else
+ {
slot.onSlotChanged();
}
- if (itemstack1.stackSize == itemstack.stackSize) {
+ if (itemstack1.stackSize == itemstack.stackSize)
+ {
return null;
}
@@ -198,4 +189,18 @@ public class Container_BackpackBase extends Container {
return itemstack;
}
+
+ /**
+ * You should override this method to prevent the player from moving the stack that
+ * opened the inventory, otherwise if the player moves it, the inventory will not
+ * be able to save properly
+ */
+ @Override
+ public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) {
+ // this will prevent the player from interacting with the item that opened the inventory:
+ if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) {
+ return null;
+ }
+ return super.slotClick(slot, button, flag, player);
+ }
}
diff --git a/src/Java/gtPlusPlus/core/container/Container_Charger.java b/src/Java/gtPlusPlus/core/container/Container_Charger.java
index 89dc8904d8..4b6c43ada6 100644
--- a/src/Java/gtPlusPlus/core/container/Container_Charger.java
+++ b/src/Java/gtPlusPlus/core/container/Container_Charger.java
@@ -6,61 +6,76 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
-public class Container_Charger extends Container {
- public static final int INPUT_1 = 0;
+public class Container_Charger extends Container
+{
+ private TileEntityCharger te;
- private final TileEntityCharger te;
+ public static final int INPUT_1 = 0;
- private int slotID = 0;
+ private int slotID = 0;
- public Container_Charger(final TileEntityCharger te, final EntityPlayer player) {
+ public Container_Charger(TileEntityCharger te, EntityPlayer player)
+ {
this.te = te;
- // Fuel Slot A
- this.addSlotToContainer(new Slot(te, this.slotID++, 80, 53));
+ //Fuel Slot A
+ addSlotToContainer(new Slot(te, slotID++, 80, 53));
- // Inventory
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 9; j++) {
- this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+
+
+ //Inventory
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 9; j++)
+ {
+ addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
// Hotbar
- for (int i = 0; i < 9; i++) {
- this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
+ for (int i = 0; i < 9; i++)
+ {
+ addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
@Override
- public boolean canInteractWith(final EntityPlayer player) {
- return this.te.isUseableByPlayer(player);
- }
-
- @Override
- public ItemStack transferStackInSlot(final EntityPlayer player, final int slotRaw) {
+ public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw)
+ {
ItemStack stack = null;
- final Slot slot = (Slot) this.inventorySlots.get(slotRaw);
+ Slot slot = (Slot)inventorySlots.get(slotRaw);
- if (slot != null && slot.getHasStack()) {
- final ItemStack stackInSlot = slot.getStack();
+ if (slot != null && slot.getHasStack())
+ {
+ ItemStack stackInSlot = slot.getStack();
stack = stackInSlot.copy();
- if (slotRaw < 3 * 9) {
- if (!this.mergeItemStack(stackInSlot, 3 * 9, this.inventorySlots.size(), true)) {
+ if (slotRaw < 3 * 9)
+ {
+ if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true))
+ {
return null;
}
}
- else if (!this.mergeItemStack(stackInSlot, 0, 3 * 9, false)) {
+ else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false))
+ {
return null;
}
- if (stackInSlot.stackSize == 0) {
- slot.putStack((ItemStack) null);
+ if (stackInSlot.stackSize == 0)
+ {
+ slot.putStack((ItemStack)null);
}
- else {
+ else
+ {
slot.onSlotChanged();
}
}
return stack;
}
+
+ @Override
+ public boolean canInteractWith(EntityPlayer player)
+ {
+ return te.isUseableByPlayer(player);
+ }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/container/Container_NHG.java b/src/Java/gtPlusPlus/core/container/Container_NHG.java
index 35e82162c1..64a84ce680 100644
--- a/src/Java/gtPlusPlus/core/container/Container_NHG.java
+++ b/src/Java/gtPlusPlus/core/container/Container_NHG.java
@@ -2,79 +2,103 @@ package gtPlusPlus.core.container;
import gtPlusPlus.core.tileentities.machines.TileEntityNHG;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.*;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
-public class Container_NHG extends Container {
- public static final int INPUT_1 = 0, INPUT_2 = 1, INPUT_3 = 2, INPUT_4 = 3, INPUT_5 = 4, INPUT_6 = 5,
- INPUT_7 = 6, INPUT_8 = 7, INPUT_9 = 8, INPUT_10 = 9, INPUT_11 = 10, INPUT_12 = 11, INPUT_13 = 12,
- INPUT_14 = 13, INPUT_15 = 14, INPUT_16 = 15, INPUT_17 = 16, INPUT_18 = 17, OUTPUT = 18;
+public class Container_NHG extends Container
+{
+ private TileEntityNHG te;
- private final TileEntityNHG te;
+ public static final int INPUT_1 = 0, INPUT_2 = 1, INPUT_3 = 2,
+ INPUT_4 = 3, INPUT_5 = 4, INPUT_6 = 5,
+ INPUT_7 = 6, INPUT_8 = 7, INPUT_9 = 8,
+ INPUT_10 = 9, INPUT_11 = 10, INPUT_12 = 11,
+ INPUT_13 = 12, INPUT_14 = 13, INPUT_15 = 14,
+ INPUT_16 = 15, INPUT_17 = 16, INPUT_18 = 17,
+ OUTPUT = 18;
+
+ private int slotID = 0;
- private int slotID = 0;
-
- public Container_NHG(final TileEntityNHG te, final EntityPlayer player) {
+ public Container_NHG(TileEntityNHG te, EntityPlayer player)
+ {
this.te = te;
- // Fuel Rods A
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- this.addSlotToContainer(new Slot(te, this.slotID++, 8 + j * 18, 17 + i * 18));
+
+ //Fuel Rods A
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ addSlotToContainer(new Slot(te, slotID++, 8 + j * 18, 17 + i * 18));
}
}
- // Fuel Rods B
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- this.addSlotToContainer(new Slot(te, this.slotID++, 116 + j * 18, 17 + i * 18));
+ //Fuel Rods B
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 3; j++)
+ {
+ addSlotToContainer(new Slot(te, slotID++, 116 + j * 18, 17 + i * 18));
}
}
- // Output
- this.addSlotToContainer(new SlotFurnace(player, te, Container_NHG.OUTPUT, 80, 53));
+ //Output
+ addSlotToContainer(new SlotFurnace(player, te, OUTPUT, 80, 53));
- // Inventory
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 9; j++) {
- this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ //Inventory
+ for (int i = 0; i < 3; i++)
+ {
+ for (int j = 0; j < 9; j++)
+ {
+ addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
// Hotbar
- for (int i = 0; i < 9; i++) {
- this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
+ for (int i = 0; i < 9; i++)
+ {
+ addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
}
}
@Override
- public boolean canInteractWith(final EntityPlayer player) {
- return this.te.isUseableByPlayer(player);
- }
-
- @Override
- public ItemStack transferStackInSlot(final EntityPlayer player, final int slotRaw) {
+ public ItemStack transferStackInSlot(EntityPlayer player, int slotRaw)
+ {
ItemStack stack = null;
- final Slot slot = (Slot) this.inventorySlots.get(slotRaw);
+ Slot slot = (Slot)inventorySlots.get(slotRaw);
- if (slot != null && slot.getHasStack()) {
- final ItemStack stackInSlot = slot.getStack();
+ if (slot != null && slot.getHasStack())
+ {
+ ItemStack stackInSlot = slot.getStack();
stack = stackInSlot.copy();
- if (slotRaw < 3 * 9) {
- if (!this.mergeItemStack(stackInSlot, 3 * 9, this.inventorySlots.size(), true)) {
+ if (slotRaw < 3 * 9)
+ {
+ if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true))
+ {
return null;
}
}
- else if (!this.mergeItemStack(stackInSlot, 0, 3 * 9, false)) {
+ else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false))
+ {
return null;
}
- if (stackInSlot.stackSize == 0) {
- slot.putStack((ItemStack) null);
+ if (stackInSlot.stackSize == 0)
+ {
+ slot.putStack((ItemStack)null);
}
- else {
+ else
+ {
slot.onSlotChanged();
}
}
return stack;
}
+
+ @Override
+ public boolean canInteractWith(EntityPlayer player)
+ {
+ return te.isUseableByPlayer(player);
+ }
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/container/Container_Workbench.java b/src/Java/gtPlusPlus/core/container/Container_Workbench.java
index 9f58fcdad8..c814f8815e 100644
--- a/src/Java/gtPlusPlus/core/container/Container_Workbench.java
+++ b/src/Java/gtPlusPlus/core/container/Container_Workbench.java
@@ -3,83 +3,92 @@ package gtPlusPlus.core.container;
import gregtech.api.gui.GT_Slot_Holo;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.interfaces.IItemBlueprint;
-import gtPlusPlus.core.inventories.*;
+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.*;
+import gtPlusPlus.core.slots.SlotBlueprint;
+import gtPlusPlus.core.slots.SlotGtTool;
+import gtPlusPlus.core.slots.SlotNoInput;
+import gtPlusPlus.core.slots.SlotOutput;
import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.inventory.*;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.world.World;
public class Container_Workbench extends Container {
- public static int HoloSlotNumber = 6;
- public static int InputSlotNumber = 9; // Number
- // of
- // Slots
- // in
- // the
- // Crafting
- // Grid
- public static int StorageSlotNumber = 16; // Number
- // of
- // slots
- // in
- // storage
- // area
- public static int ToolSlotNumber = 5; // Number
- // of
- // slots
- // in
- // the
- // tool
- // area
- // up
- // top
- public static int InOutputSlotNumber = Container_Workbench.InputSlotNumber
- + Container_Workbench.StorageSlotNumber + Container_Workbench.ToolSlotNumber
- + Container_Workbench.HoloSlotNumber; // Same
- // plus
- // Output
- // Slot
- public static int InventorySlotNumber = 36; // Inventory
-
- // Slots
- // (Inventory
- // and
- // Hotbar)
- public static int InventoryOutSlotNumber = Container_Workbench.InventorySlotNumber + 1; // Inventory
- // Slot
- // Number
- // +
- // Output
- public static int FullSlotNumber = Container_Workbench.InventorySlotNumber
- + Container_Workbench.InOutputSlotNumber; // All
- // slots
- protected TileEntityWorkbench tile_entity;
- public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
-
- public final InventoryWorkbenchChest inventoryChest;
- public final InventoryWorkbenchTools inventoryTool;
- public final InventoryWorkbenchHoloSlots inventoryHolo;
- public final InventoryWorkbenchHoloCrafting inventoryCrafting;
- private final World worldObj;
- private final int posX;
- private final int posY;
- private final int posZ;
-
- private final int slotOutput = 0;
- private final int[] slotHolo = new int[5];
- private final int[] slotCrafting = new int[9];
- private final int[] slotStorage = new int[16];
- private final int[] slotTools = new int[5];
-
- public Container_Workbench(final InventoryPlayer inventory, final TileEntityWorkbench tile) {
+ protected TileEntityWorkbench tile_entity;
+ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
+ public final InventoryWorkbenchChest inventoryChest;
+ public final InventoryWorkbenchTools inventoryTool;
+ public final InventoryWorkbenchHoloSlots inventoryHolo;
+ public final InventoryWorkbenchHoloCrafting inventoryCrafting;
+
+ private World worldObj;
+ private int posX;
+ private int posY;
+ private int posZ;
+
+ public static int HoloSlotNumber = 6;
+ public static int InputSlotNumber = 9; //Number of Slots in the Crafting Grid
+ public static int StorageSlotNumber = 16; //Number of slots in storage area
+ public static int ToolSlotNumber = 5; // Number of slots in the tool area up top
+ public static int InOutputSlotNumber = InputSlotNumber + StorageSlotNumber + ToolSlotNumber + HoloSlotNumber; //Same plus Output Slot
+ public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar)
+ public static int InventoryOutSlotNumber = InventorySlotNumber + 1; //Inventory Slot Number + Output
+ public static int FullSlotNumber = InventorySlotNumber + InOutputSlotNumber; //All slots
+
+ private int slotOutput = 0;
+ private int[] slotHolo = new int[5];
+ private int[] slotCrafting = new int[9];
+ private int[] slotStorage = new int[16];
+ private int[] slotTools = new int[5];
+
+ public void moveCraftingToChest(){
+ //Check Chest Space
+ for (int i=0;i<9;i++){
+ if (craftMatrix.getStackInSlot(i) != null){
+ for (int r=0;r<16;r++){
+ if (inventoryChest.getStackInSlot(r) == null || (inventoryChest.getStackInSlot(r).getItem() == craftMatrix.getStackInSlot(i).getItem() && (64-craftMatrix.getStackInSlot(i).stackSize) <= (64-craftMatrix.getStackInSlot(i).stackSize))){
+ inventoryChest.setInventorySlotContents(r, craftMatrix.getStackInSlot(i));
+ craftMatrix.setInventorySlotContents(i, null);
+ break;
+ }
+ }
+ }
+ }
+ //For Each Space or already existing itemstack, move one itemstack or fill current partial stack
+ //Remove old itemstack or partial stack from crafting grid
+ }
+
+ public void moveChestToCrafting(){
+ //Check Crafting items and slots
+ for (int i=0;i<9;i++){
+ if (craftMatrix.getStackInSlot(i) == null || craftMatrix.getStackInSlot(i).stackSize > 0){
+ for (int r=0;r<16;r++){
+ if (inventoryChest.getStackInSlot(r) != null){
+ craftMatrix.setInventorySlotContents(i, craftMatrix.getStackInSlot(r));
+ inventoryChest.setInventorySlotContents(r, null);
+ }
+ }
+ }
+ }
+ //For Each already existing itemstack, fill current partial stack
+ //Remove partial stack from chest area
+ }
+
+
+ public Container_Workbench(InventoryPlayer inventory, TileEntityWorkbench tile){
this.tile_entity = tile;
this.inventoryChest = tile.inventoryChest;
this.inventoryTool = tile.inventoryTool;
@@ -88,329 +97,308 @@ public class Container_Workbench extends Container {
int var6;
int var7;
- this.worldObj = tile.getWorldObj();
- this.posX = tile.xCoord;
- this.posY = tile.yCoord;
- this.posZ = tile.zCoord;
-
- int o = 0;
-
- // Output slot
- this.addSlotToContainer(
- new SlotOutput(inventory.player, this.craftMatrix, tile.inventoryCraftResult, 0, 136, 64));
- // Util Slots
- this.addSlotToContainer(new SlotBlueprint(this.inventoryHolo, 1, 136, 28)); // Blueprint
- this.addSlotToContainer(new SlotNoInput(this.inventoryHolo, 2, 154, 28)); // Hopper
- this.addSlotToContainer(new GT_Slot_Holo(this.inventoryHolo, 3, 154, 64, false, false, 64)); // Parking
- // Holo Slots
- this.addSlotToContainer(new GT_Slot_Holo(this.inventoryHolo, 4, 154, 46, false, false, 1));
- this.addSlotToContainer(new GT_Slot_Holo(this.inventoryHolo, 5, 136, 46, false, false, 1));
-
- for (int i = 1; i < 6; i++) {
- this.slotHolo[o] = o + 1;
+ worldObj = tile.getWorldObj();
+ posX = tile.xCoord;
+ posY = tile.yCoord;
+ posZ = tile.zCoord;
+
+ int o=0;
+
+ //Output slot
+ addSlotToContainer(new SlotOutput(inventory.player, this.craftMatrix, tile.inventoryCraftResult, 0, 136, 64));
+ //Util Slots
+ addSlotToContainer(new SlotBlueprint(inventoryHolo, 1, 136, 28)); //Blueprint
+ addSlotToContainer(new SlotNoInput(inventoryHolo, 2, 154, 28)); //Hopper
+ addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 3, 154, 64, false, false, 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));
+
+ for (int i=1; i<6; i++){
+ slotHolo[o] = o+1;
o++;
}
- o = 0;
+ o=0;
- this.updateCraftingMatrix();
+ updateCraftingMatrix();
- // Crafting Grid
- for (var6 = 0; var6 < 3; ++var6) {
- for (var7 = 0; var7 < 3; ++var7) {
+ //Crafting Grid
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 3; ++var7)
+ {
this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 3, 82 + var7 * 18, 28 + var6 * 18));
- /*
- * if (this.inventoryCrafting.getStackInSlot(o) != null){
- * this.craftMatrix.setInventorySlotContents(o,
- * inventoryCrafting.getStackInSlot(o));
- * this.inventoryCrafting.setInventorySlotContents(o, null); }
- */
- this.slotCrafting[o] = o + 6;
+ /*if (this.inventoryCrafting.getStackInSlot(o) != null){
+ this.craftMatrix.setInventorySlotContents(o, inventoryCrafting.getStackInSlot(o));
+ this.inventoryCrafting.setInventorySlotContents(o, null);
+ } */
+ slotCrafting[o] = o+6;
o++;
}
}
- o = 0;
+ o=0;
- // Storage Side
- for (var6 = 0; var6 < 4; ++var6) {
- for (var7 = 0; var7 < 4; ++var7) {
- // Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+"
- // x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18));
- this.addSlotToContainer(new Slot(this.inventoryChest, var7 + var6 * 4, 8 + var7 * 18, 7 + var6 * 18));
- this.slotStorage[o] = o + 15;
+ //Storage Side
+ for (var6 = 0; var6 < 4; ++var6)
+ {
+ for (var7 = 0; var7 < 4; ++var7)
+ {
+ //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18));
+ this.addSlotToContainer(new Slot(inventoryChest, var7 + var6 * 4, 8 + var7 * 18, 7 + var6 * 18));
+ slotStorage[o] = o+15;
o++;
}
}
- o = 0;
+ o=0;
- // Tool Slots
- for (var6 = 0; var6 < 1; ++var6) {
- for (var7 = 0; var7 < 5; ++var7) {
- this.addSlotToContainer(
- new SlotGtTool(this.inventoryTool, var7 + var6 * 3, 82 + var7 * 18, 8 + var6 * 18));
- this.slotTools[o] = o + 31;
+ //Tool Slots
+ for (var6 = 0; var6 < 1; ++var6)
+ {
+ for (var7 = 0; var7 < 5; ++var7)
+ {
+ this.addSlotToContainer(new SlotGtTool(inventoryTool, var7 + var6 * 3, 82 + var7 * 18, 8 + var6 * 18));
+ slotTools[o] = o+31;
o++;
}
- }
+ }
- // Player Inventory
- for (var6 = 0; var6 < 3; ++var6) {
- for (var7 = 0; var7 < 9; ++var7) {
+ //Player Inventory
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 9; ++var7)
+ {
this.addSlotToContainer(new Slot(inventory, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18));
}
}
- // Player Hotbar
- for (var6 = 0; var6 < 9; ++var6) {
+ //Player Hotbar
+ for (var6 = 0; var6 < 9; ++var6)
+ {
this.addSlotToContainer(new Slot(inventory, var6, 8 + var6 * 18, 142));
}
- this.onCraftMatrixChanged(this.craftMatrix);
+ this.onCraftMatrixChanged(this.craftMatrix);
}
@Override
- public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
- if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockWorkbench) {
- return false;
- }
-
- return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D;
- }
-
- // Can merge Slot
- @Override
- public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) {
- return p_94530_2_.inventory != this.tile_entity.inventoryCraftResult
- && super.func_94530_a(p_94530_1_, p_94530_2_);
- }
+ public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){
- public void moveChestToCrafting() {
- // Check Crafting items and slots
- for (int i = 0; i < 9; i++) {
- if (this.craftMatrix.getStackInSlot(i) == null || this.craftMatrix.getStackInSlot(i).stackSize > 0) {
- for (int r = 0; r < 16; r++) {
- if (this.inventoryChest.getStackInSlot(r) != null) {
- this.craftMatrix.setInventorySlotContents(i, this.craftMatrix.getStackInSlot(r));
- this.inventoryChest.setInventorySlotContents(r, null);
- }
- }
+ if (!aPlayer.worldObj.isRemote){
+ if (aSlotIndex == 999 || aSlotIndex == -999){
+ //Utils.LOG_WARNING("??? - "+aSlotIndex);
}
- }
- // For Each already existing itemstack, fill current partial stack
- // Remove partial stack from chest area
- }
-
- public void moveCraftingToChest() {
- // Check Chest Space
- for (int i = 0; i < 9; i++) {
- if (this.craftMatrix.getStackInSlot(i) != null) {
- for (int r = 0; r < 16; r++) {
- if (this.inventoryChest.getStackInSlot(r) == null || this.inventoryChest.getStackInSlot(r)
- .getItem() == this.craftMatrix.getStackInSlot(i).getItem()
- && 64 - this.craftMatrix.getStackInSlot(i).stackSize <= 64
- - this.craftMatrix.getStackInSlot(i).stackSize) {
- this.inventoryChest.setInventorySlotContents(r, this.craftMatrix.getStackInSlot(i));
- this.craftMatrix.setInventorySlotContents(i, null);
- break;
- }
- }
- }
- }
- // For Each Space or already existing itemstack, move one itemstack or
- // fill current partial stack
- // Remove old itemstack or partial stack from crafting grid
- }
-
- @Override
- public void onContainerClosed(final EntityPlayer par1EntityPlayer) {
- super.onContainerClosed(par1EntityPlayer);
- this.saveCraftingMatrix();
- }
-
- @Override
- public void onCraftMatrixChanged(final IInventory iiventory) {
- this.tile_entity.inventoryCraftResult.setInventorySlotContents(0,
- CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
- }
-
- private void saveCraftingMatrix() {
- for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) {
- this.tile_entity.inventoryCrafting.setInventorySlotContents(i, this.craftMatrix.getStackInSlot(i));
- }
- }
- /*
- * @Override public void onCraftMatrixChanged(IInventory par1IInventory){
- * //Custom Recipe Handler //craftResult.setInventorySlotContents(0,
- * Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix,
- * worldObj));
- *
- * //Vanilla CraftingManager Utils.LOG_WARNING(
- * "checking crafting grid for a valid output."); ItemStack temp =
- * CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
- * if (temp != null){ Utils.LOG_WARNING("Output found. "
- * +temp.getDisplayName()+" x"+temp.stackSize);
- * craftResult.setInventorySlotContents(slotOutput, temp); } else {
- * Utils.LOG_WARNING("No Valid output found.");
- * craftResult.setInventorySlotContents(slotOutput, null); } }
- */
-
- /*
- * @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) {
- * for (int o=0; o<craftMatrix.getSizeInventory(); o++){
- * this.inventoryCrafting.setInventorySlotContents(o,
- * craftMatrix.getStackInSlot(o));
- * this.craftMatrix.setInventorySlotContents(o, null); }
- */
-
- // super.onContainerClosed(par1EntityPlayer);
-
- /*
- * if (worldObj.isRemote) { return; }
- *
- * for (int i = 0; i < InputSlotNumber; i++) { ItemStack itemstack =
- * craftMatrix.getStackInSlotOnClosing(i);
- *
- * if (itemstack != null) {
- * par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); } }
- */
-
- @Override
- public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold,
- final EntityPlayer aPlayer) {
-
- if (!aPlayer.worldObj.isRemote) {
- if (aSlotIndex == 999 || aSlotIndex == -999) {
- // Utils.LOG_WARNING("??? - "+aSlotIndex);
- }
-
- if (aSlotIndex == this.slotOutput) {
+ if (aSlotIndex == slotOutput){
Utils.LOG_WARNING("Player Clicked on the output slot");
- // TODO
+ //TODO
}
- for (final int x : this.slotHolo) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the Holo Grid");
- if (x == 1) {
- Utils.LOG_WARNING("Player Clicked Blueprint slot in the Holo Grid");
+ for (int x : slotHolo){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Holo Grid");
+ if (x == 1){
+ Utils.LOG_WARNING("Player Clicked Blueprint slot in the Holo Grid");
}
- else if (x == 2) {
+ else if (x == 2){
Utils.LOG_WARNING("Player Clicked Right Arrow slot in the Holo Grid");
- if (this.inventoryHolo.getStackInSlot(1) != null) {
+ if (inventoryHolo.getStackInSlot(1) != null){
Utils.LOG_WARNING("Found an ItemStack.");
- if (this.inventoryHolo.getStackInSlot(1).getItem() instanceof IItemBlueprint) {
+ if (inventoryHolo.getStackInSlot(1).getItem() instanceof IItemBlueprint){
Utils.LOG_WARNING("Found a blueprint.");
- final ItemStack tempBlueprint = this.inventoryHolo.getStackInSlot(1);
- final ItemBlueprint tempItemBlueprint = (ItemBlueprint) tempBlueprint.getItem();
- if (this.inventoryHolo.getStackInSlot(0) != null
- && !tempItemBlueprint.hasBlueprint(tempBlueprint)) {
+ ItemStack tempBlueprint = inventoryHolo.getStackInSlot(1);
+ ItemBlueprint tempItemBlueprint = (ItemBlueprint) tempBlueprint.getItem();
+ if (inventoryHolo.getStackInSlot(0) != null && !tempItemBlueprint.hasBlueprint(tempBlueprint)){
Utils.LOG_WARNING("Output slot was not empty.");
- Utils.LOG_WARNING(
- "Trying to manipulate NBT data on the blueprint stack, then replace it with the new one.");
- tempItemBlueprint.setBlueprint(this.inventoryHolo.getStackInSlot(1),
- this.craftMatrix, this.inventoryHolo.getStackInSlot(0));
- final ItemStack newTempBlueprint = ItemUtils.getSimpleStack(tempItemBlueprint);
- this.inventoryHolo.setInventorySlotContents(1, newTempBlueprint);
- Utils.LOG_WARNING(ItemUtils
- .getArrayStackNames(tempItemBlueprint.getBlueprint(newTempBlueprint)));
+ Utils.LOG_WARNING("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 = ItemUtils.getSimpleStack(tempItemBlueprint);
+ inventoryHolo.setInventorySlotContents(1, newTempBlueprint);
+ Utils.LOG_WARNING(ItemUtils.getArrayStackNames(tempItemBlueprint.getBlueprint(newTempBlueprint)));
}
else {
- if (tempItemBlueprint.hasBlueprint(tempBlueprint)) {
+ if (tempItemBlueprint.hasBlueprint(tempBlueprint)){
Utils.LOG_WARNING("Blueprint already holds a recipe.");
}
else {
- Utils.LOG_WARNING("Output slot was empty.");
+ Utils.LOG_WARNING("Output slot was empty.");
}
}
}
else {
- Utils.LOG_WARNING("ItemStack found was not a blueprint.");
+ Utils.LOG_WARNING("ItemStack found was not a blueprint.");
}
}
else {
Utils.LOG_WARNING("No ItemStack found in Blueprint slot.");
}
}
- else if (x == 3) {
- Utils.LOG_WARNING("Player Clicked Big [P] slot in the Holo Grid");
+ else if (x == 3){
+ Utils.LOG_WARNING("Player Clicked Big [P] slot in the Holo Grid");
}
- else if (x == 4) {
- Utils.LOG_WARNING("Player Clicked Transfer to Crafting Grid slot in the Holo Grid");
+ else if (x == 4){
+ Utils.LOG_WARNING("Player Clicked Transfer to Crafting Grid slot in the Holo Grid");
}
- else if (x == 5) {
- Utils.LOG_WARNING("Player Clicked Transfer to Storage Grid slot in the Holo Grid");
+ else if (x == 5){
+ Utils.LOG_WARNING("Player Clicked Transfer to Storage Grid slot in the Holo Grid");
}
}
}
- for (final int x : this.slotCrafting) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the crafting Grid");
+ for (int x : slotCrafting){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the crafting Grid");
}
}
- for (final int x : this.slotStorage) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the storage Grid");
+ for (int x : slotStorage){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the storage Grid");
}
}
- for (final int x : this.slotTools) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the tool Grid");
+ for (int x : slotTools){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the tool Grid");
}
}
}
- // Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid");
+ //Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid");
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
+ private void updateCraftingMatrix() {
+ for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
+ craftMatrix.setInventorySlotContents(i, tile_entity.inventoryCrafting.getStackInSlot(i));
+ }
+ }
+
+ @Override
+ public void onCraftMatrixChanged(IInventory iiventory) {
+ tile_entity.inventoryCraftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
+ }
+
@Override
- public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) {
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ super.onContainerClosed(par1EntityPlayer);
+ saveCraftingMatrix();
+ }
+
+ private void saveCraftingMatrix() {
+ for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
+ tile_entity.inventoryCrafting.setInventorySlotContents(i, craftMatrix.getStackInSlot(i));
+ }
+ }
+
+
+
+
+ /*@Override
+ public void onCraftMatrixChanged(IInventory par1IInventory){
+ //Custom Recipe Handler
+ //craftResult.setInventorySlotContents(0, Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix, worldObj));
+
+ //Vanilla CraftingManager
+ Utils.LOG_WARNING("checking crafting grid for a valid output.");
+ ItemStack temp = CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
+ if (temp != null){
+ Utils.LOG_WARNING("Output found. "+temp.getDisplayName()+" x"+temp.stackSize);
+ craftResult.setInventorySlotContents(slotOutput, temp);
+ }
+ else {
+ Utils.LOG_WARNING("No Valid output found.");
+ craftResult.setInventorySlotContents(slotOutput, null);
+ }
+ }*/
+
+ /*@Override
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ for (int o=0; o<craftMatrix.getSizeInventory(); o++){
+ this.inventoryCrafting.setInventorySlotContents(o, craftMatrix.getStackInSlot(o));
+ this.craftMatrix.setInventorySlotContents(o, null);
+ }*/
+
+ //super.onContainerClosed(par1EntityPlayer);
+
+ /*if (worldObj.isRemote)
+ {
+ return;
+ }
+
+ for (int i = 0; i < InputSlotNumber; i++)
+ {
+ ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
+
+ if (itemstack != null)
+ {
+ par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false);
+ }
+ }*/
+
+ @Override
+ public boolean canInteractWith(EntityPlayer par1EntityPlayer){
+ if (worldObj.getBlock(posX, posY, posZ) != ModBlocks.blockWorkbench){
+ return false;
+ }
+
+ return par1EntityPlayer.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64D;
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
+ {
ItemStack var3 = null;
- final Slot var4 = (Slot) this.inventorySlots.get(par2);
+ Slot var4 = (Slot)this.inventorySlots.get(par2);
- if (var4 != null && var4.getHasStack()) {
- final ItemStack var5 = var4.getStack();
+ if (var4 != null && var4.getHasStack())
+ {
+ ItemStack var5 = var4.getStack();
var3 = var5.copy();
- if (par2 == 0) {
- if (!this.mergeItemStack(var5, Container_Workbench.InOutputSlotNumber,
- Container_Workbench.FullSlotNumber, true)) {
+ if (par2 == 0)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true))
+ {
return null;
}
var4.onSlotChange(var5, var3);
}
- else if (par2 >= Container_Workbench.InOutputSlotNumber
- && par2 < Container_Workbench.InventoryOutSlotNumber) {
- if (!this.mergeItemStack(var5, Container_Workbench.InventoryOutSlotNumber,
- Container_Workbench.FullSlotNumber, false)) {
+ else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false))
+ {
return null;
}
}
- else if (par2 >= Container_Workbench.InventoryOutSlotNumber && par2 < Container_Workbench.FullSlotNumber) {
- if (!this.mergeItemStack(var5, Container_Workbench.InOutputSlotNumber,
- Container_Workbench.InventoryOutSlotNumber, false)) {
+ else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false))
+ {
return null;
}
}
- else if (!this.mergeItemStack(var5, Container_Workbench.InOutputSlotNumber,
- Container_Workbench.FullSlotNumber, false)) {
+ else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false))
+ {
return null;
}
- if (var5.stackSize == 0) {
- var4.putStack((ItemStack) null);
+ if (var5.stackSize == 0)
+ {
+ var4.putStack((ItemStack)null);
}
- else {
+ else
+ {
var4.onSlotChanged();
}
- if (var5.stackSize == var3.stackSize) {
+ if (var5.stackSize == var3.stackSize)
+ {
return null;
}
@@ -420,10 +408,11 @@ public class Container_Workbench extends Container {
return var3;
}
- private void updateCraftingMatrix() {
- for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) {
- this.craftMatrix.setInventorySlotContents(i, this.tile_entity.inventoryCrafting.getStackInSlot(i));
- }
+ //Can merge Slot
+ @Override
+ public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) {
+ return p_94530_2_.inventory != tile_entity.inventoryCraftResult && super.func_94530_a(p_94530_1_, p_94530_2_);
}
+
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/container/Container_WorkbenchAdvanced.java b/src/Java/gtPlusPlus/core/container/Container_WorkbenchAdvanced.java
index d8481a60d4..f7dc7bb08c 100644
--- a/src/Java/gtPlusPlus/core/container/Container_WorkbenchAdvanced.java
+++ b/src/Java/gtPlusPlus/core/container/Container_WorkbenchAdvanced.java
@@ -3,84 +3,58 @@ package gtPlusPlus.core.container;
import gregtech.api.gui.GT_Slot_Holo;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.interfaces.IItemBlueprint;
-import gtPlusPlus.core.inventories.*;
+import gtPlusPlus.core.inventories.InventoryWorkbenchChest;
+import gtPlusPlus.core.inventories.InventoryWorkbenchHoloCrafting;
+import gtPlusPlus.core.inventories.InventoryWorkbenchHoloSlots;
+import gtPlusPlus.core.inventories.InventoryWorkbenchToolsElectric;
import gtPlusPlus.core.item.general.ItemBlueprint;
-import gtPlusPlus.core.slots.*;
+import gtPlusPlus.core.slots.SlotBlueprint;
+import gtPlusPlus.core.slots.SlotGtToolElectric;
+import gtPlusPlus.core.slots.SlotNoInput;
+import gtPlusPlus.core.slots.SlotOutput;
import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.item.ItemUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
-import net.minecraft.inventory.*;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.world.World;
public class Container_WorkbenchAdvanced extends Container {
- public static int HoloSlotNumber = 6;
- public static int InputSlotNumber = 9; // Number
- // of
- // Slots
- // in
- // the
- // Crafting
- // Grid
- public static int StorageSlotNumber = 16; // Number
- // of
- // slots
- // in
- // storage
- // area
- public static int ToolSlotNumber = 5; // Number
- // of
- // slots
- // in
- // the
- // tool
- // area
- // up
- // top
- public static int InOutputSlotNumber = Container_WorkbenchAdvanced.InputSlotNumber
- + Container_WorkbenchAdvanced.StorageSlotNumber + Container_WorkbenchAdvanced.ToolSlotNumber
- + Container_WorkbenchAdvanced.HoloSlotNumber; // Same
- // plus
- // Output
- // Slot
- public static int InventorySlotNumber = 36; // Inventory
-
- // Slots
- // (Inventory
- // and
- // Hotbar)
- public static int InventoryOutSlotNumber = Container_WorkbenchAdvanced.InventorySlotNumber
- + 1; // Inventory
- // Slot
- // Number
- // +
- // Output
- public static int FullSlotNumber = Container_WorkbenchAdvanced.InventorySlotNumber
- + Container_WorkbenchAdvanced.InOutputSlotNumber; // All
- // slots
- protected TileEntityWorkbenchAdvanced tile_entity;
- public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
-
- public final InventoryWorkbenchChest inventoryChest;
- public final InventoryWorkbenchToolsElectric inventoryTool;
- public final InventoryWorkbenchHoloSlots inventoryHolo;
- public final InventoryWorkbenchHoloCrafting inventoryCrafting;
- private final World worldObj;
- private final int posX;
- private final int posY;
- private final int posZ;
-
- private final int slotOutput = 0;
- private final int[] slotHolo = new int[5];
- private final int[] slotCrafting = new int[9];
- private final int[] slotStorage = new int[16];
- private final int[] slotTools = new int[5];
-
- public Container_WorkbenchAdvanced(final InventoryPlayer inventory, final TileEntityWorkbenchAdvanced tile) {
+ protected TileEntityWorkbenchAdvanced tile_entity;
+ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
+ public final InventoryWorkbenchChest inventoryChest;
+ public final InventoryWorkbenchToolsElectric inventoryTool;
+ public final InventoryWorkbenchHoloSlots inventoryHolo;
+ public final InventoryWorkbenchHoloCrafting inventoryCrafting;
+
+ private World worldObj;
+ private int posX;
+ private int posY;
+ private int posZ;
+
+ public static int HoloSlotNumber = 6;
+ public static int InputSlotNumber = 9; //Number of Slots in the Crafting Grid
+ public static int StorageSlotNumber = 16; //Number of slots in storage area
+ public static int ToolSlotNumber = 5; // Number of slots in the tool area up top
+ public static int InOutputSlotNumber = InputSlotNumber + StorageSlotNumber + ToolSlotNumber + HoloSlotNumber; //Same plus Output Slot
+ public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar)
+ public static int InventoryOutSlotNumber = InventorySlotNumber + 1; //Inventory Slot Number + Output
+ public static int FullSlotNumber = InventorySlotNumber + InOutputSlotNumber; //All slots
+
+ private int slotOutput = 0;
+ private int[] slotHolo = new int[5];
+ private int[] slotCrafting = new int[9];
+ private int[] slotStorage = new int[16];
+ private int[] slotTools = new int[5];
+
+ public Container_WorkbenchAdvanced(InventoryPlayer inventory, TileEntityWorkbenchAdvanced tile){
this.tile_entity = tile;
this.inventoryChest = tile.inventoryChest;
this.inventoryTool = tile.inventoryTool;
@@ -89,293 +63,308 @@ public class Container_WorkbenchAdvanced extends Container {
int var6;
int var7;
- this.worldObj = tile.getWorldObj();
- this.posX = tile.xCoord;
- this.posY = tile.yCoord;
- this.posZ = tile.zCoord;
-
- int o = 0;
-
- // Output slot
- this.addSlotToContainer(
- new SlotOutput(inventory.player, this.craftMatrix, tile.inventoryCraftResult, 0, 136, 64));
- // Util Slots
- this.addSlotToContainer(new SlotBlueprint(this.inventoryHolo, 1, 136, 28)); // Blueprint
- this.addSlotToContainer(new SlotNoInput(this.inventoryHolo, 2, 154, 28)); // Hopper
- this.addSlotToContainer(new GT_Slot_Holo(this.inventoryHolo, 3, 154, 64, false, false, 64)); // Parking
- // Holo Slots
- this.addSlotToContainer(new GT_Slot_Holo(this.inventoryHolo, 4, 154, 46, false, false, 1));
- this.addSlotToContainer(new GT_Slot_Holo(this.inventoryHolo, 5, 136, 46, false, false, 1));
-
- for (int i = 1; i < 6; i++) {
- this.slotHolo[o] = o + 1;
+ worldObj = tile.getWorldObj();
+ posX = tile.xCoord;
+ posY = tile.yCoord;
+ posZ = tile.zCoord;
+
+ int o=0;
+
+ //Output slot
+ addSlotToContainer(new SlotOutput(inventory.player, this.craftMatrix, tile.inventoryCraftResult, 0, 136, 64));
+ //Util Slots
+ addSlotToContainer(new SlotBlueprint(inventoryHolo, 1, 136, 28)); //Blueprint
+ addSlotToContainer(new SlotNoInput(inventoryHolo, 2, 154, 28)); //Hopper
+ addSlotToContainer(new GT_Slot_Holo(inventoryHolo, 3, 154, 64, false, false, 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));
+
+ for (int i=1; i<6; i++){
+ slotHolo[o] = o+1;
o++;
}
- o = 0;
+ o=0;
- this.updateCraftingMatrix();
+ updateCraftingMatrix();
- // Crafting Grid
- for (var6 = 0; var6 < 3; ++var6) {
- for (var7 = 0; var7 < 3; ++var7) {
+ //Crafting Grid
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 3; ++var7)
+ {
this.addSlotToContainer(new Slot(this.craftMatrix, var7 + var6 * 3, 82 + var7 * 18, 28 + var6 * 18));
- /*
- * if (this.inventoryCrafting.getStackInSlot(o) != null){
- * this.craftMatrix.setInventorySlotContents(o,
- * inventoryCrafting.getStackInSlot(o));
- * this.inventoryCrafting.setInventorySlotContents(o, null); }
- */
- this.slotCrafting[o] = o + 6;
+ /*if (this.inventoryCrafting.getStackInSlot(o) != null){
+ this.craftMatrix.setInventorySlotContents(o, inventoryCrafting.getStackInSlot(o));
+ this.inventoryCrafting.setInventorySlotContents(o, null);
+ } */
+ slotCrafting[o] = o+6;
o++;
}
}
- o = 0;
+ o=0;
- // Storage Side
- for (var6 = 0; var6 < 4; ++var6) {
- for (var7 = 0; var7 < 4; ++var7) {
- // Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+"
- // x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18));
- this.addSlotToContainer(new Slot(this.inventoryChest, var7 + var6 * 4, 8 + var7 * 18, 7 + var6 * 18));
- this.slotStorage[o] = o + 15;
+ //Storage Side
+ for (var6 = 0; var6 < 4; ++var6)
+ {
+ for (var7 = 0; var7 < 4; ++var7)
+ {
+ //Utils.LOG_WARNING("Adding slots at var:"+(var7 + var6 * 4)+" x:"+(8 + var7 * 18)+" y:"+(7 + var6 * 18));
+ this.addSlotToContainer(new Slot(inventoryChest, var7 + var6 * 4, 8 + var7 * 18, 7 + var6 * 18));
+ slotStorage[o] = o+15;
o++;
}
}
- o = 0;
+ o=0;
- // Tool Slots
- for (var6 = 0; var6 < 1; ++var6) {
- for (var7 = 0; var7 < 5; ++var7) {
- this.addSlotToContainer(new SlotGtToolElectric(this.inventoryTool, var7 + var6 * 3, 82 + var7 * 18,
- 8 + var6 * 18, 3, false));
- this.slotTools[o] = o + 31;
+ //Tool Slots
+ for (var6 = 0; var6 < 1; ++var6)
+ {
+ for (var7 = 0; var7 < 5; ++var7)
+ {
+ this.addSlotToContainer(new SlotGtToolElectric(inventoryTool, var7 + var6 * 3, 82 + var7 * 18, 8 + var6 * 18, 3, false));
+ slotTools[o] = o+31;
o++;
}
- }
+ }
- // Player Inventory
- for (var6 = 0; var6 < 3; ++var6) {
- for (var7 = 0; var7 < 9; ++var7) {
+ //Player Inventory
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 9; ++var7)
+ {
this.addSlotToContainer(new Slot(inventory, var7 + var6 * 9 + 9, 8 + var7 * 18, 84 + var6 * 18));
}
}
- // Player Hotbar
- for (var6 = 0; var6 < 9; ++var6) {
+ //Player Hotbar
+ for (var6 = 0; var6 < 9; ++var6)
+ {
this.addSlotToContainer(new Slot(inventory, var6, 8 + var6 * 18, 142));
}
- this.onCraftMatrixChanged(this.craftMatrix);
-
- }
-
- @Override
- public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
- if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockWorkbench) {
- return false;
- }
-
- return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D;
- }
-
- // Can merge Slot
- @Override
- public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) {
- return p_94530_2_.inventory != this.tile_entity.inventoryCraftResult
- && super.func_94530_a(p_94530_1_, p_94530_2_);
- }
-
- @Override
- public void onContainerClosed(final EntityPlayer par1EntityPlayer) {
- super.onContainerClosed(par1EntityPlayer);
- this.saveCraftingMatrix();
- }
-
- @Override
- public void onCraftMatrixChanged(final IInventory iiventory) {
- this.tile_entity.inventoryCraftResult.setInventorySlotContents(0,
- CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj));
- }
+ this.onCraftMatrixChanged(this.craftMatrix);
- private void saveCraftingMatrix() {
- for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) {
- this.tile_entity.inventoryCrafting.setInventorySlotContents(i, this.craftMatrix.getStackInSlot(i));
- }
}
- /*
- * @Override public void onCraftMatrixChanged(IInventory par1IInventory){
- * //Custom Recipe Handler //craftResult.setInventorySlotContents(0,
- * Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix,
- * worldObj));
- *
- * //Vanilla CraftingManager Utils.LOG_WARNING(
- * "checking crafting grid for a valid output."); ItemStack temp =
- * CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
- * if (temp != null){ Utils.LOG_WARNING("Output found. "
- * +temp.getDisplayName()+" x"+temp.stackSize);
- * craftResult.setInventorySlotContents(slotOutput, temp); } else {
- * Utils.LOG_WARNING("No Valid output found.");
- * craftResult.setInventorySlotContents(slotOutput, null); } }
- */
-
- /*
- * @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) {
- * for (int o=0; o<craftMatrix.getSizeInventory(); o++){
- * this.inventoryCrafting.setInventorySlotContents(o,
- * craftMatrix.getStackInSlot(o));
- * this.craftMatrix.setInventorySlotContents(o, null); }
- */
-
- // super.onContainerClosed(par1EntityPlayer);
-
- /*
- * if (worldObj.isRemote) { return; }
- *
- * for (int i = 0; i < InputSlotNumber; i++) { ItemStack itemstack =
- * craftMatrix.getStackInSlotOnClosing(i);
- *
- * if (itemstack != null) {
- * par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false); } }
- */
-
@Override
- public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold,
- final EntityPlayer aPlayer) {
+ public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer){
- if (!aPlayer.worldObj.isRemote) {
- if (aSlotIndex == 999 || aSlotIndex == -999) {
- // Utils.LOG_WARNING("??? - "+aSlotIndex);
+ if (!aPlayer.worldObj.isRemote){
+ if (aSlotIndex == 999 || aSlotIndex == -999){
+ //Utils.LOG_WARNING("??? - "+aSlotIndex);
}
- if (aSlotIndex == this.slotOutput) {
+ if (aSlotIndex == slotOutput){
Utils.LOG_WARNING("Player Clicked on the output slot");
- // TODO
+ //TODO
}
- for (final int x : this.slotHolo) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the Holo Grid");
- if (x == 1) {
- Utils.LOG_WARNING("Player Clicked Blueprint slot in the Holo Grid");
+ for (int x : slotHolo){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Holo Grid");
+ if (x == 1){
+ Utils.LOG_WARNING("Player Clicked Blueprint slot in the Holo Grid");
}
- else if (x == 2) {
+ else if (x == 2){
Utils.LOG_WARNING("Player Clicked Right Arrow slot in the Holo Grid");
- if (this.inventoryHolo.getStackInSlot(1) != null) {
+ if (inventoryHolo.getStackInSlot(1) != null){
Utils.LOG_WARNING("Found an ItemStack.");
- if (this.inventoryHolo.getStackInSlot(1).getItem() instanceof IItemBlueprint) {
+ if (inventoryHolo.getStackInSlot(1).getItem() instanceof IItemBlueprint){
Utils.LOG_WARNING("Found a blueprint.");
- final ItemStack tempBlueprint = this.inventoryHolo.getStackInSlot(1);
- final ItemBlueprint tempItemBlueprint = (ItemBlueprint) tempBlueprint.getItem();
- if (this.inventoryHolo.getStackInSlot(0) != null
- && !tempItemBlueprint.hasBlueprint(tempBlueprint)) {
+ ItemStack tempBlueprint = inventoryHolo.getStackInSlot(1);
+ ItemBlueprint tempItemBlueprint = (ItemBlueprint) tempBlueprint.getItem();
+ if (inventoryHolo.getStackInSlot(0) != null && !tempItemBlueprint.hasBlueprint(tempBlueprint)){
Utils.LOG_WARNING("Output slot was not empty.");
- Utils.LOG_WARNING(
- "Trying to manipulate NBT data on the blueprint stack, then replace it with the new one.");
- tempItemBlueprint.setBlueprint(this.inventoryHolo.getStackInSlot(1),
- this.craftMatrix, this.inventoryHolo.getStackInSlot(0));
- final ItemStack newTempBlueprint = ItemUtils.getSimpleStack(tempItemBlueprint);
- this.inventoryHolo.setInventorySlotContents(1, newTempBlueprint);
- Utils.LOG_WARNING(ItemUtils
- .getArrayStackNames(tempItemBlueprint.getBlueprint(newTempBlueprint)));
+ Utils.LOG_WARNING("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 = ItemUtils.getSimpleStack(tempItemBlueprint);
+ inventoryHolo.setInventorySlotContents(1, newTempBlueprint);
+ Utils.LOG_WARNING(ItemUtils.getArrayStackNames(tempItemBlueprint.getBlueprint(newTempBlueprint)));
}
else {
- if (tempItemBlueprint.hasBlueprint(tempBlueprint)) {
+ if (tempItemBlueprint.hasBlueprint(tempBlueprint)){
Utils.LOG_WARNING("Blueprint already holds a recipe.");
}
else {
- Utils.LOG_WARNING("Output slot was empty.");
+ Utils.LOG_WARNING("Output slot was empty.");
}
}
}
else {
- Utils.LOG_WARNING("ItemStack found was not a blueprint.");
+ Utils.LOG_WARNING("ItemStack found was not a blueprint.");
}
}
else {
Utils.LOG_WARNING("No ItemStack found in Blueprint slot.");
}
}
- else if (x == 3) {
- Utils.LOG_WARNING("Player Clicked Big [P] slot in the Holo Grid");
+ else if (x == 3){
+ Utils.LOG_WARNING("Player Clicked Big [P] slot in the Holo Grid");
}
- else if (x == 4) {
- Utils.LOG_WARNING("Player Clicked Transfer to Crafting Grid slot in the Holo Grid");
+ else if (x == 4){
+ Utils.LOG_WARNING("Player Clicked Transfer to Crafting Grid slot in the Holo Grid");
}
- else if (x == 5) {
- Utils.LOG_WARNING("Player Clicked Transfer to Storage Grid slot in the Holo Grid");
+ else if (x == 5){
+ Utils.LOG_WARNING("Player Clicked Transfer to Storage Grid slot in the Holo Grid");
}
}
}
- for (final int x : this.slotCrafting) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the crafting Grid");
+ for (int x : slotCrafting){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the crafting Grid");
}
}
- for (final int x : this.slotStorage) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the storage Grid");
+ for (int x : slotStorage){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the storage Grid");
}
}
- for (final int x : this.slotTools) {
- if (aSlotIndex == x) {
- Utils.LOG_WARNING("Player Clicked slot " + aSlotIndex + " in the tool Grid");
+ for (int x : slotTools){
+ if (aSlotIndex == x){
+ Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the tool Grid");
}
}
}
- // Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid");
+ //Utils.LOG_WARNING("Player Clicked slot "+aSlotIndex+" in the Grid");
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
+ private void updateCraftingMatrix() {
+ for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
+ craftMatrix.setInventorySlotContents(i, tile_entity.inventoryCrafting.getStackInSlot(i));
+ }
+ }
+
+ @Override
+ public void onCraftMatrixChanged(IInventory iiventory) {
+ tile_entity.inventoryCraftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ super.onContainerClosed(par1EntityPlayer);
+ saveCraftingMatrix();
+ }
+
+ private void saveCraftingMatrix() {
+ for (int i = 0; i < craftMatrix.getSizeInventory(); i++) {
+ tile_entity.inventoryCrafting.setInventorySlotContents(i, craftMatrix.getStackInSlot(i));
+ }
+ }
+
+
+
+
+ /*@Override
+ public void onCraftMatrixChanged(IInventory par1IInventory){
+ //Custom Recipe Handler
+ //craftResult.setInventorySlotContents(0, Workbench_CraftingHandler.getInstance().findMatchingRecipe(craftMatrix, worldObj));
+
+ //Vanilla CraftingManager
+ Utils.LOG_WARNING("checking crafting grid for a valid output.");
+ ItemStack temp = CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
+ if (temp != null){
+ Utils.LOG_WARNING("Output found. "+temp.getDisplayName()+" x"+temp.stackSize);
+ craftResult.setInventorySlotContents(slotOutput, temp);
+ }
+ else {
+ Utils.LOG_WARNING("No Valid output found.");
+ craftResult.setInventorySlotContents(slotOutput, null);
+ }
+ }*/
+
+ /*@Override
+ public void onContainerClosed(EntityPlayer par1EntityPlayer)
+ {
+ for (int o=0; o<craftMatrix.getSizeInventory(); o++){
+ this.inventoryCrafting.setInventorySlotContents(o, craftMatrix.getStackInSlot(o));
+ this.craftMatrix.setInventorySlotContents(o, null);
+ }*/
+
+ //super.onContainerClosed(par1EntityPlayer);
+
+ /*if (worldObj.isRemote)
+ {
+ return;
+ }
+
+ for (int i = 0; i < InputSlotNumber; i++)
+ {
+ ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
+
+ if (itemstack != null)
+ {
+ par1EntityPlayer.dropPlayerItemWithRandomChoice(itemstack, false);
+ }
+ }*/
+
+ @Override
+ public boolean canInteractWith(EntityPlayer par1EntityPlayer){
+ if (worldObj.getBlock(posX, posY, posZ) != ModBlocks.blockWorkbench){
+ return false;
+ }
+
+ return par1EntityPlayer.getDistanceSq((double)posX + 0.5D, (double)posY + 0.5D, (double)posZ + 0.5D) <= 64D;
+ }
+
+
@Override
- public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2) {
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
+ {
ItemStack var3 = null;
- final Slot var4 = (Slot) this.inventorySlots.get(par2);
+ Slot var4 = (Slot)this.inventorySlots.get(par2);
- if (var4 != null && var4.getHasStack()) {
- final ItemStack var5 = var4.getStack();
+ if (var4 != null && var4.getHasStack())
+ {
+ ItemStack var5 = var4.getStack();
var3 = var5.copy();
- if (par2 == 0) {
- if (!this.mergeItemStack(var5, Container_WorkbenchAdvanced.InOutputSlotNumber,
- Container_WorkbenchAdvanced.FullSlotNumber, true)) {
+ if (par2 == 0)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true))
+ {
return null;
}
var4.onSlotChange(var5, var3);
}
- else if (par2 >= Container_WorkbenchAdvanced.InOutputSlotNumber
- && par2 < Container_WorkbenchAdvanced.InventoryOutSlotNumber) {
- if (!this.mergeItemStack(var5, Container_WorkbenchAdvanced.InventoryOutSlotNumber,
- Container_WorkbenchAdvanced.FullSlotNumber, false)) {
+ else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false))
+ {
return null;
}
}
- else if (par2 >= Container_WorkbenchAdvanced.InventoryOutSlotNumber
- && par2 < Container_WorkbenchAdvanced.FullSlotNumber) {
- if (!this.mergeItemStack(var5, Container_WorkbenchAdvanced.InOutputSlotNumber,
- Container_WorkbenchAdvanced.InventoryOutSlotNumber, false)) {
+ else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false))
+ {
return null;
}
}
- else if (!this.mergeItemStack(var5, Container_WorkbenchAdvanced.InOutputSlotNumber,
- Container_WorkbenchAdvanced.FullSlotNumber, false)) {
+ else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false))
+ {
return null;
}
- if (var5.stackSize == 0) {
- var4.putStack((ItemStack) null);
+ if (var5.stackSize == 0)
+ {
+ var4.putStack((ItemStack)null);
}
- else {
+ else
+ {
var4.onSlotChanged();
}
- if (var5.stackSize == var3.stackSize) {
+ if (var5.stackSize == var3.stackSize)
+ {
return null;
}
@@ -385,10 +374,11 @@ public class Container_WorkbenchAdvanced extends Container {
return var3;
}
- private void updateCraftingMatrix() {
- for (int i = 0; i < this.craftMatrix.getSizeInventory(); i++) {
- this.craftMatrix.setInventorySlotContents(i, this.tile_entity.inventoryCrafting.getStackInSlot(i));
- }
+ //Can merge Slot
+ @Override
+ public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) {
+ return p_94530_2_.inventory != tile_entity.inventoryCraftResult && super.func_94530_a(p_94530_1_, p_94530_2_);
}
+
} \ No newline at end of file