OSDN Git Service

素材製作台(減算処理・NBT処理抜き)を製作
[chemicraft/chemicraft.git] / common / chemicraft / tileentity / TileEntityChemicalCraftingTable.java
1 package chemicraft.tileentity;
2
3 import java.io.DataOutputStream;
4
5 import net.minecraft.src.IInventory;
6 import net.minecraft.src.ItemStack;
7 import net.minecraft.src.NBTTagCompound;
8 import net.minecraft.src.NBTTagList;
9 import net.minecraft.src.Packet;
10 import net.minecraft.src.TileEntity;
11 import chemicraft.inventory.InventoryChemicalCraftingMaterial;
12 import chemicraft.inventory.InventoryChemicalCraftingNBT;
13 import chemicraft.inventory.InventoryChemicalCraftingResult;
14 import chemicraft.system.PacketHandler;
15
16 import com.google.common.io.ByteArrayDataInput;
17
18 public class TileEntityChemicalCraftingTable extends TileEntity {
19
20         public IInventory chemicalCraftingInvMaterial = new InventoryChemicalCraftingMaterial();
21         public IInventory chemicalCraftingInvResult = new InventoryChemicalCraftingResult();
22         public IInventory chemicalCraftingInvNBT = new InventoryChemicalCraftingNBT();
23
24
25         public TileEntityChemicalCraftingTable() {
26                 super();
27         }
28
29         @Override
30         public void updateEntity() {
31                 super.updateEntity();
32         }
33
34
35         @Override
36         public void readFromNBT(NBTTagCompound par1) {
37                 super.readFromNBT(par1);
38
39                 NBTTagList var2 = par1.getTagList("Items");
40                 for (int var3 = 0; var3 < var2.tagCount(); ++var3)
41                 {
42                         NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
43                         int var5 = var4.getByte("Slot") & 255;
44
45                         if (var5 >= 0 && var5 < this.chemicalCraftingInvMaterial.getSizeInventory())
46                         {
47                                 this.chemicalCraftingInvMaterial.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4));
48                         }
49                 }
50
51                 NBTTagList var6 = par1.getTagList("Items2");
52                 for (int var7 = 0; var7 < var6.tagCount(); ++var7)
53                 {
54                         NBTTagCompound var4 = (NBTTagCompound)var6.tagAt(var7);
55                         int var5 = var4.getByte("Slot2") & 255;
56
57                         if (var5 >= 0 && var5 < this.chemicalCraftingInvResult.getSizeInventory())
58                         {
59                                 this.chemicalCraftingInvResult.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4));
60                         }
61                 }
62
63                 NBTTagList var8 = par1.getTagList("Items3");
64                 for (int var9 = 0; var9 < var8.tagCount(); ++var9)
65                 {
66                         NBTTagCompound var11 = (NBTTagCompound)var8.tagAt(var9);
67                         int var10 = var11.getByte("Slot3") & 255;
68
69                         if (var10 >= 0 && var10 < this.chemicalCraftingInvNBT.getSizeInventory())
70                         {
71                                 this.chemicalCraftingInvNBT.setInventorySlotContents(var10, ItemStack.loadItemStackFromNBT(var11));
72                         }
73                 }
74         }
75
76
77         @Override
78         public void writeToNBT(NBTTagCompound par1) {
79                 super.writeToNBT(par1);
80
81                 NBTTagList var2 = new NBTTagList();
82                 for (int var3 = 0; var3 < this.chemicalCraftingInvMaterial.getSizeInventory(); ++var3)
83                 {
84                         if (this.chemicalCraftingInvMaterial.getStackInSlot(var3) != null)
85                         {
86                                 NBTTagCompound var4 = new NBTTagCompound();
87                                 var4.setByte("Slot", (byte)var3);
88                                 this.chemicalCraftingInvMaterial.getStackInSlot(var3).writeToNBT(var4);
89                                 var2.appendTag(var4);
90                         }
91                 }
92                 par1.setTag("Items", var2);
93
94                 NBTTagList var5 = new NBTTagList();
95                 for (int var6 = 0; var6 < this.chemicalCraftingInvResult.getSizeInventory(); ++var6)
96                 {
97                         if (this.chemicalCraftingInvResult.getStackInSlot(var6) != null)
98                         {
99                                 NBTTagCompound var7 = new NBTTagCompound();
100                                 var7.setByte("Slot2", (byte)var6);
101                                 this.chemicalCraftingInvResult.getStackInSlot(var6).writeToNBT(var7);
102                                 var5.appendTag(var7);
103                         }
104                 }
105                 par1.setTag("Items2", var5);
106
107                 NBTTagList var8 = new NBTTagList();
108                 for (int var9 = 0; var9 < this.chemicalCraftingInvNBT.getSizeInventory(); ++var9)
109                 {
110                         if (this.chemicalCraftingInvNBT.getStackInSlot(var9) != null)
111                         {
112                                 NBTTagCompound var10 = new NBTTagCompound();
113                                 var10.setByte("Slot3", (byte)var9);
114                                 this.chemicalCraftingInvNBT.getStackInSlot(var9).writeToNBT(var10);
115                                 var8.appendTag(var10);
116                         }
117                 }
118                 par1.setTag("Items3", var8);
119         }
120
121
122         @Override
123         public Packet getDescriptionPacket() {
124                 return PacketHandler.getPacket(this);
125         }
126
127
128         public void readPacket(ByteArrayDataInput data) {
129                 try {
130                 } catch (Exception e) {
131                         e.printStackTrace();
132                 }
133         }
134
135
136         public void writePacket(DataOutputStream dos){
137                 try {
138                 } catch (Exception e) {
139                         e.printStackTrace();
140                 }
141         }
142
143 }