Astral Sorcery

Astral Sorcery

63M Downloads

NBT Tags Added, Won't Dissapear, REF1334

desagas opened this issue ยท 6 comments

commented

This similar issue is now in 1.16.4 in AS 1.13.8. See #1334, but not for items that do not normally have nbt data.

Essentially, every single weapon, tool, or armour that you touch with your main hand or body will have the AS_Amulet_holder NBT tag attached to it. While above, it was said that the tag is removed when removed from the main hand, this is not the case in 1.16.4.1.13.8. The tag does not get removed, and thus makes sorting anything into anything like drawers impossible, without touching everything single one of the objects, like swords from wither skelies, or what have you.

If it is intended, it hinders sortability, even if the amulet affects are good. I really wish it would only have the tag when used or held. Because each and every item I touch adds the exact same tag, numbers and all, and, if i remember correct, all gems are added in the perk tree for the individual players, is it not possible to have this attached to the player, and not the objects?

commented

The issue here being the inability to track itemstacks.
I cannot safely determine which player holds a given itemstack and thus i cannot add enchantments based off of the equipment or other things of that player.
As a result, i have to add the player's UUID onto the item so i can be sure it definitely is/isn't that player and thus make it behave accordingly.

Additionally, i cannot determine when an itemstack leaves an inventory or when it gets added to one, as the concept of inventories isn't well defined alltogether and no events are associated to that that'd allow for removal/addition of such data when being removed/added to an "inventory".

However, if the item is put from the active hotbar slot into another slot in the player's inventory, the Tag does get removed. If you place it from the active hotbar slot (or any other equipment-slot, so helmet, chestplate, legging, boots, offhand, mainhand, for that matter) into another inventory, i just don't have a way of tracking that itemstack and thus have no way of removing the tag again. This isn't something i can fix either as it is a conceptual issue in minecraft's codebase.

Also, i cannot have that "attached to the player" as i'm only able to work off of a arbitrary itemstack. I don't even know if the player is holding/wearing that item at the moment of inspection.
So let's say you're looking at a itemstack in a chest, for example trying to look at its tooltip to see its enchantments.
I only have that itemstack as data i can work with. Currently, i then check if the itemstack has a player UUID attached to it in its NBT data, if so, i try get that online player with that UUID. If one exists, i check if any gearpiece the player has equipped or is holding matches with the itemstack in question. That way i can find out if that itemstack is actually currently held by the player or not. If all of that is the case, i can safely run code that'll add enchantments dynamically and thus ensure the functionality of the resplendent prism and perk effects.
So the critical point here is trying to make a connection from (any) itemstack to the player who might be holding that itemstack. And that cannot be achieved unless i add data that helps me determine that player to the itemstack.

Unfortunately, as for potentially more tech savvy java developers who come across this, no i cannot work with object references either as the itemstack object used for querying enchantment data and the like is copied multiple times, so the actual reference itself isn't the same.

And this functionality has nothing to do with gems added in the perk tree.

commented

@HellFirePvP : Alright, i fixed the error, whether or not it creates another issue for something else, I am not sure.

In NBTHelper, from 356 to 359, there are extended words added to the tags that you are trying to remove. The words "most/least" prevent the nbt tags from matching, and thus, being removed. When removing these additional words, as well as commenting out the duplicate line, the nbt tag is removed, as you have describe previously.

Here is my PR: #1604

commented

If the item is put from the active hotbar slot into another slot in the player's inventory, the Tag does get removed.

While I appreciate your reply, Im sorry, but as much as you may think the the tag get removed, it does not. Below is the pudding: This is what I did to make this happen, which is identical to the packs I am playing:

This is what I did.

  1. I installed forge 1.16.4..13, the latest Astral, and JEI. Nothing more.
  2. I gave myself, in Survival, a diamond sword and a diamond chest plate.
  3. I put them on my hotbar, and scroll to make them main hand, and NBT instantly bumps to 2, which is because the AS_AMULET tag is added.
  4. I tried all of the following steps to remove it ...
  • A. scrolling mainhand off of sword or chst plate ... nope, nbt tag still there.
  • B. Shift clicking the sword and chestplate into my main inventory off of the hotbar ... nope, still there.
  • C. Manually dragging the sword and chestplate into my main inventory off of my hotbar ... nope, still there.
  • D. Identical to B and C above, but when sword or chestplate is in main hand ... nope, still there.
  • E. Throwing sword and chestplate on ground from main hand ... nope, still there.

You can see the remaining tags in hotbar and main inventory, for every single method listed above, it is the same. Not one of the slots listed is my main hand.

Screen Shot 2020-12-27 at 12 20 53 PM

So, I am curious, none of the methods I have tried above are removing the tag when being taking out of the main hand, when placed elsewhere in my personal player inventory ... how are you making it remove the tag?

As for the codebase which you referenced, you are doing a check to see if nbt tag already exists, before adding it again, are you not, to prevent duplicated nbt? Or is this just something that the game wont allow, to write the exact same nbt tag to an item twice? It seems strange that you would not be able to a check for that tag, and remove it. I'm going to try and do a bit of research into this, and see if I cant figure it out.

Thanks for any help.

commented

Is there a way to have a grindstone remove such a tag? Or is this an enchant remover thing only?

commented

Just to note, that this amulet NBT thing also breaks every recipe which requires specific NBT on an item.

commented

Ah. seems like the format how minecraft stores/loads UUIDs has changed.

That doesn't negate the problems this has overall conceptually, but at least fixes getting rid of the tag again.