Soulbound enchant does not work when Twilight Forest is present
dandin87 opened this issue ยท 5 comments
Describe the bug
Soulbound Enchanted items are voided on death when Twilight Forest mod is present
To Reproduce
- Add Twilight Forest to mods
- Have Soulbound enchanted equipment, then die
- Soulbound items are gone
No errors in the logs. This is technically on TF to fix I assume, but figured I would make you aware of it, and perhaps you could help figure out the issue causing it.
https://github.com/TeamTwilight/twilightforest-fabric/issues/88
Yeah I noticed this in the aof developer discord channel but just didn't have time to check on it until now. The soulbound items are readded to the player inventory in ServerPlayerEntityMixin.java. I did try to take a deeper look at this but I'm not sure how much I actually have managed to uncover so far. I found that this will not happen if the player is in creative mode for some reason. The item is also deleted after my mod is done handling the respawn event, so yes I would assume this is on twilight fabrics side as well.
Could also help to mention that I mixin into the same method that handle teleportation from the end to overworld, however with a check if the player is dead or alive. I don't think that would have anything to do with the issue but might as well mention it in case it would for some reason.
Other than that this is pretty much all I have so far. I don't really know exactly why this happens. I haven't read the twilight fabric source that carefully, just noticed there were no server side mixins that I could find. I will post any update here if I find anything else I think could be useful
Phantom Chesteplate, Is never lost on death. I'm not sure where the logic for this is, but it seems highly likely this might be the conflicting issue.
https://github.com/TeamTwilight/twilightforest-fabric/blob/1.18.new/src/main/java/twilightforest/item/PhantomArmorItem.java
Ah I think twilight is doing something similar to what I do then. Clearing the inventory and applying the items that should be kept (by this mod). At least I think this is what's happening but I don't know since I can't find this in twilight fabric's source at the moment. I could take a look and see if there is a way for me to disable this twilight feature when it's loaded, and also include the phantom armor in the soulbound items tag provided by my mod. I guess AlphaMode could do this as well, or implement a similar solution, but if not I'm happy to. Can't get on my computer to do this until in about a two days from now though.
I found where the issue came from by the way. Here twilight will read from stored NBT data and replace the inventory with what the mod stored itself (using the load
method). That's why items stored by my mod as soulbound will disappear. In other words it's confirmed twilight forest causes this issue. The 1.19 version seems to have fixed this, however not the 1.18 version. So I made a mixin on my side that will do what the 1.19 version of twilight does, but if AlphaMode decides to fix it themselves for 1.18 I will remove my mixin.
The mixin seems to be working however, and I'll try to release the update the coming week.