aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java
blob: 5738962c10a0bae90dd07b3d66c94adaade9ea0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package gregtech.common.items.behaviors;

import gregtech.api.items.GT_MetaBase_Item;
import gregtech.api.util.GT_Utility;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

public class Behaviour_DataOrb
  extends Behaviour_None
{
  public List<String> getAdditionalToolTips(GT_MetaBase_Item aItem, List<String> aList, ItemStack aStack)
  {
    if (!getDataTitle(aStack).equals(""))
    {
      aList.add(getDataTitle(aStack));
      aList.add(getDataName(aStack));
    }
    return aList;
  }
  
  public static void copyInventory(ItemStack[] aInventory, ItemStack[] aNewContent, int aIndexlength)
  {
    for (int i = 0; i < aIndexlength; i++) {
      if (aNewContent[i] == null) {
        aInventory[i] = null;
      } else {
        aInventory[i] = GT_Utility.copy(new Object[] { aNewContent[i] });
      }
    }
  }
  
  public static String getDataName(ItemStack aStack)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null) {
      return "";
    }
    return tNBT.getString("mDataName");
  }
  
  public static String getDataTitle(ItemStack aStack)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null) {
      return "";
    }
    return tNBT.getString("mDataTitle");
  }
  
  public static NBTTagCompound setDataName(ItemStack aStack, String aDataName)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null) {
      tNBT = new NBTTagCompound();
    }
    tNBT.setString("mDataName", aDataName);
    aStack.setTagCompound(tNBT);
    return tNBT;
  }
  
  public static NBTTagCompound setDataTitle(ItemStack aStack, String aDataTitle)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null) {
      tNBT = new NBTTagCompound();
    }
    tNBT.setString("mDataTitle", aDataTitle);
    aStack.setTagCompound(tNBT);
    return tNBT;
  }
  
  public static ItemStack[] getNBTInventory(ItemStack aStack)
  {
    ItemStack[] tInventory = new ItemStack[256];
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null) {
      return tInventory;
    }
    NBTTagList tNBT_ItemList = tNBT.getTagList("Inventory", 10);
    for (int i = 0; i < tNBT_ItemList.tagCount(); i++)
    {
      NBTTagCompound tag = tNBT_ItemList.getCompoundTagAt(i);
      byte slot = tag.getByte("Slot");
      if ((slot >= 0) && (slot < tInventory.length)) {
        tInventory[slot] = GT_Utility.loadItem(tag);
      }
    }
    return tInventory;
  }
  
  public static NBTTagCompound setNBTInventory(ItemStack aStack, ItemStack[] aInventory)
  {
    NBTTagCompound tNBT = aStack.getTagCompound();
    if (tNBT == null) {
      tNBT = new NBTTagCompound();
    }
    NBTTagList tNBT_ItemList = new NBTTagList();
    for (int i = 0; i < aInventory.length; i++)
    {
      ItemStack stack = aInventory[i];
      if (stack != null)
      {
        NBTTagCompound tag = new NBTTagCompound();
        tag.setByte("Slot", (byte)i);
        stack.writeToNBT(tag);
        tNBT_ItemList.appendTag(tag);
      }
    }
    tNBT.setTag("Inventory", tNBT_ItemList);
    aStack.setTagCompound(tNBT);
    return tNBT;
  }
}



/* Location:           F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar

 * Qualified Name:     gregtech.common.items.behaviors.Behaviour_DataOrb

 * JD-Core Version:    0.7.0.1

 */