Infamous-Misadventures / Dungeons-Libraries

MIT License
6 stars 4 forks source link

[1.19.2-3.0.9-beta][compability] "caps" tag (BuiltInEnchantments) #35

Closed tabr closed 8 months ago

tabr commented 1 year ago

This mod add a tag to any taken item:

caps: { "dungeons_libraries:built_in_enchantments": { BuiltInEnchantments: [] }

So AE2 can't be used - items doubled(with tag and without). Is there any way to fix this?

For example add this tag only while enchanting?

Random832 commented 1 year ago

To clarify things, the problem as described by the user on the AE2 discord is that the tag [and possibly the capability provider, it's not clear if this is an attachment issue or a serialization issue] is somehow being attached only to items that have been in the player's inventory and not e.g. to machine outputs of the same item that are directly imported into the AE system.

tabr commented 1 year ago

mod BuildingGadgets doesn't work too.

Random832 commented 1 year ago

On further investigation:

The capability tag attaches to any items that are in a player's inventory for any reason It does not attach to freshly spawned item entities with /summon It does attach to items thrown out of a player's inventory When items are collected by a hopper they have the tag only if the item entity already had the tag When transferred by a hopper to a container, the stack in the chest gets the tag, even if the one in the hopper did not have the tag. When a GUI is opened, the tag is added to the itemstacks in the container block's inventory, even if the player does not do anything. When a stack in a dropper does not have the tag, it is not applied either to an item thrown out of the dropper, or to the stack remaining in the dropper

Random832 commented 1 year ago

Confirmed with no other mods. Confirmed to be the cause of #6 [when the building gadget is bound to a container that contains an "uncontaminated" itemstack, the preview no longer turns red, but it still cannot place blocks]

Patrigan commented 1 year ago

It has something to do with how Forge serializers this nonsense, but it is incredibly unclear what exactly is causing it. Investigating.

Patrigan commented 1 year ago

I will be releasing a new version 3.0.10-beta. I am now giving forge a completely empty nbt, I used to give it an nbt with an empty list for the enchants. I hope this could fix it already.

I also personally think these other mods might be doing somnething that is incompatible with forge their tagging system. Basically, the tag should be on EVERY item (because I can not check for enchantability, due to a looping issue with another mod)

Patrigan commented 1 year ago

To be clear, unsure if this is an actual fix...

tabr commented 1 year ago

my fix was (but i didn't test all mod features) //forgeBus.addGenericListener(ItemStack.class, AttacherBuiltInEnchantments::attach); ... //event.register(BuiltInEnchantments.class);

https://pastebin.com/KZbvMW5Q

Patrigan commented 1 year ago

Well, basically now you removed BuiltInEnchantments... That does not seem like a real solution....

dje4321 commented 1 year ago

Tested commit 2496bc49fd7dafa5e0cd67faef06621f9a947f6e to resolve #35. Can confirm issue is not resolved by this commit

Dumping NBT data from the player containing a meta-inventory from AE2 shows the difference between an item AE2 will recognize and one it will not

"Inventory":[
      {
         "Slot":0b,
         "ForgeCaps":{
            "dungeons_libraries:built_in_enchantments":{

            }
         },
         "id":"ae2:item_storage_cell_256k",
         "Count":1b,
         "tag":{
            "keys":[
               {
                  "#c":"ae2:i",
                  "id":"ae2:certus_quartz_crystal"
               },
               {
                  "#c":"ae2:i",
                  "id":"ae2:certus_quartz_crystal",
                  "caps":{
                     "dungeons_libraries:built_in_enchantments":{

                     }
                  }
               }
            ],
            "amts":[
               L; 12L,
               4L
            ],
            "ic":16L
         }
      }
   ]

As you can see by the NBT data, the mod tagging the item with "caps":{"dungeons_libraries:built_in_enchantments":{} and is preventing other mods from being able to identify items.

Specifically, Line 48 of AttacherBuiltInEnchantments.java is whats most likely going to be causing this issue to occur. Not familiar enough with java coding or Modded development to propose a real solution here but Ill update this thread if I find anything else

Patrigan commented 1 year ago

Basically, the line you are talking about makes it possible for an item to have a built-in enchantment. Deleting that line no longer makes it possible.

So that is not the right solution.

I am very interested in what AE2 does, I feel like they are creating copies, without calling forge their capability code. In theory, all itemstacks created as you normally would, should have the tag.

Have you tried reporting this to the AE2 team?

cplir-c commented 1 year ago

com.infamous.dungeons_libraries.items#onAttachItemStackCapabilities(AttachCapabilitiesEvent)

that would be the line doing it, you could suggest the mod author to change it so it only happens to items that can be enchanted by the dungeon suite - mayo the silly, AE2 discord, as to "why some stacks have it and others wouldn't" https://discord.com/channels/922828438274986004/922828438274986007/1077472964401975417

Does it only happen to items with a stack size of more than 1?

One example of an unenchanted diamond item in a barrel's NBT data

Thelnfamous1 commented 1 year ago

I suppose as a quick fix, we could limit it to items that have a max stack size of 1 and/or is damageable

adamantii commented 1 year ago

I am very interested in what AE2 does, I feel like they are creating copies, without calling forge their capability code. In theory, all itemstacks created as you normally would, should have the tag.

I ran into this issue while using an AE2 auto-crafting setup, I looked at the NBT and saw that the tag does get attached to items created by AE2, but since it makes items unidentifiable by other mods it doesn't stop the crafting process

JLC-Gaming commented 1 year ago

I saw it was mentioned above, I'm having the mentioned issues with Building Gadgets, is there any sort of temporary solution or wait for a fix?

Currently running v3.0.10-beta

Darkmega18 commented 1 year ago

So has this been worked out? I've just run slap into this bug for the builders gadget also. I'm ever so slightly miffed that you guys have been making so many bugs for me lately. >_<' that forge cap stuff makes it kinda annoying to edit down nbtdata for various datapack and loot related things too...

dje4321 commented 1 year ago

So has this been worked out? I've just run slap into this bug for the builders gadget also. I'm ever so slightly miffed that you guys have been making so many bugs for me lately. >_<' that forge cap stuff makes it kinda annoying to edit down nbtdata for various datapack and loot related things too...

You'll need to apply the #43 PR to resolve the bug

Thelnfamous1 commented 8 months ago

Fixed by #43