OSDN Git Service

修正・変更
authorponkotate <ponkotate@users.sourceforge.jp>
Sun, 10 Mar 2013 07:22:08 +0000 (16:22 +0900)
committerponkotate <ponkotate@users.sourceforge.jp>
Sun, 10 Mar 2013 07:22:08 +0000 (16:22 +0900)
電解台・熱解台のShiftクリック対応。
化合台のドロップ処理。(多分完成??)

common/pcc/chemicraft/container/ContainerChemicalCombinationTable.java
common/pcc/chemicraft/container/ContainerElectrolysisTable.java
common/pcc/chemicraft/container/ContainerPyrolysisTable.java
common/pcc/chemicraft/slot/SlotElectrolysisResult.java
resources/pcc/chemicraft/items/items.png

index ada41bc..e47fd87 100644 (file)
@@ -148,9 +148,25 @@ public class ContainerChemicalCombinationTable extends Container {
                return super.slotClick(par1, par2, par3, par4EntityPlayer);
        }
 
-       @Override
-       public void onCraftGuiClosed(EntityPlayer par1EntityPlayer){
+       public void onCraftGuiClosed(EntityPlayer par1EntityPlayer)
+       {
                super.onCraftGuiClosed(par1EntityPlayer);
+
+               if (!this.worldObj.isRemote)
+               {
+                       for (int var2 = 0; var2 < 18; var2++){
+                               ItemStack var3 = null;
+                               if (var2 < 15){
+                                       var3 = this.invm.getStackInSlotOnClosing(var2);
+                               } else if (var2 < 16) {
+                                       var3 = this.invr.getStackInSlotOnClosing(var2 - 15);
+                               }
+
+                               if (var3 != null){
+                                       par1EntityPlayer.dropPlayerItem(var3);
+                               }
+                       }
+               }
        }
 
 }
index 493692d..a1b9369 100644 (file)
@@ -1,8 +1,13 @@
 package pcc.chemicraft.container;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.inventory.Container;
+import net.minecraft.inventory.IInventory;
 import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
 import net.minecraft.world.World;
 import pcc.chemicraft.ChemiCraft;
 import pcc.chemicraft.inventory.InventoryElectrolysisFuel;
@@ -72,4 +77,39 @@ public class ContainerElectrolysisTable extends Container {
                return this.worldObj.getBlockId(this.posX, this.posY, this.posZ) != ChemiCraft.instance.electrolysisTableID ? 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;
+       }
+
 }
index 38d6911..c00c380 100644 (file)
@@ -3,8 +3,12 @@ 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;
@@ -21,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;
@@ -28,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++) {
@@ -57,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;
+       }
+
 }
index 046630d..60f591b 100644 (file)
@@ -2,6 +2,7 @@ package pcc.chemicraft.slot;
 
 import net.minecraft.inventory.IInventory;
 import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
 
 public class SlotElectrolysisResult extends Slot
 {
@@ -10,4 +11,9 @@ public class SlotElectrolysisResult extends Slot
                super(par1iInventory, par2, par3, par4);
        }
 
+       @Override
+       public boolean isItemValid(ItemStack par1ItemStack){
+               return false;
+       }
+
 }
index 3ec284e..5be4625 100644 (file)
Binary files a/resources/pcc/chemicraft/items/items.png and b/resources/pcc/chemicraft/items/items.png differ