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) {
		return stack.getTagCompound().getString("name");
	}
}

@@ -1080,37 +1080,138 @@
 %0D%0A%09%09
-return stack.getTagCompound()
+NBTTagCompound tagCompound = stack.getTagCompound();%0D%0A%09%09if (tagCompound == null) %7B%0D%0A%09%09%09return %22no nbt%22;%0D%0A%09%09%7D%0D%0A%09%09return tagCompound
 .get

Fix a potential bug when using DebugItem