/
DebugItem.java
42 lines (36 loc) · 1.21 KB
/
DebugItem.java
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
package mezz.jei.debug;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class DebugItem extends Item {
private static final RandomStringMaker RANDOM_STRING_MAKER = new RandomStringMaker(12);
private static final int MAX_DAMAGE = 1000;
public DebugItem(String name) {
setUnlocalizedName(name);
setCreativeTab(CreativeTabs.SEARCH);
setMaxDamage(MAX_DAMAGE);
setHasSubtypes(true);
}
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
for (int i = 0; i < 10000; i++) {
String name = RANDOM_STRING_MAKER.nextString();
ItemStack itemStack = new ItemStack(itemIn);
itemStack.setItemDamage((int)(Math.random() * MAX_DAMAGE));
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("name", name);
itemStack.setTagCompound(nbt);
subItems.add(itemStack);
}
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
NBTTagCompound tagCompound = stack.getTagCompound();
if (tagCompound == null) {
return "no nbt";
}
return tagCompound.getString("name");
}
}