PlayerEx

PlayerEx

5M Downloads

Found another odd conflict with the mod Icarus

githubbingitup opened this issue ยท 6 comments

commented

Hi. Sorry, but I found another one!
Icarus is a flight mod that adds some really awesome wings as trinket accessories and for some reason PlayerEx stops them from working. I also had some trouble with the regular Elytra, but that might have been from some library mods I was troubleshooting with.

Setup:
mc 1.16.5
fabric-api-0.36.0+1.16
playerex-2.0.2-1.16.5
trinkets-2.6.7
icarus-1.2

commented

Hi there,
After taking a look at the source I found the problem: it's an issue with CaelusAPI - it adds an attribute for flight to act as a boolean determining whether elytra flight is possible.

Looking back on these bug reports, I think I've made a bit of an oversight with the design of PlayerEx: any mod that adds an attribute to the player is automatically incompatible unless a datapack entry for that attribute is made. So to solve this issue, either I add one .json file for the flight attribute, or the mod author does, or the end user adds a datapack containing the same .json.

I'll add a fix for this incompatibility in the next update, but in the mean time I think I'm gonna add a note on the curseforge page about how the end user can fix it themselves.

Tl;dr; this likely solvable by adding a datapack entry.

Thanks for the report, I appreciate your consistent testing.

commented

Oh I see!
When you say you'll add a fix - do you mean you'll specifically add support for CaelusAPI or do you mean you plan to rework it so that attributes from other mods aren't disabled?

On a related note I reported a bug for BetterEnd and the mod author thinks that its also due to their custom attribute and PlayerEx so a pretty similar situation. Though I'm not sure why in that case it causes a crash, since with Icarus it simply doesn't work but that might be because of how they are checking to see the attribute and I think they are planning to fix that.

But the page is here if you want to see, so I suppose a good handful of mods may have conflicting attributes.
paulevsGitch/BetterEnd#214

commented

Hi,
So when I said I'll add a fix, all that means is I'll add the necessary json attribute for flight to be included by default in the mod, to save end users having to patch it themselves by using a datapack. I'm almost 100% certain that's the whole issue: just a missing json.

It would be hard to rework the mod again for 1.16.5 so that this wasn't an issue, but I can at least think about a more clever way to implement datadriven attributes for 1.17.

The thing is, attributes in minecraft have two steps to working: step one, register them - this is fine, and PlayerEx doesn't override or remove registered attributes, vanilla nor modded; step two, add the attribute to the desired entity's attribute container (this is where the problem occurs). PlayerEx override's the player's (PlayerEntity) attribute container with one that supports lazy-loading attributes from datapack jsons. This means that only attributes that exist in json form are added to the player's attribute container - so when a mod adds an attribute to the player without including the necessary json to support it, a crash occurs because some code looks for an attribute that the player doesn't have. The fix is nice and easy though: just add the json file - either by external datapack or by including it as default; either by the mod's author or by me.

As for Icarus, the issue is not directly with Icarus, rather its jar-in-jar bundled Caelus API - Caelus API is the mod that adds the flight attribute, and the code that uses it. Regardless of what mod is specifically causing the problem, I'm certain that it's an easy fix; so rather than releasing another version just to patch one json file, I'd instead prefer to wait for more bugs to be discovered so I can get the most out of each release.

commented

Thanks for the very detailed answer!
For adding other mod attributes, do we simply need to add the json file to /playerex/attributes and follow the same layout as as the others?

commented

It's slightly more complicated than just adding to data/playerex/attributes:

So for Caelus API for example, it would be adding the json: data/minecraft/atttributes/caelus.elytra_flight.json. The reason being here; as you can see, there is no modid, which means that the attribute has been registered as a vanilla minecraft attribute, hence the minecraft data folder; and the attribute has been registered using the key caelus.elytra_flight, hence the json naming.

To add attributes for other mods, you need to look into their githubs and find out exactly how they're registering the attribute: you're looking for the namespace (which will usually be either minecraft or their modid), and you're looking for the path (which is whatever they've called their attribute in when registering it). The namespace is the name of the folder data/namespace/, and the path is the name of the json.

As for formatting the json, you'll need a new UUID, which can be done with this website, entering the code:

public class HelloWorld {
    public static void main(String []args){
       System.out.println("" + java.util.UUID.randomUUID());
    }
}

and the rest is generally straight forward using the wiki. Since we're talking about adding attributes for mod compatibility, you don't have to worry about functions.

Hope that helps,
Thanks.

commented

This should now be fixed in v2.0.3.