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
|
package gregtech.common.items.behaviors;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import gregtech.api.items.MetaBaseItem;
import gregtech.api.util.GTUtility;
public class BehaviourDataOrb extends BehaviourNone {
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] = GTUtility.copyOrNull(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) {
tInventory[slot] = GTUtility.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;
}
@Override
public List<String> getAdditionalToolTips(MetaBaseItem aItem, List<String> aList, ItemStack aStack) {
if (!(getDataTitle(aStack).isEmpty())) {
aList.add(getDataTitle(aStack));
aList.add(getDataName(aStack));
}
return aList;
}
}
|