OSDN Git Service

ts
authormozipi <mozipi@users.sourceforge.jp>
Tue, 1 Jan 2013 12:37:27 +0000 (21:37 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Tue, 1 Jan 2013 12:37:27 +0000 (21:37 +0900)
common/chemicraft/container/ContainerChemicalCombinationTable.java
common/chemicraft/gui/GuiChemicalCombinationTable.java
common/chemicraft/tileentity/TileEntityChemicalCombinationTable.java

index 4752cd9..968680e 100644 (file)
@@ -1,6 +1,5 @@
 package chemicraft.container;
 
-import net.minecraft.src.Block;
 import net.minecraft.src.Container;
 import net.minecraft.src.EntityPlayer;
 import net.minecraft.src.ItemStack;
index d8161ed..ce2c079 100644 (file)
@@ -11,8 +11,9 @@ import net.minecraft.src.ItemStack;
 import chemicraft.ChemiCraft;
 import chemicraft.container.ContainerChemicalCombinationTable;
 import chemicraft.tileentity.TileEntityChemicalCombinationTable;
-import chemicraft.util.Auxiliary.ArrayAuxiliary;
 import chemicraft.util.ComparatorItemStack;
+import cpw.mods.fml.common.Side;
+import cpw.mods.fml.common.asm.SideOnly;
 import cpw.mods.fml.common.network.PacketDispatcher;
 
 public class GuiChemicalCombinationTable extends GuiContainer {
@@ -43,6 +44,7 @@ public class GuiChemicalCombinationTable extends GuiContainer {
        }
 
        @Override
+       @SideOnly(Side.CLIENT)
        protected void actionPerformed(GuiButton par1GuiButton) {
                if(par1GuiButton.id == 0){
                        this.field_00001(this.tileentity);
@@ -53,6 +55,7 @@ public class GuiChemicalCombinationTable extends GuiContainer {
                return;
        }
 
+       @SideOnly(Side.CLIENT)
        protected void field_00001(TileEntityChemicalCombinationTable par1){
                IInventory inv = par1.getInvMaterial();
                ItemStack[] stacks = new ItemStack[inv.getSizeInventory()];
@@ -66,11 +69,16 @@ public class GuiChemicalCombinationTable extends GuiContainer {
 
                for(int i = 0;i < stacks.length;i++){
                        if(stacks[i].stackSize > 1){
-                               par1.setAtoms(ChemiCraft.atomsList[stacks[i].getItemDamage()] + stacks[i].stackSize);
+                               par1.setAtoms(ChemiCraft.atomsList[stacks[i].getItemDamage()], stacks[i].stackSize);
                        }else{
-                               par1.setAtoms(ChemiCraft.atomsList[stacks[i].getItemDamage()]);
+                               par1.setAtoms(ChemiCraft.atomsList[stacks[i].getItemDamage()], 1);
                        }
                }
+
+               for(int i = 0;i < stacks.length;i++){
+                       inv.setInventorySlotContents(i, null);
+               }
+
        }
 
        @Override
index 9f80cff..c738a44 100644 (file)
@@ -8,12 +8,17 @@ import net.minecraft.src.NBTTagCompound;
 import net.minecraft.src.NBTTagList;
 import net.minecraft.src.Packet;
 import net.minecraft.src.TileEntity;
+import net.minecraft.src.WorldServer;
 import chemicraft.inventory.InventoryChemicalCombinationTableMaterial;
 import chemicraft.inventory.InventoryChemicalCombinationTableResult;
 import chemicraft.system.PacketHandler;
 
 import com.google.common.io.ByteArrayDataInput;
 
+import cpw.mods.fml.common.Side;
+import cpw.mods.fml.common.asm.SideOnly;
+import cpw.mods.fml.common.network.PacketDispatcher;
+
 public class TileEntityChemicalCombinationTable extends TileEntity {
 
        private InventoryChemicalCombinationTableMaterial invm = new InventoryChemicalCombinationTableMaterial();
@@ -23,6 +28,19 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
        private ArrayList<Integer> atomsAmountList = new ArrayList<Integer>();
        private int atomsListSize = 0;
 
+       int t = 0;
+
+       @Override
+       public void updateEntity(){
+               super.updateEntity();
+               t++;
+               if(t % 5 == 0 && this.worldObj instanceof WorldServer){
+                       System.out.println(this.atomsListSize);
+                       System.out.println(this.atomsList);
+                       System.out.println(this.atomsAmountList);
+               }
+       }
+
        @Override
        public void readFromNBT(NBTTagCompound par1){
                super.readFromNBT(par1);
@@ -51,11 +69,9 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
                }
 
                this.atomsListSize = par1.getInteger("atomsListSize");
-
                for(int i = 0;i < this.atomsListSize;i++){
                        this.atomsList.add(par1.getString("atomsList") + i);
                }
-
                for(int i = 0;i < this.atomsListSize;i++){
                        this.atomsAmountList.add(par1.getInteger("atomsAmountList") + i);
                }
@@ -101,7 +117,7 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
 
                this.atomsListSize = this.atomsList.size();
                par1.setInteger("atomsListSize", this.atomsListSize);
-
+               //System.out.println();
        }
 
        @Override
@@ -133,6 +149,15 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
                                }
                        }
 
+                       this.atomsListSize = data.readInt();
+                       this.atomsList.clear();
+                       this.atomsAmountList.clear();
+                       for(int i = 0;i < this.atomsListSize;i++){
+                               this.atomsList.add(data.readUTF());
+                       }
+                       for(int i = 0;i < this.atomsListSize;i++){
+                               this.atomsAmountList.add(data.readInt());
+                       }
                } catch (Exception e) {
                        e.printStackTrace();
                }
@@ -178,17 +203,40 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
                                }
                        }
 
+                       dos.writeInt(this.atomsList.size());
+                       for(int i = 0;i < this.atomsList.size();i++){
+                               dos.writeUTF(this.atomsList.get(i));
+                       }
+                       for(int i = 0;i < this.atomsAmountList.size();i++){
+                               dos.writeInt(this.atomsAmountList.get(i));
+                       }
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
 
-       public void setAtoms(String par1){
-
+       @SideOnly(Side.CLIENT)
+       public void setAtoms(String par1, int par2){
+               if(this.atomsList.indexOf(par1) != -1){
+                       int var1 = this.atomsList.indexOf(par1);
+                       this.atomsAmountList.set(var1, this.atomsAmountList.get(var1) + par2);
+               }else{
+                       this.atomsList.add(par1);
+                       this.atomsAmountList.add(par2);
+               }
+               PacketDispatcher.sendPacketToServer(this.getDescriptionPacket());
        }
 
        public String getAtoms(){
-               return this.atomsList;
+               StringBuffer var1 = new StringBuffer();
+               for(int i = 0;i < this.atomsList.size();i++){
+                       if(this.atomsAmountList.get(i) != 1){
+                               var1.append(this.atomsList.get(i) + this.atomsAmountList.get(i));
+                       }else{
+                               var1.append(this.atomsList.get(i));
+                       }
+               }
+               return var1.toString();
        }
 
        public ArrayList<String> getAtomsList(){
@@ -199,6 +247,7 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
                return this.atomsAmountList;
        }
 
+       @SuppressWarnings("unused")
        protected boolean isNumber(String par1){
                try {
                        int var1 = Integer.valueOf(new String(par1));