Jump to content

Merging Tag Compounds?


Recommended Posts

        if (!world.isRemote && this.data != null) {
            NBTTagCompound atag = is.getTagCompound();
            if (atag == null) atag = new NBTTagCompound();
            if (!atag.hasKey(KEY)) {
                atag.setBoolean(KEY, true);
                try {
                    is.getTagCompound().setBoolean(KEY, true);
                } catch (NBTException nbtexception) {
                    LogManager.getLogger(RWBYModels.MODID).error("Couldn't load data tag for " + this.getRegistryName());


atag is the first part of this which is the current data of the item. the portion inside of try is replacing the tag compound from before while this might be all well and good.it doesn't pass along Enchantments which is why I'm curious if there's a way to merge the two data sets rather then completely override the data though I suspect that's not possible just from looking around. though there is this 


which would appear to get a retrievable list of the enchantments in the tagcompound though I'm not sure if there is a way to use that data to reapply the enchantments after the data is wiped. **please keep in mind I am not really familiar with nbt stuff so this all could be entirely wrong and I'm missing a simpler way to do this. but live and learn the reason I'm wiping the data in the first place is because the items have attribute modifiers and I don't want those passed to the new item when they transform however I'd like to keep enchantments if possible.

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.

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.


  • Create New...

Important Information

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