OSDN Git Service

原子記号と番号書いてー
authormozipi <mozipi@users.sourceforge.jp>
Mon, 31 Dec 2012 14:15:06 +0000 (23:15 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Mon, 31 Dec 2012 14:15:06 +0000 (23:15 +0900)
common/chemicraft/ChemiCraft.java
common/chemicraft/gui/GuiChemicalCombinationTable.java
common/chemicraft/item/ItemAtomGrenade.java
common/chemicraft/system/PacketHandler.java
common/chemicraft/tileentity/TileEntityChemicalCombinationTable.java
common/chemicraft/tileentity/TileEntityDecompositionTable.java
common/chemicraft/tileentity/TileEntityToolAndWeaponCraftingTable.java

index 992f9a2..093c26c 100644 (file)
@@ -311,6 +311,56 @@ public class ChemiCraft {
        public final static int CARBON = 5;\r
        public final static int NITROGEN = 6;\r
        public final static int OXYGEN = 7;\r
+       public final static int FLUORINE = 8;\r
+       public final static int NEON = 9;\r
+       public final static int SODIUM = 10;\r
+       public final static int MAGNESIUM = 11;\r
+       public final static int ALMINIUM = 12;\r
+       public final static int SILICON = 13;\r
+       public final static int PHOSPHORUS = 14;\r
+       public final static int SULFUR = 15;\r
+       public final static int CHLORINE = 16;\r
+       public final static int ARGON = 17;\r
+       public final static int POTASSIUM = 18;\r
+       public final static int CALCIUM = 19;\r
+       public final static int SCANDIUM = 20;\r
+       public final static int TITANIUM = 21;\r
+       public final static int VANADIUM = 22;\r
+       public final static int CHROMIUM = 23;\r
+       public final static int MANGANESE = 24;\r
+       public final static int IRON = 25;\r
+       public final static int COBALT = 26;\r
+       public final static int NICKEL = 27;\r
+       public final static int COPPER = 28;\r
+       public final static int ZINC = 29;\r
+       public final static int GALLIUM = 30;\r
+       public final static int GERMANIUM = 31;\r
+       public final static int ARSENIC = 32;\r
+       public final static int SELENIUM = 33;\r
+       public final static int BROMINE = 34;\r
+       public final static int KRYPTON = 35;\r
+       public final static int RUBIDIUM = 36;\r
+       public final static int STRONTIUM = 37;\r
+       public final static int YTTORIUM = 38;\r
+       public final static int ZIRCONIUM = 39;\r
+       public final static int NIOBIUM = 40;\r
+       public final static int MOLYBDENUM = 41;\r
+       public final static int TECHNETIUM = 42;\r
+       public final static int RUTHENIUM = 43;\r
+       public final static int RHODIUM = 44;\r
+       public final static int PALLADIUM = 45;\r
+       public final static int SILVER = 46;\r
+       public final static int CADMIUM = 47;\r
        public final static int URANIUM = 91;\r
 \r
+       public final static String HYDROGEN_ = "H";\r
+       public final static String HELIUM_ = "He";\r
+       public final static String LITHIUM_ = "Li";\r
+       public final static String BERYLLIUM_ = "Be";\r
+       public final static String BORON_ = "B";\r
+       public final static String CARBON_ = "C";\r
+       public final static String NITOROGEN_ = "N";\r
+       public final static String OXYGEN_ = "O";\r
+\r
+\r
 }
\ No newline at end of file
index 243965c..044eb5b 100644 (file)
@@ -1,26 +1,39 @@
 package chemicraft.gui;
 
+import java.util.Arrays;
+
 import net.minecraft.src.EntityPlayer;
+import net.minecraft.src.GuiButton;
 import net.minecraft.src.GuiContainer;
 import net.minecraft.src.GuiTextField;
+import net.minecraft.src.IInventory;
+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.network.PacketDispatcher;
 
 public class GuiChemicalCombinationTable extends GuiContainer {
 
        private GuiTextField atomList;
 
+       private TileEntityChemicalCombinationTable tileentity;
+
        public GuiChemicalCombinationTable(EntityPlayer par1EntityPlayer, TileEntityChemicalCombinationTable par2) {
                super(new ContainerChemicalCombinationTable(par1EntityPlayer, par2));
+               this.tileentity = par2;
        }
 
        @Override
        public void initGui(){
                super.initGui();
-               this.atomList = new GuiTextField(this.fontRenderer, 100, 65, 70, 15);
+               this.atomList = new GuiTextField(this.fontRenderer, 92, 7, 80, 15);
                this.atomList.setFocused(false);
                this.atomList.setMaxStringLength(10);
+               this.controlList.add(new GuiButton(0, this.guiLeft + 132 - 41, this.guiTop + 63, 40, 20, "Add"));
+               this.controlList.add(new GuiButton(1, this.guiLeft + 132, this.guiTop + 63, 40, 20, "Eject"));
        }
 
        @Override
@@ -30,6 +43,32 @@ public class GuiChemicalCombinationTable extends GuiContainer {
        }
 
        @Override
+       protected void actionPerformed(GuiButton par1GuiButton) {
+               if(par1GuiButton.id == 0){
+                       this.field_00001(this.tileentity);
+                       PacketDispatcher.sendPacketToServer(this.tileentity.getDescriptionPacket());
+               }else if(par1GuiButton.id == 1){
+
+               }
+               return;
+       }
+
+       protected void field_00001(TileEntityChemicalCombinationTable par1){
+               IInventory inv = par1.getInvMaterial();
+               ItemStack[] stacks = new ItemStack[inv.getSizeInventory()];
+               for(int i = 0;i < stacks.length;i++){
+                       if(inv.getStackInSlot(i) != null){
+                               stacks[i] = inv.getStackInSlot(i);
+                       }
+               }
+               Arrays.sort(stacks, new ComparatorItemStack());
+               stacks = ChemiCraft.instance.arrayAuxiliary.deleteNull(stacks);
+
+               for(int i = 0;i < stacks.length;i++){
+               }
+       }
+
+       @Override
        protected void drawGuiContainerForegroundLayer() {
                this.atomList.drawTextBox();
        }
index cfabf5b..58ad121 100644 (file)
@@ -53,7 +53,6 @@ public class ItemAtomGrenade extends Item {
 
        @Override
        public void addInformation(ItemStack par1ItemStack, List par2List) {
-               System.out.println(par1ItemStack.hasTagCompound());
                if(par1ItemStack.hasTagCompound()){
                        NBTTagList var1 = par1ItemStack.getTagCompound().getTagList("Effect");
 
index 7f13fdd..89430f3 100644 (file)
@@ -11,7 +11,10 @@ import net.minecraft.src.Packet250CustomPayload;
 import net.minecraft.src.TileEntity;\r
 import net.minecraft.src.World;\r
 import chemicraft.ChemiCraft;\r
+import chemicraft.tileentity.TileEntityChemicalCombinationTable;\r
 import chemicraft.tileentity.TileEntityChemicalCraftingTable;\r
+import chemicraft.tileentity.TileEntityDecompositionTable;\r
+import chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable;\r
 \r
 import com.google.common.io.ByteArrayDataInput;\r
 import com.google.common.io.ByteStreams;\r
@@ -48,18 +51,24 @@ public class PacketHandler implements IPacketHandler {
                        worldServer = ((EntityPlayer)player).worldObj;\r
                        if(worldClient != null && worldServer == null){\r
                                var1 = worldClient.getBlockTileEntity(x, y, z);\r
+                               if(var1 instanceof TileEntityChemicalCombinationTable) ((TileEntityChemicalCombinationTable)var1).readPacket(badi);\r
+                               if(var1 instanceof TileEntityChemicalCraftingTable) ((TileEntityChemicalCraftingTable)var1).readPacket(badi);\r
+                               if(var1 instanceof TileEntityDecompositionTable) ((TileEntityDecompositionTable)var1).readPacket(badi);\r
+                               if(var1 instanceof TileEntityToolAndWeaponCraftingTable) ((TileEntityToolAndWeaponCraftingTable)var1).readPacket(badi);\r
                                return;\r
                        }\r
                        if(worldServer != null){\r
                                var1 = worldServer.getBlockTileEntity(x, y, z);\r
+                               if(var1 instanceof TileEntityChemicalCombinationTable) ((TileEntityChemicalCombinationTable)var1).readPacket(badi);\r
+                               if(var1 instanceof TileEntityChemicalCraftingTable) ((TileEntityChemicalCraftingTable)var1).readPacket(badi);\r
+                               if(var1 instanceof TileEntityDecompositionTable) ((TileEntityDecompositionTable)var1).readPacket(badi);\r
+                               if(var1 instanceof TileEntityToolAndWeaponCraftingTable) ((TileEntityToolAndWeaponCraftingTable)var1).readPacket(badi);\r
                        }\r
                        return;\r
                }\r
        }\r
 \r
 \r
-       /*\r
-        * Commented by mozipi.\r
        public static Packet getPacket(TileEntityDecompositionTable tileEntity) {\r
                ByteArrayOutputStream var1 = new ByteArrayOutputStream(128);\r
                DataOutputStream var2 = new DataOutputStream(var1);\r
@@ -152,7 +161,7 @@ public class PacketHandler implements IPacketHandler {
                packet.isChunkDataPacket = true;\r
                return packet;\r
        }\r
-        */\r
+\r
        public static Packet getPacket(TileEntityChemicalCraftingTable tileEntity) {\r
                ByteArrayOutputStream var1 = new ByteArrayOutputStream(128);\r
                DataOutputStream var2 = new DataOutputStream(var1);\r
index d4c8257..01235d4 100644 (file)
@@ -1,10 +1,16 @@
 package chemicraft.tileentity;
 
+import java.io.DataOutputStream;
+
+import com.google.common.io.ByteArrayDataInput;
+
 import chemicraft.inventory.InventoryChemicalCombinationTableMaterial;
 import chemicraft.inventory.InventoryChemicalCombinationTableResult;
+import chemicraft.system.PacketHandler;
 import net.minecraft.src.ItemStack;
 import net.minecraft.src.NBTTagCompound;
 import net.minecraft.src.NBTTagList;
+import net.minecraft.src.Packet;
 import net.minecraft.src.TileEntity;
 
 public class TileEntityChemicalCombinationTable extends TileEntity {
@@ -12,6 +18,8 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
        private InventoryChemicalCombinationTableMaterial invm = new InventoryChemicalCombinationTableMaterial();
        private InventoryChemicalCombinationTableResult invr = new InventoryChemicalCombinationTableResult();
 
+       private String atomsList = "";
+
        @Override
        public void readFromNBT(NBTTagCompound par1){
                super.readFromNBT(par1);
@@ -38,11 +46,122 @@ public class TileEntityChemicalCombinationTable extends TileEntity {
                                this.invr.setInventorySlotContents(var8, ItemStack.loadItemStackFromNBT(var7));
                        }
                }
+
+               this.atomsList = par1.getString("AtomsList");
+       }
+
+       @Override
+       public Packet getDescriptionPacket() {
+               return PacketHandler.getPacket(this);
        }
 
        @Override
        public void writeToNBT(NBTTagCompound par1){
                super.writeToNBT(par1);
+               NBTTagList var2 = new NBTTagList();
+               for (int var3 = 0; var3 < this.invm.getSizeInventory(); ++var3)
+               {
+                       if (this.invm.getStackInSlot(var3) != null)
+                       {
+                               NBTTagCompound var4 = new NBTTagCompound();
+                               var4.setByte("Slot", (byte)var3);
+                               this.invm.getStackInSlot(var3).writeToNBT(var4);
+                               var2.appendTag(var4);
+                       }
+               }
+               par1.setTag("Items", var2);
+
+               NBTTagList var5 = new NBTTagList();
+               for (int var6 = 0; var6 < this.invr.getSizeInventory(); ++var6)
+               {
+                       if (this.invr.getStackInSlot(var6) != null)
+                       {
+                               NBTTagCompound var7 = new NBTTagCompound();
+                               var7.setByte("Slot2", (byte)var6);
+                               this.invr.getStackInSlot(var6).writeToNBT(var7);
+                               var5.appendTag(var7);
+                       }
+               }
+               par1.setTag("Items2", var5);
+
+               par1.setString("AtomsList", this.atomsList);
+       }
+
+       public void readPacket(ByteArrayDataInput data) {
+               try {
+                       for(int i = 0;i < this.invm.getSizeInventory();i++){
+                               int id = data.readInt();
+                               int size = data.readByte();
+                               int damage = data.readInt();
+                               if(id != 0 && size != 0){
+                                       this.invm.setInventorySlotContents(i, new ItemStack(id, size, damage));
+                               }else{
+                                       this.invm.setInventorySlotContents(i, null);
+                               }
+                       }
+
+                       for(int i = 0;i < this.invr.getSizeInventory();i++){
+                               int id = data.readInt();
+                               int size = data.readByte();
+                               int damage = data.readInt();
+                               if(id != 0 && size != 0){
+                                       this.invr.setInventorySlotContents(i, new ItemStack(id, size, damage));
+                               }else{
+                                       this.invr.setInventorySlotContents(i, null);
+                               }
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+
+       public void writePacket(DataOutputStream dos){
+               try {
+                       for(int i = 0;i < this.invm.getSizeInventory();i++){
+                               int id = 0;
+                               int size = 0;
+                               int damage  = 0;
+                               ItemStack itemstack = this.invm.getStackInSlot(i);
+                               if(itemstack != null){
+                                       id = itemstack.itemID;
+                                       size = itemstack.stackSize;
+                                       damage = itemstack.getItemDamage();
+                                       dos.writeInt(id);
+                                       dos.writeByte(size);
+                                       dos.writeInt(damage);
+                               }else{
+                                       dos.writeInt(0);
+                                       dos.writeByte(0);
+                                       dos.writeInt(0);
+                               }
+                       }
+
+                       for(int i = 0;i < this.invr.getSizeInventory();i++){
+                               int id = 0;
+                               int size = 0;
+                               int damage  = 0;
+                               ItemStack itemstack = this.invr.getStackInSlot(i);
+                               if(itemstack != null){
+                                       id = itemstack.itemID;
+                                       size = itemstack.stackSize;
+                                       damage = itemstack.getItemDamage();
+                                       dos.writeInt(id);
+                                       dos.writeByte(size);
+                                       dos.writeInt(damage);
+                               }else{
+                                       dos.writeInt(0);
+                                       dos.writeByte(0);
+                                       dos.writeInt(0);
+                               }
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       public void setAtoms(String par1){
+               this.atomsList = this.atomsList + par1;
        }
 
        public InventoryChemicalCombinationTableMaterial getInvMaterial(){
index edc8a5c..abe1501 100644 (file)
@@ -1,7 +1,26 @@
 package chemicraft.tileentity;
 
+import java.io.DataOutputStream;
+
+import com.google.common.io.ByteArrayDataInput;
+
 import net.minecraft.src.TileEntity;
 
 public class TileEntityDecompositionTable extends TileEntity {
 
+       public void readPacket(ByteArrayDataInput data) {
+               try {
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+
+       public void writePacket(DataOutputStream dos){
+               try {
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
 }
index a936f50..87c609b 100644 (file)
@@ -1,7 +1,26 @@
 package chemicraft.tileentity;
 
+import java.io.DataOutputStream;
+
+import com.google.common.io.ByteArrayDataInput;
+
 import net.minecraft.src.TileEntity;
 
 public class TileEntityToolAndWeaponCraftingTable extends TileEntity {
 
+       public void readPacket(ByteArrayDataInput data) {
+               try {
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+
+       public void writePacket(DataOutputStream dos){
+               try {
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
 }