OSDN Git Service

いろいろした
[chemicraft/chemicraft.git] / common / pcc / chemicraft / core / nbt / NBTRecipeGrenade.java
1 package pcc.chemicraft.core.nbt;
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 implements 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                         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 == ChemiCraftCore.instance.atomsID && materials[i].getItemDamage() == ChemiCraftData.HYDROGEN) {
27                                         tag.setString("GrenadeEffect" + i, "Hydrogen");
28                                 }
29                                 if (materials[i].itemID-256 == ChemiCraftCore.instance.atomsID && materials[i].getItemDamage() == ChemiCraftData.CARBON) {
30                                         tag.setString("GrenadeEffect" + i, "Carbon");
31                                 }
32                                 if (materials[i].itemID-256 == ChemiCraftCore.instance.atomsID && materials[i].getItemDamage() == ChemiCraftData.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() == ChemiCraftData.HYDROGEN) {
47                                         var1[i] = materials[i];
48                                 } else if (materials[i].getItemDamage() == ChemiCraftData.CARBON) {
49                                         var1[i] = materials[i];
50                                 } else if (materials[i].getItemDamage() == ChemiCraftData.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 }