OSDN Git Service

827e9360ea28e9d2b2b42277335428ba724c4c1b
[chemicraft/chemicraft.git] / common / chemicraft / util / NBTRecipeGrenade.java
1 package chemicraft.util;
2
3 import net.minecraft.src.ItemStack;
4 import net.minecraft.src.NBTTagCompound;
5 import net.minecraft.src.NBTTagList;
6 import chemicraft.ChemiCraft;
7
8 public class NBTRecipeGrenade extends ChemicalNBTRecipe {
9
10         @Override
11         public void setNBT(ItemStack[] materials, ItemStack result) {
12                 if(result.stackTagCompound == null){
13                         result.stackTagCompound = new NBTTagCompound();
14                 }
15
16                 if (!result.stackTagCompound.hasKey("Effect"))
17                 {
18                         result.stackTagCompound.setTag("Effect", new NBTTagList("Effect"));
19                 }
20
21                 NBTTagList tagList = (NBTTagList) result.getTagCompound().getTag("Effect");
22                 NBTTagCompound tag = new NBTTagCompound();
23
24                 for(int i = 0;i < materials.length;i++){
25                         if(materials[i] != null){
26                                 if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.HYDROGEN){
27                                         tag.setString("GrenadeEffect" + i, "Hydrogen");
28                                 }
29                                 if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.CARBON){
30                                         tag.setString("GrenadeEffect" + i, "Carbon");
31                                 }
32                                 if(materials[i].itemID-256 == ChemiCraft.instance.atomsID && materials[i].getItemDamage() == ChemiCraft.URANIUM){
33                                         tag.setString("GrenadeEffect" + i, "Uranium");
34                                 }
35                         }
36                 }
37                 tagList.appendTag(tag);
38
39         }
40
41         @Override
42         public ItemStack[] getMatchItems(ItemStack[] materials) {
43                 ItemStack[] var1 = new ItemStack[materials.length];
44                 for(int i = 0;i < var1.length;i++){
45                         if(materials[i] != null){
46                                 if(materials[i].getItemDamage() == ChemiCraft.HYDROGEN){
47                                         var1[i] = materials[i];
48                                 }else if(materials[i].getItemDamage() == ChemiCraft.CARBON){
49                                         var1[i] = materials[i];
50                                 }else if(materials[i].getItemDamage() == ChemiCraft.URANIUM){
51                                         var1[i] = materials[i];
52                                 }else{
53                                         var1[i] = null;
54                                 }
55                         }else{
56                                 var1[i] = null;
57                         }
58                 }
59                 return var1;
60         }
61
62 }