OSDN Git Service

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