Jump to content

[SOLVED] [1.8] Adding Attributes to an ItemStack


mrCookieSlime

Recommended Posts

I am not sure what you want but I feel like NBT could be your solution.

Give more informations pls. What are you triing to do?

 

I do know that Attributes utilise NBT, but I am trying to add an Attribute to an ItemStack. I never used NBT though.

 

 

... I am trying to add an Attribute, I know what an Attribute consists of...

Link to comment
Share on other sites

I linked you the NBT structure of Attributes. If you add this to an ItemStack it will have the desired Attributes.

 

Exactly that is my Question...

How do I add it?

Or in other words, could you redirect me to a good tutorial about NBT covering more complex entries like Attributes since my knowledge currently does not reach any further than the basic String, Integer, etc... Setting.

Link to comment
Share on other sites

NBT is nothing more than "basic integer, string setting". NBT is a very simple format. You get the NBT Tag for an ItemStack using stack.getStackTagCompound(), it is initially null so you need to set it if needed using setStackTagCompound(). This NBTTagCompound is called "the Tag tag" in the wiki article I linked.

 

It is getTagCompound not getStackTagCompound

 

and by more complex I mean the modification of the "AttributeModifiers" Tag List as I have no clue how to retrieve and modify that. I also would like to know how to include multiple Components into one Path since the Name, Amount and Operation obviously stick together to one Entry in the List.

 

 

EDIT: Nevermind, screw it, I figured it out. I was basically seeing it like the Markup Languages JSON or YML storing Keys and Values with Subpaths, although it is more like a HashMap, anyway, got it working now. Thanks for your help though.

 

I do have one Question though left:

nbt.getTagList(key, type)

 

What does the integer type represent in this method?

 

EDIT: Figured that out as well. Feel free to lock this Thread.

Link to comment
Share on other sites

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.