squidlex Posted June 4, 2020 Posted June 4, 2020 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! Quote
TheGreyGhost Posted June 4, 2020 Posted June 4, 2020 Hi A working example is here https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe08_itemgroup -TGG 1 Quote
squidlex Posted June 4, 2020 Author Posted June 4, 2020 (edited) 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, 2020 by squidlex Quote
squidlex Posted June 4, 2020 Author Posted June 4, 2020 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. Quote
poopoodice Posted June 5, 2020 Posted June 5, 2020 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 1 Quote
squidlex Posted June 5, 2020 Author Posted June 5, 2020 1 hour ago, poopoodice said: CompoundNBT Thank you! I got it working Quote
Recommended Posts
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.