Keep client-only sub-GUI types out of condition and zone descriptors

Same leak as the ability magic editor: @SideOnly strips the annotated method on a
server but not the synthetic lambdas it generates, so ConditionHasEffect,
ConditionQuestCompleted, AbilityTrap and AbilityZone all shipped methods whose
descriptors named a client-only GUI class. Each field is now built in the GUI
class it belongs to.
This commit is contained in:
KAMKEEL committed 2026-08-11 05:00:02 -04:00
1 parent 466b49db5e
commit 677d50fa03
8 files changed
+104 -49

No files matched your search

@@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.builder.FieldDef;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.SubGuiInterface;
@@ -12,6 +13,25 @@ public class SubGuiZonePresetSelector extends SubGuiInterface {
public String selectedPreset = null;
/**
* Builds the zone editor's preset field.
* <p>
* This lives here rather than in AbilityZone because the lambda below carries this class in
* its method descriptor. AbilityZone is a both-side class, and @SideOnly does not strip the
* synthetic lambda methods it generates - so anything reflecting over its declared methods
* on a server would resolve that descriptor and fail to find this client-only type.
*/
public static FieldDef createPresetField(java.util.function.Consumer<String> applyPreset) {
return FieldDef.subGuiField("gui.applyPreset",
SubGuiZonePresetSelector::new,
gui -> {
SubGuiZonePresetSelector selector = (SubGuiZonePresetSelector) gui;
if (selector.selectedPreset != null) {
applyPreset.accept(selector.selectedPreset);
}
});
}
private static final String[] PRESET_NAMES = {"DEFAULT", "TOXIC", "INFERNO", "ARCANE", "ELECTRIC", "FROST"};
private static final String[] PRESET_LABELS = {
"ability.preset.default", "ability.preset.toxic", "ability.preset.inferno",