OSDN Git Service

修正・変更
[chemicraft/chemicraft.git] / common / pcc / chemicraft / container / ContainerPyrolysisTable.java
index bc3d466..c00c380 100644 (file)
@@ -3,13 +3,18 @@ package pcc.chemicraft.container;
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.inventory.Container;
 import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
 import net.minecraft.world.World;
 import pcc.chemicraft.ChemiCraft;
+import pcc.chemicraft.inventory.InventoryPyrolysisTableFuel;
+import pcc.chemicraft.inventory.InventoryPyrolysisTableMaterial;
+import pcc.chemicraft.inventory.InventoryPyrolysisTableResult;
 import pcc.chemicraft.slot.SlotPyrolysisTableFuel;
 import pcc.chemicraft.slot.SlotPyrolysisTableMaterial;
 import pcc.chemicraft.slot.SlotPyrolysisTableResult;
 import pcc.chemicraft.tileentity.TileEntityPyrolysisTable;
 
+
 public class ContainerPyrolysisTable extends Container {
 
        private World worldObj;
@@ -20,6 +25,10 @@ public class ContainerPyrolysisTable extends Container {
 
        private TileEntityPyrolysisTable tileentity;
 
+       private InventoryPyrolysisTableMaterial invm;
+       private InventoryPyrolysisTableResult invr;
+       private InventoryPyrolysisTableFuel invf;
+
        public ContainerPyrolysisTable(EntityPlayer par1EntityPlayer, TileEntityPyrolysisTable par2){
                super();
                this.tileentity = par2;
@@ -27,6 +36,12 @@ public class ContainerPyrolysisTable extends Container {
                this.posX = par2.xCoord;
                this.posY = par2.yCoord;
                this.posZ = par2.zCoord;
+               this.invm = par2.getInvMaterial();
+               this.invr = par2.getInvResult();
+               this.invf = par2.getInvFuel();
+               this.invm.setEventHandler(this);
+               this.invr.setEventHandler(this);
+               this.invf.setEventHandler(this);
 
                for (int i = 0; i < 4; i++) {
                        for (int j = 0; j < 4; j++) {
@@ -56,4 +71,39 @@ public class ContainerPyrolysisTable extends Container {
                return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.pyrolysisTableID ? false : par1EntityPlayer.getDistanceSq((double)this.posX + 0.5D, (double)this.posY + 0.5D, (double)this.posZ + 0.5D) <= 64.0D;
        }
 
+       @Override
+       public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
+       {
+               ItemStack var3 = null;
+               Slot var4 = (Slot)this.inventorySlots.get(par2);
+
+               if (var4 != null && var4.getHasStack())
+               {
+                       ItemStack var5 = var4.getStack();
+                       var3 = var5.copy();
+
+                       if (par2 < 18 ){
+                               if (!this.mergeItemStack(var5, 18, this.inventorySlots.size(), true))
+                               {
+                                       return null;
+                               }
+                       }
+                       else if (!this.mergeItemStack(var5, 16, 18, false))
+                       {
+                               return null;
+                       }
+
+                       if (var5.stackSize == 0)
+                       {
+                               var4.putStack((ItemStack)null);
+                       }
+                       else
+                       {
+                               var4.onSlotChanged();
+                       }
+               }
+
+               return var3;
+       }
+
 }