private TileEntityMaterialCraftingTable tileEntity;
+ private InventoryMaterialCrafting inv;
+
+
public ContainerMaterialCraftingTable(EntityPlayer par1EntityPlayer, TileEntityMaterialCraftingTable par2)
{
this.posY = par2.yCoord;
this.posZ = par2.zCoord;
this.tileEntity = par2;
+ this.inv = (InventoryMaterialCrafting) par2.getInventorys();
//GenerateInventory
this.generateSlots("Decomposition", par2.getInventorys());
//GeneratePlayerInventory
{
this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 143));
}
+
+ ((InventoryMaterialCrafting) par2.getInventorys()).setEventHandler(this);
+
+ }
+
+
+
+ @Override
+ public void onCraftMatrixChanged(IInventory par1IInventory){
+ par1IInventory.setInventorySlotContents(12, ChemiCraftAPI.instance.getCraftingManager().getMaterialResult(par1IInventory));
+ ((InventoryMaterialCrafting) par1IInventory).setFlag(true);
}
@Override
- public void onCraftMatrixChanged(IInventory par1IInventory){}
+ public ItemStack slotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer)
+ {
+ super.slotClick(par1, par2, par3, par4EntityPlayer);
+ if(par1 == 12){
+ ((InventoryMaterialCrafting) this.tileEntity.getInventorys()).setFlag2(true);
+ for(int i = 0;i < 9;i++){
+ if(this.inv.getStackInSlot(i+3) != null){
+ if(this.inv.getStackInSlot(i+3).stackSize >= 1){
+ this.putStackInSlot(i+3, new ItemStack(this.inv.getStackInSlot(i+3).itemID, --this.inv.getStackInSlot(i+3).stackSize, this.inv.getStackInSlot(i+3).getItemDamage()));
+ }else{
+ this.putStackInSlot(i+3, null);
+ }
+ }
+ }
+ }
+ return null;
+ }
- private void generateSlots(String activeTabs, IInventory[] inventorys){
+ private void generateSlots(String activeTabs, IInventory inventorys){
int count = 0;
for(int i = 0;i < 3;i++){
- this.addSlotToContainer(new Slot(inventorys[0], count, 30 + 18 * i, 7));
+ this.addSlotToContainer(new Slot(inventorys, count, 30 + 18 * i, 7));
count++;
}
for(int i = 0;i < 3;i++){
for(int j = 0;j < 3;j++){
- this.addSlotToContainer(new Slot(inventorys[0], count, 30 + 18 * j, 27 + 18 * i));
+ this.addSlotToContainer(new Slot(inventorys, count, 30 + 18 * j, 27 + 18 * i));
count++;
}
}
- this.addSlotToContainer(new SlotMaterialCraftingResult(inventorys[0], count, 123, 33));
+ this.addSlotToContainer(new SlotMaterialCraftingResult(inventorys, count, 123, 33));
}
}