Keep client-only sub-GUI types out of Ability's method descriptors

The magic editor field was built with lambdas inside Ability.getAllDefinitions.
subGuiField is generic, so those lambdas took SubGuiAbilityMagic as their
descriptor type. @SideOnly strips the annotated method on a server but not the
synthetic lambdas it generates, so anything reflecting over Ability's declared
methods - Nashorn's adapter generator when a script touches an ability - hit
NoClassDefFoundError. Building the field in the client class keeps the type out
of Ability entirely.
This commit is contained in:
KAMKEEL committed 2026-08-11 04:44:14 -04:00
1 parent c79f5998d6
commit dedbe94cd8
2 files changed
+28 -13

No files matched your search

@@ -840,19 +840,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
return sb.toString();
}).tab("General"));
defs.add(FieldDef.subGuiField("ability.magic.editor",
() -> new SubGuiAbilityMagic(magicData.copy()),
gui -> {
MagicData result = ((SubGuiAbilityMagic) gui).magicData;
magicData.getMagics().clear();
for (Map.Entry<Integer, MagicEntry> e : result.getMagics().entrySet()) {
magicData.getMagics().put(e.getKey(), e.getValue());
}
})
.buttonLabel(() -> magicData.isEmpty()
? StatCollector.translateToLocal("ability.magic.usesCaster")
: magicData.getMagics().size() + " Magic(s)")
.tab("General"));
defs.add(SubGuiAbilityMagic.createMagicField(magicData));
}
// ── Target tab ───────────────────────────────────────────────