1 package chemicraft.container;
3 import net.minecraft.src.Container;
4 import net.minecraft.src.EntityPlayer;
5 import net.minecraft.src.IInventory;
6 import net.minecraft.src.ItemStack;
7 import net.minecraft.src.Slot;
8 import net.minecraft.src.World;
9 import chemicraft.ChemiCraft;
10 import chemicraft.ChemiCraftAPI;
11 import chemicraft.inventory.InventoryChemicalCraftingMaterial;
12 import chemicraft.inventory.InventoryChemicalCraftingNBT;
13 import chemicraft.inventory.InventoryChemicalCraftingResult;
14 import chemicraft.slot.SlotChemicalCraftingResult;
15 import chemicraft.tileentity.TileEntityChemicalCraftingTable;
16 import chemicraft.util.ChemicalNBTRecipe;
18 public class ContainerChemicalCraftingTable extends Container {
23 private World worldObj;
37 private TileEntityChemicalCraftingTable tileEntity;
40 private InventoryChemicalCraftingMaterial invm;
41 private InventoryChemicalCraftingResult invr;
42 private InventoryChemicalCraftingNBT invn;
44 private ChemicalNBTRecipe useNBT;
48 public ContainerChemicalCraftingTable(EntityPlayer par1EntityPlayer, TileEntityChemicalCraftingTable par2)
51 this.worldObj = par2.worldObj;
52 this.posX = par2.xCoord;
53 this.posY = par2.yCoord;
54 this.posZ = par2.zCoord;
55 this.tileEntity = par2;
56 this.invm = (InventoryChemicalCraftingMaterial) this.tileEntity.chemicalCraftingInvMaterial;
57 this.invr = (InventoryChemicalCraftingResult) this.tileEntity.chemicalCraftingInvResult;
58 this.invn = (InventoryChemicalCraftingNBT) this.tileEntity.chemicalCraftingInvNBT;
60 this.generateSlots(this.invm, this.invr, this.invn);
61 //GeneratePlayerInventory
64 for (var3 = 0; var3 < 3; ++var3)
66 for (int var4 = 0; var4 < 9; ++var4)
68 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 85 + var3 * 18));
72 for (var3 = 0; var3 < 9; ++var3)
74 this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 143));
77 this.invm.setEventHandler(this);
78 this.invr.setEventHandler(this);
79 this.invn.setEventHandler(this);
80 this.onCraftMatrixChanged(invm);
86 public void onCraftMatrixChanged(IInventory par1IInventory){
87 ChemiCraftAPI.instance.getCraftingManager().chemicalCrafting(this.invm, this.invr, this.invn);
91 public void onCraftGuiClosed(EntityPlayer par1EntityPlayer){
92 super.onCraftGuiClosed(par1EntityPlayer);
98 public boolean canInteractWith(EntityPlayer par1EntityPlayer){
99 return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.ChemicalCraftingTableID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
105 public ItemStack transferStackInSlot(int par1){
111 private void generateSlots(IInventory materialInv, IInventory resultInv, IInventory nbtInv){
112 for(int i = 0;i < 3;i++){
113 this.addSlotToContainer(new Slot(invn, i, 30 + 18 * i, 7));
115 for(int i = 0;i < 3;i++){
116 for(int j = 0;j < 3;j++){
117 this.addSlotToContainer(new Slot(invm, i * 3 + j, 30 + 18 * j, 27 + 18 * i));
120 this.addSlotToContainer(new SlotChemicalCraftingResult(invr, 0, 123, 33));