Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built Fabric jar using incorrect refmap #43

Open
ejektaflex opened this issue Feb 28, 2024 · 7 comments
Open

Built Fabric jar using incorrect refmap #43

ejektaflex opened this issue Feb 28, 2024 · 7 comments

Comments

@ejektaflex
Copy link

When I try to build my JAR file for Fabric, I get this error:

 Mixin apply for mod kambrik failed kambrik.mixins.json:StructurePoolAccessor from mod kambrik -> net.minecraft.class_3785: org.spongepowered.asm.mixin.gen.throwables.InvalidAccessorException No candidates were found matching elements:Lit/unimi/dsi/fastutil/objects/ObjectArrayList; in net/minecraft/class_3785 for kambrik.mixins.json:StructurePoolAccessor from mod kambrik->@Accessor[FIELD_GETTER]::getElements()Lit/unimi/dsi/fastutil/objects/ObjectArrayList; [INJECT Applicator Phase -> kambrik.mixins.json:StructurePoolAccessor from mod kambrik -> Apply Accessors ->  -> Locate -> kambrik.mixins.json:StructurePoolAccessor from mod kambrik->@Accessor[FIELD_GETTER]::getElements()Lit/unimi/dsi/fastutil/objects/ObjectArrayList;]

StructurePoolAccessor is a Mixin in Kambrik, my mod.

I noticed that the .jar file contains a Kambrik-common-refmap.json. It's unused in kambrik.mixins.json. If I add the following line to kambrik.mixins.json:

	"refmap": "Kambrik-common-refmap.json"

The mod will launch successfully. As such, it seems that refmaps aren't being linked properly. I don't know much about how refmaps work, or how they're supposed to work, but this is what seems to be happening. It happens with ArchLoom 1.4-SNAPSHOT and 1.5-SNAPSHOT.

@Juuxel
Copy link
Member

Juuxel commented Feb 28, 2024

Do you have Architectury Plugin installed? It should fix this issue, which really isn't a Loom issue (the mixin config is in the common Gradle project, so its refmap property would need to be added in :common:remapJar, which isn't run here due to the project structure).

@ejektaflex
Copy link
Author

What would I have to set in my remapJar task?
Here is my current remapJar, but it doesn't run for common:
https://github.com/ejektaflex/Bountiful/blob/96f85f641b2d0c42f7de77834482deaee21789e3/build.gradle.kts#L111

@Juuxel
Copy link
Member

Juuxel commented Feb 28, 2024

You can't fix it by tweaking remapJar settings since remapJar only does the refmap name adding for a mixin config from the current Gradle project. Architectury Plugin does it separately with its custom task.

The easiest solutions are using Architectury Plugin (in compile-only mode if needed) or specifying the refmap name manually in the mixin config.

@ejektaflex
Copy link
Author

Cool, I've fixed this by doing:

loom {
    mixin {
        defaultRefmapName.set("Bountiful-common-refmap.json")
    }
}

Do you have an example of how this is done using Architectury Plugin? I'm depending on it in my gradle setup, but I don't exactly know how to utilize it.

Thanks so much!

@Juuxel
Copy link
Member

Juuxel commented Feb 28, 2024

If you include the common classes in the Fabric jar by bundling :common's transformProductionFabric configuration, it'll apply the transformers. Example from Arch API's code:
https://github.com/architectury/architectury-api/blob/cd74016d85b562affb21890cb8796b1e34ac2ca9/fabric/build.gradle#L33

@ejektaflex
Copy link
Author

It's my understanding that I'm already doing this. Could the problem arise because I'm not including transitive dependencies?

My code: https://github.com/ejektaflex/Bountiful/blob/d6e52965fc5b631e2160534f4fa83ccc63104b49/fabric/build.gradle.kts#L50C1-L50C114

@Juuxel
Copy link
Member

Juuxel commented Mar 1, 2024

No, I don't think it affects anything since that project dependency won't even have any transitive deps. As far as I can tell, the code should already work 🤔

I also don't think this is directly related to Loom, so I'm moving the issue to Arch Plugin's repo.

@Juuxel Juuxel transferred this issue from architectury/architectury-loom Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants