Jump to content

Recommended Posts

Posted

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!

Posted (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 by squidlex
Posted

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.

Posted

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

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.