Posted June 4, 20205 yr Hi there, I'm trying to add existing vanilla items to a new Creative Tab. I've already created my tab, but I don't know how to add vanilla items, let alone with NBT data stored in them. Say for example I want to add a chest with NBT data to a new tab. Any help would be greatly appreciated!
June 4, 20205 yr Hi A working example is here https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe08_itemgroup -TGG
June 4, 20205 yr Author 8 hours ago, diesieben07 said: Override fill in your ItemGroup class and add whatever stacks you desire to the provided list. 8 hours ago, TheGreyGhost said: A working example is here Thank you both for you replies! Would you be able to explain why this won't show up? It worked with modded items but not when using the override method. public class ModItemGroup extends ItemGroup { public ModItemGroup(int index, String label) { super(index, label); } @Override public ItemStack createIcon() { return new ItemStack(Items.DRAGON_EGG); } @Override public void fill(NonNullList<ItemStack> items) { items.add(new ItemStack(Items.DRAGON_EGG)); } } I fixed it, it was an error with me hardcoding an index like an idiot. Thanks for all your help! Edited June 4, 20205 yr by squidlex
June 4, 20205 yr Author So I now have the Creative Tab down, but how do I add NBT data to an ItemStack? At the moment I'm messing with ItemStack.write() but I don't know if that's correct or how to properly format NBT within it.
June 5, 20205 yr The write in Itemstack is something that writes an itemstack in a nbt tag iirc. What you are looking for should be either create a new CompoundNBT or getTag from the itemstack and use compound.putInt()... putBoolean... etc
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.