diff --git a/dependencies.gradle b/dependencies.gradle index 5f8f40b1e..287ae0e20 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -38,6 +38,9 @@ dependencies { runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev") runtimeOnlyNonPublishable("curse.maven:Nashorn-374413:2924946") +// compileOnly(files("./tools/bukkit-api/spigot-api-ONLY.jar")) +// compileOnly(files("./tools/bukkit-api/Vault-1.4.1.jar")) + shadowImplementation(project.files("tools/standalone-JaninoLoader-1.0.1-ALPHA.jar")) annotationProcessor(project.files("tools/standalone-JaninoLoader-1.0.1-ALPHA.jar")) diff --git a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java index cce9bbe58..2ba840aec 100644 --- a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java +++ b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java @@ -31,6 +31,7 @@ public abstract class RenderAbilityProjectile extends Render { */ protected void setupRenderState() { GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_ALPHA_TEST); @@ -48,9 +49,7 @@ public abstract class RenderAbilityProjectile extends Render { * Restore GL state after rendering. */ protected void restoreRenderState() { - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopAttrib(); GL11.glPopMatrix(); } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java index f7325a24f..007e4f2f4 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java @@ -29,10 +29,14 @@ import noppes.npcs.scripted.NpcAPI; import noppes.npcs.scripted.event.AbilityEvent; import noppes.npcs.scripted.event.player.PlayerAbilityEvent; +import noppes.npcs.client.gui.builder.FieldDef; + import java.util.ArrayList; +import java.util.Collections; import java.util.List; import net.minecraft.entity.Entity; +import somehussar.gui.annotationHandling.GuiEditable; public abstract class Ability implements IAbility { @@ -57,8 +61,8 @@ public abstract class Ability implements IAbility { // Timing (ticks) protected int cooldownTicks = 0; // Added to global cooldown after ability completes protected int windUpTicks = 20; - protected int dazedTicks = 80; // Only used when interrupted during WINDUP (if interruptible) protected boolean syncWindupWithAnimation = true; + protected int dazedTicks = 80; // Only used when interrupted during WINDUP (if interruptible) // Interruption protected boolean interruptible = true; @@ -337,19 +341,123 @@ public abstract class Ability implements IAbility { } /** - * Returns true if this ability type has custom settings that need a Type-specific tab. - * Override to return true if the ability has settings beyond the base Ability fields. + * Returns the declarative field definitions for this ability's GUI. + * Override in subclasses to declare type-specific and visual fields. + * The GUI rendering engine in SubGuiAbilityConfig uses this list to + * automatically build the Type and Visual tabs. */ - public boolean hasTypeSettings() { - return false; + @SideOnly(Side.CLIENT) + public List getFieldDefinitions() { + return Collections.emptyList(); } /** - * Get the number of rows needed for type-specific settings in the GUI. - * Each row is approximately 24 pixels. Used for GUI layout. + * Returns field definitions for all base Ability fields (General, Target, Effects tabs). */ - public int getTypeSettingsRowCount() { - return 0; + @SideOnly(Side.CLIENT) + public List getBaseFieldDefinitions() { + List defs = new ArrayList<>(); + + // General tab + defs.add(FieldDef.stringField("gui.name", this::getName, this::setName) + .tab("General")); + defs.add(FieldDef.row( + FieldDef.intField("ability.weight", this::getWeight, this::setWeight).range(1, 1000), + FieldDef.boolField("gui.enabled", this::isEnabled, this::setEnabled) + ).tab("General")); + defs.add(FieldDef.section("ability.section.timing").tab("General")); + // WindUp: 3 mutually exclusive entries based on animation/sync state + defs.add(FieldDef.intField("ability.windUpTicks", this::getRawWindUpTicks, this::setWindUpTicks) + .tab("General").range(0, 1000) + .visibleWhen(() -> !hasWindUpAnimation())); + defs.add(FieldDef.row( + FieldDef.intField("ability.windUpTicks", this::getRawWindUpTicks, this::setWindUpTicks).range(0, 1000), + FieldDef.boolField("ability.syncWindup", this::isSyncWindupWithAnimation, this::setSyncWindupWithAnimation) + .hover("ability.hover.sync") + ).tab("General").visibleWhen(() -> hasWindUpAnimation() && !isSyncWindupWithAnimation())); + defs.add(FieldDef.row( + FieldDef.labelField("ability.windUpTicks", () -> getWindUpTicks() + "t"), + FieldDef.boolField("ability.syncWindup", this::isSyncWindupWithAnimation, this::setSyncWindupWithAnimation) + .hover("ability.hover.sync") + ).tab("General").visibleWhen(() -> hasWindUpAnimation() && isSyncWindupWithAnimation())); + defs.add(FieldDef.intField("ability.cooldownTicks", this::getCooldownTicks, this::setCooldownTicks) + .tab("General").range(0, 10000)); + defs.add(FieldDef.section("ability.section.movement").tab("General")); + defs.add(FieldDef.stringEnumField("ability.lockMovement", LockMovementType.getDisplayKeys(), + () -> this.getLockMovement().getDisplayKey(), + v -> { + String[] keys = LockMovementType.getDisplayKeys(); + for (int i = 0; i < keys.length; i++) { + if (keys[i].equals(v)) { this.setLockMovement(LockMovementType.fromOrdinal(i)); break; } + } + }) + .tab("General").hover("ability.hover.lockMove")); + defs.add(FieldDef.row( + FieldDef.boolField("ability.interruptible", this::isInterruptible, this::setInterruptible) + .hover("ability.hover.interruptible"), + FieldDef.intField("ability.dazedTicks", this::getDazedTicks, this::setDazedTicks) + .range(0, 1000).visibleWhen(this::isInterruptible) + ).tab("General")); + + // Target tab + defs.add(FieldDef.row( + FieldDef.intField("ability.minRange", () -> (int) getMinRange(), v -> setMinRange(v)).range(0, 100), + FieldDef.intField("ability.maxRange", () -> (int) getMaxRange(), v -> setMaxRange(v)).range(1, 100) + ).tab("Target")); + if (!isTargetingModeLocked()) { + defs.add(FieldDef.enumField("ability.targetingMode", TargetingMode.class, + this::getTargetingMode, this::setTargetingMode) + .tab("Target").hover("ability.hover.targeting")); + } + + // Effects tab - Sounds + defs.add(FieldDef.section("ability.section.sounds").tab("Effects")); + defs.add(FieldDef.soundSubGui("ability.windUpSound", this::getWindUpSound, this::setWindUpSound) + .tab("Effects")); + defs.add(FieldDef.soundSubGui("ability.activeSound", this::getActiveSound, this::setActiveSound) + .tab("Effects")); + // Effects tab - Animations + defs.add(FieldDef.section("ability.section.animations").tab("Effects")); + defs.add(FieldDef.animSubGui("ability.windUpAnimation", + this::getWindUpAnimationId, this::setWindUpAnimationId, + this::getWindUpAnimationName, this::setWindUpAnimationName) + .tab("Effects")); + defs.add(FieldDef.animSubGui("ability.activeAnimation", + this::getActiveAnimationId, this::setActiveAnimationId, + this::getActiveAnimationName, this::setActiveAnimationName) + .tab("Effects")); + + // Effects tab - Telegraph + TelegraphType tType = getTelegraphType(); + if (tType != null && tType != TelegraphType.NONE) { + defs.add(FieldDef.section("ability.section.telegraph").tab("Effects") + .hover("telegraph." + tType.name().toLowerCase())); + defs.add(FieldDef.boolField("ability.showTelegraph", this::isShowTelegraph, this::setShowTelegraph) + .tab("Effects").hover("ability.hover.showTelegraph")); + defs.add(FieldDef.colorSubGui("ability.windUpColor", this::getWindUpColor, this::setWindUpColor) + .tab("Effects").visibleWhen(this::isShowTelegraph)); + defs.add(FieldDef.colorSubGui("ability.activeColor", this::getActiveColor, this::setActiveColor) + .tab("Effects").visibleWhen(this::isShowTelegraph)); + } + + return defs; + } + + /** + * Returns ALL field definitions: base (General/Target/Effects) + type-specific (Type/Visual). + */ + @SideOnly(Side.CLIENT) + public final List getAllFieldDefinitions() { + List all = new ArrayList<>(getBaseFieldDefinitions()); + List typeDefs = getFieldDefinitions(); + // Default tab for type-specific fields that don't explicitly set one + for (FieldDef def : typeDefs) { + if (def.getTab() == null) { + def.tab("Type"); + } + } + all.addAll(typeDefs); + return all; } /** @@ -805,6 +913,7 @@ public abstract class Ability implements IAbility { nbt.setFloat("maxRange", maxRange); nbt.setInteger("cooldown", cooldownTicks); nbt.setInteger("windUp", windUpTicks); + nbt.setBoolean("syncWindup", syncWindupWithAnimation); nbt.setInteger("recovery", dazedTicks); nbt.setBoolean("interruptible", interruptible); nbt.setInteger("lockMovement", lockMovement.ordinal()); @@ -854,6 +963,7 @@ public abstract class Ability implements IAbility { maxRange = nbt.getFloat("maxRange"); cooldownTicks = nbt.getInteger("cooldown"); windUpTicks = nbt.getInteger("windUp"); + syncWindupWithAnimation = !nbt.hasKey("syncWindup") || nbt.getBoolean("syncWindup"); dazedTicks = nbt.getInteger("recovery"); interruptible = nbt.getBoolean("interruptible"); lockMovement = LockMovementType.fromOrdinal(nbt.getInteger("lockMovement")); @@ -974,13 +1084,29 @@ public abstract class Ability implements IAbility { } public int getWindUpTicks() { - return this.calculateWindupFromAnimation(); + return calculateWindupFromAnimation(); + } + + public int getRawWindUpTicks() { + return windUpTicks; } public void setWindUpTicks(int windUpTicks) { this.windUpTicks = Math.max(0, windUpTicks); } + public boolean isSyncWindupWithAnimation() { + return syncWindupWithAnimation; + } + + public boolean hasWindUpAnimation() { + return (windUpAnimationName != null && !windUpAnimationName.isEmpty()) || windUpAnimationId >= 0; + } + + public void setSyncWindupWithAnimation(boolean syncWindupWithAnimation) { + this.syncWindupWithAnimation = syncWindupWithAnimation; + } + public int getDazedTicks() { return dazedTicks; } @@ -989,14 +1115,6 @@ public abstract class Ability implements IAbility { this.dazedTicks = Math.max(0, dazedTicks); } - public boolean isSyncWindupWithAnimation() { - return syncWindupWithAnimation; - } - - public void setSyncWindupWithAnimation(boolean syncWindupWithAnimation) { - this.syncWindupWithAnimation = syncWindupWithAnimation; - } - public boolean isInterruptible() { return interruptible; } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityEffect.java b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityEffect.java index 47e03f10d..57f0cbf17 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityEffect.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityEffect.java @@ -38,6 +38,13 @@ public class AbilityEffect { return potionId; } + public static String[] getLangKeys() { + EffectType[] types = values(); + String[] keys = new String[types.length]; + for (int i = 0; i < types.length; i++) keys[i] = types[i].langKey; + return keys; + } + public static EffectType fromOrdinal(int ordinal) { EffectType[] values = values(); if (ordinal >= 0 && ordinal < values.length) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/AnchorPoint.java b/src/main/java/kamkeel/npcs/controllers/data/ability/AnchorPoint.java index 01100c318..1c308493c 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/AnchorPoint.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/AnchorPoint.java @@ -45,4 +45,17 @@ public enum AnchorPoint { } return names; } + + @Override + public String toString() { + switch (this) { + case FRONT: return "ability.anchor.front"; + case CENTER: return "ability.anchor.center"; + case RIGHT_HAND: return "ability.anchor.rightHand"; + case LEFT_HAND: return "ability.anchor.leftHand"; + case ABOVE_HEAD: return "ability.anchor.aboveHead"; + case CHEST: return "ability.anchor.chest"; + default: return name(); + } + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java b/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java index bd1bb6a47..9bdbdac6f 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java @@ -22,5 +22,16 @@ public enum TargetingMode { /** * AOE centered on target */ - AOE_TARGET + AOE_TARGET; + + @Override + public String toString() { + switch (this) { + case AGGRO_TARGET: return "ability.target.aggro_target"; + case SELF: return "ability.target.self"; + case AOE_SELF: return "ability.target.aoe_self"; + case AOE_TARGET: return "ability.target.aoe_target"; + default: return name(); + } + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java new file mode 100644 index 000000000..5edd0a718 --- /dev/null +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java @@ -0,0 +1,180 @@ +package kamkeel.npcs.controllers.data.ability.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import kamkeel.npcs.controllers.data.ability.AbilityEffect; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import noppes.npcs.client.gui.builder.FieldDef; +import noppes.npcs.client.gui.builder.FieldType; +import noppes.npcs.client.gui.builder.GuiFieldBuilder; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.GuiNpcTextField; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Ability-specific extension of {@link GuiFieldBuilder} that handles + * the EFFECTS_LIST field type. + */ +@SideOnly(Side.CLIENT) +public class AbilityFieldBuilder extends GuiFieldBuilder { + + // Effects list metadata: widgetId -> [effectIndex, action] + // action: 0=type, 1=duration(text), 2=amp, 3=delete, 4=add + private final Map effectWidgetMeta = new HashMap<>(); + + public AbilityFieldBuilder(GuiNPCInterface parent, FontRenderer fontRenderer) { + super(parent, fontRenderer); + } + + @Override + protected int build(List fields) { + effectWidgetMeta.clear(); + return super.build(fields); + } + + @Override + protected int buildField(FieldDef def, int y, List fields, int index) { + if (def.getType() == FieldType.EFFECTS_LIST) { + return renderEffectsList(def, y); + } + return -1; // not handled + } + + @SuppressWarnings("unchecked") + private int renderEffectsList(FieldDef def, int y) { + // Section header + y += 3; + sw.addLabel(new GuiNpcLabel(labelId++, def.getLabel(), colLLabel, y + 2, 0xFFFF55)); + y += 15; + + List effects = (List) def.getValue(); + if (effects == null) effects = new ArrayList<>(); + + String[] typeNames = AbilityEffect.EffectType.getLangKeys(); + String[] ampValues = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}; + + for (int e = 0; e < effects.size() && e < 5; e++) { + AbilityEffect effect = effects.get(e); + + // Type selector button + int typeIdx = effect.getType().ordinal(); + GuiNpcButton typeBtn = new GuiNpcButton(widgetId, colLLabel, y, 100, 20, typeNames, typeIdx); + sw.addButton(typeBtn); + buttonFieldMap.put(widgetId, def); + effectWidgetMeta.put(widgetId, new int[]{e, 0}); + widgetId++; + + // Duration text field + GuiNpcTextField durField = new GuiNpcTextField(widgetId, parent, fontRenderer, + colLLabel + 104, y, 50, 20, String.valueOf(effect.getDurationTicks())); + durField.setIntegersOnly(); + durField.setMinMaxDefault(1, 12000, 60); + sw.addTextField(durField); + textFieldMap.put(widgetId, def); + effectWidgetMeta.put(widgetId, new int[]{e, 1}); + widgetId++; + + // Amplifier selector (0-10) + GuiNpcButton ampBtn = new GuiNpcButton(widgetId, colLLabel + 158, y, 40, 20, ampValues, effect.getAmplifier()); + sw.addButton(ampBtn); + buttonFieldMap.put(widgetId, def); + effectWidgetMeta.put(widgetId, new int[]{e, 2}); + widgetId++; + + // Delete button + GuiNpcButton delBtn = new GuiNpcButton(clearId, colLLabel + 202, y, 20, 20, "X"); + sw.addButton(delBtn); + clearFieldMap.put(clearId, def); + effectWidgetMeta.put(clearId, new int[]{e, 3}); + clearId++; + + y += rowHeight; + } + + // Add button (if < 5 effects) + if (effects.size() < 5) { + GuiNpcButton addBtn = new GuiNpcButton(widgetId, colLLabel, y, 50, 20, "gui.add"); + sw.addButton(addBtn); + buttonFieldMap.put(widgetId, def); + effectWidgetMeta.put(widgetId, new int[]{effects.size(), 4}); + widgetId++; + clearId++; + y += rowHeight; + } + + return y; + } + + // ═══════════════════════════════════════════════════════════════════ + // EVENT HANDLING OVERRIDES + // ═══════════════════════════════════════════════════════════════════ + + @Override + @SuppressWarnings("unchecked") + public boolean handleButtonEvent(int buttonId, GuiButton button) { + // Check effects list buttons via metadata + int[] meta = effectWidgetMeta.get(buttonId); + if (meta != null) { + FieldDef def = buttonFieldMap.get(buttonId); + if (def == null) def = clearFieldMap.get(buttonId); + if (def != null && def.getType() == FieldType.EFFECTS_LIST) { + List effects = (List) def.getValue(); + if (effects == null) return false; + int effectIdx = meta[0]; + int action = meta[1]; + + switch (action) { + case 0: // Type changed + if (effectIdx < effects.size()) { + effects.get(effectIdx).setType(AbilityEffect.EffectType.fromOrdinal(((GuiNpcButton) button).getValue())); + } + return true; + case 2: // Amp changed + if (effectIdx < effects.size()) { + effects.get(effectIdx).setAmplifier(((GuiNpcButton) button).getValue()); + } + return true; + case 3: // Delete + if (effectIdx < effects.size()) { + effects.remove(effectIdx); + } + return true; + case 4: // Add + if (effects.size() < 5) { + effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0)); + } + return true; + } + } + } + + return super.handleButtonEvent(buttonId, button); + } + + @Override + @SuppressWarnings("unchecked") + public boolean handleTextFieldEvent(int textFieldId, GuiNpcTextField field) { + int[] meta = effectWidgetMeta.get(textFieldId); + if (meta != null && meta[1] == 1) { // duration field + FieldDef def = textFieldMap.get(textFieldId); + if (def != null && def.getType() == FieldType.EFFECTS_LIST) { + List effects = (List) def.getValue(); + if (effects != null && meta[0] < effects.size()) { + effects.get(meta[0]).setDurationTicks(field.getInteger()); + } + return true; + } + } + + return super.handleTextFieldEvent(textFieldId, field); + } + + public Map getEffectWidgetMeta() { return effectWidgetMeta; } +} diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldDefs.java b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldDefs.java new file mode 100644 index 000000000..bc1dc9ab8 --- /dev/null +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldDefs.java @@ -0,0 +1,26 @@ +package kamkeel.npcs.controllers.data.ability.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import kamkeel.npcs.controllers.data.ability.AbilityEffect; +import noppes.npcs.client.gui.builder.FieldDef; +import noppes.npcs.client.gui.builder.FieldType; + +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; + +/** + * Ability-specific FieldDef factories. These create FieldDef instances + * with types that require ability-specific rendering (e.g. EFFECTS_LIST). + */ +@SideOnly(Side.CLIENT) +public class AbilityFieldDefs { + + @SuppressWarnings("unchecked") + public static FieldDef effectsListField(String label, Supplier> getter, Consumer> setter) { + return FieldDef.custom(label, FieldType.EFFECTS_LIST, + () -> getter.get(), + v -> setter.accept((List) v)); + } +} diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeamDual.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeamDual.java index 54c806604..955fa1a42 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeamDual.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeamDual.java @@ -7,6 +7,8 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.ability.data.*; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; @@ -17,12 +19,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityBeamDual; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.ValueUtil; +import java.util.Arrays; +import java.util.List; + public class AbilityBeamDual extends Ability { private float beamWidth = 0.4f; private float headSize = 0.6f; @@ -64,17 +66,6 @@ public class AbilityBeamDual extends Ability { this.activeAnimationName = "Ability_BeamDual_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityBeamDual(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -384,6 +375,119 @@ public class AbilityBeamDual extends Ability { public void setAnchorPoint(int beam, int point) { getAnchorData(beam).anchorPoint = AnchorPoint.fromOrdinal(point); } public void setAnchorPoint(int point) { getAnchorData(0).anchorPoint = AnchorPoint.fromOrdinal(point); } + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.section("ability.section.beam"), + FieldDef.row( + FieldDef.floatField("ability.beamWidth", this::getBeamWidth, this::setBeamWidth), + FieldDef.floatField("ability.headSize", this::getHeadSize, this::setHeadSize) + ), + FieldDef.row( + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.section("ability.section.dual"), + FieldDef.boolField("ability.dualFire", this::isDualFire, this::setDualFire), + FieldDef.intField("ability.dualFireDelay", this::getDualFireDelay, this::setDualFireDelay) + .visibleWhen(this::isDualFire), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming) + .hover("ability.hover.homing"), + FieldDef.row( + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength) + .visibleWhen(this::isHoming), + FieldDef.floatField("gui.range", this::getHomingRange, this::setHomingRange) + .visibleWhen(this::isHoming) + ), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive) + .hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius) + .visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + // Visual tab - Beam 1 + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, + () -> getAnchorPointEnum(0), v -> setAnchorPointEnum(0, v)) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.beam1").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", + () -> getInnerColor(0), v -> setInnerColor(0, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", + () -> isOuterColorEnabled(0), v -> setOuterColorEnabled(0, v)) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", + () -> getOuterColor(0), v -> setOuterColor(0, v)) + .tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", + () -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v)) + .visibleWhen(() -> isOuterColorEnabled(0)), + FieldDef.floatField("ability.outerAlpha", + () -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v)) + .range(0, 1).visibleWhen(() -> isOuterColorEnabled(0)) + ).tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", + () -> getRotationSpeed(0), v -> setRotationSpeed(0, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", + () -> hasLightningEffect(0), v -> setLightningEffect(0, v)) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", + () -> getLightningDensity(0), v -> setLightningDensity(0, v)) + .range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)), + FieldDef.floatField("gui.radius", + () -> getLightningRadius(0), v -> setLightningRadius(0, v)) + .range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0)) + ).tab("ability.tab.visual"), + // Visual tab - Beam 2 + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, + () -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v)) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.beam2").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", + () -> getInnerColor(1), v -> setInnerColor(1, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", + () -> isOuterColorEnabled(1), v -> setOuterColorEnabled(1, v)) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", + () -> getOuterColor(1), v -> setOuterColor(1, v)) + .tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", + () -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v)) + .visibleWhen(() -> isOuterColorEnabled(1)), + FieldDef.floatField("ability.outerAlpha", + () -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v)) + .range(0, 1).visibleWhen(() -> isOuterColorEnabled(1)) + ).tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", + () -> getRotationSpeed(1), v -> setRotationSpeed(1, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", + () -> hasLightningEffect(1), v -> setLightningEffect(1, v)) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", + () -> getLightningDensity(1), v -> setLightningDensity(1, v)) + .range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)), + FieldDef.floatField("gui.radius", + () -> getLightningRadius(1), v -> setLightningRadius(1, v)) + .range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1)) + ).tab("ability.tab.visual") + ); + } + @Override @SideOnly(Side.CLIENT) public Entity createPreviewEntity(EntityNPCInterface npc) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java index 37d88e1f7..d149dc3ad 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java @@ -14,13 +14,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCharge; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityCharge; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -58,17 +58,6 @@ public class AbilityCharge extends Ability implements IAbilityCharge { this.activeSound = "mob.zombie.attack"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityCharge(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -405,4 +394,20 @@ public class AbilityCharge extends Ability implements IAbilityCharge { public void setHitWidth(float hitWidth) { this.hitWidth = hitWidth; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("ability.chargeSpeed", this::getChargeSpeed, this::setChargeSpeed) + ), + FieldDef.row( + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.floatField("ability.hitWidth", this::getHitWidth, this::setHitWidth) + ), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java index 3ba6c3079..ba0962356 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -11,13 +9,17 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCutter; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.api.ability.type.IAbilityCutter; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -31,7 +33,16 @@ public class AbilityCutter extends Ability implements IAbilityCutter { public enum SweepMode { SWIPE, - SPIN + SPIN; + + @Override + public String toString() { + switch (this) { + case SWIPE: return "ability.sweep.swipe"; + case SPIN: return "ability.sweep.spin"; + default: return name(); + } + } } private float arcAngle = 90.0f; @@ -65,17 +76,6 @@ public class AbilityCutter extends Ability implements IAbilityCutter { this.activeAnimationName = "Ability_Cutter_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityCutter(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -313,4 +313,30 @@ public class AbilityCutter extends Ability implements IAbilityCutter { public float getCurrentRotation() { return currentRotation; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("gui.range", this::getRange, this::setRange) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.section("ability.section.sweep"), + FieldDef.enumField("ability.sweepMode", SweepMode.class, this::getSweepModeEnum, this::setSweepModeEnum) + .hover("ability.hover.sweepMode"), + FieldDef.row( + FieldDef.floatField("ability.arcAngle", this::getArcAngle, this::setArcAngle), + FieldDef.floatField("ability.innerRadius", this::getInnerRadius, this::setInnerRadius) + ), + FieldDef.floatField("ability.sweepSpeed", this::getSweepSpeed, this::setSweepSpeed), + FieldDef.intField("ability.spinDuration", this::getSpinDurationTicks, this::setSpinDurationTicks) + .range(1, 1000) + .visibleWhen(() -> this.getSweepModeEnum() == SweepMode.SPIN), + FieldDef.boolField("ability.piercing", this::isPiercing, this::setPiercing) + .hover("ability.hover.piercing"), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java index e070b099e..fb5d59f0e 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java @@ -12,13 +12,13 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDash; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.client.gui.builder.FieldDef; import noppes.npcs.api.ability.type.IAbilityDash; +import java.util.Arrays; +import java.util.List; import java.util.Random; /** @@ -32,7 +32,16 @@ public class AbilityDash extends Ability implements IAbilityDash { */ public enum DashMode { AGGRESSIVE, - DEFENSIVE + DEFENSIVE; + + @Override + public String toString() { + switch (this) { + case AGGRESSIVE: return "ability.dash.aggressive"; + case DEFENSIVE: return "ability.dash.defensive"; + default: return name(); + } + } } /** @@ -101,18 +110,6 @@ public class AbilityDash extends Ability implements IAbilityDash { this.activeSound = "mob.endermen.portal"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui( - IAbilityConfigCallback callback) { - return new SubGuiAbilityDash(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -351,4 +348,17 @@ public class AbilityDash extends Ability implements IAbilityDash { public DashDirection getChosenDirection() { return chosenDirection; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.enumField("ability.dashMode", DashMode.class, this::getDashModeEnum, this::setDashModeEnum) + .hover("ability.hover.dashMode"), + FieldDef.row( + FieldDef.floatField("ability.dashDistance", this::getDashDistance, this::setDashDistance), + FieldDef.floatField("ability.dashSpeed", this::getDashSpeed, this::setDashSpeed) + ) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDisc.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDisc.java index 36bc898b2..f44270c14 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDisc.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDisc.java @@ -17,10 +17,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDisc; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityDisc; + +import java.util.Arrays; +import java.util.List; import noppes.npcs.entity.EntityNPCInterface; /** @@ -64,17 +66,6 @@ public class AbilityDisc extends Ability implements IAbilityDisc { this.activeAnimationName = "Ability_Disc_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityDisc(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -279,4 +270,69 @@ public class AbilityDisc extends Ability implements IAbilityDisc { public int getPreviewActiveDuration() { return lifespanData.maxLifetime > 0 ? Math.min(lifespanData.maxLifetime, 100) : 100; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.section("ability.section.disc"), + FieldDef.row( + FieldDef.floatField("gui.radius", this::getDiscRadius, this::setDiscRadius), + FieldDef.floatField("gui.thickness", this::getDiscThickness, this::setDiscThickness) + ), + FieldDef.row( + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming) + .hover("ability.hover.homing"), + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength) + .visibleWhen(this::isHoming), + FieldDef.section("ability.section.boomerang"), + FieldDef.boolField("gui.enabled", this::isBoomerang, this::setBoomerang) + .hover("ability.hover.boomerang"), + FieldDef.intField("gui.delay", this::getBoomerangDelay, this::setBoomerangDelay) + .visibleWhen(this::isBoomerang), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive) + .hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius) + .visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + // Visual tab + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, this::getAnchorPointEnum, this::setAnchorPointEnum) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.colors").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor) + .tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth) + .visibleWhen(this::isOuterColorEnabled), + FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha) + .range(0, 1).visibleWhen(this::isOuterColorEnabled) + ).tab("ability.tab.visual"), + FieldDef.section("ability.section.effects").tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity) + .range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect), + FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius) + .range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect) + ).tab("ability.tab.visual") + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDiscDual.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDiscDual.java index 1495c49a0..cf57498c3 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDiscDual.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDiscDual.java @@ -7,6 +7,8 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.ability.data.*; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; @@ -17,12 +19,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDiscDual; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.ValueUtil; +import java.util.Arrays; +import java.util.List; + public class AbilityDiscDual extends Ability { // Disc geometry @@ -34,7 +36,7 @@ public class AbilityDiscDual extends Ability { private int boomerangDelay = 40; // Dual properties - private boolean dualFire= true; + private boolean dualFire = true; private int dualFireDelay = 10; // Energy data classes @@ -72,17 +74,6 @@ public class AbilityDiscDual extends Ability { this.activeAnimationName = "Ability_DiscDual_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityDiscDual(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -393,6 +384,120 @@ public class AbilityDiscDual extends Ability { public void setAnchorPoint(int orb, int point) { getAnchorData(orb).anchorPoint = AnchorPoint.fromOrdinal(point); } public void setAnchorPoint(int point) { getAnchorData(0).anchorPoint = AnchorPoint.fromOrdinal(point); } + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.section("ability.section.disc"), + FieldDef.row( + FieldDef.floatField("gui.radius", this::getDiscRadius, this::setDiscRadius), + FieldDef.floatField("gui.thickness", this::getDiscThickness, this::setDiscThickness) + ), + FieldDef.row( + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.section("ability.section.dual"), + FieldDef.boolField("ability.dualFire", this::isDualFire, this::setDualFire), + FieldDef.intField("ability.dualFireDelay", this::getDualFireDelay, this::setDualFireDelay) + .visibleWhen(this::isDualFire), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming) + .hover("ability.hover.homing"), + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength) + .visibleWhen(this::isHoming), + FieldDef.section("ability.section.boomerang"), + FieldDef.boolField("gui.enabled", this::isBoomerang, this::setBoomerang) + .hover("ability.hover.boomerang"), + FieldDef.intField("gui.delay", this::getBoomerangDelay, this::setBoomerangDelay) + .visibleWhen(this::isBoomerang), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive) + .hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius) + .visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + // Visual tab - Disc 1 + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, + () -> getAnchorPointEnum(0), v -> setAnchorPointEnum(0, v)) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.disc1").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", + () -> getInnerColor(0), v -> setInnerColor(0, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", + () -> isOuterColorEnabled(0), v -> setOuterColorEnabled(0, v)) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", + () -> getOuterColor(0), v -> setOuterColor(0, v)) + .tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", + () -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v)) + .visibleWhen(() -> isOuterColorEnabled(0)), + FieldDef.floatField("ability.outerAlpha", + () -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v)) + .range(0, 1).visibleWhen(() -> isOuterColorEnabled(0)) + ).tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", + () -> getRotationSpeed(0), v -> setRotationSpeed(0, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", + () -> hasLightningEffect(0), v -> setLightningEffect(0, v)) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", + () -> getLightningDensity(0), v -> setLightningDensity(0, v)) + .range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)), + FieldDef.floatField("gui.radius", + () -> getLightningRadius(0), v -> setLightningRadius(0, v)) + .range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0)) + ).tab("ability.tab.visual"), + // Visual tab - Disc 2 + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, + () -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v)) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.disc2").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", + () -> getInnerColor(1), v -> setInnerColor(1, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", + () -> isOuterColorEnabled(1), v -> setOuterColorEnabled(1, v)) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", + () -> getOuterColor(1), v -> setOuterColor(1, v)) + .tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", + () -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v)) + .visibleWhen(() -> isOuterColorEnabled(1)), + FieldDef.floatField("ability.outerAlpha", + () -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v)) + .range(0, 1).visibleWhen(() -> isOuterColorEnabled(1)) + ).tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", + () -> getRotationSpeed(1), v -> setRotationSpeed(1, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", + () -> hasLightningEffect(1), v -> setLightningEffect(1, v)) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", + () -> getLightningDensity(1), v -> setLightningDensity(1, v)) + .range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)), + FieldDef.floatField("gui.radius", + () -> getLightningRadius(1), v -> setLightningRadius(1, v)) + .range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1)) + ).tab("ability.tab.visual") + ); + } + @Override @SideOnly(Side.CLIENT) public Entity createPreviewEntity(EntityNPCInterface npc) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityEnergyBeam.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityEnergyBeam.java index 700f771c7..03182d847 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityEnergyBeam.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityEnergyBeam.java @@ -17,10 +17,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityEnergyBeam; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityEnergyBeam; + +import java.util.Arrays; +import java.util.List; import noppes.npcs.entity.EntityNPCInterface; /** @@ -61,17 +63,6 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { this.activeAnimationName = "Ability_Beam_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityEnergyBeam(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -282,4 +273,68 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { public int getPreviewActiveDuration() { return lifespanData.maxLifetime > 0 ? Math.min(lifespanData.maxLifetime, 100) : 100; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.section("ability.section.beam"), + FieldDef.row( + FieldDef.floatField("ability.beamWidth", this::getBeamWidth, this::setBeamWidth), + FieldDef.floatField("ability.headSize", this::getHeadSize, this::setHeadSize) + ), + FieldDef.row( + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming) + .hover("ability.hover.homing"), + FieldDef.row( + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength) + .visibleWhen(this::isHoming), + FieldDef.floatField("gui.range", this::getHomingRange, this::setHomingRange) + .visibleWhen(this::isHoming) + ), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive) + .hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius) + .visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + // Visual tab + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, this::getAnchorPointEnum, this::setAnchorPointEnum) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.colors").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor) + .tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth) + .visibleWhen(this::isOuterColorEnabled), + FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha) + .range(0, 1).visibleWhen(this::isOuterColorEnabled) + ).tab("ability.tab.visual"), + FieldDef.section("ability.section.effects").tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity) + .range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect), + FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius) + .range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect) + ).tab("ability.tab.visual") + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java index 223a1180c..9e420741f 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -11,13 +9,18 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityGuard; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.api.ability.type.IAbilityGuard; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Arrays; +import java.util.List; import java.util.Random; /** @@ -45,7 +48,16 @@ public class AbilityGuard extends Ability implements IAbilityGuard { public enum CounterType { FLAT, - PERCENT + PERCENT; + + @Override + public String toString() { + switch (this) { + case FLAT: return "ability.counter.flat"; + case PERCENT: return "ability.counter.percent"; + default: return name(); + } + } } public AbilityGuard() { @@ -64,18 +76,6 @@ public class AbilityGuard extends Ability implements IAbilityGuard { this.allowedBy = UserType.NPC_ONLY; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui( - IAbilityConfigCallback callback) { - return new SubGuiAbilityGuard(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -294,4 +294,28 @@ public class AbilityGuard extends Ability implements IAbilityGuard { public void setCounterAnimationId(int counterAnimationId) { this.counterAnimationId = counterAnimationId; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.intField("ability.duration", this::getDurationTicks, this::setDurationTicks).range(1, 1000), + FieldDef.floatField("ability.damageReduction", this::getDamageReduction, this::setDamageReduction), + FieldDef.section("ability.section.counter"), + FieldDef.boolField("gui.enabled", this::isCanCounter, this::setCanCounter).hover("ability.hover.canCounter"), + FieldDef.enumField("gui.type", CounterType.class, this::getCounterTypeEnum, this::setCounterTypeEnum) + .hover("ability.hover.counterType").visibleWhen(this::isCanCounter), + FieldDef.row( + FieldDef.floatField("gui.value", this::getCounterValue, this::setCounterValue) + .visibleWhen(this::isCanCounter), + FieldDef.floatField("gui.chance", this::getCounterChance, this::setCounterChance) + .visibleWhen(this::isCanCounter) + ), + FieldDef.stringField("gui.sound", this::getCounterSound, this::setCounterSound) + .visibleWhen(this::isCanCounter), + FieldDef.intField("gui.animation", this::getCounterAnimationId, this::setCounterAnimationId) + .visibleWhen(this::isCanCounter), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java index 0700b1f01..d98110faf 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -14,13 +12,17 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHazard; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.api.ability.type.IAbilityHazard; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Random; @@ -35,14 +37,35 @@ public class AbilityHazard extends Ability implements IAbilityHazard { public enum HazardShape { CIRCLE, RING, - CONE + CONE; + + @Override + public String toString() { + switch (this) { + case CIRCLE: return "ability.shape.circle"; + case RING: return "ability.shape.ring"; + case CONE: return "ability.shape.cone"; + default: return name(); + } + } } public enum PlacementMode { AT_CASTER, AT_TARGET, FOLLOW_CASTER, - FOLLOW_TARGET + FOLLOW_TARGET; + + @Override + public String toString() { + switch (this) { + case AT_CASTER: return "ability.placement.atCaster"; + case AT_TARGET: return "ability.placement.atTarget"; + case FOLLOW_CASTER: return "ability.placement.followCaster"; + case FOLLOW_TARGET: return "ability.placement.followTarget"; + default: return name(); + } + } } private int durationTicks = 100; @@ -90,18 +113,6 @@ public class AbilityHazard extends Ability implements IAbilityHazard { this.telegraphType = TelegraphType.CIRCLE; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui( - IAbilityConfigCallback callback) { - return new SubGuiAbilityHazard(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -616,4 +627,35 @@ public class AbilityHazard extends Ability implements IAbilityHazard { public double getZoneZ() { return zoneZ; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.intField("ability.duration", this::getDurationTicks, this::setDurationTicks).range(1, 2000), + FieldDef.enumField("ability.shape", HazardShape.class, this::getShapeEnum, this::setShapeEnum) + .hover("ability.hover.shape"), + FieldDef.enumField("ability.placement", PlacementMode.class, this::getPlacementEnum, this::setPlacementEnum) + .hover("ability.hover.placement"), + FieldDef.section("ability.section.area"), + FieldDef.row( + FieldDef.floatField("gui.radius", this::getRadius, this::setRadius), + FieldDef.floatField("ability.innerRadius", this::getInnerRadius, this::setInnerRadius) + ), + FieldDef.section("ability.section.damage"), + FieldDef.row( + FieldDef.floatField("ability.damagePerSecond", this::getDamagePerSecond, this::setDamagePerSecond), + FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval) + ), + FieldDef.section("ability.section.debuffs"), + FieldDef.row( + FieldDef.intField("ability.slownessLevel", this::getSlownessLevel, this::setSlownessLevel), + FieldDef.intField("ability.debuffDuration", this::getDebuffDuration, this::setDebuffDuration) + ), + FieldDef.intField("ability.poisonLevel", this::getPoisonLevel, this::setPoisonLevel), + FieldDef.boolField("ability.affectsCaster", this::isAffectsCaster, this::setAffectsCaster) + .hover("ability.hover.affectsCaster"), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java index 898d54f57..ceb20a86c 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -11,14 +9,16 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeal; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.client.gui.builder.FieldDef; import noppes.npcs.api.ability.type.IAbilityHeal; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -58,17 +58,6 @@ public class AbilityHeal extends Ability implements IAbilityHeal { this.showTelegraph = false; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityHeal(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -289,4 +278,27 @@ public class AbilityHeal extends Ability implements IAbilityHeal { public void setInstantHeal(boolean instantHeal) { this.instantHeal = instantHeal; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.boolField("ability.instantHeal", this::isInstantHeal, this::setInstantHeal) + .hover("ability.hover.instant"), + FieldDef.intField("ability.duration", this::getDurationTicks, this::setDurationTicks) + .range(1, 1000).visibleWhen(() -> !this.isInstantHeal()), + FieldDef.section("ability.section.healing"), + FieldDef.row( + FieldDef.floatField("ability.healAmount", this::getHealAmount, this::setHealAmount), + FieldDef.floatField("ability.healPercent", this::getHealPercent, this::setHealPercent) + ), + FieldDef.floatField("ability.healRadius", this::getHealRadius, this::setHealRadius), + FieldDef.row( + FieldDef.boolField("ability.healSelf", this::isHealSelf, this::setHealSelf) + .hover("ability.hover.healSelf"), + FieldDef.boolField("ability.healAllies", this::isHealAllies, this::setHealAllies) + .hover("ability.hover.healAllies") + ) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java index 3419492c3..3db472c1a 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java @@ -9,12 +9,14 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityHeavyHit; import noppes.npcs.entity.EntityNPCInterface; +import java.util.Arrays; +import java.util.List; + /** * Heavy Hit ability: Single-target melee attack with optional stun. * Deals high damage to one target and can stun them. @@ -41,18 +43,6 @@ public class AbilityHeavyHit extends Ability implements IAbilityHeavyHit { this.activeAnimationName = "Ability_HeavyHit_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui( - IAbilityConfigCallback callback) { - return new SubGuiAbilityHeavyHit(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -114,4 +104,16 @@ public class AbilityHeavyHit extends Ability implements IAbilityHeavyHit { public void setKnockback(float knockback) { this.knockback = knockback; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback) + ), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityLaserShot.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityLaserShot.java index 5d42b23cc..b5d196cb5 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityLaserShot.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityLaserShot.java @@ -7,6 +7,8 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.ability.data.*; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import kamkeel.npcs.entity.EntityAbilityLaser; import kamkeel.npcs.util.AnchorPointHelper; @@ -16,10 +18,10 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityLaserShot; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.api.ability.type.IAbilityLaserShot; + +import java.util.Arrays; +import java.util.List; import noppes.npcs.entity.EntityNPCInterface; /** @@ -59,17 +61,6 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { this.activeAnimationName = "Ability_Laser_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityLaserShot(this, callback); - } - @Override public boolean isTargetingModeLocked() { return false; @@ -253,4 +244,52 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { public boolean spawnPreviewDuringWindup() { return false; // Laser has no charging, spawns at active phase } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.row( + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.floatField("ability.knockbackUp", this::getKnockbackUp, this::setKnockbackUp) + ), + FieldDef.section("ability.section.beam"), + FieldDef.row( + FieldDef.floatField("ability.laserWidth", this::getLaserWidth, this::setLaserWidth), + FieldDef.floatField("ability.expansionSpeed", this::getExpansionSpeed, this::setExpansionSpeed) + ), + FieldDef.row( + FieldDef.intField("ability.lingerTicks", this::getLingerTicks, this::setLingerTicks), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive).hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius).visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + + // Visual tab + FieldDef.section("ability.section.colors").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor).tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled).tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor) + .tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth) + .visibleWhen(this::isOuterColorEnabled), + FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha) + .range(0, 1).visibleWhen(this::isOuterColorEnabled) + ).tab("ability.tab.visual"), + FieldDef.section("ability.section.effects").tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect).tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity) + .range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect), + FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius) + .range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect) + ).tab("ability.tab.visual") + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java index 0ae1c6182..dcad556b6 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java @@ -17,10 +17,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityOrb; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityOrb; + +import java.util.Arrays; +import java.util.List; import noppes.npcs.entity.EntityNPCInterface; /** @@ -60,17 +62,6 @@ public class AbilityOrb extends Ability implements IAbilityOrb { this.activeAnimationName = "Ability_Orb_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityOrb(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -418,4 +409,56 @@ public class AbilityOrb extends Ability implements IAbilityOrb { public int getPreviewActiveDuration() { return lifespanData.maxLifetime > 0 ? Math.min(lifespanData.maxLifetime, 100) : 100; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getOrbSpeed, this::setOrbSpeed) + ), + FieldDef.row( + FieldDef.floatField("stats.size", this::getOrbSize, this::setOrbSize), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback) + ), + FieldDef.row( + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming).hover("ability.hover.homing"), + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength).visibleWhen(this::isHoming), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive).hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius).visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + + + // Visual tab + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, this::getAnchorPointEnum, this::setAnchorPointEnum) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.colors").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor).tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled).tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor) + .tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth) + .visibleWhen(this::isOuterColorEnabled), + FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha) + .range(0, 1).visibleWhen(this::isOuterColorEnabled) + ).tab("ability.tab.visual"), + FieldDef.section("ability.section.effects").tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed).tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect).tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity) + .range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect), + FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius) + .range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect) + ).tab("ability.tab.visual") + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrbDual.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrbDual.java index 1e28d5820..1efa694ba 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrbDual.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrbDual.java @@ -7,6 +7,8 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.ability.data.*; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; @@ -17,12 +19,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityOrbDual; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.util.ValueUtil; +import java.util.Arrays; +import java.util.List; + public class AbilityOrbDual extends Ability { // Ability-specific properties private float orbSize = 1.0f; @@ -63,17 +65,6 @@ public class AbilityOrbDual extends Ability { this.activeAnimationName = "Ability_BeamDual_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityOrbDual(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -464,6 +455,109 @@ public class AbilityOrbDual extends Ability { public void setAnchorPoint(int orb, int point) { getAnchorData(orb).anchorPoint = AnchorPoint.fromOrdinal(point); } public void setAnchorPoint(int point) { getAnchorData(0).anchorPoint = AnchorPoint.fromOrdinal(point); } + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + // Type tab + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getOrbSpeed, this::setOrbSpeed) + ), + FieldDef.row( + FieldDef.floatField("stats.size", this::getOrbSize, this::setOrbSize), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback) + ), + FieldDef.row( + FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance), + FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime) + ), + FieldDef.section("ability.section.dual"), + FieldDef.boolField("ability.dualFire", this::isDualFire, this::setDualFire), + FieldDef.intField("ability.dualFireDelay", this::getDualFireDelay, this::setDualFireDelay) + .visibleWhen(this::isDualFire), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming).hover("ability.hover.homing"), + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength).visibleWhen(this::isHoming), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive).hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius).visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + // Visual tab - Orb 1 + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, + () -> getAnchorPointEnum(0), v -> setAnchorPointEnum(0, v)) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.orb1").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", + () -> getInnerColor(0), v -> setInnerColor(0, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", + () -> isOuterColorEnabled(0), v -> setOuterColorEnabled(0, v)) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", + () -> getOuterColor(0), v -> setOuterColor(0, v)) + .tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", + () -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v)) + .visibleWhen(() -> isOuterColorEnabled(0)), + FieldDef.floatField("ability.outerAlpha", + () -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v)) + .range(0, 1).visibleWhen(() -> isOuterColorEnabled(0)) + ).tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", + () -> getRotationSpeed(0), v -> setRotationSpeed(0, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", + () -> hasLightningEffect(0), v -> setLightningEffect(0, v)) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", + () -> getLightningDensity(0), v -> setLightningDensity(0, v)) + .range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)), + FieldDef.floatField("gui.radius", + () -> getLightningRadius(0), v -> setLightningRadius(0, v)) + .range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0)) + ).tab("ability.tab.visual"), + // Visual tab - Orb 2 + FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, + () -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v)) + .tab("ability.tab.visual"), + FieldDef.section("ability.section.orb2").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", + () -> getInnerColor(1), v -> setInnerColor(1, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", + () -> isOuterColorEnabled(1), v -> setOuterColorEnabled(1, v)) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", + () -> getOuterColor(1), v -> setOuterColor(1, v)) + .tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)), + FieldDef.row( + FieldDef.floatField("ability.outerWidth", + () -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v)) + .visibleWhen(() -> isOuterColorEnabled(1)), + FieldDef.floatField("ability.outerAlpha", + () -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v)) + .range(0, 1).visibleWhen(() -> isOuterColorEnabled(1)) + ).tab("ability.tab.visual"), + FieldDef.floatField("ability.rotationSpeed", + () -> getRotationSpeed(1), v -> setRotationSpeed(1, v)) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.lightning", + () -> hasLightningEffect(1), v -> setLightningEffect(1, v)) + .tab("ability.tab.visual"), + FieldDef.row( + FieldDef.floatField("gui.density", + () -> getLightningDensity(1), v -> setLightningDensity(1, v)) + .range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)), + FieldDef.floatField("gui.radius", + () -> getLightningRadius(1), v -> setLightningRadius(1, v)) + .range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1)) + ).tab("ability.tab.visual") + ); + } + @Override @SideOnly(Side.CLIENT) public Entity createPreviewEntity(EntityNPCInterface npc) { diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java index c465bc0a5..d8dd4aebc 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java @@ -10,11 +10,14 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityProjectile; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; +import noppes.npcs.entity.EntityNPCInterface; + import noppes.npcs.api.ability.type.IAbilityProjectile; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; + +import java.util.Arrays; import java.util.List; /** @@ -47,17 +50,6 @@ public class AbilityProjectile extends Ability implements IAbilityProjectile { this.showTelegraph = false; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityProjectile(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -256,4 +248,24 @@ public class AbilityProjectile extends Ability implements IAbilityProjectile { public void setHomingStrength(float homingStrength) { this.homingStrength = homingStrength; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + FieldDef.stringEnumField("ability.projectileType", new String[]{"fireball", "arrow", "magic"}, this::getProjectileType, this::setProjectileType), + FieldDef.section("ability.section.homing"), + FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming).hover("ability.hover.homing"), + FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength).visibleWhen(this::isHoming), + FieldDef.section("ability.section.explosive"), + FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive).hover("ability.hover.explosive"), + FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius).visibleWhen(this::isExplosive), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java index 6416cc0ba..b2c72ed24 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java @@ -11,13 +11,13 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityShockwave; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityShockwave; +import java.util.Arrays; import java.util.List; /** @@ -44,17 +44,6 @@ public class AbilityShockwave extends Ability implements IAbilityShockwave { this.activeSound = "random.explode"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityShockwave(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -175,4 +164,18 @@ public class AbilityShockwave extends Ability implements IAbilityShockwave { this.maxTargets = maxTargets; } + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.section("ability.section.push"), + FieldDef.row( + FieldDef.floatField("gui.radius", this::getPushRadius, this::setPushRadius), + FieldDef.floatField("gui.strength", this::getPushStrength, this::setPushStrength) + ), + FieldDef.intField("ability.maxTargets", this::getMaxTargets, this::setMaxTargets), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java index 64e0255ca..94381209b 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java @@ -13,13 +13,14 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilitySlam; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.api.ability.type.IAbilitySlam; +import somehussar.gui.annotationHandling.GuiEditable; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; +import java.util.Arrays; import java.util.List; /** @@ -64,17 +65,6 @@ public class AbilitySlam extends Ability implements IAbilitySlam { this.activeAnimationName = "Ability_Slam_Active"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilitySlam(this, callback); - } - /** * Slam can be AOE_SELF (jump in place) or AOE_TARGET (leap to target). */ @@ -581,4 +571,22 @@ public class AbilitySlam extends Ability implements IAbilitySlam { public void setLeapHeight(float leapHeight) { this.leapHeight = leapHeight; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.row( + FieldDef.floatField("gui.radius", this::getRadius, this::setRadius), + FieldDef.floatField("ability.knockback", this::getKnockbackStrength, this::setKnockbackStrength) + ), + FieldDef.section("ability.section.leap"), + FieldDef.row( + FieldDef.floatField("gui.speed", this::getLeapSpeed, this::setLeapSpeed), + FieldDef.floatField("gui.height", this::getLeapHeight, this::setLeapHeight) + ), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySweeper.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySweeper.java index d2acc4df3..e57c47e20 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySweeper.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySweeper.java @@ -6,6 +6,8 @@ import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.ability.data.EnergyColorData; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; @@ -14,11 +16,12 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import noppes.npcs.LogWriter; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilitySweeper; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.api.ability.type.IAbilitySweeper; +import java.util.Arrays; +import java.util.List; +import noppes.npcs.entity.EntityNPCInterface; + /** * Sweeper ability: A low sweeping beam that rotates around the NPC. * Players can jump over it. The beam completes a set number of rotations before ending. @@ -60,17 +63,6 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper { this.showTelegraph = true; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilitySweeper(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -204,4 +196,44 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper { public void setOuterColorWidth(float outerColorWidth) { colorData.outerColorWidth = outerColorWidth; } public boolean isOuterColorEnabled() { return colorData.outerColorEnabled; } public void setOuterColorEnabled(boolean outerColorEnabled) { colorData.outerColorEnabled = outerColorEnabled; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval) + ), + FieldDef.section("ability.section.beam"), + FieldDef.row( + FieldDef.floatField("gui.length", this::getBeamLength, this::setBeamLength), + FieldDef.floatField("gui.width", this::getBeamWidth, this::setBeamWidth) + ), + FieldDef.row( + FieldDef.floatField("gui.height", this::getBeamHeight, this::setBeamHeight), + FieldDef.floatField("ability.sweepSpeed", this::getSweepSpeed, this::setSweepSpeed) + ), + FieldDef.intField("ability.rotations", this::getNumberOfRotations, this::setNumberOfRotations), + FieldDef.row( + FieldDef.boolField("ability.piercing", this::isPiercing, this::setPiercing) + .hover("ability.hover.piercing"), + FieldDef.boolField("ability.lockTarget", this::isLockOnTarget, this::setLockOnTarget) + .hover("ability.hover.lockTarget") + ), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects), + + // Visual tab + FieldDef.section("ability.section.colors").tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor) + .tab("ability.tab.visual"), + FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled) + .tab("ability.tab.visual"), + FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor) + .tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled), + FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth) + .tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java index 4e4a5dff7..528ddc025 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -14,13 +12,17 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTeleport; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.api.ability.type.IAbilityTeleport; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Arrays; import java.util.List; import java.util.Random; @@ -35,7 +37,17 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport { public enum TeleportMode { BLINK, BEHIND, - SINGLE + SINGLE; + + @Override + public String toString() { + switch (this) { + case BLINK: return "ability.teleport.blink"; + case BEHIND: return "ability.teleport.behind"; + case SINGLE: return "ability.teleport.single"; + default: return name(); + } + } } private static final Random RANDOM = new Random(); @@ -72,18 +84,6 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport { this.activeSound = "mob.endermen.portal"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui( - IAbilityConfigCallback callback) { - return new SubGuiAbilityTeleport(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -555,4 +555,37 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport { public void setDamageRadius(float damageRadius) { this.damageRadius = damageRadius; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.enumField("ability.mode", TeleportMode.class, this::getModeEnum, this::setModeEnum), + FieldDef.floatField("ability.blinkRadius", this::getBlinkRadius, this::setBlinkRadius) + .visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK || this.getModeEnum() == TeleportMode.SINGLE), + FieldDef.row( + FieldDef.intField("ability.blinkCount", this::getBlinkCount, this::setBlinkCount) + .visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK), + FieldDef.intField("ability.blinkDelay", this::getBlinkDelayTicks, this::setBlinkDelayTicks) + .visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK) + ), + FieldDef.floatField("ability.behindDistance", this::getBehindDistance, this::setBehindDistance) + .visibleWhen(() -> this.getModeEnum() == TeleportMode.BEHIND), + FieldDef.boolField("ability.lineOfSight", this::isRequireLineOfSight, this::setRequireLineOfSight) + .hover("ability.hover.lineOfSight") + .visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK || this.getModeEnum() == TeleportMode.SINGLE), + FieldDef.section("ability.section.damage"), + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("gui.radius", this::getDamageRadius, this::setDamageRadius) + ), + FieldDef.row( + FieldDef.boolField("ability.damageAtStart", this::isDamageAtStart, this::setDamageAtStart) + .hover("ability.hover.dmgAtStart"), + FieldDef.boolField("ability.damageAtEnd", this::isDamageAtEnd, this::setDamageAtEnd) + .hover("ability.hover.dmgAtEnd") + ), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java index a50fe57a1..c4f371056 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -12,13 +10,17 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTrap; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; import noppes.npcs.api.ability.type.IAbilityTrap; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Random; @@ -34,7 +36,17 @@ public class AbilityTrap extends Ability implements IAbilityTrap { public enum TrapPlacement { AT_CASTER, AT_TARGET, - AHEAD_OF_CASTER + AHEAD_OF_CASTER; + + @Override + public String toString() { + switch (this) { + case AT_CASTER: return "ability.trapPlace.atCaster"; + case AT_TARGET: return "ability.trapPlace.atTarget"; + case AHEAD_OF_CASTER: return "ability.trapPlace.aheadOfCaster"; + default: return name(); + } + } } private int durationTicks = 200; @@ -73,17 +85,6 @@ public class AbilityTrap extends Ability implements IAbilityTrap { this.telegraphType = TelegraphType.CIRCLE; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) { - return new SubGuiAbilityTrap(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -464,4 +465,31 @@ public class AbilityTrap extends Ability implements IAbilityTrap { public boolean isArmed() { return armed; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.intField("ability.duration", this::getDurationTicks, this::setDurationTicks) + .range(1, 2000), + FieldDef.enumField("ability.placement", TrapPlacement.class, this::getPlacementEnum, this::setPlacementEnum) + .hover("ability.hover.placement"), + FieldDef.section("ability.section.trigger"), + FieldDef.row( + FieldDef.floatField("gui.radius", this::getTriggerRadius, this::setTriggerRadius), + FieldDef.intField("ability.armTime", this::getArmTime, this::setArmTime) + ), + FieldDef.row( + FieldDef.intField("ability.maxTriggers", this::getMaxTriggers, this::setMaxTriggers), + FieldDef.intField("ability.triggerCooldown", this::getTriggerCooldown, this::setTriggerCooldown) + ), + FieldDef.section("ability.section.damage"), + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("gui.radius", this::getDamageRadius, this::setDamageRadius) + ), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java index f289f0f72..6c92304e2 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java @@ -1,7 +1,5 @@ package kamkeel.npcs.controllers.data.ability.type; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -10,13 +8,16 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.client.gui.builder.FieldDef; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs; import noppes.npcs.api.ability.type.IAbilityVortex; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -62,18 +63,6 @@ public class AbilityVortex extends Ability implements IAbilityVortex { this.activeSound = "mob.ghast.fireball"; } - @Override - public boolean hasTypeSettings() { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public SubGuiAbilityConfig createConfigGui( - IAbilityConfigCallback callback) { - return new SubGuiAbilityVortex(this, callback); - } - @Override public boolean isTargetingModeLocked() { return true; @@ -309,4 +298,31 @@ public class AbilityVortex extends Ability implements IAbilityVortex { public void setPullDamage(float pullDamage) { this.pullDamage = pullDamage; } + + @SideOnly(Side.CLIENT) + @Override + public List getFieldDefinitions() { + return Arrays.asList( + FieldDef.row( + FieldDef.floatField("ability.pullRadius", this::getPullRadius, this::setPullRadius), + FieldDef.floatField("ability.pullStrength", this::getPullStrength, this::setPullStrength) + ), + FieldDef.section("ability.section.damage"), + FieldDef.row( + FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage), + FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback) + ), + FieldDef.section("ability.section.aoe"), + FieldDef.boolField("gui.enabled", this::isAoe, this::setAoe) + .hover("ability.hover.aoe"), + FieldDef.intField("ability.maxTargets", this::getMaxTargets, this::setMaxTargets) + .visibleWhen(this::isAoe), + FieldDef.section("ability.section.pullDamage"), + FieldDef.boolField("gui.enabled", this::isDamageOnPull, this::setDamageOnPull) + .hover("ability.hover.dmgOnPull"), + FieldDef.floatField("enchantment.damage", this::getPullDamage, this::setPullDamage) + .visibleWhen(this::isDamageOnPull), + AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects) + ); + } } diff --git a/src/main/java/kamkeel/npcs/util/BukkitUtil.java b/src/main/java/kamkeel/npcs/util/BukkitUtil.java index bc35cae6c..29f4a522f 100644 --- a/src/main/java/kamkeel/npcs/util/BukkitUtil.java +++ b/src/main/java/kamkeel/npcs/util/BukkitUtil.java @@ -33,6 +33,8 @@ public class BukkitUtil { private static Method getPluginManager; private static Method isPluginEnabled; + private static Method getPlugin; + /** * Initializes Bukkit integration using reflection. * Should be called during FMLServerStartedEvent to ensure Bukkit is fully loaded. @@ -63,6 +65,7 @@ public class BukkitUtil { Class pluginManagerClass = Class.forName("org.bukkit.plugin.PluginManager"); isPluginEnabled = pluginManagerClass.getMethod("isPluginEnabled", String.class); + getPlugin = pluginManagerClass.getMethod("getPlugin", String.class); bukkitEnabled = true; logger.info("Bukkit integration enabled"); @@ -95,7 +98,6 @@ public class BukkitUtil { /** * Checks if a specific Bukkit plugin is enabled. - * * @param pluginName the plugin name to check * @return true if the plugin is enabled */ @@ -113,7 +115,6 @@ public class BukkitUtil { /** * Gets a Bukkit OfflinePlayer by name. - * * @param playerName the player name * @return the OfflinePlayer object, or null if not available */ @@ -130,7 +131,6 @@ public class BukkitUtil { /** * Gets a Bukkit Player by name (online players only). - * * @param playerName the player name * @return the Player object, or null if not online or not available */ @@ -147,7 +147,6 @@ public class BukkitUtil { /** * Gets a service provider from Bukkit's ServicesManager. - * * @param serviceClass the service class to get * @return the service provider, or null if not available */ @@ -186,4 +185,13 @@ public class BukkitUtil { public static Class getPlayerClass() { return playerClass; } + + public static Object getPlugin(String plugin) { + try { + return getPlugin.invoke(getPluginManager.invoke(null), plugin); + } catch (Throwable ignored) { + + } + return null; + } } diff --git a/src/main/java/kamkeel/npcs/util/VaultUtil.java b/src/main/java/kamkeel/npcs/util/VaultUtil.java index 64743ffba..c25ea3f3a 100644 --- a/src/main/java/kamkeel/npcs/util/VaultUtil.java +++ b/src/main/java/kamkeel/npcs/util/VaultUtil.java @@ -75,8 +75,12 @@ public class VaultUtil { } // Load Vault classes - economyClass = Class.forName("net.milkbowl.vault.economy.Economy"); - economyResponseClass = Class.forName("net.milkbowl.vault.economy.EconomyResponse"); + Object vault = BukkitUtil.getPlugin("Vault"); + if (vault == null) + return; + ClassLoader vaultLoader = vault.getClass().getClassLoader(); + economyClass = vaultLoader.loadClass("net.milkbowl.vault.economy.Economy"); + economyResponseClass = vaultLoader.loadClass("net.milkbowl.vault.economy.EconomyResponse"); // Get Economy methods (using deprecated String methods for broader compatibility) isEnabled = economyClass.getMethod("isEnabled"); @@ -174,7 +178,6 @@ public class VaultUtil { /** * Checks if a player has an account in the economy system. - * * @param player the player to check * @return true if the player has an account */ @@ -184,7 +187,6 @@ public class VaultUtil { /** * Checks if a player has an account in the economy system. - * * @param playerName the player name to check * @return true if the player has an account */ @@ -205,7 +207,6 @@ public class VaultUtil { /** * Gets the balance of a player. - * * @param player the player * @return the player's balance, or 0 if not available */ @@ -215,7 +216,6 @@ public class VaultUtil { /** * Gets the balance of a player by name. - * * @param playerName the player name * @return the player's balance, or 0 if not available */ @@ -236,7 +236,6 @@ public class VaultUtil { /** * Checks if a player has at least the specified amount. - * * @param player the player * @param amount the amount to check * @return true if the player has at least the specified amount @@ -247,9 +246,8 @@ public class VaultUtil { /** * Checks if a player has at least the specified amount. - * * @param playerName the player name - * @param amount the amount to check + * @param amount the amount to check * @return true if the player has at least the specified amount */ public static boolean has(String playerName, double amount) { @@ -269,7 +267,6 @@ public class VaultUtil { /** * Withdraws money from a player's account. - * * @param player the player * @param amount the amount to withdraw * @return true if the transaction was successful @@ -280,9 +277,8 @@ public class VaultUtil { /** * Withdraws money from a player's account. - * * @param playerName the player name - * @param amount the amount to withdraw + * @param amount the amount to withdraw * @return true if the transaction was successful */ public static boolean withdrawMoney(String playerName, double amount) { @@ -305,7 +301,6 @@ public class VaultUtil { /** * Adds money to a player's account (deposit). - * * @param player the player * @param amount the amount to add * @return true if the transaction was successful @@ -316,9 +311,8 @@ public class VaultUtil { /** * Adds money to a player's account (deposit). - * * @param playerName the player name - * @param amount the amount to add + * @param amount the amount to add * @return true if the transaction was successful */ public static boolean addMoney(String playerName, double amount) { @@ -342,7 +336,6 @@ public class VaultUtil { /** * Sets a player's balance to the specified amount. * This withdraws all money first, then deposits the new amount. - * * @param player the player * @param amount the new balance * @return true if the transaction was successful @@ -354,9 +347,8 @@ public class VaultUtil { /** * Sets a player's balance to the specified amount. * This withdraws all money first, then deposits the new amount. - * * @param playerName the player name - * @param amount the new balance + * @param amount the new balance * @return true if the transaction was successful */ public static boolean setBalance(String playerName, double amount) { @@ -376,7 +368,6 @@ public class VaultUtil { /** * Formats an amount according to the economy plugin's settings. - * * @param amount the amount to format * @return the formatted string, or the raw number as string if not available */ @@ -393,7 +384,6 @@ public class VaultUtil { /** * Gets the plural currency name (e.g., "Dollars"). - * * @return the plural currency name, or "coins" if not available */ public static String getCurrencyNamePlural() { @@ -409,7 +399,6 @@ public class VaultUtil { /** * Gets the singular currency name (e.g., "Dollar"). - * * @return the singular currency name, or "coin" if not available */ public static String getCurrencyNameSingular() { @@ -425,7 +414,6 @@ public class VaultUtil { /** * Creates an account for the player if one doesn't exist. - * * @param player the player * @return true if the account was created or already exists */ @@ -435,7 +423,6 @@ public class VaultUtil { /** * Creates an account for the player if one doesn't exist. - * * @param playerName the player name * @return true if the account was created or already exists */ @@ -472,7 +459,6 @@ public class VaultUtil { /** * Gets a list of all bank names. - * * @return list of bank names, or empty list if not available */ @SuppressWarnings("unchecked") @@ -489,7 +475,6 @@ public class VaultUtil { /** * Gets the balance of a bank. - * * @param bankName the bank name * @return the bank balance, or 0 if not available */ @@ -507,9 +492,8 @@ public class VaultUtil { /** * Checks if a bank has at least the specified amount. - * * @param bankName the bank name - * @param amount the amount to check + * @param amount the amount to check * @return true if the bank has at least the specified amount */ public static boolean bankHas(String bankName, double amount) { @@ -526,9 +510,8 @@ public class VaultUtil { /** * Withdraws money from a bank. - * * @param bankName the bank name - * @param amount the amount to withdraw + * @param amount the amount to withdraw * @return true if the transaction was successful */ public static boolean bankWithdraw(String bankName, double amount) { @@ -545,9 +528,8 @@ public class VaultUtil { /** * Deposits money into a bank. - * * @param bankName the bank name - * @param amount the amount to deposit + * @param amount the amount to deposit * @return true if the transaction was successful */ public static boolean bankDeposit(String bankName, double amount) { @@ -564,9 +546,8 @@ public class VaultUtil { /** * Transfers money from one player to another. - * - * @param from the player to take money from - * @param to the player to give money to + * @param from the player to take money from + * @param to the player to give money to * @param amount the amount to transfer * @return true if the transfer was successful */ @@ -576,10 +557,9 @@ public class VaultUtil { /** * Transfers money from one player to another. - * * @param fromPlayerName the player name to take money from - * @param toPlayerName the player name to give money to - * @param amount the amount to transfer + * @param toPlayerName the player name to give money to + * @param amount the amount to transfer * @return true if the transfer was successful */ public static boolean transfer(String fromPlayerName, String toPlayerName, double amount) { diff --git a/src/main/java/noppes/npcs/CustomNpcsPermissions.java b/src/main/java/noppes/npcs/CustomNpcsPermissions.java index 5e7c2924e..af9b2b9af 100644 --- a/src/main/java/noppes/npcs/CustomNpcsPermissions.java +++ b/src/main/java/noppes/npcs/CustomNpcsPermissions.java @@ -66,8 +66,8 @@ public class CustomNpcsPermissions { public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn"); public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag"); public static final Permission GLOBAL_ANIMATION = new Permission("customnpcs.global.animation"); - public static final Permission GLOBAL_ABILITY = new Permission("customnpcs.global.ability"); public static final Permission GLOBAL_MAGIC = new Permission("customnpcs.global.magic"); + public static final Permission GLOBAL_ABILITY = new Permission("customnpcs.global.ability"); public static final Permission GLOBAL_EFFECT = new Permission("customnpcs.global.effect"); public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob"); @@ -111,9 +111,6 @@ public class CustomNpcsPermissions { public static final Permission PROFILE_REGION_BYPASS = new Permission("customnpcs.profile.region-bypass"); public static final Permission PROFILE_MAX = new Permission("customnpcs.profile.max.*"); - // Auction - public static final Permission AUCTION_TRADES_MAX = new Permission("customnpcs.auction.trades.*"); - public static CustomNpcsPermissions Instance; private Method hasPermission; diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java index 32cfc51b2..60c3561b3 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java @@ -2,22 +2,16 @@ package noppes.npcs.client.gui.advanced; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.Condition; -import kamkeel.npcs.controllers.data.ability.LockMovementType; -import kamkeel.npcs.controllers.data.ability.TargetingMode; -import kamkeel.npcs.controllers.data.telegraph.TelegraphType; -import noppes.npcs.controllers.data.Animation; -import noppes.npcs.controllers.data.Frame; -import noppes.npcs.controllers.AnimationController; +import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldBuilder; +import noppes.npcs.client.gui.builder.FieldDef; import net.minecraft.client.gui.GuiButton; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.select.GuiAnimationSelection; -import noppes.npcs.client.gui.select.GuiSoundSelection; import noppes.npcs.client.gui.util.GuiMenuTopButton; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.GuiNpcTextField; +import noppes.npcs.client.gui.util.GuiScrollWindow; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.client.gui.util.ISubGuiListener; import noppes.npcs.client.gui.util.ITextfieldListener; @@ -26,153 +20,96 @@ import noppes.npcs.client.gui.util.SubGuiInterface; import java.util.ArrayList; import java.util.List; -/** - * Base SubGui for editing ability configuration with tabbed interface. - * Uses GuiMenuTopButton for navigation tabs. - *

- * Tabs: - * - General: Name, Weight, Lock Movement, Interruptible, Timing - * - Type: Type-specific settings per Ability (override in subclasses) - * - Target: Min/Max Range, Targeting Mode, Conditions (up to 3) - * - Effects: Sounds, Animations, Telegraph settings, Colors - *

- * Subclasses should override initTypeTab() and handleTypeButton()/handleTypeTextField() - * to provide type-specific settings UI. - */ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldListener, ISubGuiListener { - // Tab constants - protected static final int TAB_GENERAL = 0; - protected static final int TAB_TYPE = 1; - protected static final int TAB_TARGET = 2; - protected static final int TAB_EFFECTS = 3; - protected static final int TAB_VISUAL = 4; + private static final int DECLARATIVE_ID_START = 1000; + private static final int CLEAR_ID_START = 2000; + private static final int LABEL_ID_START = 3000; - // Core references - protected final Ability ability; - protected final IAbilityConfigCallback callback; - protected int activeTab = TAB_GENERAL; + // Fixed tab indices + private static final int TAB_GENERAL = 0; + private static final int TAB_TYPE = 1; + private static final int TAB_TARGET = 2; + private static final int TAB_EFFECTS = 3; + // Custom tabs start at index 4 - // ═══════════════════════════════════════════════════════════════════════════ - // CACHED VALUES - General Tab - // ═══════════════════════════════════════════════════════════════════════════ - protected String name; - protected boolean enabled; - protected int weight; - protected LockMovementType lockMovement; - protected boolean interruptible; + // Tab name strings (matching FieldDef.tab() values) + private static final String TAB_NAME_GENERAL = "General"; + private static final String TAB_NAME_TYPE = "Type"; + private static final String TAB_NAME_TARGET = "Target"; + private static final String TAB_NAME_EFFECTS = "Effects"; - // Timing - protected int cooldownTicks; - protected int windUpTicks; - protected int dazedTicks; - protected boolean syncWindupWithAnimation; // Sync windup ticks with animation duration + private static final int L_LABEL_X = 5; + private static final int ROW_H = 24; - // ═══════════════════════════════════════════════════════════════════════════ - // CACHED VALUES - Target Tab - // ═══════════════════════════════════════════════════════════════════════════ - protected float minRange; - protected float maxRange; - protected TargetingMode targetingMode; - protected List conditions; + private final Ability ability; + private final IAbilityConfigCallback callback; + private int activeTab = TAB_GENERAL; - // ═══════════════════════════════════════════════════════════════════════════ - // CACHED VALUES - Effects Tab - // ═══════════════════════════════════════════════════════════════════════════ - protected String windUpSound; - protected String activeSound; - protected int windUpAnimationId; - protected int activeAnimationId; - protected String windUpAnimationName = null; - protected String activeAnimationName = null; + private List fieldDefs; + private List customTabNames; - // Telegraph - protected boolean showTelegraph; - protected int windUpColor; - protected int activeColor; + private List conditions; + private int editingConditionIndex = -1; - // Editing state - protected int editingColorId = 0; - protected int editingSoundId = 0; - protected int editingAnimationId = 0; - protected int editingConditionIndex = -1; + private AbilityFieldBuilder builder; - // ═══════════════════════════════════════════════════════════════════════════ - // ABILITY TYPE FEATURES - // ═══════════════════════════════════════════════════════════════════════════ - protected final boolean supportsTelegraph; - protected final boolean targetingModeLocked; - protected final boolean hasTypeSettings; - protected final boolean hasVisualSettings; + // Scroll position preservation per tab + private float[] tabScrollY; public SubGuiAbilityConfig(Ability ability, IAbilityConfigCallback callback) { this.ability = ability; this.callback = callback; - - // Cache values from ability - General - this.name = ability.getName() != null ? ability.getName() : ""; - this.enabled = ability.isEnabled(); - this.weight = ability.getWeight(); - this.lockMovement = ability.getLockMovement(); - this.interruptible = ability.isInterruptible(); - - // Timing - this.cooldownTicks = ability.getCooldownTicks(); - this.windUpTicks = ability.getWindUpTicks(); - this.dazedTicks = ability.getDazedTicks(); - this.syncWindupWithAnimation = ability.isSyncWindupWithAnimation(); - - // Target - this.minRange = ability.getMinRange(); - this.maxRange = ability.getMaxRange(); - this.targetingMode = ability.getTargetingMode(); this.conditions = new ArrayList<>(ability.getConditions()); - // Effects - this.windUpSound = ability.getWindUpSound(); - this.activeSound = ability.getActiveSound(); - // Animation: check name first (built-in), then ID (user) - this.windUpAnimationName = ability.getWindUpAnimationName(); - this.activeAnimationName = ability.getActiveAnimationName(); - this.windUpAnimationId = ability.getWindUpAnimationId(); - this.activeAnimationId = ability.getActiveAnimationId(); - - // Telegraph - this.showTelegraph = ability.isShowTelegraph(); - this.windUpColor = ability.getWindUpColor(); - this.activeColor = ability.getActiveColor(); - - // Determine ability type features - TelegraphType defaultType = ability.getTelegraphType(); - this.supportsTelegraph = defaultType != null && defaultType != TelegraphType.NONE; - this.targetingModeLocked = ability.isTargetingModeLocked(); - this.hasTypeSettings = ability.hasTypeSettings(); - this.hasVisualSettings = hasVisualSettings(); + this.fieldDefs = ability.getAllFieldDefinitions(); + discoverCustomTabs(); setBackground("menubg.png", 217); xSize = 356; ySize = 200; } + private void discoverCustomTabs() { + customTabNames = new ArrayList<>(); + for (FieldDef def : fieldDefs) { + String tab = def.getTab(); + if (tab != null + && !TAB_NAME_GENERAL.equals(tab) + && !TAB_NAME_TYPE.equals(tab) + && !TAB_NAME_TARGET.equals(tab) + && !TAB_NAME_EFFECTS.equals(tab) + && !customTabNames.contains(tab)) { + customTabNames.add(tab); + } + } + tabScrollY = new float[4 + customTabNames.size()]; + } + + // ═══════════════════════════════════════════════════════════════════════════ + // INIT GUI + // ═══════════════════════════════════════════════════════════════════════════ + @Override public void initGui() { + // Save scroll position before super clears scroll windows + GuiScrollWindow oldSw = getScrollableGui(0); + if (oldSw != null && activeTab < tabScrollY.length) { + tabScrollY[activeTab] = oldSw.nextScrollY; + } + super.initGui(); - // ═══════════════════════════════════════════════════════════════════════ - // TOP TABS using GuiMenuTopButton - // ═══════════════════════════════════════════════════════════════════════ + // Tab buttons — always show General, Type, Target, Effects GuiMenuTopButton generalTab = new GuiMenuTopButton(90, guiLeft + 4, guiTop - 17, "menu.general"); generalTab.active = (activeTab == TAB_GENERAL); addTopButton(generalTab); - GuiMenuTopButton lastTab = generalTab; - if (hasTypeSettings) { - GuiMenuTopButton typeTab = new GuiMenuTopButton(91, lastTab, "gui.type"); - typeTab.active = (activeTab == TAB_TYPE); - addTopButton(typeTab); - lastTab = typeTab; - } + GuiMenuTopButton typeTab = new GuiMenuTopButton(91, lastTab, "gui.type"); + typeTab.active = (activeTab == TAB_TYPE); + addTopButton(typeTab); + lastTab = typeTab; GuiMenuTopButton targetTab = new GuiMenuTopButton(92, lastTab, "script.target"); targetTab.active = (activeTab == TAB_TARGET); @@ -184,277 +121,113 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi addTopButton(effectsTab); lastTab = effectsTab; - if (hasVisualSettings) { - GuiMenuTopButton visualTab = new GuiMenuTopButton(94, lastTab, "ability.tab.visual"); - visualTab.active = (activeTab == TAB_VISUAL); - addTopButton(visualTab); + // Custom tabs (Visual, etc.) + for (int i = 0; i < customTabNames.size(); i++) { + GuiMenuTopButton ct = new GuiMenuTopButton(94 + i, lastTab, customTabNames.get(i)); + ct.active = (activeTab == 4 + i); + addTopButton(ct); + lastTab = ct; } - // Close button (X) in top menu bar - use -1000 to avoid any ID conflicts GuiMenuTopButton closeBtn = new GuiMenuTopButton(-1000, guiLeft + xSize - 22, guiTop - 17, "X"); addTopButton(closeBtn); - int contentY = guiTop + 5; + // Build scroll window dimensions + int swX = guiLeft + 4; + int swY = guiTop + 5; + int swW = xSize - 8; + int swH = ySize - 10; - // ═══════════════════════════════════════════════════════════════════════ - // TAB CONTENT - // ═══════════════════════════════════════════════════════════════════════ - switch (activeTab) { - case TAB_GENERAL: - initGeneralTab(contentY); - break; - case TAB_TYPE: - initTypeTab(contentY); - break; - case TAB_TARGET: - initTargetTab(contentY); - break; - case TAB_EFFECTS: - initEffectsTab(contentY); - break; - case TAB_VISUAL: - initVisualTab(contentY); - break; - } + int y = 5; + int labelCounter = LABEL_ID_START; - // ═══════════════════════════════════════════════════════════════════════ - // BOTTOM ROW - Enabled toggle (only on General tab) - // ═══════════════════════════════════════════════════════════════════════ + // General tab: type label at top — need to reserve space before building if (activeTab == TAB_GENERAL) { - addLabel(new GuiNpcLabel(99, "gui.enabled", guiLeft + 8, guiTop + ySize - 18)); - GuiNpcButton enabledBtn = new GuiNpcButton(2, guiLeft + 55, guiTop + ySize - 24, 40, 20, new String[]{"gui.no", "gui.yes"}, enabled ? 1 : 0); - enabledBtn.setTextColor(enabled ? 0x00FF00 : 0xFF0000); - addButton(enabledBtn); + y += ROW_H; + } + + // Build declarative fields into an auto-created scroll window + List tabFields = getVisibleFieldsForTab(activeTab); + builder = new AbilityFieldBuilder(this, fontRendererObj); + builder.startIds(DECLARATIVE_ID_START, CLEAR_ID_START, labelCounter); + builder.startY(y); + + GuiScrollWindow sw = builder.buildScrollWindow(tabFields, swX, swY, swW, swH); + + // General tab: add type label at top of scroll window + if (activeTab == TAB_GENERAL) { + sw.addLabel(new GuiNpcLabel(builder.getNextLabelId(), "gui.type", 5, 5 + 5, 0xFFFFFF)); + sw.addLabel(new GuiNpcLabel(builder.getNextLabelId() + 1, ability.getTypeId(), 55, 5 + 5, 0xFFFFFF)); + } + + // Conditions on target tab — appended after field defs + if (activeTab == TAB_TARGET) { + int condY = renderConditions(sw, builder.getLastBuildY(), builder.getNextLabelId()); + sw.maxScrollY = Math.max(condY - swH, 0); + } + + // Restore scroll position + if (activeTab < tabScrollY.length) { + float restored = Math.min(tabScrollY[activeTab], sw.maxScrollY); + sw.nextScrollY = restored; + sw.scrollY = restored; } } - // ═══════════════════════════════════════════════════════════════════════════ - // GENERAL TAB - // ═══════════════════════════════════════════════════════════════════════════ + private List getVisibleFieldsForTab(int tabIndex) { + List result = new ArrayList<>(); - private void initGeneralTab(int startY) { - int y = startY; - int col1LabelX = guiLeft + 8; - int col1FieldX = guiLeft + 70; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 248; - - // Row 1: Type (read-only) + Name - addLabel(new GuiNpcLabel(1, "gui.type", col1LabelX, y + 5)); - addLabel(new GuiNpcLabel(2, ability.getTypeId(), col1FieldX, y + 5)); - - addLabel(new GuiNpcLabel(3, "gui.name", col2LabelX, y + 5)); - GuiNpcTextField nameField = new GuiNpcTextField(1, this, fontRendererObj, col2FieldX, y, 100, 20, name); - addTextField(nameField); - - y += 24; - - // Row 2: Weight + Lock Movement - addLabel(new GuiNpcLabel(4, "ability.weight", col1LabelX, y + 5)); - GuiNpcTextField weightField = new GuiNpcTextField(3, this, fontRendererObj, col1FieldX, y, 40, 20, "" + weight); - weightField.setIntegersOnly(); - weightField.setMinMaxDefault(1, 1000, 10); - addTextField(weightField); - - addLabel(new GuiNpcLabel(5, "ability.lockMove", col2LabelX, y + 5)); - GuiNpcButton lockMoveBtn = new GuiNpcButton(16, col2FieldX, y, 60, 20, LockMovementType.getDisplayKeys(), lockMovement.ordinal()); - lockMoveBtn.setHoverText("ability.hover.lockMove"); - addButton(lockMoveBtn); - - y += 24; - - // Row 3: Interruptible + Dazed Ticks (only if interruptible) - addLabel(new GuiNpcLabel(6, "ability.interruptible", col1LabelX, y + 5)); - GuiNpcButton interruptBtn = new GuiNpcButton(14, guiLeft + 85, y, 40, 20, new String[]{"gui.no", "gui.yes"}, interruptible ? 1 : 0); - interruptBtn.setHoverText("ability.hover.interruptible"); - addButton(interruptBtn); - - // Only show dazed ticks if interruptible is enabled - if (interruptible) { - addLabel(new GuiNpcLabel(12, "ability.dazed", col2LabelX, y + 5)); - GuiNpcTextField dazedField = new GuiNpcTextField(13, this, fontRendererObj, col2FieldX, y, 40, 20, "" + dazedTicks); - dazedField.setIntegersOnly(); - dazedField.setMinMaxDefault(0, 1000, 80); - addTextField(dazedField); - } - - y += 28; - - // Separator - Timing section header - addLabel(new GuiNpcLabel(7, "ability.timing", col1LabelX, y)); - y += 14; - - // Check if windup animation is selected (either by name or ID) - boolean hasWindupAnimation = windUpAnimationId >= 0 || (windUpAnimationName != null && !windUpAnimationName.isEmpty()); - - // Row 4: Windup Ticks + Cooldown Ticks - addLabel(new GuiNpcLabel(10, "ability.windup", col1LabelX, y + 5)); - - // Only show windup textbox if sync is off or no animation selected - if (!syncWindupWithAnimation || !hasWindupAnimation) { - GuiNpcTextField windupField = new GuiNpcTextField(11, this, fontRendererObj, col1FieldX, y, 40, 20, "" + windUpTicks); - windupField.setIntegersOnly(); - windupField.setMinMaxDefault(0, 1000, 20); - addTextField(windupField); + String tabName; + if (tabIndex >= 4) { + int customIndex = tabIndex - 4; + if (customIndex >= 0 && customIndex < customTabNames.size()) { + tabName = customTabNames.get(customIndex); + } else { + return result; + } } else { - // Show calculated value as label when synced - addLabel(new GuiNpcLabel(11, "" + windUpTicks, col1FieldX + 5, y + 5)); + switch (tabIndex) { + case TAB_GENERAL: tabName = TAB_NAME_GENERAL; break; + case TAB_TYPE: tabName = TAB_NAME_TYPE; break; + case TAB_TARGET: tabName = TAB_NAME_TARGET; break; + case TAB_EFFECTS: tabName = TAB_NAME_EFFECTS; break; + default: tabName = TAB_NAME_TYPE; break; + } } - // Sync toggle button - only show if windup animation is selected - if (hasWindupAnimation) { - String syncLabel = syncWindupWithAnimation ? "ability.syncOn" : "ability.syncOff"; - GuiNpcButton syncBtn = new GuiNpcButton(17, guiLeft + 115, y, 50, 20, syncLabel); - syncBtn.setHoverText("ability.hover.sync"); - addButton(syncBtn); + for (FieldDef def : fieldDefs) { + if (tabName.equals(def.getTab()) && def.isVisible()) { + result.add(def); + } } - addLabel(new GuiNpcLabel(13, "ability.cooldown", col2LabelX, y + 5)); - GuiNpcTextField cooldownField = new GuiNpcTextField(10, this, fontRendererObj, col2FieldX, y, 40, 20, "" + cooldownTicks); - cooldownField.setIntegersOnly(); - cooldownField.setMinMaxDefault(0, 10000, 0); - addTextField(cooldownField); + return result; } // ═══════════════════════════════════════════════════════════════════════════ - // TYPE TAB - Override in subclasses for type-specific settings + // CONDITIONS (Target tab) // ═══════════════════════════════════════════════════════════════════════════ - /** - * Override this method to render type-specific settings in the Type tab. - * Use the helper methods createFloatField(), createIntField(), etc. - * Button/TextField IDs should start at 100. - * - * @param startY The Y position to start rendering from - */ - protected void initTypeTab(int startY) { - // Default: show message that no type settings are available - addLabel(new GuiNpcLabel(100, "ability.noTypeSettings", guiLeft + 8, startY + 5)); - } + private int renderConditions(GuiScrollWindow sw, int y, int labelCounter) { + y += 3; + sw.addLabel(new GuiNpcLabel(labelCounter, "ability.conditions", L_LABEL_X, y + 2, 0xFFFF55)); + y += 15; - /** - * Override this method to handle button clicks for type-specific buttons. - * Button IDs 100+ are reserved for type-specific use. - */ - protected void handleTypeButton(int id, GuiNpcButton button) { - // Default: no-op - } - - /** - * Override this method to handle text field changes for type-specific fields. - * Field IDs 100+ are reserved for type-specific use. - */ - protected void handleTypeTextField(int id, GuiNpcTextField field) { - // Default: no-op - } - - // ═══════════════════════════════════════════════════════════════════════════ - // VISUAL TAB - Override in subclasses for visual settings (colors, etc.) - // ═══════════════════════════════════════════════════════════════════════════ - - /** - * Override to return true if this ability has visual settings (colors, glow, etc.). - * When true, a Visual tab will be shown in the GUI. - */ - protected boolean hasVisualSettings() { - return false; - } - - /** - * Override this method to render visual settings in the Visual tab. - * Use button/text field IDs starting at 200 for visual settings. - * - * @param startY The Y position to start rendering from - */ - protected void initVisualTab(int startY) { - // Default: show message that no visual settings are available - addLabel(new GuiNpcLabel(200, "ability.noVisualSettings", guiLeft + 8, startY + 5)); - } - - /** - * Override this method to handle button clicks for visual-specific buttons. - * Button IDs 200+ are reserved for visual-specific use. - */ - protected void handleVisualButton(int id, GuiNpcButton button) { - // Default: no-op - } - - /** - * Override this method to handle text field changes for visual-specific fields. - * Field IDs 200+ are reserved for visual-specific use. - */ - protected void handleVisualTextField(int id, GuiNpcTextField field) { - // Default: no-op - } - - // ═══════════════════════════════════════════════════════════════════════════ - // TARGET TAB - // ═══════════════════════════════════════════════════════════════════════════ - - private void initTargetTab(int startY) { - int y = startY; - int col1LabelX = guiLeft + 8; - int col1FieldX = guiLeft + 70; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 248; - - // Row 1: Min Range + Max Range - addLabel(new GuiNpcLabel(20, "ability.minRange", col1LabelX, y + 5)); - GuiNpcTextField minRangeField = new GuiNpcTextField(5, this, fontRendererObj, col1FieldX, y, 40, 20, "" + (int) minRange); - minRangeField.setIntegersOnly(); - minRangeField.setMinMaxDefault(0, 100, 0); - addTextField(minRangeField); - - addLabel(new GuiNpcLabel(21, "ability.maxRange", col2LabelX, y + 5)); - GuiNpcTextField maxRangeField = new GuiNpcTextField(6, this, fontRendererObj, col2FieldX, y, 40, 20, "" + (int) maxRange); - maxRangeField.setIntegersOnly(); - maxRangeField.setMinMaxDefault(1, 100, 20); - addTextField(maxRangeField); - - y += 24; - - // Row 2: Targeting Mode (if not locked) - addLabel(new GuiNpcLabel(22, "ability.targeting", col1LabelX, y + 5)); - if (!targetingModeLocked) { - String[] targetingModes = getAvailableTargetingModes(); - int selectedIndex = getTargetingModeIndex(targetingMode); - GuiNpcButton targetBtn = new GuiNpcButton(4, col1FieldX, y, 90, 20, targetingModes, selectedIndex); - targetBtn.setHoverText("ability.hover.targeting"); - addButton(targetBtn); - } else { - String modeName = "ability.target." + targetingMode.name().toLowerCase(); - addLabel(new GuiNpcLabel(23, modeName, col1FieldX, y + 5)); - } - - y += 28; - - // ───────────────────────────────────────────────────────────────────── - // CONDITIONS SECTION (up to 3) - // ───────────────────────────────────────────────────────────────────── - addLabel(new GuiNpcLabel(24, "ability.conditions", col1LabelX, y)); - y += 14; - - // Display existing conditions (similar to Marks pattern) for (int i = 0; i < conditions.size() && i < 3; i++) { Condition cond = conditions.get(i); String condName = getConditionDisplayName(cond); - - // Condition type button - addButton(new GuiNpcButton(50 + i * 10, col1LabelX, y, 140, 20, condName)); - - // Edit button - addButton(new GuiNpcButton(51 + i * 10, col1LabelX + 145, y, 40, 20, "gui.edit")); - - // Delete button - addButton(new GuiNpcButton(52 + i * 10, col1LabelX + 190, y, 20, 20, "X")); - + sw.addButton(new GuiNpcButton(50 + i * 10, L_LABEL_X, y, 140, 20, condName)); + sw.addButton(new GuiNpcButton(51 + i * 10, L_LABEL_X + 145, y, 40, 20, "gui.edit")); + sw.addButton(new GuiNpcButton(52 + i * 10, L_LABEL_X + 190, y, 20, 20, "X")); y += 22; } - // Add button (if less than 3 conditions) if (conditions.size() < 3) { - addButton(new GuiNpcButton(80, col1LabelX, y, 50, 20, "gui.add")); + sw.addButton(new GuiNpcButton(80, L_LABEL_X, y, 50, 20, "gui.add")); + y += ROW_H; } + + return y; } private String getConditionDisplayName(Condition cond) { @@ -470,155 +243,18 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi case "target_hp_below": return StatCollector.translateToLocal("condition.target_hp_below") + " " + (int) (getConditionThreshold(cond) * 100) + "%"; case "hit_count": - Condition.ConditionHitCount hitCount = (Condition.ConditionHitCount) cond; - return StatCollector.translateToLocal("condition.hit_count") + ": " + hitCount.getRequiredHits() + "/" + hitCount.getWithinTicks() + "t"; + Condition.ConditionHitCount hc = (Condition.ConditionHitCount) cond; + return StatCollector.translateToLocal("condition.hit_count") + ": " + hc.getRequiredHits() + "/" + hc.getWithinTicks() + "t"; default: return typeId; } } private float getConditionThreshold(Condition cond) { - // Read threshold from NBT since inner classes don't expose it NBTTagCompound nbt = cond.writeNBT(); return nbt.hasKey("threshold") ? nbt.getFloat("threshold") : 0.5f; } - private String[] getAvailableTargetingModes() { - TargetingMode[] modes = ability.getAllowedTargetingModes(); - if (modes == null) { - modes = TargetingMode.values(); - } - String[] result = new String[modes.length]; - for (int i = 0; i < modes.length; i++) { - result[i] = "ability.target." + modes[i].name().toLowerCase(); - } - return result; - } - - private int getTargetingModeIndex(TargetingMode mode) { - TargetingMode[] modes = ability.getAllowedTargetingModes(); - if (modes == null) { - return mode.ordinal(); - } - for (int i = 0; i < modes.length; i++) { - if (modes[i] == mode) return i; - } - return 0; - } - - // ═══════════════════════════════════════════════════════════════════════════ - // EFFECTS TAB - // ═══════════════════════════════════════════════════════════════════════════ - - private void initEffectsTab(int startY) { - int y = startY; - int col1LabelX = guiLeft + 8; - int col1FieldX = guiLeft + 85; - int col1ClearX = guiLeft + 160; - int col2LabelX = guiLeft + 185; - int col2FieldX = guiLeft + 255; - - // ───────────────────────────────────────────────────────────────────── - // SOUNDS SECTION - // ───────────────────────────────────────────────────────────────────── - addLabel(new GuiNpcLabel(30, "advanced.sounds", col1LabelX, y)); - y += 14; - - // Wind Up Sound - addLabel(new GuiNpcLabel(31, "ability.windUpSound", col1LabelX, y + 5)); - String windUpSoundDisplay = windUpSound != null && !windUpSound.isEmpty() ? truncateString(windUpSound, 10) : StatCollector.translateToLocal("gui.none"); - addButton(new GuiNpcButton(30, col1FieldX, y, 70, 20, windUpSoundDisplay)); - addButton(new GuiNpcButton(35, col1ClearX, y, 20, 20, "X")); - - // Active Sound - addLabel(new GuiNpcLabel(32, "ability.activeSound", col2LabelX, y + 5)); - String activeSoundDisplay = activeSound != null && !activeSound.isEmpty() ? truncateString(activeSound, 10) : StatCollector.translateToLocal("gui.none"); - addButton(new GuiNpcButton(31, col2FieldX, y, 70, 20, activeSoundDisplay)); - addButton(new GuiNpcButton(36, col2FieldX + 75, y, 20, 20, "X")); - - y += 26; - - // ───────────────────────────────────────────────────────────────────── - // ANIMATIONS SECTION - // ───────────────────────────────────────────────────────────────────── - addLabel(new GuiNpcLabel(33, "menu.animations", col1LabelX, y)); - y += 14; - - // Wind Up Animation - addLabel(new GuiNpcLabel(34, "ability.windUpAnim", col1LabelX, y + 5)); - String windUpAnimName = getAnimationName(windUpAnimationId, true); - addButton(new GuiNpcButton(32, col1FieldX, y, 70, 20, windUpAnimName)); - addButton(new GuiNpcButton(37, col1ClearX, y, 20, 20, "X")); - - // Active Animation - addLabel(new GuiNpcLabel(35, "ability.activeAnim", col2LabelX, y + 5)); - String activeAnimName = getAnimationName(activeAnimationId, false); - addButton(new GuiNpcButton(33, col2FieldX, y, 70, 20, activeAnimName)); - addButton(new GuiNpcButton(38, col2FieldX + 75, y, 20, 20, "X")); - - y += 26; - - // ───────────────────────────────────────────────────────────────────── - // TELEGRAPH SECTION (only if supported) - // ───────────────────────────────────────────────────────────────────── - if (supportsTelegraph) { - addLabel(new GuiNpcLabel(40, "ability.telegraph", col1LabelX, y)); - y += 14; - - // Show Telegraph - addLabel(new GuiNpcLabel(41, "ability.showTelegraph", col1LabelX, y + 5)); - GuiNpcButton telegraphBtn = new GuiNpcButton(20, guiLeft + 95, y, 40, 20, new String[]{"gui.no", "gui.yes"}, showTelegraph ? 1 : 0); - telegraphBtn.setHoverText("ability.hover.showTelegraph"); - addButton(telegraphBtn); - - // Telegraph Type (separate column) - String typeKey = ability.getTelegraphType().name().toLowerCase(); - addLabel(new GuiNpcLabel(42, "ability.telegraphType", guiLeft + 200, y + 5)); - String telegraphLangKey = typeKey.equals("none") ? "gui.none" : "telegraph." + typeKey; - addLabel(new GuiNpcLabel(43, telegraphLangKey, guiLeft + 280, y + 5)); - - y += 24; - - // Colors - only show when telegraph is enabled - if (showTelegraph) { - addLabel(new GuiNpcLabel(44, "ability.windUpColor", col1LabelX, y + 5)); - String windUpHex = String.format("%06X", windUpColor & 0xFFFFFF); - GuiNpcButton windUpColorBtn = new GuiNpcButton(22, guiLeft + 95, y, 55, 20, windUpHex); - windUpColorBtn.setTextColor(windUpColor & 0xFFFFFF); - addButton(windUpColorBtn); - - addLabel(new GuiNpcLabel(45, "ability.activeColor", guiLeft + 200, y + 5)); - String activeHex = String.format("%06X", activeColor & 0xFFFFFF); - GuiNpcButton activeColorBtn = new GuiNpcButton(24, guiLeft + 280, y, 55, 20, activeHex); - activeColorBtn.setTextColor(activeColor & 0xFFFFFF); - addButton(activeColorBtn); - } - } - } - - private String truncateString(String str, int maxLen) { - if (str == null) return ""; - if (str.length() <= maxLen) return str; - int lastSlash = str.lastIndexOf('/'); - if (lastSlash >= 0 && str.length() - lastSlash <= maxLen) { - return "..." + str.substring(lastSlash); - } - return "..." + str.substring(str.length() - maxLen + 3); - } - - private String getAnimationName(int animId, boolean isWindUp) { - String animName = isWindUp ? windUpAnimationName : activeAnimationName; - // Check if we have a built-in animation (by name) - if (animName != null && !animName.isEmpty()) { - return truncateString(animName, 8); - } - // Check if we have a user animation (by ID) - if (animId >= 0) { - return "ID: " + animId; - } - return StatCollector.translateToLocal("gui.none"); - } - // ═══════════════════════════════════════════════════════════════════════════ // BUTTON EVENTS // ═══════════════════════════════════════════════════════════════════════════ @@ -627,154 +263,60 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi public void buttonEvent(GuiButton guibutton) { int id = guibutton.id; - // Tab switching - if (id == 90) { - activeTab = TAB_GENERAL; - initGui(); - return; - } - if (id == 91 && hasTypeSettings) { - activeTab = TAB_TYPE; - initGui(); - return; - } - if (id == 92) { - activeTab = TAB_TARGET; - initGui(); - return; - } - if (id == 93) { - activeTab = TAB_EFFECTS; - initGui(); - return; - } - if (id == 94 && hasVisualSettings) { - activeTab = TAB_VISUAL; + // Tab switching — fixed tabs + if (id == 90) { activeTab = TAB_GENERAL; initGui(); return; } + if (id == 91) { activeTab = TAB_TYPE; initGui(); return; } + if (id == 92) { activeTab = TAB_TARGET; initGui(); return; } + if (id == 93) { activeTab = TAB_EFFECTS; initGui(); return; } + // Custom tabs (94+) + if (id >= 94 && id < 94 + customTabNames.size()) { + activeTab = 4 + (id - 94); initGui(); return; } + if (id == -1000) { close(); return; } - // Enabled button (bottom left) - if (id == 2) { - enabled = ((GuiNpcButton) guibutton).getValue() == 1; - initGui(); - } + // Condition buttons (50-80) + if (handleConditionButton(id)) return; - // General tab buttons - else if (id == 14) { - interruptible = ((GuiNpcButton) guibutton).getValue() == 1; - initGui(); // Refresh to show/hide dazed ticks field - } else if (id == 16) { - lockMovement = LockMovementType.fromOrdinal(((GuiNpcButton) guibutton).getValue()); - } else if (id == 17) { - // Toggle sync on/off - syncWindupWithAnimation = !syncWindupWithAnimation; - if (syncWindupWithAnimation) { - // Calculate windup ticks from animation when turning sync on - calculateWindupFromAnimation(); - } - initGui(); - } - - // Target tab - Targeting mode - else if (id == 4) { - TargetingMode[] modes = ability.getAllowedTargetingModes(); - int idx = ((GuiNpcButton) guibutton).getValue(); - if (modes != null && idx < modes.length) { - targetingMode = modes[idx]; + // Declarative field handling (effects list, booleans, enums, sub-guis, clear buttons) + if (builder.handleButtonEvent(id, guibutton)) { + // SUB_GUI needs special handling: open the sub-gui + FieldDef subGuiDef = builder.getActiveSubGuiField(); + if (subGuiDef != null && subGuiDef.getSubGuiFactory() != null) { + setSubGui(subGuiDef.getSubGuiFactory().get()); } else { - targetingMode = TargetingMode.values()[idx]; + initGui(); } - } - - // Close button (X in top menu) - use -1000 to avoid any ID conflicts - else if (id == -1000) { - close(); return; } + } - // Target tab - Condition buttons (50-79) - else if (id >= 50 && id < 80) { + private boolean handleConditionButton(int id) { + if (id >= 50 && id < 80) { int condIndex = (id - 50) / 10; int action = (id - 50) % 10; - if (action == 0 || action == 1) { - // Click on condition name or Edit button - open edit subgui if (condIndex < conditions.size()) { editingConditionIndex = condIndex; setSubGui(new SubGuiConditionEdit(conditions.get(condIndex))); } } else if (action == 2) { - // Delete button if (condIndex < conditions.size()) { conditions.remove(condIndex); initGui(); } } + return true; } - // Add condition button - else if (id == 80) { + if (id == 80) { if (conditions.size() < 3) { editingConditionIndex = conditions.size(); setSubGui(new SubGuiConditionEdit(null)); } + return true; } - - // Effects tab - Telegraph - else if (id == 20) { - showTelegraph = ((GuiNpcButton) guibutton).getValue() == 1; - initGui(); - } else if (id == 22) { - editingColorId = 22; - setSubGui(new SubGuiColorSelector(windUpColor)); - } else if (id == 24) { - editingColorId = 24; - setSubGui(new SubGuiColorSelector(activeColor)); - } - - // Effects tab - Sound buttons - else if (id == 30) { - editingSoundId = 30; - setSubGui(new GuiSoundSelection(windUpSound)); - } else if (id == 31) { - editingSoundId = 31; - setSubGui(new GuiSoundSelection(activeSound)); - } - // Sound clear buttons - else if (id == 35) { - windUpSound = ""; - initGui(); - } else if (id == 36) { - activeSound = ""; - initGui(); - } - // Animation buttons - else if (id == 32) { - editingAnimationId = 32; - setSubGui(new GuiAnimationSelection(windUpAnimationId, windUpAnimationName)); - } else if (id == 33) { - editingAnimationId = 33; - setSubGui(new GuiAnimationSelection(activeAnimationId, activeAnimationName)); - } - // Animation clear buttons - else if (id == 37) { - windUpAnimationId = -1; - windUpAnimationName = ""; - initGui(); - } else if (id == 38) { - activeAnimationId = -1; - activeAnimationName = ""; - initGui(); - } - - // Visual-specific buttons (200+) - delegate to subclass - else if (id >= 200) { - handleVisualButton(id, (GuiNpcButton) guibutton); - } - // Type-specific buttons (100-199) - delegate to subclass - else if (id >= 100) { - handleTypeButton(id, (GuiNpcButton) guibutton); - } + return false; } // ═══════════════════════════════════════════════════════════════════════════ @@ -783,95 +325,22 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi @Override public void unFocused(GuiNpcTextField textField) { - int id = textField.id; - - // General tab - if (id == 1) { - name = textField.getText(); - } else if (id == 3) { - weight = textField.getInteger(); - } - - // Target tab - else if (id == 5) { - minRange = textField.getInteger(); - } else if (id == 6) { - maxRange = textField.getInteger(); - } - - // Timing (General tab) - else if (id == 10) { - cooldownTicks = textField.getInteger(); - } else if (id == 11) { - windUpTicks = textField.getInteger(); - } else if (id == 13) { - dazedTicks = textField.getInteger(); - } - - // Visual-specific fields (200+) - delegate to subclass - else if (id >= 200) { - handleVisualTextField(id, textField); - } - // Type-specific fields (100-199) - delegate to subclass - else if (id >= 100) { - handleTypeTextField(id, textField); - } + if (textField.id < DECLARATIVE_ID_START) return; + builder.handleTextFieldEvent(textField.id, textField); } // ═══════════════════════════════════════════════════════════════════════════ - // SUBGUI CLOSED HANDLER + // SUB GUI CLOSED // ═══════════════════════════════════════════════════════════════════════════ @Override public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingColorId == 22) { - windUpColor = 0x80000000 | rgb; - } else if (editingColorId == 24) { - activeColor = 0xC0000000 | rgb; - } - editingColorId = 0; + if (builder.handleSubGuiClosed(subgui)) { initGui(); - } else if (subgui instanceof GuiSoundSelection) { - GuiSoundSelection soundSelector = (GuiSoundSelection) subgui; - if (soundSelector.selectedResource != null) { - String sound = soundSelector.selectedResource.toString(); - if (editingSoundId == 30) { - windUpSound = sound; - } else if (editingSoundId == 31) { - activeSound = sound; - } - } - editingSoundId = 0; - initGui(); - } else if (subgui instanceof GuiAnimationSelection) { - GuiAnimationSelection animSelector = (GuiAnimationSelection) subgui; - if (editingAnimationId == 32) { - if (animSelector.isBuiltInSelected()) { - // Built-in animation selected - use name, clear ID - windUpAnimationName = animSelector.selectedBuiltInName; - windUpAnimationId = -1; - } else { - // User animation selected - use ID, clear name - windUpAnimationId = animSelector.selectedAnimationId; - windUpAnimationName = ""; - } - } else if (editingAnimationId == 33) { - if (animSelector.isBuiltInSelected()) { - // Built-in animation selected - use name, clear ID - activeAnimationName = animSelector.selectedBuiltInName; - activeAnimationId = -1; - } else { - // User animation selected - use ID, clear name - activeAnimationId = animSelector.selectedAnimationId; - activeAnimationName = ""; - } - } - editingAnimationId = 0; - initGui(); - } else if (subgui instanceof SubGuiConditionEdit) { + return; + } + + if (subgui instanceof SubGuiConditionEdit) { SubGuiConditionEdit condEdit = (SubGuiConditionEdit) subgui; Condition result = condEdit.getResult(); if (result != null && editingConditionIndex >= 0) { @@ -887,179 +356,33 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi } // ═══════════════════════════════════════════════════════════════════════════ - // CLOSE - Save before closing + // CLOSE / APPLY // ═══════════════════════════════════════════════════════════════════════════ @Override public void close() { - // Apply all cached values to the ability before closing applyToAbility(); - - // Notify callback that ability was saved callback.onAbilitySaved(ability); - - // Close the GUI super.close(); } - // ═══════════════════════════════════════════════════════════════════════════ - // APPLY TO ABILITY - // ═══════════════════════════════════════════════════════════════════════════ - protected void applyToAbility() { - // General - ability.setName(name); - ability.setEnabled(enabled); - ability.setWeight(weight); - ability.setLockMovement(lockMovement); - ability.setInterruptible(interruptible); - - // If sync is enabled and we have a windup animation, recalculate before saving - boolean hasWindupAnimation = windUpAnimationId >= 0 || (windUpAnimationName != null && !windUpAnimationName.isEmpty()); - if (syncWindupWithAnimation && hasWindupAnimation) { - calculateWindupFromAnimation(); - } - - // Timing - ability.setCooldownTicks(cooldownTicks); - ability.setWindUpTicks(windUpTicks); - ability.setDazedTicks(dazedTicks); - ability.setSyncWindupWithAnimation(syncWindupWithAnimation); - - // Target - ability.setMinRange(minRange); - ability.setMaxRange(maxRange); - ability.setTargetingMode(targetingMode); - - // Conditions ability.getConditions().clear(); - for (Condition c : conditions) { - ability.addCondition(c); - } - - // Effects - ability.setWindUpSound(windUpSound); - ability.setActiveSound(activeSound); - ability.setWindUpAnimationId(windUpAnimationId); - ability.setActiveAnimationId(activeAnimationId); - ability.setWindUpAnimationName(windUpAnimationName != null ? windUpAnimationName : ""); - ability.setActiveAnimationName(activeAnimationName != null ? activeAnimationName : ""); - - // Telegraph - ability.setShowTelegraph(showTelegraph); - ability.setWindUpColor(windUpColor); - ability.setActiveColor(activeColor); - - // Type-specific values are applied directly in handleTypeTextField and handleTypeButton + for (Condition c : conditions) ability.addCondition(c); } - /** - * Called when an ability is loaded from saved presets. - */ public void loadAbility(Ability loadedAbility) { if (loadedAbility == null) return; - - // Copy all values from loaded ability to current ability NBTTagCompound nbt = loadedAbility.writeNBT(); - // Keep the current typeId since we can't change types mid-edit nbt.setString("typeId", ability.getTypeId()); ability.readNBT(nbt); - // Update cached values - this.name = ability.getName() != null ? ability.getName() : ""; - this.enabled = ability.isEnabled(); - this.weight = ability.getWeight(); - this.lockMovement = ability.getLockMovement(); - this.interruptible = ability.isInterruptible(); - - this.cooldownTicks = ability.getCooldownTicks(); - this.windUpTicks = ability.getWindUpTicks(); - this.dazedTicks = ability.getDazedTicks(); - - this.minRange = ability.getMinRange(); - this.maxRange = ability.getMaxRange(); - this.targetingMode = ability.getTargetingMode(); this.conditions = new ArrayList<>(ability.getConditions()); - - this.showTelegraph = ability.isShowTelegraph(); - this.windUpColor = ability.getWindUpColor(); - this.activeColor = ability.getActiveColor(); - + this.fieldDefs = ability.getAllFieldDefinitions(); + discoverCustomTabs(); initGui(); } - // ═══════════════════════════════════════════════════════════════════════════ - // SYNC ANIMATION - // ═══════════════════════════════════════════════════════════════════════════ - - /** - * Calculates windup ticks from the selected windup animation's total duration. - */ - private void calculateWindupFromAnimation() { - if (AnimationController.Instance == null) { - return; - } - - Animation animation = null; - // Check for built-in animation (by name) first - if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) { - animation = (Animation) AnimationController.Instance.get(windUpAnimationName, true); - } - // Fall back to user animation (by ID) - else if (windUpAnimationId >= 0) { - animation = (Animation) AnimationController.Instance.get(windUpAnimationId); - } - - if (animation == null || animation.frames.isEmpty()) { - return; - } - - // Calculate total duration by summing all frame durations - int totalDuration = 0; - for (Frame frame : animation.frames) { - totalDuration += frame.getDuration(); - } - - // Update the cached value and refresh GUI - windUpTicks = totalDuration; - initGui(); - } - - // ═══════════════════════════════════════════════════════════════════════════ - // HELPER METHODS FOR SUBCLASSES - // ═══════════════════════════════════════════════════════════════════════════ - - /** - * Creates a float text field for type-specific settings. - */ - protected GuiNpcTextField createFloatField(int id, int x, int y, int width, float value) { - GuiNpcTextField field = new GuiNpcTextField(id, this, fontRendererObj, x, y, width, 20, String.format("%.1f", value)); - return field; - } - - /** - * Creates an integer text field for type-specific settings. - */ - protected GuiNpcTextField createIntField(int id, int x, int y, int width, int value) { - GuiNpcTextField field = new GuiNpcTextField(id, this, fontRendererObj, x, y, width, 20, "" + value); - field.setIntegersOnly(); - return field; - } - - /** - * Parses a float from a text field with a fallback default value. - */ - protected float parseFloat(GuiNpcTextField field, float defaultValue) { - try { - return Float.parseFloat(field.getText()); - } catch (NumberFormatException e) { - return defaultValue; - } - } - - /** - * Gets the ability being edited. - */ protected Ability getAbility() { return ability; } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeamDual.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeamDual.java deleted file mode 100644 index 3e1886c53..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeamDual.java +++ /dev/null @@ -1,328 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityBeamDual; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.*; - -import java.util.List; - -public class SubGuiAbilityBeamDual extends SubGuiAbilityConfig { - private final AbilityBeamDual beam; - private int editingVisualColorId = 0; - private int editingBeam = 0; - - public SubGuiAbilityBeamDual(AbilityBeamDual ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.beam = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, beam.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, beam.getSpeed())); - - y += 24; - - // Row 2: Beam Width + Head Size - addLabel(new GuiNpcLabel(102, "ability.beamWidth", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, beam.getBeamWidth())); - - addLabel(new GuiNpcLabel(103, "ability.headSize", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, beam.getHeadSize())); - - y += 24; - - // Row 3: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (beam.isHoming()) { - addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, beam.getHomingStrength())); - } - - y += 24; - - // Row 4: Max Distance (+ Homing Range only if homing) - if (beam.isHoming()) { - addLabel(new GuiNpcLabel(106, "ability.homingRange", labelX, y + 5)); - addTextField(createFloatField(106, fieldX, y, 50, beam.getHomingRange())); - } - - addLabel(new GuiNpcLabel(107, "ability.maxDist", beam.isHoming() ? col2LabelX : labelX, y + 5)); - addTextField(createFloatField(107, beam.isHoming() ? col2FieldX : fieldX, y, 50, beam.getMaxDistance())); - - y += 24; - - // Row 5: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(108, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (beam.isExplosive()) { - addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(109, col2FieldX, y, 50, beam.getExplosionRadius())); - } - - y += 24; - - // Row 6: Knockback + Max Lifetime - addLabel(new GuiNpcLabel(110, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(110, fieldX, y, 50, beam.getKnockback())); - - addLabel(new GuiNpcLabel(111, "ability.lifetime", col2LabelX, y + 5)); - addTextField(createIntField(111, col2FieldX, y, 50, beam.getMaxLifetime())); - - y += 24; - - addLabel(new GuiNpcLabel(112, "ability.dualFire", labelX, y + 5)); - addButton(new GuiNpcButtonYesNo(112, fieldX, y, beam.isDualFire())); - - if (beam.isDualFire()) { - addLabel(new GuiNpcLabel(113, "ability.dualFireDelay", col2LabelX, y + 5)); - addTextField(createIntField(113, col2FieldX, y, 50, beam.getDualFireDelay())); - } - - y += 24; - - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), beam.getAnchorPointEnum(editingBeam).ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Outer Color - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", beam.getInnerColor(editingBeam) & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(beam.getInnerColor(editingBeam) & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5)); - String outerHex = String.format("%06X", beam.getOuterColor(editingBeam) & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(beam.getOuterColor(editingBeam) & 0xFFFFFF); - outerColorBtn.setEnabled(beam.isOuterColorEnabled(editingBeam)); - addButton(outerColorBtn); - - y += 24; - - // Row 2: Outer Color Enabled + Outer Color Width - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isOuterColorEnabled(editingBeam) ? 1 : 0)); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, beam.getOuterColorWidth(editingBeam)); - widthField.setEnabled(beam.isOuterColorEnabled(editingBeam)); - addTextField(widthField); - - y += 24; - - // Row 3: Rotation Speed - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", labelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, fieldX, y, 55, beam.getOuterColorAlpha(editingBeam)); - alphaField.setEnabled(beam.isOuterColorEnabled(editingBeam)); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(205, col2FieldX, y, 50, beam.getRotationSpeed(editingBeam))); - - y += 24; - - // Row 4: Lightning Effect Enabled (only affects head) - addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.hasLightningEffect(editingBeam) ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (beam.hasLightningEffect(editingBeam)) { - y += 24; - - // Row 5: Density + Radius - addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + beam.getLightningDensity(editingBeam)); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + beam.getLightningRadius(editingBeam)); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - - y += 24; - - addButton(new GuiNpcButton(400, col2FieldX, y, 55, 20, new String[]{"Beam 1", "Beam 2"}, editingBeam)); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - beam.setHoming(value == 1); - initGui(); - break; - case 108: - beam.setExplosive(value == 1); - initGui(); - break; - case 112: - beam.setDualFire(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(beam.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(beam.getInnerColor(editingBeam))); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(beam.getOuterColor(editingBeam))); - break; - case 202: - beam.setOuterColorEnabled(editingBeam, value == 1); - initGui(); - break; - case 206: - beam.setLightningEffect(editingBeam, value == 1); - initGui(); - break; - case 210: - beam.setAnchorPointEnum(editingBeam, AnchorPoint.fromOrdinal(value)); - break; - case 400: - editingBeam = (editingBeam + 1) % 2; - initGui(); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - beam.setInnerColor(editingBeam, rgb); - } else if (editingVisualColorId == 201) { - beam.setOuterColor(editingBeam, rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - beam.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - beam.setDamage(parseFloat(field, beam.getDamage())); - break; - case 101: - beam.setSpeed(parseFloat(field, beam.getSpeed())); - break; - case 102: - beam.setBeamWidth(parseFloat(field, beam.getBeamWidth())); - break; - case 103: - beam.setHeadSize(parseFloat(field, beam.getHeadSize())); - break; - case 105: - beam.setHomingStrength(parseFloat(field, beam.getHomingStrength())); - break; - case 106: - beam.setHomingRange(parseFloat(field, beam.getHomingRange())); - break; - case 107: - beam.setMaxDistance(parseFloat(field, beam.getMaxDistance())); - break; - case 109: - beam.setExplosionRadius(parseFloat(field, beam.getExplosionRadius())); - break; - case 110: - beam.setKnockback(parseFloat(field, beam.getKnockback())); - break; - case 111: - beam.setMaxLifetime(field.getInteger()); - break; - case 113: - beam.setDualFireDelay(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - beam.setOuterColorWidth(editingBeam, parseFloat(field, beam.getOuterColorWidth(editingBeam))); - break; - case 204: - beam.setOuterColorAlpha(editingBeam, parseFloat(field, beam.getOuterColorAlpha(editingBeam))); - break; - case 205: - beam.setRotationSpeed(editingBeam, parseFloat(field, beam.getRotationSpeed(editingBeam))); - break; - case 207: - beam.setLightningDensity(editingBeam, parseFloat(field, beam.getLightningDensity(editingBeam))); - break; - case 208: - beam.setLightningRadius(editingBeam, parseFloat(field, beam.getLightningRadius(editingBeam))); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java deleted file mode 100644 index ea35797c4..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java +++ /dev/null @@ -1,92 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityCharge; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Charge ability type-specific settings. - */ -public class SubGuiAbilityCharge extends SubGuiAbilityConfig { - - private final AbilityCharge charge; - - public SubGuiAbilityCharge(AbilityCharge ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.charge = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, charge.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, charge.getChargeSpeed())); - - y += 24; - - // Row 2: Knockback - addLabel(new GuiNpcLabel(102, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, charge.getKnockback())); - - y += 24; - - // Row 3: Hit Width + Effects - addLabel(new GuiNpcLabel(104, "ability.hitWidth", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, charge.getHitWidth())); - - addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - if (id == 150) { - setSubGui(new SubGuiAbilityEffects(charge.getEffects())); - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - charge.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - charge.setDamage(parseFloat(field, charge.getDamage())); - break; - case 101: - charge.setChargeSpeed(parseFloat(field, charge.getChargeSpeed())); - break; - case 102: - charge.setKnockback(parseFloat(field, charge.getKnockback())); - break; - case 104: - charge.setHitWidth(parseFloat(field, charge.getHitWidth())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java deleted file mode 100644 index a1539536d..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java +++ /dev/null @@ -1,141 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityCutter; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Cutter ability type-specific settings. - */ -public class SubGuiAbilityCutter extends SubGuiAbilityConfig { - - private final AbilityCutter cutter; - - public SubGuiAbilityCutter(AbilityCutter ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.cutter = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Range - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, cutter.getDamage())); - - addLabel(new GuiNpcLabel(101, "gui.range", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, cutter.getRange())); - - y += 24; - - // Row 2: Arc Angle + Inner Radius - addLabel(new GuiNpcLabel(102, "ability.arcAngle", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, cutter.getArcAngle())); - - addLabel(new GuiNpcLabel(103, "ability.innerRadius", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, cutter.getInnerRadius())); - - y += 24; - - // Row 3: Knockback + Sweep Speed - addLabel(new GuiNpcLabel(104, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, cutter.getKnockback())); - - addLabel(new GuiNpcLabel(105, "ability.sweepSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, cutter.getSweepSpeed())); - - y += 24; - - // Row 4: Sweep Mode + Piercing - addLabel(new GuiNpcLabel(106, "ability.sweepMode", labelX, y + 5)); - String[] sweepModes = {"Swipe", "Spin"}; - GuiNpcButton sweepModeBtn = new GuiNpcButton(106, fieldX, y, 70, 20, sweepModes, cutter.getSweepModeEnum().ordinal()); - sweepModeBtn.setHoverText("ability.hover.sweepMode"); - addButton(sweepModeBtn); - - addLabel(new GuiNpcLabel(107, "ability.piercing", col2LabelX, y + 5)); - GuiNpcButton piercingBtn = new GuiNpcButton(107, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, cutter.isPiercing() ? 1 : 0); - piercingBtn.setHoverText("ability.hover.piercing"); - addButton(piercingBtn); - - y += 24; - - // Row 5: Spin Duration (only for SPIN mode) + Effects button - if (cutter.getSweepModeEnum() == AbilityCutter.SweepMode.SPIN) { - addLabel(new GuiNpcLabel(108, "ability.duration", labelX, y + 5)); - GuiNpcTextField durationField = createIntField(108, fieldX, y, 50, cutter.getSpinDurationTicks()); - durationField.setMinMaxDefault(1, 1000, 60); - addTextField(durationField); - } - - addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 106: - cutter.setSweepModeEnum(AbilityCutter.SweepMode.values()[value]); - initGui(); // Refresh to show/hide duration field - break; - case 107: - cutter.setPiercing(value == 1); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(cutter.getEffects())); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - cutter.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - cutter.setDamage(parseFloat(field, cutter.getDamage())); - break; - case 101: - cutter.setRange(parseFloat(field, cutter.getRange())); - break; - case 102: - cutter.setArcAngle(parseFloat(field, cutter.getArcAngle())); - break; - case 103: - cutter.setInnerRadius(parseFloat(field, cutter.getInnerRadius())); - break; - case 104: - cutter.setKnockback(parseFloat(field, cutter.getKnockback())); - break; - case 105: - cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed())); - break; - case 108: - cutter.setSpinDurationTicks(field.getInteger()); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java deleted file mode 100644 index 9d7bd63b6..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java +++ /dev/null @@ -1,65 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.type.AbilityDash; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; - -/** - * GUI for configuring Dash ability type-specific settings. - */ -public class SubGuiAbilityDash extends SubGuiAbilityConfig { - - private final AbilityDash dash; - - public SubGuiAbilityDash(AbilityDash ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.dash = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Dash Mode - addLabel(new GuiNpcLabel(100, "ability.mode", labelX, y + 5)); - String[] dashModes = {"Aggressive", "Defensive"}; - GuiNpcButton modeBtn = new GuiNpcButton(100, fieldX, y, 80, 20, dashModes, dash.getDashModeEnum().ordinal()); - modeBtn.setHoverText("ability.hover.dashMode"); - addButton(modeBtn); - - y += 24; - - // Row 2: Dash Distance + Dash Speed - addLabel(new GuiNpcLabel(101, "ability.dashDist", labelX, y + 5)); - addTextField(createFloatField(101, fieldX, y, 50, dash.getDashDistance())); - - addLabel(new GuiNpcLabel(102, "ability.dashSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(102, col2FieldX, y, 50, dash.getDashSpeed())); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - if (id == 100) { - dash.setDashModeEnum(AbilityDash.DashMode.values()[button.getValue()]); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 101: - dash.setDashDistance(parseFloat(field, dash.getDashDistance())); - break; - case 102: - dash.setDashSpeed(parseFloat(field, dash.getDashSpeed())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java deleted file mode 100644 index 7f3d04d9e..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java +++ /dev/null @@ -1,323 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityDisc; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Disc ability type-specific settings. - */ -public class SubGuiAbilityDisc extends SubGuiAbilityConfig { - - private final AbilityDisc disc; - private int editingVisualColorId = 0; - - public SubGuiAbilityDisc(AbilityDisc ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.disc = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, disc.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, disc.getSpeed())); - - y += 24; - - // Row 2: Disc Radius + Disc Thickness - addLabel(new GuiNpcLabel(102, "ability.discRadius", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, disc.getDiscRadius())); - - addLabel(new GuiNpcLabel(103, "ability.discThickness", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, disc.getDiscThickness())); - - y += 24; - - // Row 3: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (disc.isHoming()) { - addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, disc.getHomingStrength())); - } - - y += 24; - - // Row 4: Boomerang + Boomerang Delay (only show delay if boomerang) - addLabel(new GuiNpcLabel(106, "ability.boomerang", labelX, y + 5)); - GuiNpcButton boomerangBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isBoomerang() ? 1 : 0); - boomerangBtn.setHoverText("ability.hover.boomerang"); - addButton(boomerangBtn); - - if (disc.isBoomerang()) { - addLabel(new GuiNpcLabel(107, "ability.boomerangDelay", col2LabelX, y + 5)); - addTextField(createIntField(107, col2FieldX, y, 50, disc.getBoomerangDelay())); - } - - y += 24; - - // Row 5: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(108, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (disc.isExplosive()) { - addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(109, col2FieldX, y, 50, disc.getExplosionRadius())); - } - - y += 24; - - // Row 6: Knockback + Max Distance - addLabel(new GuiNpcLabel(110, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(110, fieldX, y, 50, disc.getKnockback())); - - addLabel(new GuiNpcLabel(111, "ability.maxDist", col2LabelX, y + 5)); - addTextField(createFloatField(111, col2FieldX, y, 50, disc.getMaxDistance())); - - y += 24; - - // Row 7: Max Lifetime + Effects button - addLabel(new GuiNpcLabel(112, "ability.lifetime", labelX, y + 5)); - addTextField(createIntField(112, fieldX, y, 50, disc.getMaxLifetime())); - - addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), disc.getAnchorPointEnum().ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Outer Color - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", disc.getInnerColor() & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(disc.getInnerColor() & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5)); - String outerHex = String.format("%06X", disc.getOuterColor() & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(disc.getOuterColor() & 0xFFFFFF); - outerColorBtn.setEnabled(disc.isOuterColorEnabled()); - addButton(outerColorBtn); - - y += 24; - - // Row 2: Outer Color Enabled + Outer Color Width - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isOuterColorEnabled() ? 1 : 0)); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, disc.getOuterColorWidth()); - widthField.setEnabled(disc.isOuterColorEnabled()); - addTextField(widthField); - - y += 24; - - // Row 3: Outer Color Alpha - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", labelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, fieldX, y, 55, disc.getOuterColorAlpha()); - alphaField.setEnabled(disc.isOuterColorEnabled()); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - y += 24; - - // Row 4: Rotation Speed - addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", labelX, y + 5)); - addTextField(createFloatField(205, fieldX, y, 50, disc.getRotationSpeed())); - - y += 24; - - // Row 5: Lightning Effect Enabled - addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.hasLightningEffect() ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (disc.hasLightningEffect()) { - y += 24; - - // Row 6: Density + Radius - addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + disc.getLightningDensity()); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + disc.getLightningRadius()); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - disc.setHoming(value == 1); - initGui(); - break; - case 106: - disc.setBoomerang(value == 1); - initGui(); - break; - case 108: - disc.setExplosive(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(disc.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(disc.getInnerColor())); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(disc.getOuterColor())); - break; - case 202: - disc.setOuterColorEnabled(value == 1); - initGui(); - break; - case 206: - disc.setLightningEffect(value == 1); - initGui(); - break; - case 210: - disc.setAnchorPointEnum(AnchorPoint.fromOrdinal(value)); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - disc.setInnerColor(rgb); - } else if (editingVisualColorId == 201) { - disc.setOuterColor(rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - disc.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - disc.setDamage(parseFloat(field, disc.getDamage())); - break; - case 101: - disc.setSpeed(parseFloat(field, disc.getSpeed())); - break; - case 102: - disc.setDiscRadius(parseFloat(field, disc.getDiscRadius())); - break; - case 103: - disc.setDiscThickness(parseFloat(field, disc.getDiscThickness())); - break; - case 105: - disc.setHomingStrength(parseFloat(field, disc.getHomingStrength())); - break; - case 107: - disc.setBoomerangDelay(field.getInteger()); - break; - case 109: - disc.setExplosionRadius(parseFloat(field, disc.getExplosionRadius())); - break; - case 110: - disc.setKnockback(parseFloat(field, disc.getKnockback())); - break; - case 111: - disc.setMaxDistance(parseFloat(field, disc.getMaxDistance())); - break; - case 112: - disc.setMaxLifetime(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - disc.setOuterColorWidth(parseFloat(field, disc.getOuterColorWidth())); - break; - case 204: - disc.setOuterColorAlpha(parseFloat(field, disc.getOuterColorAlpha())); - break; - case 205: - disc.setRotationSpeed(parseFloat(field, disc.getRotationSpeed())); - break; - case 207: - disc.setLightningDensity(parseFloat(field, disc.getLightningDensity())); - break; - case 208: - disc.setLightningRadius(parseFloat(field, disc.getLightningRadius())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDiscDual.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDiscDual.java deleted file mode 100644 index c8ab5a352..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDiscDual.java +++ /dev/null @@ -1,341 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityDiscDual; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.*; - -import java.util.List; - -public class SubGuiAbilityDiscDual extends SubGuiAbilityConfig { - private final AbilityDiscDual disc; - private int editingVisualColorId = 0; - private int editingDisc = 0; - - public SubGuiAbilityDiscDual(AbilityDiscDual ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.disc = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, disc.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, disc.getSpeed())); - - y += 24; - - // Row 2: Disc Radius + Disc Thickness - addLabel(new GuiNpcLabel(102, "ability.discRadius", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, disc.getDiscRadius())); - - addLabel(new GuiNpcLabel(103, "ability.discThickness", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, disc.getDiscThickness())); - - y += 24; - - // Row 3: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (disc.isHoming()) { - addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, disc.getHomingStrength())); - } - - y += 24; - - // Row 4: Boomerang + Boomerang Delay (only show delay if boomerang) - addLabel(new GuiNpcLabel(106, "ability.boomerang", labelX, y + 5)); - GuiNpcButton boomerangBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isBoomerang() ? 1 : 0); - boomerangBtn.setHoverText("ability.hover.boomerang"); - addButton(boomerangBtn); - - if (disc.isBoomerang()) { - addLabel(new GuiNpcLabel(107, "ability.boomerangDelay", col2LabelX, y + 5)); - addTextField(createIntField(107, col2FieldX, y, 50, disc.getBoomerangDelay())); - } - - y += 24; - - // Row 5: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(108, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (disc.isExplosive()) { - addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(109, col2FieldX, y, 50, disc.getExplosionRadius())); - } - - y += 24; - - // Row 6: Knockback + Max Distance - addLabel(new GuiNpcLabel(110, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(110, fieldX, y, 50, disc.getKnockback())); - - addLabel(new GuiNpcLabel(111, "ability.maxDist", col2LabelX, y + 5)); - addTextField(createFloatField(111, col2FieldX, y, 50, disc.getMaxDistance())); - - y += 24; - - // Row 7: Max Lifetime + Effects button - addLabel(new GuiNpcLabel(112, "ability.lifetime", labelX, y + 5)); - addTextField(createIntField(112, fieldX, y, 50, disc.getMaxLifetime())); - - y += 24; - - addLabel(new GuiNpcLabel(113, "ability.dualFire", labelX, y + 5)); - addButton(new GuiNpcButtonYesNo(113, fieldX, y, disc.isDualFire())); - - if (disc.isDualFire()) { - addLabel(new GuiNpcLabel(114, "ability.dualFireDelay", col2LabelX, y + 5)); - addTextField(createIntField(114, col2FieldX, y, 50, disc.getDualFireDelay())); - } - - addButton(new GuiNpcButton(150, col2LabelX + 120, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), disc.getAnchorPointEnum(editingDisc).ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Outer Color - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", disc.getInnerColor(editingDisc) & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(disc.getInnerColor(editingDisc) & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5)); - String outerHex = String.format("%06X", disc.getOuterColor(editingDisc) & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(disc.getOuterColor(editingDisc) & 0xFFFFFF); - outerColorBtn.setEnabled(disc.isOuterColorEnabled(editingDisc)); - addButton(outerColorBtn); - - y += 24; - - // Row 2: Outer Color Enabled + Outer Color Width - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isOuterColorEnabled(editingDisc) ? 1 : 0)); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, disc.getOuterColorWidth(editingDisc)); - widthField.setEnabled(disc.isOuterColorEnabled(editingDisc)); - addTextField(widthField); - - y += 24; - - // Row 3: Outer Color Alpha - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", labelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, fieldX, y, 55, disc.getOuterColorAlpha(editingDisc)); - alphaField.setEnabled(disc.isOuterColorEnabled(editingDisc)); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - y += 24; - - // Row 4: Rotation Speed - addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", labelX, y + 5)); - addTextField(createFloatField(205, fieldX, y, 50, disc.getRotationSpeed(editingDisc))); - - y += 24; - - // Row 5: Lightning Effect Enabled - addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.hasLightningEffect(editingDisc) ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (disc.hasLightningEffect(editingDisc)) { - y += 24; - - // Row 6: Density + Radius - addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + disc.getLightningDensity(editingDisc)); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + disc.getLightningRadius(editingDisc)); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - - y += 24; - - addButton(new GuiNpcButton(400, col2FieldX, y, 55, 20, new String[]{"Disc 1", "Disc 2"}, editingDisc)); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - disc.setHoming(value == 1); - initGui(); - break; - case 106: - disc.setBoomerang(value == 1); - initGui(); - break; - case 108: - disc.setExplosive(value == 1); - initGui(); - break; - case 113: - disc.setDualFire(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(disc.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(disc.getInnerColor(editingDisc))); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(disc.getOuterColor(editingDisc))); - break; - case 202: - disc.setOuterColorEnabled(editingDisc, value == 1); - initGui(); - break; - case 206: - disc.setLightningEffect(editingDisc, value == 1); - initGui(); - break; - case 210: - disc.setAnchorPointEnum(editingDisc, AnchorPoint.fromOrdinal(value)); - break; - case 400: - editingDisc = (editingDisc + 1) % 2; - initGui(); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - disc.setInnerColor(editingDisc, rgb); - } else if (editingVisualColorId == 201) { - disc.setOuterColor(editingDisc, rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - disc.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - disc.setDamage(parseFloat(field, disc.getDamage())); - break; - case 101: - disc.setSpeed(parseFloat(field, disc.getSpeed())); - break; - case 102: - disc.setDiscRadius(parseFloat(field, disc.getDiscRadius())); - break; - case 103: - disc.setDiscThickness(parseFloat(field, disc.getDiscThickness())); - break; - case 105: - disc.setHomingStrength(parseFloat(field, disc.getHomingStrength())); - break; - case 107: - disc.setBoomerangDelay(field.getInteger()); - break; - case 109: - disc.setExplosionRadius(parseFloat(field, disc.getExplosionRadius())); - break; - case 110: - disc.setKnockback(parseFloat(field, disc.getKnockback())); - break; - case 111: - disc.setMaxDistance(parseFloat(field, disc.getMaxDistance())); - break; - case 112: - disc.setMaxLifetime(field.getInteger()); - break; - case 114: - disc.setDualFireDelay(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - disc.setOuterColorWidth(editingDisc, parseFloat(field, disc.getOuterColorWidth(editingDisc))); - break; - case 204: - disc.setOuterColorAlpha(editingDisc, parseFloat(field, disc.getOuterColorAlpha(editingDisc))); - break; - case 205: - disc.setRotationSpeed(editingDisc, parseFloat(field, disc.getRotationSpeed(editingDisc))); - break; - case 207: - disc.setLightningDensity(editingDisc, parseFloat(field, disc.getLightningDensity(editingDisc))); - break; - case 208: - disc.setLightningRadius(editingDisc, parseFloat(field, disc.getLightningRadius(editingDisc))); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEffects.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEffects.java deleted file mode 100644 index 56ddaf9f6..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEffects.java +++ /dev/null @@ -1,202 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import net.minecraft.client.gui.GuiButton; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.ITextfieldListener; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.ArrayList; -import java.util.List; - -/** - * SubGui for editing ability effects (potion effects that apply to targets). - * Allows adding/removing effects and configuring type, duration, and amplifier. - */ -public class SubGuiAbilityEffects extends SubGuiInterface implements ITextfieldListener { - - private static final int MAX_EFFECTS = 5; - - // Effect type names for display - private static final String[] EFFECT_TYPE_NAMES = { - "gui.none", - "potion.moveSlowdown", - "potion.weakness", - "potion.poison", - "potion.wither", - "potion.blindness", - "potion.confusion", - "potion.hunger", - "potion.digSlowDown" - }; - - // Working copy of effects - private List effects; - private boolean cancelled = false; - - public SubGuiAbilityEffects(List existingEffects) { - // Create working copies of effects - this.effects = new ArrayList<>(); - if (existingEffects != null) { - for (AbilityEffect effect : existingEffects) { - this.effects.add(effect.copy()); - } - } - - setBackground("menubg.png"); - xSize = 280; - ySize = 180; - } - - @Override - public void initGui() { - super.initGui(); - - int y = guiTop + 8; - int labelX = guiLeft + 8; - - // Title - addLabel(new GuiNpcLabel(0, "ability.effects", labelX, y)); - y += 16; - - // Column headers - addLabel(new GuiNpcLabel(1, "gui.type", guiLeft + 10, y)); - addLabel(new GuiNpcLabel(2, "gui.duration", guiLeft + 115, y)); - addLabel(new GuiNpcLabel(3, "gui.amp", guiLeft + 175, y)); - y += 14; - - // Effect rows - for (int i = 0; i < effects.size() && i < MAX_EFFECTS; i++) { - AbilityEffect effect = effects.get(i); - int baseId = 1 + i * 10; - - // Type selector button - int typeIndex = effect.getType().ordinal(); - GuiNpcButton typeBtn = new GuiNpcButton(baseId, guiLeft + 8, y, 100, 20, EFFECT_TYPE_NAMES, typeIndex); - typeBtn.setHoverText("effect.hover.type"); - addButton(typeBtn); - - // Duration text field - GuiNpcTextField durField = new GuiNpcTextField(baseId + 1, this, fontRendererObj, - guiLeft + 112, y, 50, 20, "" + effect.getDurationTicks()); - durField.setIntegersOnly(); - durField.setMinMaxDefault(1, 12000, 60); - durField.setHoverText("effect.hover.duration"); - addTextField(durField); - - // Amplifier selector (0-10) - String[] ampValues = new String[11]; - for (int a = 0; a <= 10; a++) { - ampValues[a] = "" + a; - } - GuiNpcButton ampBtn = new GuiNpcButton(baseId + 2, guiLeft + 168, y, 40, 20, ampValues, effect.getAmplifier()); - ampBtn.setHoverText("effect.hover.amplifier"); - addButton(ampBtn); - - // Delete button - addButton(new GuiNpcButton(baseId + 3, guiLeft + 215, y, 20, 20, "X")); - - y += 24; - } - - // Add button (if space available) - if (effects.size() < MAX_EFFECTS) { - addButton(new GuiNpcButton(100, guiLeft + 8, y, 50, 20, "gui.add")); - } - - // Bottom buttons - addButton(new GuiNpcButton(65, guiLeft + 8, guiTop + ySize - 28, 60, 20, "gui.cancel")); - addButton(new GuiNpcButton(66, guiLeft + xSize - 68, guiTop + ySize - 28, 60, 20, "gui.done")); - } - - @Override - public void buttonEvent(GuiButton guibutton) { - int id = guibutton.id; - - // Add button - if (id == 100) { - if (effects.size() < MAX_EFFECTS) { - // Add new effect with default values (Slowness, 60 ticks, amp 0) - effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0)); - initGui(); - } - return; - } - - // Cancel button - if (id == 65) { - cancelled = true; - close(); - return; - } - - // Done button - if (id == 66) { - // Remove any NONE effects before saving - effects.removeIf(e -> !e.isValid()); - cancelled = false; - close(); - return; - } - - // Effect row buttons (id >= 1 and < 100) - if (id >= 1 && id < 100) { - int effectIndex = (id - 1) / 10; - int action = (id - 1) % 10; - - if (effectIndex >= 0 && effectIndex < effects.size()) { - AbilityEffect effect = effects.get(effectIndex); - - switch (action) { - case 0: // Type selector - int typeIndex = ((GuiNpcButton) guibutton).getValue(); - effect.setType(AbilityEffect.EffectType.fromOrdinal(typeIndex)); - break; - case 2: // Amplifier selector - int amp = ((GuiNpcButton) guibutton).getValue(); - effect.setAmplifier(amp); - break; - case 3: // Delete button - effects.remove(effectIndex); - initGui(); - break; - } - } - } - } - - @Override - public void unFocused(GuiNpcTextField textField) { - int id = textField.id; - - // Duration text fields (baseId + 1) - if (id >= 2 && id < 100) { - int effectIndex = (id - 1) / 10; - int action = (id - 1) % 10; - - if (action == 1 && effectIndex >= 0 && effectIndex < effects.size()) { - effects.get(effectIndex).setDurationTicks(textField.getInteger()); - } - } - } - - /** - * Returns the resulting effects list after the dialog closes. - * Returns null if cancelled. - */ - public List getResult() { - if (cancelled) { - return null; - } - return effects; - } - - /** - * Returns true if the dialog was cancelled. - */ - public boolean wasCancelled() { - return cancelled; - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java deleted file mode 100644 index 3f70e5aca..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java +++ /dev/null @@ -1,312 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityEnergyBeam; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Energy Beam ability type-specific settings. - * Energy Beam is a homing head with trailing path (DBZ-style). - */ -public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { - - private final AbilityEnergyBeam beam; - private int editingVisualColorId = 0; - - public SubGuiAbilityEnergyBeam(AbilityEnergyBeam ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.beam = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, beam.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, beam.getSpeed())); - - y += 24; - - // Row 2: Beam Width + Head Size - addLabel(new GuiNpcLabel(102, "ability.beamWidth", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, beam.getBeamWidth())); - - addLabel(new GuiNpcLabel(103, "ability.headSize", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, beam.getHeadSize())); - - y += 24; - - // Row 3: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (beam.isHoming()) { - addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, beam.getHomingStrength())); - } - - y += 24; - - // Row 4: Max Distance (+ Homing Range only if homing) - if (beam.isHoming()) { - addLabel(new GuiNpcLabel(106, "ability.homingRange", labelX, y + 5)); - addTextField(createFloatField(106, fieldX, y, 50, beam.getHomingRange())); - } - - addLabel(new GuiNpcLabel(107, "ability.maxDist", beam.isHoming() ? col2LabelX : labelX, y + 5)); - addTextField(createFloatField(107, beam.isHoming() ? col2FieldX : fieldX, y, 50, beam.getMaxDistance())); - - y += 24; - - // Row 5: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(108, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (beam.isExplosive()) { - addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(109, col2FieldX, y, 50, beam.getExplosionRadius())); - } - - y += 24; - - // Row 6: Knockback + Max Lifetime - addLabel(new GuiNpcLabel(110, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(110, fieldX, y, 50, beam.getKnockback())); - - addLabel(new GuiNpcLabel(111, "ability.lifetime", col2LabelX, y + 5)); - addTextField(createIntField(111, col2FieldX, y, 50, beam.getMaxLifetime())); - - y += 24; - - // Row 7: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), beam.getAnchorPointEnum().ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Outer Color - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", beam.getInnerColor() & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(beam.getInnerColor() & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5)); - String outerHex = String.format("%06X", beam.getOuterColor() & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(beam.getOuterColor() & 0xFFFFFF); - outerColorBtn.setEnabled(beam.isOuterColorEnabled()); - addButton(outerColorBtn); - - y += 24; - - // Row 2: Outer Color Enabled + Outer Color Width - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isOuterColorEnabled() ? 1 : 0)); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, beam.getOuterColorWidth()); - widthField.setEnabled(beam.isOuterColorEnabled()); - addTextField(widthField); - - y += 24; - - // Row 3: Rotation Speed - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", labelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, fieldX, y, 55, beam.getOuterColorAlpha()); - alphaField.setEnabled(beam.isOuterColorEnabled()); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(205, col2FieldX, y, 50, beam.getRotationSpeed())); - - y += 24; - - // Row 4: Lightning Effect Enabled (only affects head) - addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.hasLightningEffect() ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (beam.hasLightningEffect()) { - y += 24; - - // Row 5: Density + Radius - addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + beam.getLightningDensity()); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + beam.getLightningRadius()); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - beam.setHoming(value == 1); - initGui(); - break; - case 108: - beam.setExplosive(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(beam.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(beam.getInnerColor())); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(beam.getOuterColor())); - break; - case 202: - beam.setOuterColorEnabled(value == 1); - initGui(); - break; - case 206: - beam.setLightningEffect(value == 1); - initGui(); - break; - case 210: - beam.setAnchorPointEnum(AnchorPoint.fromOrdinal(value)); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - beam.setInnerColor(rgb); - } else if (editingVisualColorId == 201) { - beam.setOuterColor(rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - beam.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - beam.setDamage(parseFloat(field, beam.getDamage())); - break; - case 101: - beam.setSpeed(parseFloat(field, beam.getSpeed())); - break; - case 102: - beam.setBeamWidth(parseFloat(field, beam.getBeamWidth())); - break; - case 103: - beam.setHeadSize(parseFloat(field, beam.getHeadSize())); - break; - case 105: - beam.setHomingStrength(parseFloat(field, beam.getHomingStrength())); - break; - case 106: - beam.setHomingRange(parseFloat(field, beam.getHomingRange())); - break; - case 107: - beam.setMaxDistance(parseFloat(field, beam.getMaxDistance())); - break; - case 109: - beam.setExplosionRadius(parseFloat(field, beam.getExplosionRadius())); - break; - case 110: - beam.setKnockback(parseFloat(field, beam.getKnockback())); - break; - case 111: - beam.setMaxLifetime(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - beam.setOuterColorWidth(parseFloat(field, beam.getOuterColorWidth())); - break; - case 204: - beam.setOuterColorAlpha(parseFloat(field, beam.getOuterColorAlpha())); - break; - case 205: - beam.setRotationSpeed(parseFloat(field, beam.getRotationSpeed())); - break; - case 207: - beam.setLightningDensity(parseFloat(field, beam.getLightningDensity())); - break; - case 208: - beam.setLightningRadius(parseFloat(field, beam.getLightningRadius())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java deleted file mode 100644 index 0d2ec667b..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java +++ /dev/null @@ -1,143 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityGuard; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Guard ability type-specific settings. - */ -public class SubGuiAbilityGuard extends SubGuiAbilityConfig { - - private final AbilityGuard guard; - - public SubGuiAbilityGuard(AbilityGuard ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.guard = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 105; - int col2LabelX = guiLeft + 165; - int col2FieldX = guiLeft + 225; - - // Row 1: Duration + Damage Reduction - addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5)); - GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, guard.getDurationTicks()); - durationField.setMinMaxDefault(1, 1000, 60); - addTextField(durationField); - - addLabel(new GuiNpcLabel(100, "ability.dmgReduce", col2LabelX, y + 5)); - addTextField(createFloatField(100, col2FieldX, y, 50, guard.getDamageReduction())); - - y += 24; - - // Row 2: Can Counter + Counter Type - addLabel(new GuiNpcLabel(101, "ability.canCounter", labelX, y + 5)); - GuiNpcButton canCounterBtn = new GuiNpcButton(101, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, guard.isCanCounter() ? 1 : 0); - canCounterBtn.setHoverText("ability.hover.canCounter"); - addButton(canCounterBtn); - - addLabel(new GuiNpcLabel(102, "ability.counterType", col2LabelX, y + 5)); - String[] types = {"Flat", "Percent"}; - GuiNpcButton counterTypeButton = new GuiNpcButton(102, col2FieldX, y, 60, 20, types, guard.getCounterTypeEnum().ordinal()); - counterTypeButton.setHoverText("ability.hover.counterType"); - counterTypeButton.setEnabled(guard.isCanCounter()); - addButton(counterTypeButton); - - y += 24; - - // Row 3: Counter Value + Counter Chance - addLabel(new GuiNpcLabel(103, "ability.counterValue", labelX, y + 5)); - GuiNpcTextField counterValueField = createFloatField(103, fieldX, y, 50, guard.getCounterValue()); - counterValueField.setEnabled(guard.isCanCounter()); - addTextField(counterValueField); - - addLabel(new GuiNpcLabel(104, "ability.counterChance", col2LabelX, y + 5)); - GuiNpcTextField counterChanceField = createFloatField(104, col2FieldX, y, 50, guard.getCounterChance()); - counterChanceField.setEnabled(guard.isCanCounter()); - addTextField(counterChanceField); - - y += 24; - - // Row 4: Counter Sound + Counter Animation - addLabel(new GuiNpcLabel(105, "ability.counterSound", labelX, y + 5)); - GuiNpcTextField counterSoundField = new GuiNpcTextField(105, this, fontRendererObj, fieldX, y, 100, 20, guard.getCounterSound()); - counterSoundField.setEnabled(guard.isCanCounter()); - addTextField(counterSoundField); - - addLabel(new GuiNpcLabel(106, "ability.counterAnim", col2LabelX, y + 5)); - GuiNpcTextField counterAnimField = createIntField(106, col2FieldX, y, 50, guard.getCounterAnimationId()); - counterAnimField.setEnabled(guard.isCanCounter()); - addTextField(counterAnimField); - - y += 24; - - // Row 5: Effects button (applies on counter) - GuiNpcButton effectsBtn = new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"); - effectsBtn.setEnabled(guard.isCanCounter()); - addButton(effectsBtn); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - switch (id) { - case 101: - guard.setCanCounter(button.getValue() == 1); - initGui(); - break; - case 102: - guard.setCounterTypeEnum(AbilityGuard.CounterType.values()[button.getValue()]); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(guard.getEffects())); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - guard.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 99: - guard.setDurationTicks(field.getInteger()); - break; - case 100: - guard.setDamageReduction(parseFloat(field, guard.getDamageReduction())); - break; - case 103: - guard.setCounterValue(parseFloat(field, guard.getCounterValue())); - break; - case 104: - guard.setCounterChance(parseFloat(field, guard.getCounterChance())); - break; - case 105: - guard.setCounterSound(field.getText()); - break; - case 106: - guard.setCounterAnimationId(field.getInteger()); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java deleted file mode 100644 index 5b8be7976..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java +++ /dev/null @@ -1,159 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityHazard; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Hazard ability type-specific settings. - */ -public class SubGuiAbilityHazard extends SubGuiAbilityConfig { - - private final AbilityHazard hazard; - - public SubGuiAbilityHazard(AbilityHazard ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.hazard = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Duration + Shape - addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5)); - GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, hazard.getDurationTicks()); - durationField.setMinMaxDefault(1, 2000, 100); - addTextField(durationField); - - addLabel(new GuiNpcLabel(100, "ability.shape", col2LabelX, y + 5)); - String[] shapes = {"Circle", "Ring", "Cone"}; - GuiNpcButton shapeBtn = new GuiNpcButton(100, col2FieldX, y, 55, 20, shapes, hazard.getShapeEnum().ordinal()); - shapeBtn.setHoverText("ability.hover.shape"); - addButton(shapeBtn); - - y += 24; - - // Row 2: Placement - addLabel(new GuiNpcLabel(101, "ability.placement", labelX, y + 5)); - String[] placements = {"Caster", "Target", "FollowCast", "FollowTgt"}; - GuiNpcButton placementBtn = new GuiNpcButton(101, fieldX, y, 70, 20, placements, hazard.getPlacementEnum().ordinal()); - placementBtn.setHoverText("ability.hover.placement"); - addButton(placementBtn); - - y += 24; - - // Row 2: Radius + Inner Radius - addLabel(new GuiNpcLabel(102, "ability.radius", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, hazard.getRadius())); - - addLabel(new GuiNpcLabel(103, "ability.innerRadius", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, hazard.getInnerRadius())); - - y += 24; - - // Row 3: Damage Per Second + Damage Interval - addLabel(new GuiNpcLabel(104, "ability.dmgPerSec", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, hazard.getDamagePerSecond())); - - addLabel(new GuiNpcLabel(105, "ability.dmgInterval", col2LabelX, y + 5)); - addTextField(createIntField(105, col2FieldX, y, 50, hazard.getDamageInterval())); - - y += 24; - - // Row 4: Slowness Level + Debuff Duration - addLabel(new GuiNpcLabel(106, "ability.slownessLvl", labelX, y + 5)); - addTextField(createIntField(106, fieldX, y, 50, hazard.getSlownessLevel())); - - addLabel(new GuiNpcLabel(107, "ability.debuffDur", col2LabelX, y + 5)); - addTextField(createIntField(107, col2FieldX, y, 50, hazard.getDebuffDuration())); - - y += 24; - - // Row 5: Poison Level + Affects Caster - addLabel(new GuiNpcLabel(108, "ability.poisonLvl", labelX, y + 5)); - addTextField(createIntField(108, fieldX, y, 50, hazard.getPoisonLevel())); - - addLabel(new GuiNpcLabel(109, "ability.affectsCaster", col2LabelX, y + 5)); - GuiNpcButton affectsCasterBtn = new GuiNpcButton(109, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, hazard.isAffectsCaster() ? 1 : 0); - affectsCasterBtn.setHoverText("ability.hover.affectsCaster"); - addButton(affectsCasterBtn); - - y += 24; - - // Row 6: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 100: - hazard.setShapeEnum(AbilityHazard.HazardShape.values()[value]); - break; - case 101: - hazard.setPlacementEnum(AbilityHazard.PlacementMode.values()[value]); - break; - case 109: - hazard.setAffectsCaster(value == 1); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(hazard.getEffects())); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - hazard.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 99: - hazard.setDurationTicks(field.getInteger()); - break; - case 102: - hazard.setRadius(parseFloat(field, hazard.getRadius())); - break; - case 103: - hazard.setInnerRadius(parseFloat(field, hazard.getInnerRadius())); - break; - case 104: - hazard.setDamagePerSecond(parseFloat(field, hazard.getDamagePerSecond())); - break; - case 105: - hazard.setDamageInterval(field.getInteger()); - break; - case 106: - hazard.setSlownessLevel(field.getInteger()); - break; - case 107: - hazard.setDebuffDuration(field.getInteger()); - break; - case 108: - hazard.setPoisonLevel(field.getInteger()); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java deleted file mode 100644 index 490b4773a..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java +++ /dev/null @@ -1,106 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.type.AbilityHeal; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; - -/** - * GUI for configuring Heal ability type-specific settings. - */ -public class SubGuiAbilityHeal extends SubGuiAbilityConfig { - - private final AbilityHeal heal; - - public SubGuiAbilityHeal(AbilityHeal ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.heal = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Instant Heal + Duration (only shown if not instant) - addLabel(new GuiNpcLabel(103, "dialog.instant", labelX, y + 5)); - GuiNpcButton instantBtn = new GuiNpcButton(103, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isInstantHeal() ? 1 : 0); - instantBtn.setHoverText("ability.hover.instant"); - addButton(instantBtn); - - if (!heal.isInstantHeal()) { - addLabel(new GuiNpcLabel(99, "ability.duration", col2LabelX, y + 5)); - GuiNpcTextField durationField = createIntField(99, col2FieldX, y, 50, heal.getDurationTicks()); - durationField.setMinMaxDefault(1, 1000, 60); - addTextField(durationField); - } - - y += 24; - - // Row 2: Heal Amount + Heal Percent - addLabel(new GuiNpcLabel(100, "ability.healAmount", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, heal.getHealAmount())); - - addLabel(new GuiNpcLabel(101, "ability.healPercent", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, heal.getHealPercent())); - - y += 24; - - // Row 3: Heal Radius - addLabel(new GuiNpcLabel(102, "ability.healRadius", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, heal.getHealRadius())); - - y += 24; - - // Row 4: Heal Self + Heal Allies - addLabel(new GuiNpcLabel(104, "ability.healSelf", labelX, y + 5)); - GuiNpcButton healSelfBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealSelf() ? 1 : 0); - healSelfBtn.setHoverText("ability.hover.healSelf"); - addButton(healSelfBtn); - - addLabel(new GuiNpcLabel(105, "ability.healAllies", col2LabelX, y + 5)); - GuiNpcButton healAlliesBtn = new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealAllies() ? 1 : 0); - healAlliesBtn.setHoverText("ability.hover.healAllies"); - addButton(healAlliesBtn); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 103: - heal.setInstantHeal(value == 1); - initGui(); // Refresh to show/hide duration field - break; - case 104: - heal.setHealSelf(value == 1); - break; - case 105: - heal.setHealAllies(value == 1); - break; - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 99: - heal.setDurationTicks(field.getInteger()); - break; - case 100: - heal.setHealAmount(parseFloat(field, heal.getHealAmount())); - break; - case 101: - heal.setHealPercent(parseFloat(field, heal.getHealPercent())); - break; - case 102: - heal.setHealRadius(parseFloat(field, heal.getHealRadius())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java deleted file mode 100644 index 897a4af1f..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java +++ /dev/null @@ -1,76 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityHeavyHit; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Heavy Hit ability type-specific settings. - */ -public class SubGuiAbilityHeavyHit extends SubGuiAbilityConfig { - - private final AbilityHeavyHit heavyHit; - - public SubGuiAbilityHeavyHit(AbilityHeavyHit ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.heavyHit = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - - // Row 1: Damage + Knockback - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, heavyHit.getDamage())); - - addLabel(new GuiNpcLabel(102, "ability.knockback", col2LabelX, y + 5)); - addTextField(createFloatField(102, guiLeft + 205, y, 50, heavyHit.getKnockback())); - - y += 24; - - // Row 2: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - if (id == 150) { - setSubGui(new SubGuiAbilityEffects(heavyHit.getEffects())); - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - heavyHit.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - heavyHit.setDamage(parseFloat(field, heavyHit.getDamage())); - break; - case 102: - heavyHit.setKnockback(parseFloat(field, heavyHit.getKnockback())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityLaserShot.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityLaserShot.java deleted file mode 100644 index 71a03e97e..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityLaserShot.java +++ /dev/null @@ -1,280 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityLaserShot; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Laser Shot ability type-specific settings. - */ -public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig { - - private final AbilityLaserShot laser; - private int editingVisualColorId = 0; - - public SubGuiAbilityLaserShot(AbilityLaserShot ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.laser = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Laser Width - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, laser.getDamage())); - - addLabel(new GuiNpcLabel(101, "ability.laserWidth", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, laser.getLaserWidth())); - - y += 24; - - // Row 2: Expansion Speed + Linger Ticks - addLabel(new GuiNpcLabel(102, "ability.expansionSpeed", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, laser.getExpansionSpeed())); - - addLabel(new GuiNpcLabel(103, "ability.lingerTicks", col2LabelX, y + 5)); - addTextField(createIntField(103, col2FieldX, y, 50, laser.getLingerTicks())); - - y += 24; - - // Row 3: Max Distance + Max Lifetime - addLabel(new GuiNpcLabel(104, "ability.maxDist", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, laser.getMaxDistance())); - - addLabel(new GuiNpcLabel(105, "ability.lifetime", col2LabelX, y + 5)); - addTextField(createIntField(105, col2FieldX, y, 50, laser.getMaxLifetime())); - - y += 24; - - // Row 4: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(106, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, laser.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (laser.isExplosive()) { - addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(107, col2FieldX, y, 50, laser.getExplosionRadius())); - } - - y += 24; - - // Row 5: Knockback + Knockback Up - addLabel(new GuiNpcLabel(108, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(108, fieldX, y, 50, laser.getKnockback())); - - addLabel(new GuiNpcLabel(109, "ability.knockbackUp", col2LabelX, y + 5)); - addTextField(createFloatField(109, col2FieldX, y, 50, laser.getKnockbackUp())); - - y += 24; - - // Row 6: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), laser.getAnchorPointEnum().ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Outer Color - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", laser.getInnerColor() & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(laser.getInnerColor() & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5)); - String outerHex = String.format("%06X", laser.getOuterColor() & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(laser.getOuterColor() & 0xFFFFFF); - outerColorBtn.setEnabled(laser.isOuterColorEnabled()); - addButton(outerColorBtn); - - y += 24; - - // Row 3: Outer Color Enabled + Outer Color Width - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, laser.isOuterColorEnabled() ? 1 : 0)); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, laser.getOuterColorWidth()); - widthField.setEnabled(laser.isOuterColorEnabled()); - addTextField(widthField); - - y += 24; - - // Row 4: Lightning Effect Enabled - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", labelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, fieldX, y, 55, laser.getOuterColorAlpha()); - alphaField.setEnabled(laser.isOuterColorEnabled()); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - addLabel(new GuiNpcLabel(205, "ability.lightning", col2LabelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(205, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, laser.hasLightningEffect() ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (laser.hasLightningEffect()) { - y += 24; - - // Row 5: Density + Radius - addLabel(new GuiNpcLabel(206, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(206, this, fontRendererObj, fieldX, y, 55, 18, "" + laser.getLightningDensity()); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(207, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(207, this, fontRendererObj, col2FieldX, y, 55, 18, "" + laser.getLightningRadius()); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 106: - laser.setExplosive(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(laser.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(laser.getInnerColor())); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(laser.getOuterColor())); - break; - case 202: - laser.setOuterColorEnabled(value == 1); - initGui(); - break; - case 205: - laser.setLightningEffect(value == 1); - initGui(); - break; - case 210: - laser.setAnchorPointEnum(AnchorPoint.fromOrdinal(value)); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - laser.setInnerColor(rgb); - } else if (editingVisualColorId == 201) { - laser.setOuterColor(rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - laser.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - laser.setOuterColorWidth(parseFloat(field, laser.getOuterColorWidth())); - break; - case 204: - laser.setOuterColorAlpha(parseFloat(field, laser.getOuterColorAlpha())); - break; - case 206: - laser.setLightningDensity(parseFloat(field, laser.getLightningDensity())); - break; - case 207: - laser.setLightningRadius(parseFloat(field, laser.getLightningRadius())); - break; - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - laser.setDamage(parseFloat(field, laser.getDamage())); - break; - case 101: - laser.setLaserWidth(parseFloat(field, laser.getLaserWidth())); - break; - case 102: - laser.setExpansionSpeed(parseFloat(field, laser.getExpansionSpeed())); - break; - case 103: - laser.setLingerTicks(field.getInteger()); - break; - case 104: - laser.setMaxDistance(parseFloat(field, laser.getMaxDistance())); - break; - case 105: - laser.setMaxLifetime(field.getInteger()); - break; - case 107: - laser.setExplosionRadius(parseFloat(field, laser.getExplosionRadius())); - break; - case 108: - laser.setKnockback(parseFloat(field, laser.getKnockback())); - break; - case 109: - laser.setKnockbackUp(parseFloat(field, laser.getKnockbackUp())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java deleted file mode 100644 index 780661c6f..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java +++ /dev/null @@ -1,294 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityOrb; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Orb ability type-specific settings. - */ -public class SubGuiAbilityOrb extends SubGuiAbilityConfig { - - private final AbilityOrb orb; - private int editingVisualColorId = 0; - - public SubGuiAbilityOrb(AbilityOrb ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.orb = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, orb.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, orb.getOrbSpeed())); - - y += 24; - - // Row 2: Orb Size + Max Distance - addLabel(new GuiNpcLabel(102, "stats.size", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, orb.getOrbSize())); - - addLabel(new GuiNpcLabel(103, "ability.maxDist", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, orb.getMaxDistance())); - - y += 24; - - // Row 3: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (orb.isHoming()) { - addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, orb.getHomingStrength())); - } - - y += 24; - - // Row 4: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(106, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (orb.isExplosive()) { - addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(107, col2FieldX, y, 50, orb.getExplosionRadius())); - } - - y += 24; - - // Row 5: Knockback + Max Lifetime - addLabel(new GuiNpcLabel(108, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(108, fieldX, y, 50, orb.getKnockback())); - - addLabel(new GuiNpcLabel(109, "ability.lifetime", col2LabelX, y + 5)); - addTextField(createIntField(109, col2FieldX, y, 50, orb.getMaxLifetime())); - - y += 24; - - // Row 6: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), orb.getAnchorPointEnum().ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Rotation Speed - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", orb.getInnerColor() & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(orb.getInnerColor() & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(205, col2FieldX, y, 55, orb.getRotationSpeed())); - - y += 24; - - // Row 3: Outer Glow Enabled - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isOuterColorEnabled() ? 1 : 0)); - - // Only show Outer Color and Width if Outer Glow is enabled - if (orb.isOuterColorEnabled()) { - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", col2LabelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, col2FieldX, y, 55, orb.getOuterColorAlpha()); - alphaField.setEnabled(orb.isOuterColorEnabled()); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - y += 24; - - // Row 4: Outer Color + Outer Width - addLabel(new GuiNpcLabel(201, "ability.outerColor", labelX, y + 5)); - String outerHex = String.format("%06X", orb.getOuterColor() & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, fieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(orb.getOuterColor() & 0xFFFFFF); - addButton(outerColorBtn); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - addTextField(createFloatField(203, col2FieldX, y, 55, orb.getOuterColorWidth())); - } - - y += 24; - - // Row 5: Lightning Effect Enabled - addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.hasLightningEffect() ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (orb.hasLightningEffect()) { - y += 24; - - // Row 61: Density + Radius - addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + orb.getLightningDensity()); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + orb.getLightningRadius()); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - orb.setHoming(value == 1); - initGui(); - break; - case 106: - orb.setExplosive(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(orb.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(orb.getInnerColor())); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(orb.getOuterColor())); - break; - case 202: - orb.setOuterColorEnabled(value == 1); - initGui(); - break; - case 206: - orb.setLightningEffect(value == 1); - initGui(); - break; - case 210: - orb.setAnchorPointEnum(AnchorPoint.fromOrdinal(value)); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - orb.setInnerColor(rgb); - } else if (editingVisualColorId == 201) { - orb.setOuterColor(rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - orb.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - orb.setDamage(parseFloat(field, orb.getDamage())); - break; - case 101: - orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed())); - break; - case 102: - orb.setOrbSize(parseFloat(field, orb.getOrbSize())); - break; - case 103: - orb.setMaxDistance(parseFloat(field, orb.getMaxDistance())); - break; - case 105: - orb.setHomingStrength(parseFloat(field, orb.getHomingStrength())); - break; - case 107: - orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius())); - break; - case 108: - orb.setKnockback(parseFloat(field, orb.getKnockback())); - break; - case 109: - orb.setMaxLifetime(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - orb.setOuterColorWidth(parseFloat(field, orb.getOuterColorWidth())); - break; - case 204: - orb.setOuterColorAlpha(parseFloat(field, orb.getOuterColorAlpha())); - break; - case 205: - orb.setRotationSpeed(parseFloat(field, orb.getRotationSpeed())); - break; - case 207: - orb.setLightningDensity(parseFloat(field, orb.getLightningDensity())); - break; - case 208: - orb.setLightningRadius(parseFloat(field, orb.getLightningRadius())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrbDual.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrbDual.java deleted file mode 100644 index cdf805f53..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrbDual.java +++ /dev/null @@ -1,312 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.AnchorPoint; -import kamkeel.npcs.controllers.data.ability.type.AbilityOrbDual; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.*; - -import java.util.List; - -public class SubGuiAbilityOrbDual extends SubGuiAbilityConfig { - private final AbilityOrbDual orb; - private int editingVisualColorId = 0; - private int editingOrb = 0; - - public SubGuiAbilityOrbDual(AbilityOrbDual ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.orb = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, orb.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, orb.getOrbSpeed())); - - y += 24; - - // Row 2: Orb Size + Max Distance - addLabel(new GuiNpcLabel(102, "stats.size", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, orb.getOrbSize())); - - addLabel(new GuiNpcLabel(103, "ability.maxDist", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, orb.getMaxDistance())); - - y += 24; - - // Row 3: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (orb.isHoming()) { - addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, orb.getHomingStrength())); - } - - y += 24; - - // Row 4: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(106, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (orb.isExplosive()) { - addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(107, col2FieldX, y, 50, orb.getExplosionRadius())); - } - - y += 24; - - // Row 5: Knockback + Max Lifetime - addLabel(new GuiNpcLabel(108, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(108, fieldX, y, 50, orb.getKnockback())); - - addLabel(new GuiNpcLabel(109, "ability.lifetime", col2LabelX, y + 5)); - addTextField(createIntField(109, col2FieldX, y, 50, orb.getMaxLifetime())); - - y += 24; - - addLabel(new GuiNpcLabel(110, "ability.dualFire", labelX, y + 5)); - addButton(new GuiNpcButtonYesNo(110, fieldX, y, orb.isDualFire())); - - if (orb.isDualFire()) { - addLabel(new GuiNpcLabel(111, "ability.dualFireDelay", col2LabelX, y + 5)); - addTextField(createIntField(111, col2FieldX, y, 50, orb.getDualFireDelay())); - } - - y += 24; - - // Row 7: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Anchor Point - addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5)); - GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), orb.getAnchorPointEnum(editingOrb).ordinal()); - anchorBtn.setHoverText("ability.hover.anchorPoint"); - addButton(anchorBtn); - - y += 24; - - // Row 2: Inner Color + Rotation Speed - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", orb.getInnerColor(editingOrb) & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(orb.getInnerColor(editingOrb) & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(205, col2FieldX, y, 55, orb.getRotationSpeed(editingOrb))); - - y += 24; - - // Row 3: Outer Glow Enabled - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isOuterColorEnabled(editingOrb) ? 1 : 0)); - - // Only show Outer Color and Width if Outer Glow is enabled - if (orb.isOuterColorEnabled()) { - addLabel(new GuiNpcLabel(204, "ability.outerAlpha", col2LabelX, y + 5)); - GuiNpcTextField alphaField = createFloatField(204, col2FieldX, y, 55, orb.getOuterColorAlpha(editingOrb)); - alphaField.setEnabled(orb.isOuterColorEnabled(editingOrb)); - alphaField.setMinMaxDefaultFloat(0, 1, 0.5f); - addTextField(alphaField); - - y += 24; - - // Row 4: Outer Color + Outer Width - addLabel(new GuiNpcLabel(201, "ability.outerColor", labelX, y + 5)); - String outerHex = String.format("%06X", orb.getOuterColor(editingOrb) & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, fieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(orb.getOuterColor(editingOrb) & 0xFFFFFF); - addButton(outerColorBtn); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - addTextField(createFloatField(203, col2FieldX, y, 55, orb.getOuterColorWidth(editingOrb))); - } - - y += 24; - - // Row 5: Lightning Effect Enabled - addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.hasLightningEffect(editingOrb) ? 1 : 0); - lightningBtn.setHoverText("ability.hover.lightning"); - addButton(lightningBtn); - - // Only show Lightning settings if Lightning is enabled - if (orb.hasLightningEffect(editingOrb)) { - y += 24; - - // Row 61: Density + Radius - addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + orb.getLightningDensity(editingOrb)); - densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); - addTextField(densityField); - - addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + orb.getLightningRadius(editingOrb)); - radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); - addTextField(radiusField); - } - - y += 24; - - addButton(new GuiNpcButton(400, col2FieldX, y, 55, 20, new String[]{"Orb 1", "Orb 2"}, editingOrb)); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - orb.setHoming(value == 1); - initGui(); - break; - case 106: - orb.setExplosive(value == 1); - initGui(); - break; - case 110: - orb.setDualFire(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(orb.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(orb.getInnerColor(editingOrb))); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(orb.getOuterColor(editingOrb))); - break; - case 202: - orb.setOuterColorEnabled(editingOrb, value == 1); - initGui(); - break; - case 206: - orb.setLightningEffect(editingOrb, value == 1); - initGui(); - break; - case 210: - orb.setAnchorPointEnum(editingOrb, AnchorPoint.fromOrdinal(value)); - break; - case 400: - editingOrb = (editingOrb + 1) % 2; - initGui(); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - orb.setInnerColor(editingOrb, rgb); - } else if (editingVisualColorId == 201) { - orb.setOuterColor(editingOrb, rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - orb.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - orb.setDamage(parseFloat(field, orb.getDamage())); - break; - case 101: - orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed())); - break; - case 102: - orb.setOrbSize(parseFloat(field, orb.getOrbSize())); - break; - case 103: - orb.setMaxDistance(parseFloat(field, orb.getMaxDistance())); - break; - case 105: - orb.setHomingStrength(parseFloat(field, orb.getHomingStrength())); - break; - case 107: - orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius())); - break; - case 108: - orb.setKnockback(parseFloat(field, orb.getKnockback())); - break; - case 109: - orb.setMaxLifetime(field.getInteger()); - break; - case 111: - orb.setDualFireDelay(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - orb.setOuterColorWidth(editingOrb, parseFloat(field, orb.getOuterColorWidth(editingOrb))); - break; - case 204: - orb.setOuterColorAlpha(editingOrb, parseFloat(field, orb.getOuterColorAlpha(editingOrb))); - break; - case 205: - orb.setRotationSpeed(editingOrb, parseFloat(field, orb.getRotationSpeed(editingOrb))); - break; - case 207: - orb.setLightningDensity(editingOrb, parseFloat(field, orb.getLightningDensity(editingOrb))); - break; - case 208: - orb.setLightningRadius(editingOrb, parseFloat(field, orb.getLightningRadius(editingOrb))); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java deleted file mode 100644 index fe66fa242..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java +++ /dev/null @@ -1,145 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityProjectile; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Projectile ability type-specific settings. - */ -public class SubGuiAbilityProjectile extends SubGuiAbilityConfig { - - private final AbilityProjectile projectile; - - public SubGuiAbilityProjectile(AbilityProjectile ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.projectile = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Speed - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, projectile.getDamage())); - - addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, projectile.getSpeed())); - - y += 24; - - // Row 2: Knockback + Projectile Type - addLabel(new GuiNpcLabel(102, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, projectile.getKnockback())); - - addLabel(new GuiNpcLabel(103, "ability.projType", col2LabelX, y + 5)); - String[] projTypes = {"fireball", "arrow", "magic"}; - int typeIdx = 0; - String currType = projectile.getProjectileType(); - for (int i = 0; i < projTypes.length; i++) { - if (projTypes[i].equals(currType)) { - typeIdx = i; - break; - } - } - addButton(new GuiNpcButton(103, col2FieldX, y, 60, 20, projTypes, typeIdx)); - - y += 24; - - // Row 3: Explosive + Explosion Radius (only show radius if explosive) - addLabel(new GuiNpcLabel(104, "ability.explosive", labelX, y + 5)); - GuiNpcButton explosiveBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, projectile.isExplosive() ? 1 : 0); - explosiveBtn.setHoverText("ability.hover.explosive"); - addButton(explosiveBtn); - - if (projectile.isExplosive()) { - addLabel(new GuiNpcLabel(105, "ability.explosionRad", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, projectile.getExplosionRadius())); - } - - y += 24; - - // Row 4: Homing + Homing Strength (only show strength if homing) - addLabel(new GuiNpcLabel(106, "ability.homing", labelX, y + 5)); - GuiNpcButton homingBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, projectile.isHoming() ? 1 : 0); - homingBtn.setHoverText("ability.hover.homing"); - addButton(homingBtn); - - if (projectile.isHoming()) { - addLabel(new GuiNpcLabel(107, "ability.homingStr", col2LabelX, y + 5)); - addTextField(createFloatField(107, col2FieldX, y, 50, projectile.getHomingStrength())); - } - - y += 24; - - // Row 5: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 103: - String[] projTypes = {"fireball", "arrow", "magic"}; - projectile.setProjectileType(projTypes[value]); - break; - case 104: - projectile.setExplosive(value == 1); - initGui(); - break; - case 106: - projectile.setHoming(value == 1); - initGui(); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(projectile.getEffects())); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - projectile.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - projectile.setDamage(parseFloat(field, projectile.getDamage())); - break; - case 101: - projectile.setSpeed(parseFloat(field, projectile.getSpeed())); - break; - case 102: - projectile.setKnockback(parseFloat(field, projectile.getKnockback())); - break; - case 105: - projectile.setExplosionRadius(parseFloat(field, projectile.getExplosionRadius())); - break; - case 107: - projectile.setHomingStrength(parseFloat(field, projectile.getHomingStrength())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java deleted file mode 100644 index 48c2c5295..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java +++ /dev/null @@ -1,95 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityShockwave; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Shockwave ability type-specific settings. - */ -public class SubGuiAbilityShockwave extends SubGuiAbilityConfig { - - private final AbilityShockwave shockwave; - - public SubGuiAbilityShockwave(AbilityShockwave ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.shockwave = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Push Radius - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, shockwave.getDamage())); - - addLabel(new GuiNpcLabel(101, "ability.pushRadius", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, shockwave.getPushRadius())); - - y += 24; - - // Row 2: Push Strength - addLabel(new GuiNpcLabel(102, "ability.pushStrength", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, shockwave.getPushStrength())); - - y += 24; - - // Row 3: Max Targets + Effects button - addLabel(new GuiNpcLabel(104, "ability.maxTargets", labelX, y + 5)); - addTextField(createIntField(104, fieldX, y, 50, shockwave.getMaxTargets())); - - addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects")); - - y += 24; - addLabel(new GuiNpcLabel(105, "ability.shockwaveFalloff", labelX, y + 5)); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - if (id == 150) { - setSubGui(new SubGuiAbilityEffects(shockwave.getEffects())); - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - shockwave.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - shockwave.setDamage(parseFloat(field, shockwave.getDamage())); - break; - case 101: - shockwave.setPushRadius(parseFloat(field, shockwave.getPushRadius())); - break; - case 102: - shockwave.setPushStrength(parseFloat(field, shockwave.getPushStrength())); - break; - case 104: - shockwave.setMaxTargets(field.getInteger()); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java deleted file mode 100644 index 4e020829b..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java +++ /dev/null @@ -1,98 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilitySlam; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Slam ability type-specific settings. - */ -public class SubGuiAbilitySlam extends SubGuiAbilityConfig { - - private final AbilitySlam slam; - - public SubGuiAbilitySlam(AbilitySlam ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.slam = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Radius - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, slam.getDamage())); - - addLabel(new GuiNpcLabel(101, "ability.radius", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, slam.getRadius())); - - y += 24; - - // Row 2: Knockback + Leap Speed - addLabel(new GuiNpcLabel(102, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, slam.getKnockbackStrength())); - - addLabel(new GuiNpcLabel(103, "ability.leapSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, slam.getLeapSpeed())); - - y += 24; - - // Row 3: Leap Height + Effects - addLabel(new GuiNpcLabel(104, "ability.leapHeight", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, slam.getLeapHeight())); - - addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - if (id == 150) { - setSubGui(new SubGuiAbilityEffects(slam.getEffects())); - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - slam.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - slam.setDamage(parseFloat(field, slam.getDamage())); - break; - case 101: - slam.setRadius(parseFloat(field, slam.getRadius())); - break; - case 102: - slam.setKnockbackStrength(parseFloat(field, slam.getKnockbackStrength())); - break; - case 103: - slam.setLeapSpeed(parseFloat(field, slam.getLeapSpeed())); - break; - case 104: - slam.setLeapHeight(parseFloat(field, slam.getLeapHeight())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySweeper.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySweeper.java deleted file mode 100644 index 1561b408a..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySweeper.java +++ /dev/null @@ -1,219 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilitySweeper; -import noppes.npcs.client.gui.SubGuiColorSelector; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Sweeper ability type-specific settings. - * Sweeper is a low rotating beam that players can jump over. - */ -public class SubGuiAbilitySweeper extends SubGuiAbilityConfig { - - private final AbilitySweeper sweeper; - private int editingVisualColorId = 0; - - public SubGuiAbilitySweeper(AbilitySweeper ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.sweeper = ability; - } - - @Override - protected boolean hasVisualSettings() { - return true; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Damage + Damage Interval - addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, sweeper.getDamage())); - - addLabel(new GuiNpcLabel(101, "ability.dmgInterval", col2LabelX, y + 5)); - addTextField(createIntField(101, col2FieldX, y, 50, sweeper.getDamageInterval())); - - y += 24; - - // Row 2: Beam Length + Beam Width - addLabel(new GuiNpcLabel(102, "ability.beamLength", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, sweeper.getBeamLength())); - - addLabel(new GuiNpcLabel(103, "ability.beamWidth", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, sweeper.getBeamWidth())); - - y += 24; - - // Row 3: Beam Height + Sweep Speed - addLabel(new GuiNpcLabel(104, "ability.beamHeight", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, sweeper.getBeamHeight())); - - addLabel(new GuiNpcLabel(105, "ability.sweepSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(105, col2FieldX, y, 50, sweeper.getSweepSpeed())); - - y += 24; - - // Row 4: Number of Rotations + Piercing - addLabel(new GuiNpcLabel(106, "ability.rotations", labelX, y + 5)); - addTextField(createIntField(106, fieldX, y, 50, sweeper.getNumberOfRotations())); - - addLabel(new GuiNpcLabel(107, "ability.piercing", col2LabelX, y + 5)); - GuiNpcButton piercingBtn = new GuiNpcButton(107, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isPiercing() ? 1 : 0); - piercingBtn.setHoverText("ability.hover.piercing"); - addButton(piercingBtn); - - y += 24; - - // Row 5: Lock On Target - addLabel(new GuiNpcLabel(108, "ability.lockTarget", labelX, y + 5)); - GuiNpcButton lockTargetBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isLockOnTarget() ? 1 : 0); - lockTargetBtn.setHoverText("ability.hover.lockTarget"); - addButton(lockTargetBtn); - - y += 24; - - // Row 6: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void initVisualTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 180; - int col2FieldX = guiLeft + 260; - - // Row 1: Inner Color + Outer Color - addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5)); - String innerHex = String.format("%06X", sweeper.getInnerColor() & 0xFFFFFF); - GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex); - innerColorBtn.setTextColor(sweeper.getInnerColor() & 0xFFFFFF); - addButton(innerColorBtn); - - addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5)); - String outerHex = String.format("%06X", sweeper.getOuterColor() & 0xFFFFFF); - GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex); - outerColorBtn.setTextColor(sweeper.getOuterColor() & 0xFFFFFF); - outerColorBtn.setEnabled(sweeper.isOuterColorEnabled()); - addButton(outerColorBtn); - - y += 24; - - // Row 2: Outer Color Enabled + Outer Color Width - addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5)); - addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isOuterColorEnabled() ? 1 : 0)); - - addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5)); - GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, sweeper.getOuterColorWidth()); - widthField.setEnabled(sweeper.isOuterColorEnabled()); - addTextField(widthField); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 107: - sweeper.setPiercing(value == 1); - break; - case 108: - sweeper.setLockOnTarget(value == 1); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(sweeper.getEffects())); - break; - } - } - - @Override - protected void handleVisualButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 200: - editingVisualColorId = 200; - setSubGui(new SubGuiColorSelector(sweeper.getInnerColor())); - break; - case 201: - editingVisualColorId = 201; - setSubGui(new SubGuiColorSelector(sweeper.getOuterColor())); - break; - case 202: - sweeper.setOuterColorEnabled(value == 1); - initGui(); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) { - SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui; - int rgb = colorSelector.color & 0x00FFFFFF; - if (editingVisualColorId == 200) { - sweeper.setInnerColor(rgb); - } else if (editingVisualColorId == 201) { - sweeper.setOuterColor(rgb); - } - editingVisualColorId = 0; - initGui(); - } else if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - sweeper.setEffects(result); - } - } else { - super.subGuiClosed(subgui); - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - sweeper.setDamage(parseFloat(field, sweeper.getDamage())); - break; - case 101: - sweeper.setDamageInterval(field.getInteger()); - break; - case 102: - sweeper.setBeamLength(parseFloat(field, sweeper.getBeamLength())); - break; - case 103: - sweeper.setBeamWidth(parseFloat(field, sweeper.getBeamWidth())); - break; - case 104: - sweeper.setBeamHeight(parseFloat(field, sweeper.getBeamHeight())); - break; - case 105: - sweeper.setSweepSpeed(parseFloat(field, sweeper.getSweepSpeed())); - break; - case 106: - sweeper.setNumberOfRotations(field.getInteger()); - break; - } - } - - @Override - protected void handleVisualTextField(int id, GuiNpcTextField field) { - switch (id) { - case 203: - sweeper.setOuterColorWidth(parseFloat(field, sweeper.getOuterColorWidth())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java deleted file mode 100644 index 4b23b0ca0..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java +++ /dev/null @@ -1,165 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityTeleport; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Teleport ability type-specific settings. - */ -public class SubGuiAbilityTeleport extends SubGuiAbilityConfig { - - private final AbilityTeleport teleport; - - public SubGuiAbilityTeleport(AbilityTeleport ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.teleport = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Mode - addLabel(new GuiNpcLabel(100, "ability.mode", labelX, y + 5)); - String[] modes = {"Blink", "Behind", "Single"}; - addButton(new GuiNpcButton(100, fieldX, y, 80, 20, modes, teleport.getModeEnum().ordinal())); - - y += 24; - - switch (teleport.getModeEnum()) { - case BLINK: - // Row 2: Blink Radius + Blink Count - addLabel(new GuiNpcLabel(101, "ability.blinkRadius", labelX, y + 5)); - addTextField(createFloatField(101, fieldX, y, 50, teleport.getBlinkRadius())); - - addLabel(new GuiNpcLabel(102, "ability.blinkCount", col2LabelX, y + 5)); - addTextField(createIntField(102, col2FieldX, y, 50, teleport.getBlinkCount())); - - y += 24; - - // Row 3: Blink Delay + Line of Sight - addLabel(new GuiNpcLabel(103, "ability.blinkDelay", labelX, y + 5)); - addTextField(createIntField(103, fieldX, y, 50, teleport.getBlinkDelayTicks())); - - addLabel(new GuiNpcLabel(105, "ability.lineOfSight", col2LabelX, y + 5)); - GuiNpcButton losBtn1 = new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isRequireLineOfSight() ? 1 : 0); - losBtn1.setHoverText("ability.hover.lineOfSight"); - addButton(losBtn1); - y += 24; - break; - case SINGLE: - // Row 2: Blink Radius + Line of Sight - addLabel(new GuiNpcLabel(101, "ability.blinkRadius", labelX, y + 5)); - addTextField(createFloatField(101, fieldX, y, 50, teleport.getBlinkRadius())); - - addLabel(new GuiNpcLabel(105, "ability.lineOfSight", col2LabelX, y + 5)); - GuiNpcButton losBtn2 = new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isRequireLineOfSight() ? 1 : 0); - losBtn2.setHoverText("ability.hover.lineOfSight"); - addButton(losBtn2); - y += 24; - break; - case BEHIND: - // Row 2: Behind Distance - addLabel(new GuiNpcLabel(104, "ability.behindDistance", labelX, y + 5)); - addTextField(createFloatField(104, fieldX, y, 50, teleport.getBehindDistance())); - y += 24; - break; - } - - // Damage + Damage Radius - addLabel(new GuiNpcLabel(106, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(106, fieldX, y, 50, teleport.getDamage())); - - addLabel(new GuiNpcLabel(107, "ability.dmgRadius", col2LabelX, y + 5)); - addTextField(createFloatField(107, col2FieldX, y, 50, teleport.getDamageRadius())); - - y += 24; - - // Damage at Start/End - addLabel(new GuiNpcLabel(108, "ability.dmgAtStart", labelX, y + 5)); - GuiNpcButton dmgStartBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isDamageAtStart() ? 1 : 0); - dmgStartBtn.setHoverText("ability.hover.dmgAtStart"); - addButton(dmgStartBtn); - - addLabel(new GuiNpcLabel(109, "ability.dmgAtEnd", col2LabelX, y + 5)); - GuiNpcButton dmgEndBtn = new GuiNpcButton(109, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isDamageAtEnd() ? 1 : 0); - dmgEndBtn.setHoverText("ability.hover.dmgAtEnd"); - addButton(dmgEndBtn); - - y += 24; - - // Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 100: - teleport.setModeEnum(AbilityTeleport.TeleportMode.values()[value]); - initGui(); - break; - case 105: - teleport.setRequireLineOfSight(value == 1); - break; - case 108: - teleport.setDamageAtStart(value == 1); - break; - case 109: - teleport.setDamageAtEnd(value == 1); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(teleport.getEffects())); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - teleport.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 101: - teleport.setBlinkRadius(parseFloat(field, teleport.getBlinkRadius())); - break; - case 102: - teleport.setBlinkCount(field.getInteger()); - break; - case 103: - teleport.setBlinkDelayTicks(field.getInteger()); - break; - case 104: - teleport.setBehindDistance(parseFloat(field, teleport.getBehindDistance())); - break; - case 106: - teleport.setDamage(parseFloat(field, teleport.getDamage())); - break; - case 107: - teleport.setDamageRadius(parseFloat(field, teleport.getDamageRadius())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java deleted file mode 100644 index 5c9c52558..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java +++ /dev/null @@ -1,126 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityTrap; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Trap ability type-specific settings. - */ -public class SubGuiAbilityTrap extends SubGuiAbilityConfig { - - private final AbilityTrap trap; - - public SubGuiAbilityTrap(AbilityTrap ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.trap = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Duration + Placement - addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5)); - GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, trap.getDurationTicks()); - durationField.setMinMaxDefault(1, 2000, 200); - addTextField(durationField); - - addLabel(new GuiNpcLabel(100, "ability.placement", col2LabelX, y + 5)); - String[] placements = {"Caster", "Target", "Ahead"}; - GuiNpcButton placementBtn = new GuiNpcButton(100, col2FieldX, y, 55, 20, placements, trap.getPlacementEnum().ordinal()); - placementBtn.setHoverText("ability.hover.placement"); - addButton(placementBtn); - - y += 24; - - // Row 2: Trigger Radius - addLabel(new GuiNpcLabel(101, "ability.triggerRad", labelX, y + 5)); - addTextField(createFloatField(101, fieldX, y, 50, trap.getTriggerRadius())); - - y += 24; - - // Row 2: Damage + Damage Radius - addLabel(new GuiNpcLabel(102, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, trap.getDamage())); - - addLabel(new GuiNpcLabel(103, "ability.dmgRadius", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, trap.getDamageRadius())); - - y += 24; - - // Row 3: Arm Time + Max Triggers - addLabel(new GuiNpcLabel(104, "ability.armTime", labelX, y + 5)); - addTextField(createIntField(104, fieldX, y, 50, trap.getArmTime())); - - addLabel(new GuiNpcLabel(105, "ability.maxTriggers", col2LabelX, y + 5)); - addTextField(createIntField(105, col2FieldX, y, 50, trap.getMaxTriggers())); - - y += 24; - - // Row 4: Knockback + Effects button - addLabel(new GuiNpcLabel(108, "ability.knockback", labelX, y + 5)); - addTextField(createFloatField(108, fieldX, y, 50, trap.getKnockback())); - - addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects")); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - if (id == 100) { - trap.setPlacementEnum(AbilityTrap.TrapPlacement.values()[button.getValue()]); - } else if (id == 150) { - setSubGui(new SubGuiAbilityEffects(trap.getEffects())); - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - trap.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 99: - trap.setDurationTicks(field.getInteger()); - break; - case 101: - trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius())); - break; - case 102: - trap.setDamage(parseFloat(field, trap.getDamage())); - break; - case 103: - trap.setDamageRadius(parseFloat(field, trap.getDamageRadius())); - break; - case 104: - trap.setArmTime(field.getInteger()); - break; - case 105: - trap.setMaxTriggers(field.getInteger()); - break; - case 108: - trap.setKnockback(parseFloat(field, trap.getKnockback())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java deleted file mode 100644 index b56828470..000000000 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java +++ /dev/null @@ -1,129 +0,0 @@ -package noppes.npcs.client.gui.advanced.ability; - -import kamkeel.npcs.controllers.data.ability.AbilityEffect; -import kamkeel.npcs.controllers.data.ability.type.AbilityVortex; -import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig; -import noppes.npcs.client.gui.util.GuiNpcButton; -import noppes.npcs.client.gui.util.GuiNpcLabel; -import noppes.npcs.client.gui.util.GuiNpcTextField; -import noppes.npcs.client.gui.util.IAbilityConfigCallback; -import noppes.npcs.client.gui.util.SubGuiInterface; - -import java.util.List; - -/** - * GUI for configuring Vortex ability type-specific settings. - */ -public class SubGuiAbilityVortex extends SubGuiAbilityConfig { - - private final AbilityVortex vortex; - - public SubGuiAbilityVortex(AbilityVortex ability, IAbilityConfigCallback callback) { - super(ability, callback); - this.vortex = ability; - } - - @Override - protected void initTypeTab(int startY) { - int y = startY; - int labelX = guiLeft + 8; - int fieldX = guiLeft + 85; - int col2LabelX = guiLeft + 145; - int col2FieldX = guiLeft + 205; - - // Row 1: Pull Radius + Pull Strength - addLabel(new GuiNpcLabel(100, "ability.pullRadius", labelX, y + 5)); - addTextField(createFloatField(100, fieldX, y, 50, vortex.getPullRadius())); - - addLabel(new GuiNpcLabel(101, "ability.pullStrength", col2LabelX, y + 5)); - addTextField(createFloatField(101, col2FieldX, y, 50, vortex.getPullStrength())); - - y += 24; - - // Row 2: Damage + Knockback - addLabel(new GuiNpcLabel(102, "enchantment.damage", labelX, y + 5)); - addTextField(createFloatField(102, fieldX, y, 50, vortex.getDamage())); - - addLabel(new GuiNpcLabel(103, "ability.knockback", col2LabelX, y + 5)); - addTextField(createFloatField(103, col2FieldX, y, 50, vortex.getKnockback())); - - y += 24; - - // Row 3: AOE + Max Targets - addLabel(new GuiNpcLabel(104, "ability.aoe", labelX, y + 5)); - GuiNpcButton aoeBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, vortex.isAoe() ? 1 : 0); - aoeBtn.setHoverText("ability.hover.aoe"); - addButton(aoeBtn); - - addLabel(new GuiNpcLabel(105, "ability.maxTargets", col2LabelX, y + 5)); - addTextField(createIntField(105, col2FieldX, y, 50, vortex.getMaxTargets())); - - y += 24; - - // Row 4: Effects button - addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects")); - - y += 24; - - // Row 5: Damage on Pull + Pull Damage - addLabel(new GuiNpcLabel(108, "ability.dmgOnPull", labelX, y + 5)); - GuiNpcButton dmgOnPullBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, vortex.isDamageOnPull() ? 1 : 0); - dmgOnPullBtn.setHoverText("ability.hover.dmgOnPull"); - addButton(dmgOnPullBtn); - - addLabel(new GuiNpcLabel(109, "ability.pullDamage", col2LabelX, y + 5)); - addTextField(createFloatField(109, col2FieldX, y, 50, vortex.getPullDamage())); - } - - @Override - protected void handleTypeButton(int id, GuiNpcButton button) { - int value = button.getValue(); - switch (id) { - case 104: - vortex.setAoe(value == 1); - break; - case 108: - vortex.setDamageOnPull(value == 1); - break; - case 150: - setSubGui(new SubGuiAbilityEffects(vortex.getEffects())); - break; - } - } - - @Override - public void subGuiClosed(SubGuiInterface subgui) { - super.subGuiClosed(subgui); - if (subgui instanceof SubGuiAbilityEffects) { - SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui; - List result = effectsGui.getResult(); - if (result != null) { - vortex.setEffects(result); - } - } - } - - @Override - protected void handleTypeTextField(int id, GuiNpcTextField field) { - switch (id) { - case 100: - vortex.setPullRadius(parseFloat(field, vortex.getPullRadius())); - break; - case 101: - vortex.setPullStrength(parseFloat(field, vortex.getPullStrength())); - break; - case 102: - vortex.setDamage(parseFloat(field, vortex.getDamage())); - break; - case 103: - vortex.setKnockback(parseFloat(field, vortex.getKnockback())); - break; - case 105: - vortex.setMaxTargets(field.getInteger()); - break; - case 109: - vortex.setPullDamage(parseFloat(field, vortex.getPullDamage())); - break; - } - } -} diff --git a/src/main/java/noppes/npcs/client/gui/builder/FieldDef.java b/src/main/java/noppes/npcs/client/gui/builder/FieldDef.java new file mode 100644 index 000000000..63f188d44 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/builder/FieldDef.java @@ -0,0 +1,300 @@ +package noppes.npcs.client.gui.builder; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import noppes.npcs.controllers.AnimationController; +import noppes.npcs.controllers.data.Animation; +import noppes.npcs.client.gui.SubGuiColorSelector; +import noppes.npcs.client.gui.select.GuiAnimationSelection; +import noppes.npcs.client.gui.select.GuiSoundSelection; +import noppes.npcs.client.gui.util.SubGuiInterface; + +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; +import java.util.function.Supplier; + +/** + * Declarative field definition for GUI rendering. + * Built via static factories and chaining methods. + * Client-side only — never instantiate or reference on the server. + */ +@SideOnly(Side.CLIENT) +public class FieldDef { + + private final String label; + private final FieldType type; + private String tab = null; + private Supplier getter; + private Consumer setter; + private BooleanSupplier visibleWhen = () -> true; + private BooleanSupplier enabledWhen = () -> true; + private String hoverText = null; + + // Numeric range + private float min = Float.MIN_VALUE; + private float max = Float.MAX_VALUE; + + // Enum support + private Class> enumClass; + private String[] stringEnumValues; + private Supplier stringEnumGetter; + private Consumer stringEnumSetter; + + // Sub-gui support + private Supplier subGuiFactory; + private Consumer subGuiResultHandler; + + // Button display + private Supplier buttonLabelSupplier; + private Supplier buttonTextColorSupplier; + private Runnable clearAction; + + // Row pairing (ROW type only) + private FieldDef leftChild; + private FieldDef rightChild; + + private FieldDef(String label, FieldType type) { + this.label = label; + this.type = type; + } + + // ═══════════════════════════════════════════════════════════════════ + // STATIC FACTORIES + // ═══════════════════════════════════════════════════════════════════ + + public static FieldDef section(String label) { + return new FieldDef(label, FieldType.SECTION_HEADER); + } + + public static FieldDef floatField(String label, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, FieldType.FLOAT); + def.getter = () -> getter.get(); + def.setter = v -> setter.accept(((Number) v).floatValue()); + return def; + } + + public static FieldDef intField(String label, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, FieldType.INT); + def.getter = () -> getter.get(); + def.setter = v -> setter.accept(((Number) v).intValue()); + return def; + } + + public static FieldDef boolField(String label, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, FieldType.BOOLEAN); + def.getter = () -> getter.get(); + def.setter = v -> setter.accept((Boolean) v); + return def; + } + + @SuppressWarnings("unchecked") + public static > FieldDef enumField(String label, Class enumClass, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, FieldType.ENUM); + def.enumClass = enumClass; + def.getter = () -> getter.get(); + def.setter = v -> setter.accept((E) v); + return def; + } + + public static FieldDef stringEnumField(String label, String[] values, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, FieldType.STRING_ENUM); + def.stringEnumValues = values; + def.stringEnumGetter = getter; + def.stringEnumSetter = setter; + return def; + } + + public static FieldDef stringField(String label, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, FieldType.STRING); + def.getter = () -> getter.get(); + def.setter = v -> setter.accept((String) v); + return def; + } + + public static FieldDef labelField(String label, Supplier textSupplier) { + FieldDef def = new FieldDef(label, FieldType.LABEL); + def.getter = () -> textSupplier.get(); + return def; + } + + public static FieldDef subGuiField(String label, Supplier factory, Consumer resultHandler) { + FieldDef def = new FieldDef(label, FieldType.SUB_GUI); + def.subGuiFactory = factory; + def.subGuiResultHandler = resultHandler; + return def; + } + + /** + * Creates a FieldDef with a custom FieldType. Used by extension code + * (e.g. AbilityFieldDefs) to create fields with types like EFFECTS_LIST + * that the base GuiFieldBuilder does not handle. + */ + public static FieldDef custom(String label, FieldType type, Supplier getter, Consumer setter) { + FieldDef def = new FieldDef(label, type); + def.getter = getter; + def.setter = setter; + return def; + } + + /** + * Creates a two-column row pairing two fields side by side. + * If one child is hidden (via visibleWhen), the other renders full-width. + */ + public static FieldDef row(FieldDef left, FieldDef right) { + FieldDef def = new FieldDef("", FieldType.ROW); + def.leftChild = left; + def.rightChild = right; + return def; + } + + // ═══════════════════════════════════════════════════════════════════ + // CONVENIENCE FACTORIES (SUB_GUI wrappers) + // ═══════════════════════════════════════════════════════════════════ + + public static FieldDef colorSubGui(String label, Supplier getter, Consumer setter) { + return subGuiField(label, + () -> new SubGuiColorSelector(getter.get()), + gui -> setter.accept(((SubGuiColorSelector) gui).color & 0x00FFFFFF)) + .buttonLabel(() -> String.format("%06X", getter.get() & 0xFFFFFF)) + .buttonTextColor(() -> getter.get() & 0xFFFFFF); + } + + public static FieldDef soundSubGui(String label, Supplier getter, Consumer setter) { + return subGuiField(label, + () -> new GuiSoundSelection(getter.get()), + gui -> { + GuiSoundSelection s = (GuiSoundSelection) gui; + if (s.selectedResource != null) setter.accept(s.selectedResource.toString()); + }) + .buttonLabel(() -> { + String s = getter.get(); + return s == null || s.isEmpty() ? "gui.none" : s; + }) + .clearable(() -> setter.accept("")); + } + + public static FieldDef animSubGui(String label, + Supplier idGetter, Consumer idSetter, + Supplier nameGetter, Consumer nameSetter) { + return subGuiField(label, + () -> new GuiAnimationSelection(idGetter.get(), nameGetter.get()), + gui -> { + GuiAnimationSelection sel = (GuiAnimationSelection) gui; + if (sel.isBuiltInSelected()) { + nameSetter.accept(sel.selectedBuiltInName); + idSetter.accept(-1); + } else { + idSetter.accept(sel.selectedAnimationId); + nameSetter.accept(""); + } + }) + .buttonLabel(() -> { + String name = nameGetter.get(); + if (name != null && !name.isEmpty()) return name; + int id = idGetter.get(); + if (id >= 0) { + Animation anim = AnimationController.Instance != null + ? (Animation) AnimationController.Instance.get(id) : null; + String animName = anim != null ? anim.getName() : ""; + return animName != null && !animName.isEmpty() + ? "(ID: " + id + ") " + animName : "ID: " + id; + } + return "gui.none"; + }) + .clearable(() -> { idSetter.accept(-1); nameSetter.accept(""); }); + } + + // ═══════════════════════════════════════════════════════════════════ + // CHAINING METHODS + // ═══════════════════════════════════════════════════════════════════ + + public FieldDef tab(String tabName) { + this.tab = tabName; + return this; + } + + public FieldDef range(float min, float max) { + this.min = min; + this.max = max; + return this; + } + + public FieldDef visibleWhen(BooleanSupplier condition) { + this.visibleWhen = condition; + return this; + } + + public FieldDef enabledWhen(BooleanSupplier condition) { + this.enabledWhen = condition; + return this; + } + + public FieldDef hover(String hoverText) { + this.hoverText = hoverText; + return this; + } + + public FieldDef buttonLabel(Supplier supplier) { + this.buttonLabelSupplier = supplier; + return this; + } + + public FieldDef buttonTextColor(Supplier supplier) { + this.buttonTextColorSupplier = supplier; + return this; + } + + public FieldDef clearable(Runnable action) { + this.clearAction = action; + return this; + } + + // ═══════════════════════════════════════════════════════════════════ + // GETTERS + // ═══════════════════════════════════════════════════════════════════ + + public String getLabel() { return label; } + public FieldType getType() { return type; } + public String getTab() { return tab; } + public boolean isVisible() { return visibleWhen.getAsBoolean(); } + public boolean isEnabled() { return enabledWhen.getAsBoolean(); } + public String getHoverText() { return hoverText; } + public float getMin() { return min; } + public float getMax() { return max; } + public boolean hasRange() { return min != Float.MIN_VALUE || max != Float.MAX_VALUE; } + public Class> getEnumClass() { return enumClass; } + public String[] getStringEnumValues() { return stringEnumValues; } + public Supplier getSubGuiFactory() { return subGuiFactory; } + public Consumer getSubGuiResultHandler() { return subGuiResultHandler; } + public boolean hasClearAction() { return clearAction != null; } + public Runnable getClearAction() { return clearAction; } + + public Object getValue() { + return getter != null ? getter.get() : null; + } + + public void setValue(Object value) { + if (setter != null) setter.accept(value); + } + + public String getStringEnumValue() { + return stringEnumGetter != null ? stringEnumGetter.get() : null; + } + + public void setStringEnumValue(String value) { + if (stringEnumSetter != null) stringEnumSetter.accept(value); + } + + public String getButtonLabel() { + if (buttonLabelSupplier != null) return buttonLabelSupplier.get(); + return label; + } + + public Integer getButtonTextColor() { + return buttonTextColorSupplier != null ? buttonTextColorSupplier.get() : null; + } + + public FieldDef getLeftChild() { return leftChild; } + public FieldDef getRightChild() { return rightChild; } + +} diff --git a/src/main/java/noppes/npcs/client/gui/builder/FieldType.java b/src/main/java/noppes/npcs/client/gui/builder/FieldType.java new file mode 100644 index 000000000..052e2f4cd --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/builder/FieldType.java @@ -0,0 +1,19 @@ +package noppes.npcs.client.gui.builder; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public enum FieldType { + FLOAT, + INT, + BOOLEAN, + ENUM, + STRING_ENUM, + SUB_GUI, + STRING, + SECTION_HEADER, + LABEL, + EFFECTS_LIST, + ROW +} diff --git a/src/main/java/noppes/npcs/client/gui/builder/GuiFieldBuilder.java b/src/main/java/noppes/npcs/client/gui/builder/GuiFieldBuilder.java new file mode 100644 index 000000000..43a3956c1 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/builder/GuiFieldBuilder.java @@ -0,0 +1,445 @@ +package noppes.npcs.client.gui.builder; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.util.StatCollector; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcButtonYesNo; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.GuiNpcTextField; +import noppes.npcs.client.gui.util.GuiScrollWindow; +import noppes.npcs.client.gui.util.SubGuiInterface; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * General-purpose builder that converts a list of {@link FieldDef} into positioned + * GUI widgets inside a {@link GuiScrollWindow}. + *

+ * Uses {@link FieldDef#row(FieldDef, FieldDef)} for two-column layouts. + * Subclasses can override {@link #buildField} to handle custom field types. + */ +@SideOnly(Side.CLIENT) +public class GuiFieldBuilder { + + // Layout defaults (2-column mode) + protected int contentRight = 330; + protected int colLLabel = 5; + protected int colLField = 75; + protected int colLWidth = 70; + protected int colRLabel = 178; + protected int colRField = 248; + protected int colRWidth = 70; + protected int rowHeight = 24; + protected int labelPadding = 8; + + // Dependencies + protected final GuiNPCInterface parent; + protected GuiScrollWindow sw; + protected final FontRenderer fontRenderer; + + // Scroll window ID + protected int scrollWindowId = 0; + + // ID counters + protected int widgetId; + protected int clearId; + protected int labelId; + + // Starting Y + protected int startY = 5; + protected int lastBuildY = 0; + + // Output maps + protected final Map buttonFieldMap = new HashMap<>(); + protected final Map textFieldMap = new HashMap<>(); + protected final Map clearFieldMap = new HashMap<>(); + + public GuiFieldBuilder(GuiNPCInterface parent, FontRenderer fontRenderer) { + this.parent = parent; + this.fontRenderer = fontRenderer; + } + + // ═══════════════════════════════════════════════════════════════════ + // CONFIG CHAINING + // ═══════════════════════════════════════════════════════════════════ + + public GuiFieldBuilder scrollWindowId(int id) { this.scrollWindowId = id; return this; } + public GuiFieldBuilder contentRight(int v) { this.contentRight = v; return this; } + public GuiFieldBuilder startIds(int widget, int clear, int label) { + this.widgetId = widget; this.clearId = clear; this.labelId = label; return this; + } + public GuiFieldBuilder startY(int y) { this.startY = y; return this; } + public GuiFieldBuilder rowHeight(int h) { this.rowHeight = h; return this; } + + // ═══════════════════════════════════════════════════════════════════ + // BUILD + // ═══════════════════════════════════════════════════════════════════ + + /** + * Creates a {@link GuiScrollWindow} at the given position/size, builds all fields into it, + * and sets maxScrollY automatically. The returned window is ready to use. + */ + public GuiScrollWindow buildScrollWindow(List fields, int x, int y, int width, int height) { + this.sw = new GuiScrollWindow(parent, x, y, width, height, 0); + sw.backgroundColor = 0x88000000; + // Register with parent first — this calls initGui() which clears widget lists, + // so we must add widgets AFTER this point + parent.addScrollableGui(scrollWindowId, sw); + int finalY = build(fields); + sw.maxScrollY = Math.max(finalY - height, 0); + return sw; + } + + /** + * Processes all fields and adds widgets to the scroll window. + * @return the final Y position after all fields + */ + protected int build(List fields) { + buttonFieldMap.clear(); + textFieldMap.clear(); + clearFieldMap.clear(); + + int y = startY; + + for (int i = 0; i < fields.size(); i++) { + FieldDef def = fields.get(i); + + // Let subclasses handle custom types; returns -1 if not handled + int customResult = buildField(def, y, fields, i); + if (customResult >= 0) { + // Subclass handled it, check if index was advanced + int newIndex = getLastHandledIndex(); + if (newIndex > i) i = newIndex; + y = customResult; + continue; + } + + // Section header + if (def.getType() == FieldType.SECTION_HEADER) { + y += 3; + GuiNpcLabel sectionLabel = new GuiNpcLabel(labelId++, def.getLabel(), colLLabel, y + 2, 0xFFFF55); + if (def.getHoverText() != null && !def.getHoverText().isEmpty()) { + sectionLabel.setHoverText(def.getHoverText()); + } + sw.addLabel(sectionLabel); + y += 15; + continue; + } + + // ROW: explicit two-column pair + if (def.getType() == FieldType.ROW) { + FieldDef left = def.getLeftChild(); + FieldDef right = def.getRightChild(); + boolean leftVis = left != null && left.isVisible(); + boolean rightVis = right != null && right.isVisible(); + + if (leftVis && rightVis) { + renderFieldAt(left, colLLabel, colLField, colLWidth, y); + renderFieldAt(right, colRLabel, colRField, colRWidth, y); + } else if (leftVis) { + renderFullWidth(left, y); + } else if (rightVis) { + renderFullWidth(right, y); + } + if (leftVis || rightVis) y += rowHeight; + continue; + } + + // Full-width field + renderFullWidth(def, y); + y += rowHeight; + } + + lastBuildY = y; + return y; + } + + /** + * Hook for subclasses to handle custom field types (e.g. EFFECTS_LIST). + * Return the new Y position if handled, or -1 if not handled (base class will process it). + * If handling advances the field index, call {@link #setLastHandledIndex(int)}. + */ + protected int buildField(FieldDef def, int y, List fields, int index) { + return -1; + } + + private int lastHandledIndex = -1; + protected void setLastHandledIndex(int index) { this.lastHandledIndex = index; } + protected int getLastHandledIndex() { return lastHandledIndex; } + + // ═══════════════════════════════════════════════════════════════════ + // FIELD RENDERING + // ═══════════════════════════════════════════════════════════════════ + + @SuppressWarnings({"unchecked", "rawtypes"}) + protected void renderFieldAt(FieldDef def, int labelX, int fieldX, int fieldW, int y) { + GuiNpcLabel fieldLabel = new GuiNpcLabel(labelId++, def.getLabel(), labelX, y + 5, 0xFFFFFF); + String hover = def.getHoverText(); + if (hover != null && !hover.isEmpty()) { + fieldLabel.setHoverText(hover); + } + sw.addLabel(fieldLabel); + + switch (def.getType()) { + case FLOAT: { + float fVal = def.getValue() instanceof Number ? ((Number) def.getValue()).floatValue() : 0f; + GuiNpcTextField tf = new GuiNpcTextField(widgetId, parent, fontRenderer, fieldX, y, fieldW, 20, String.valueOf(fVal)); + tf.setFloatsOnly(); + if (def.hasRange()) tf.setMinMaxDefaultFloat(def.getMin(), def.getMax(), fVal); + if (!def.isEnabled()) tf.setEnabled(false); + if (hover != null) tf.setHoverText(hover); + sw.addTextField(tf); + textFieldMap.put(widgetId, def); + widgetId++; + clearId++; + break; + } + case INT: { + int iVal = def.getValue() instanceof Number ? ((Number) def.getValue()).intValue() : 0; + GuiNpcTextField tf = new GuiNpcTextField(widgetId, parent, fontRenderer, fieldX, y, fieldW, 20, String.valueOf(iVal)); + tf.setIntegersOnly(); + if (def.hasRange()) tf.setMinMaxDefault((int) def.getMin(), (int) def.getMax(), iVal); + if (!def.isEnabled()) tf.setEnabled(false); + if (hover != null) tf.setHoverText(hover); + sw.addTextField(tf); + textFieldMap.put(widgetId, def); + widgetId++; + clearId++; + break; + } + case STRING: { + String sVal = def.getValue() != null ? def.getValue().toString() : ""; + GuiNpcTextField tf = new GuiNpcTextField(widgetId, parent, fontRenderer, fieldX, y, fieldW, 20, sVal); + if (!def.isEnabled()) tf.setEnabled(false); + if (hover != null) tf.setHoverText(hover); + sw.addTextField(tf); + textFieldMap.put(widgetId, def); + widgetId++; + clearId++; + break; + } + case LABEL: { + String text = def.getValue() != null ? def.getValue().toString() : ""; + sw.addLabel(new GuiNpcLabel(labelId++, text, fieldX, y + 5, 0xAAAAAA)); + widgetId++; + clearId++; + break; + } + case BOOLEAN: { + boolean bVal = def.getValue() instanceof Boolean ? (Boolean) def.getValue() : false; + GuiNpcButtonYesNo btn = new GuiNpcButtonYesNo(widgetId, fieldX, y, fieldW, 20, bVal); + if (!def.isEnabled()) btn.setEnabled(false); + if (hover != null) btn.setHoverText(hover); + sw.addButton(btn); + buttonFieldMap.put(widgetId, def); + widgetId++; + clearId++; + break; + } + case ENUM: { + Class> enumClass = def.getEnumClass(); + if (enumClass != null) { + Enum[] constants = enumClass.getEnumConstants(); + String[] names = new String[constants.length]; + for (int i = 0; i < constants.length; i++) names[i] = constants[i].toString(); + int selected = def.getValue() instanceof Enum ? ((Enum) def.getValue()).ordinal() : 0; + GuiNpcButton btn = new GuiNpcButton(widgetId, fieldX, y, fieldW, 20, names, selected); + if (!def.isEnabled()) btn.setEnabled(false); + if (hover != null) btn.setHoverText(hover); + sw.addButton(btn); + buttonFieldMap.put(widgetId, def); + } + widgetId++; + clearId++; + break; + } + case STRING_ENUM: { + String[] values = def.getStringEnumValues(); + if (values != null && values.length > 0) { + String curVal = def.getStringEnumValue(); + int selected = 0; + for (int i = 0; i < values.length; i++) { + if (values[i].equals(curVal)) { selected = i; break; } + } + GuiNpcButton btn = new GuiNpcButton(widgetId, fieldX, y, fieldW, 20, values, selected); + if (!def.isEnabled()) btn.setEnabled(false); + if (hover != null) btn.setHoverText(hover); + sw.addButton(btn); + buttonFieldMap.put(widgetId, def); + } + widgetId++; + clearId++; + break; + } + case SUB_GUI: { + String btnText = def.getButtonLabel(); + int btnW; + if (def.hasClearAction()) { + btnW = contentRight - 22 - fieldX; + GuiNpcButton clearBtn = new GuiNpcButton(clearId, contentRight - 20, y, 20, 20, "X"); + sw.addButton(clearBtn); + clearFieldMap.put(clearId, def); + } else { + btnW = contentRight - fieldX; + } + GuiNpcButton btn = new GuiNpcButton(widgetId, fieldX, y, btnW, 20, btnText); + Integer textColor = def.getButtonTextColor(); + if (textColor != null) btn.setTextColor(textColor); + if (!def.isEnabled()) btn.setEnabled(false); + if (hover != null) btn.setHoverText(hover); + sw.addButton(btn); + buttonFieldMap.put(widgetId, def); + widgetId++; + clearId++; + break; + } + default: + // Unknown type — skip, incrementing IDs to stay in sync + widgetId++; + clearId++; + break; + } + } + + private void renderFullWidth(FieldDef def, int y) { + int fieldW = getFullFieldWidth(def); + String translated = StatCollector.translateToLocal(def.getLabel()); + int labelW = fontRenderer.getStringWidth(translated); + int fieldX = colLLabel + labelW + labelPadding; + renderFieldAt(def, colLLabel, fieldX, fieldW, y); + } + + protected int getFullFieldWidth(FieldDef def) { + switch (def.getType()) { + case FLOAT: + case INT: return 60; + case STRING: return 200; + case BOOLEAN: return 50; + case LABEL: return 60; + case ENUM: + case STRING_ENUM: return 120; + case SUB_GUI: return def.hasClearAction() ? 175 : 200; + default: return 80; + } + } + + // ═══════════════════════════════════════════════════════════════════ + // EVENT HANDLING + // ═══════════════════════════════════════════════════════════════════ + + private FieldDef activeSubGuiField; + + /** + * Handles button events for declarative fields. + * Call from parent GUI's buttonEvent(). Returns true if the event was handled. + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public boolean handleButtonEvent(int buttonId, GuiButton button) { + // Check clear buttons first + if (clearFieldMap.containsKey(buttonId)) { + FieldDef def = clearFieldMap.get(buttonId); + if (def != null && def.hasClearAction()) { + def.getClearAction().run(); + return true; + } + } + + // Check field buttons + FieldDef def = buttonFieldMap.get(buttonId); + if (def == null) return false; + + switch (def.getType()) { + case BOOLEAN: + def.setValue(((GuiNpcButton) button).getValue() == 1); + return true; + case ENUM: { + int idx = ((GuiNpcButton) button).getValue(); + Class> ec = def.getEnumClass(); + if (ec != null) { + Enum[] constants = ec.getEnumConstants(); + if (idx >= 0 && idx < constants.length) def.setValue(constants[idx]); + } + return true; + } + case STRING_ENUM: { + int idx = ((GuiNpcButton) button).getValue(); + String[] values = def.getStringEnumValues(); + if (values != null && idx >= 0 && idx < values.length) def.setStringEnumValue(values[idx]); + return true; + } + case SUB_GUI: + activeSubGuiField = def; + return true; + default: + return false; + } + } + + /** + * Handles text field unfocus events for declarative fields. + * Call from parent GUI's unFocused(). Returns true if the event was handled. + */ + public boolean handleTextFieldEvent(int textFieldId, GuiNpcTextField field) { + FieldDef def = textFieldMap.get(textFieldId); + if (def == null) return false; + + switch (def.getType()) { + case FLOAT: + try { def.setValue(Float.parseFloat(field.getText())); } catch (NumberFormatException ignored) {} + return true; + case INT: + try { def.setValue(Integer.parseInt(field.getText())); } catch (NumberFormatException ignored) {} + return true; + case STRING: + def.setValue(field.getText()); + return true; + default: + return false; + } + } + + /** + * Handles sub-gui close events. Call from parent GUI's subGuiClosed(). + * Returns true if the event was handled (activeSubGuiField was set). + */ + public boolean handleSubGuiClosed(SubGuiInterface subgui) { + if (activeSubGuiField != null) { + FieldDef def = activeSubGuiField; + activeSubGuiField = null; + if (def.getSubGuiResultHandler() != null) { + def.getSubGuiResultHandler().accept(subgui); + } + return true; + } + return false; + } + + /** + * Returns the FieldDef for the currently active sub-gui, or null. + * After handleButtonEvent returns true for a SUB_GUI field, the parent + * should check this and call setSubGui(def.getSubGuiFactory().get()). + */ + public FieldDef getActiveSubGuiField() { return activeSubGuiField; } + + /** + * Clears the active sub-gui field tracking. + */ + public void clearActiveSubGuiField() { activeSubGuiField = null; } + + // ═══════════════════════════════════════════════════════════════════ + // GETTERS + // ═══════════════════════════════════════════════════════════════════ + + public Map getButtonFieldMap() { return buttonFieldMap; } + public Map getTextFieldMap() { return textFieldMap; } + public Map getClearFieldMap() { return clearFieldMap; } + public GuiScrollWindow getScrollWindow() { return sw; } + public int getLastBuildY() { return lastBuildY; } + public int getNextLabelId() { return labelId; } +} diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiAnimationSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiAnimationSelection.java index 2a1f04344..7161722d5 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiAnimationSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiAnimationSelection.java @@ -55,7 +55,6 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr * Constructor for selecting by name (built-in) or ID (user). */ public GuiAnimationSelection(int animationId, String animationName) { - drawDefaultBackground = false; title = ""; setBackground("menubg.png"); xSize = 220; diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java index 341b3cc48..aae3043ce 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiSoundSelection.java @@ -39,7 +39,6 @@ public class GuiSoundSelection extends SubGuiInterface implements ICustomScrollL public static HashMap> cachedDomains = new HashMap<>(); public GuiSoundSelection(String sound) { - drawDefaultBackground = false; title = ""; setBackground("menubg.png"); xSize = 366; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java index 0bf481ffb..3f3ca9223 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiCustomScroll.java @@ -104,8 +104,10 @@ public class GuiCustomScroll extends GuiScreen { GL11.glTranslatef(guiLeft, guiTop, 0.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (selectable) + if (selectable && !hasSubGUI) hover = getMouseOver(i, j); + else if (hasSubGUI) + hover = -1; drawItems(); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java index d09bddecf..4ebafd54f 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java @@ -2,6 +2,7 @@ package noppes.npcs.client.gui.util; import kamkeel.npcs.util.TextSplitter; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; @@ -151,8 +152,23 @@ public class GuiNpcButton extends GuiButton { public void drawButton(Minecraft mc, int mouseX, int mouseY) { if (!this.visible) return; + // Auto-truncate display text if wider than button + String original = this.displayString; + FontRenderer fr = mc.fontRenderer; + if (fr != null) { + int maxTextWidth = this.width - 6; + if (fr.getStringWidth(original) > maxTextWidth) { + String ellipsis = "..."; + int targetWidth = maxTextWidth - fr.getStringWidth(ellipsis); + if (targetWidth > 0) { + this.displayString = fr.trimStringToWidth(original, targetWidth) + ellipsis; + } + } + } // First, draw the button normally using the superclass method. super.drawButton(mc, mouseX, mouseY); + // Restore original display string + this.displayString = original; // Then, if an icon texture is set, draw it. if (iconTexture != null) { mc.getTextureManager().bindTexture(iconTexture); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java index f620e1e63..60b4afdb6 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcLabel.java @@ -1,18 +1,32 @@ package noppes.npcs.client.gui.util; +import kamkeel.npcs.util.TextSplitter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.StatCollector; import noppes.npcs.client.CustomNpcResourceListener; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; -public class GuiNpcLabel { +import java.util.Iterator; +import java.util.List; + +public class GuiNpcLabel extends Gui { public String label; public int x, y, color; public boolean enabled = true; public int id; public boolean drawShadow = false; + // Hover text support + public String hoverableText = ""; + private boolean wasHovered = false; + private int hoverCount = 0; + public GuiNpcLabel(int id, Object label, int x, int y, int color) { this.id = id; this.label = StatCollector.translateToLocal(label.toString()); @@ -25,6 +39,10 @@ public class GuiNpcLabel { this(id, label, x, y, CustomNpcResourceListener.DefaultTextColor); } + public void setHoverText(String text) { + this.hoverableText = text; + } + public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) { if (enabled) fontRenderer.drawString(label, x, y, color, drawShadow); @@ -34,4 +52,119 @@ public class GuiNpcLabel { int size = Minecraft.getMinecraft().fontRenderer.getStringWidth(label); x += (width - size) / 2; } + + public boolean isMouseOver(int mouseX, int mouseY, FontRenderer fr) { + int width = fr.getStringWidth(label); + return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 10; + } + + /** + * Draws hover tooltip if the mouse is over this label. + * @param localMouseX Mouse X in scroll-local coordinates (for hit testing) + * @param localMouseY Mouse Y in scroll-local coordinates (for hit testing) + * @param screenMouseX Mouse X in screen coordinates (for tooltip positioning) + * @param screenMouseY Mouse Y in screen coordinates (for tooltip positioning) + * @param hasSubGui Whether a sub-gui is open + * @param fr FontRenderer for measuring label width + */ + public void drawHover(int localMouseX, int localMouseY, int screenMouseX, int screenMouseY, boolean hasSubGui, FontRenderer fr) { + if (hasSubGui || hoverableText.isEmpty()) return; + + boolean hovered = isMouseOver(localMouseX, localMouseY, fr); + if (!hovered) { + wasHovered = false; + hoverCount = 0; + return; + } + if (!wasHovered) { + wasHovered = true; + hoverCount = 0; + } + if (hoverCount < 65) hoverCount++; + + if (hoverCount > 60) { + GL11.glPushMatrix(); + Minecraft mc = Minecraft.getMinecraft(); + String displayString = StatCollector.translateToLocal(hoverableText); + GL11.glColor4f(1, 1, 1, 1); + List lines = TextSplitter.splitText(displayString, 30); + drawHoveringText(lines, screenMouseX, screenMouseY, mc); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + + @SuppressWarnings("rawtypes") + protected void drawHoveringText(List textLines, int x, int y, Minecraft mc) { + if (mc.fontRenderer == null || textLines.isEmpty()) + return; + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int maxWidth = 0; + Iterator iterator = textLines.iterator(); + while (iterator.hasNext()) { + String s = (String) iterator.next(); + int lineWidth = mc.fontRenderer.getStringWidth(s); + if (lineWidth > maxWidth) { + maxWidth = lineWidth; + } + } + + int j2 = x + 12; + int k2 = y - 12; + int maxHeight = 8; + + if (textLines.size() > 1) { + maxHeight += 2 + (textLines.size() - 1) * 10; + } + + ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + int screenWidth = scaledRes.getScaledWidth(); + int screenHeight = scaledRes.getScaledHeight(); + + if (j2 + maxWidth + 6 > screenWidth) { + j2 = x - maxWidth - 16; + } + if (j2 < 4) { + j2 = 4; + } + if (k2 + maxHeight + 6 > screenHeight) { + k2 = screenHeight - maxHeight - 6; + } + if (k2 < 4) { + k2 = 4; + } + + this.zLevel = 300.0F; + int j1 = -267386864; + this.drawGradientRect(j2 - 3, k2 - 4, j2 + maxWidth + 3, k2 - 3, j1, j1); + this.drawGradientRect(j2 - 3, k2 + maxHeight + 3, j2 + maxWidth + 3, k2 + maxHeight + 4, j1, j1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 + maxHeight + 3, j1, j1); + this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + maxHeight + 3, j1, j1); + this.drawGradientRect(j2 + maxWidth + 3, k2 - 3, j2 + maxWidth + 4, k2 + maxHeight + 3, j1, j1); + int k1 = 1347420415; + int l1 = (k1 & 16711422) >> 1 | k1 & -16777216; + this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + maxHeight + 3 - 1, k1, l1); + this.drawGradientRect(j2 + maxWidth + 2, k2 - 3 + 1, j2 + maxWidth + 3, k2 + maxHeight + 3 - 1, k1, l1); + this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 - 3 + 1, k1, k1); + this.drawGradientRect(j2 - 3, k2 + maxHeight + 2, j2 + maxWidth + 3, k2 + maxHeight + 3, l1, l1); + + for (int i2 = 0; i2 < textLines.size(); ++i2) { + String s1 = (String) textLines.get(i2); + mc.fontRenderer.drawStringWithShadow(s1, j2, k2, -1); + if (i2 == 0) { + k2 += 2; + } + k2 += 10; + } + + this.zLevel = 0.0F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java b/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java index 3273f1f6c..ab6e612d4 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java @@ -97,6 +97,11 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC } public void mouseClicked(int i, int j, int k) { + // Ignore clicks outside the visible scroll window area + if (i < xPos || i > xPos + clipWidth || j < yPos || j > yPos + clipHeight) { + return; + } + i = i - xPos; j = (int) (j - yPos + scrollY); @@ -246,6 +251,12 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC } GL11.glPopMatrix(); + + // Draw hover texts in screen space (after scissor/translation are undone) + // so tooltips are not clipped and are positioned correctly + if (isMouseOver(mouseX, mouseY)) { + drawHoverTexts(mouseX, mouseY); + } } public void drawScreen(int mouseX, int mouseY, float partialTicks, int mouseScroll) { @@ -275,8 +286,26 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC } for (GuiNpcButton button : buttons.values()) { button.updateSubGUI(subGui); + } + } + + /** + * Draws hover texts for buttons in screen space (called after GL scissor/translate are undone). + * Hover state was already computed during drawComponents with scroll-local coords. + */ + private void drawHoverTexts(int mouseX, int mouseY) { + boolean subGui = parent.hasSubGui(); + for (GuiNpcButton button : buttons.values()) { if (!button.hoverableText.isEmpty()) { - button.drawHover(i, j, subGui); + button.drawHover(mouseX, mouseY, subGui); + } + } + // Label hover: convert screen mouse to scroll-local coords for hit testing + int localMouseX = mouseX - xPos; + int localMouseY = (int) (mouseY - yPos + scrollY); + for (GuiNpcLabel label : labels.values()) { + if (!label.hoverableText.isEmpty()) { + label.drawHover(localMouseX, localMouseY, mouseX, mouseY, subGui, fontRendererObj); } } } diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java index 64b37340f..7f9fdd19b 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockBeamRenderer.java @@ -26,8 +26,8 @@ public class BlockBeamRenderer extends BlockRendererInterface { public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) { TileVariant tile = (TileVariant) var1; - GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef((float) var2 + 0.5f, (float) var4 + 1.5f, (float) var6 + 0.5f); //GL11.glScalef(1.2f, 1.1f, 1.2f); GL11.glRotatef(180, 0, 0, 1); diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java index 738819500..60799c767 100644 --- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java +++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java @@ -342,5 +342,10 @@ public class ScriptContainer implements IScriptUnit { public void setErrored(boolean errored) { this.errored = errored; } + + @Override + public boolean isJanino() { + return false; + } } diff --git a/src/main/java/somehussar/gui/AnnotatedGui.java b/src/main/java/somehussar/gui/AnnotatedGui.java new file mode 100644 index 000000000..8cdf224d5 --- /dev/null +++ b/src/main/java/somehussar/gui/AnnotatedGui.java @@ -0,0 +1,44 @@ +package somehussar.gui; + +import net.minecraft.client.gui.GuiScreen; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.SubGuiInterface; +import somehussar.gui.annotationHandling.GuiFieldHandler; +import somehussar.gui.annotationHandling.field.EditableField; + +public class AnnotatedGui extends SubGuiInterface { + private final GuiFieldHandler.ClassMetadata metadata; + + public AnnotatedGui(T object, String[] groups, GuiScreen parent) { + this(object, groups, parent, 256, 216); + } + + public AnnotatedGui(T object, String[] groups, GuiScreen parent, int xSize, int ySize) { + if (object != null) + metadata = GuiFieldHandler.getMetadata(object.getClass()); + else + metadata = null; + setBackground("menubg.png"); + this.xSize = xSize; + this.ySize = ySize; + closeOnEsc = true; + this.parent = parent; + } + + @Override + public void initGui() { + super.initGui(); + if (metadata == null) + return; + + int i = 0; + for (EditableField field : metadata.getParent().getDeclaredFields()) { + addLabel(new GuiNpcLabel(i++, field.getName(), guiLeft+8, guiTop+i*15+5)); + } + } + + @Override + public void save() { + + } +} diff --git a/src/main/java/somehussar/gui/ImmediateTextField.java b/src/main/java/somehussar/gui/ImmediateTextField.java new file mode 100644 index 000000000..5f49a9d84 --- /dev/null +++ b/src/main/java/somehussar/gui/ImmediateTextField.java @@ -0,0 +1,32 @@ +package somehussar.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import noppes.npcs.client.gui.util.GuiNpcTextField; +import somehussar.gui.annotationHandling.field.EditableField; + +public class ImmediateTextField extends GuiNpcTextField{ + private final EditableField editableField; +// +// private final GuiNpcTextField encapsulatedField; + + public ImmediateTextField(int id, EditableField field, int xPos, int yPos) { + this(id, field, Minecraft.getMinecraft().fontRenderer, xPos, yPos); + } + public ImmediateTextField(int id, EditableField field, FontRenderer fontRenderer, int xPos, int yPos) { + super(id, null, fontRenderer, xPos, yPos, 0, 0, null); + + this.editableField = field; + } + + @Override + public void drawTextBox(int mousX, int mousY) { + + } + + @Override + public void mouseClicked(int xPos, int yPos, int k) { + xPos -= this.xPosition; + yPos -= this.yPosition; + } +} diff --git a/src/main/java/somehussar/gui/annotationHandling/FieldConstraint.java b/src/main/java/somehussar/gui/annotationHandling/FieldConstraint.java new file mode 100644 index 000000000..7a9b124e4 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/FieldConstraint.java @@ -0,0 +1,5 @@ +package somehussar.gui.annotationHandling; + +public interface FieldConstraint { + void validate(Object value); +} diff --git a/src/main/java/somehussar/gui/annotationHandling/FieldConstraints.java b/src/main/java/somehussar/gui/annotationHandling/FieldConstraints.java new file mode 100644 index 000000000..9a48fd1e3 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/FieldConstraints.java @@ -0,0 +1,27 @@ +package somehussar.gui.annotationHandling; + +public final class FieldConstraints { + + private static final FieldConstraints EMPTY = + new FieldConstraints(new FieldConstraint[0]); + + private final FieldConstraint[] constraints; + + public FieldConstraints(FieldConstraint[] constraints) { + this.constraints = constraints; + } + + public static FieldConstraints empty() { + return EMPTY; + } + + public void validate(Object value) { + for (FieldConstraint c : constraints) { + c.validate(value); + } + } + + public boolean isEmpty() { + return constraints.length == 0; + } +} diff --git a/src/main/java/somehussar/gui/annotationHandling/GuiEditable.java b/src/main/java/somehussar/gui/annotationHandling/GuiEditable.java new file mode 100644 index 000000000..596f3ab2f --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/GuiEditable.java @@ -0,0 +1,46 @@ +package somehussar.gui.annotationHandling; + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface GuiEditable { + + @Retention(RetentionPolicy.RUNTIME) + @interface Field { + String value(); + + /** + * Display order + * Higher value = higher priority. + */ + int order() default 0; + + } + + @Retention(RetentionPolicy.RUNTIME) + @interface Group { + String value(); + } + + @Retention(RetentionPolicy.RUNTIME) + @interface Size { + int labelWidth() default 60; + int fieldWidth() default 50; + + GuiEditable.Size DEFAULT_SIZE = new GuiEditable.Size() { + @Override + public int labelWidth() { + return 60; + } + + @Override + public int fieldWidth() { + return 50; + } + @Override public Class annotationType() { return GuiEditable.Size.class; } + }; + + } +} diff --git a/src/main/java/somehussar/gui/annotationHandling/GuiFieldHandler.java b/src/main/java/somehussar/gui/annotationHandling/GuiFieldHandler.java new file mode 100644 index 000000000..c6b7f3625 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/GuiFieldHandler.java @@ -0,0 +1,140 @@ +package somehussar.gui.annotationHandling; + +import somehussar.gui.annotationHandling.constraints.ConstraintFactory; +import somehussar.gui.annotationHandling.constraints.NumericConstraint; +import somehussar.gui.annotationHandling.constraints.NumericConstraintFactory; +import somehussar.gui.annotationHandling.field.EditableField; + +import java.lang.annotation.Annotation; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public final class GuiFieldHandler { + + private static final Map, ClassMetadata> CACHE = new HashMap<>(); + private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); + + public static final Map, ConstraintFactory> registry = new HashMap<>(); + + static { + registry.put(NumericConstraint.class, new NumericConstraintFactory()); + } + + + private GuiFieldHandler() {} + + public static ClassMetadata getMetadata(Class type) { + return CACHE.computeIfAbsent(type, GuiFieldHandler::scanClass); + } + + @SuppressWarnings({"RawUseOfParameterized"}) + private static ClassMetadata scanClass(Class type) { + if (!type.isAnnotationPresent(GuiEditable.class)) { + return null; + } + + ClassMetadata parent = null; + + Class superCls = type.getSuperclass(); + if (superCls != null && superCls != Object.class) { + parent = getMetadata(superCls); + } + + List list = new ArrayList<>(); + for (Field field : type.getDeclaredFields()) { + EditableField editableField = createEditableField(field); + + if (editableField != null) { + list.add(editableField); + } + } + + return new ClassMetadata( + type, + list.toArray(list.toArray(new EditableField[0])), + parent + ); + } + + @SuppressWarnings({"RawUseOfParameterized", "unchecked"}) + private static EditableField createEditableField(Field field) { + try { + GuiEditable.Field fieldConfig = field.getAnnotation(GuiEditable.Field.class); + if (fieldConfig == null) return null; + if (Modifier.isFinal(field.getModifiers())) return null; + + GuiEditable.Size size = field.getAnnotation(GuiEditable.Size.class); + if (size == null) size = GuiEditable.Size.DEFAULT_SIZE;; + + field.setAccessible(true); + EditableField.Builder builder = new EditableField.Builder() + .name(fieldConfig.value()) + .type(field.getType()) + .getter(LOOKUP.unreflectGetter(field)) + .setter(LOOKUP.unreflectSetter(field)) + .constraints(buildConstraints(field)) + .order(fieldConfig.order()) + .size(size); + + + GuiEditable.Group group = field.getAnnotation(GuiEditable.Group.class); + if (group != null) + builder.group(group.value()); + + + return builder.build(); + } catch (IllegalAccessException e) { + throw new RuntimeException( + "Failed to bind field: " + field, e); + } + } + + @SuppressWarnings({"RawUseOfParameterized", "unchecked"}) + private static FieldConstraints buildConstraints(Field field) { + List list = new ArrayList<>(); + + for (Annotation ann : field.getAnnotations()) { + ConstraintFactory factory = registry.get(ann.annotationType()); + if (factory != null) { + FieldConstraint c = factory.create(field, ann); + list.add(c); + } + } + + if (list.isEmpty()) return FieldConstraints.empty(); + return new FieldConstraints(list.toArray(new FieldConstraint[0])); + } + + + @SuppressWarnings({"RawUseOfParameterized"}) + public static final class ClassMetadata { + final Class type; + final EditableField[] fields; // only declared fields + final ClassMetadata parent; // superclass metadata (nullable) + + ClassMetadata(Class type, EditableField[] fields, ClassMetadata parent) { + this.type = type; + this.fields = fields; + this.parent = parent; + } + + public ClassMetadata getParent() { + return parent; + } + + public EditableField[] getDeclaredFields() { + return fields; + } + + public Class getType() { + return type; + } + } + + +} diff --git a/src/main/java/somehussar/gui/annotationHandling/constraints/ConstraintFactory.java b/src/main/java/somehussar/gui/annotationHandling/constraints/ConstraintFactory.java new file mode 100644 index 000000000..d62de94b4 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/constraints/ConstraintFactory.java @@ -0,0 +1,10 @@ +package somehussar.gui.annotationHandling.constraints; + +import somehussar.gui.annotationHandling.FieldConstraint; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +public interface ConstraintFactory { + FieldConstraint create(Field field, A annotation); +} diff --git a/src/main/java/somehussar/gui/annotationHandling/constraints/NumericConstraint.java b/src/main/java/somehussar/gui/annotationHandling/constraints/NumericConstraint.java new file mode 100644 index 000000000..3b9268a30 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/constraints/NumericConstraint.java @@ -0,0 +1,13 @@ +package somehussar.gui.annotationHandling.constraints; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(value = RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface NumericConstraint { + double min() default Double.NEGATIVE_INFINITY; + double max() default Double.POSITIVE_INFINITY; +} diff --git a/src/main/java/somehussar/gui/annotationHandling/constraints/NumericConstraintFactory.java b/src/main/java/somehussar/gui/annotationHandling/constraints/NumericConstraintFactory.java new file mode 100644 index 000000000..24b08ceb9 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/constraints/NumericConstraintFactory.java @@ -0,0 +1,13 @@ +package somehussar.gui.annotationHandling.constraints; + +import somehussar.gui.annotationHandling.FieldConstraint; + +import java.lang.reflect.Field; + +public class NumericConstraintFactory implements ConstraintFactory { + + @Override + public FieldConstraint create(Field field, NumericConstraint ann) { + return new NumericRangeConstraint(ann.min(), ann.max()); + } +} diff --git a/src/main/java/somehussar/gui/annotationHandling/constraints/NumericRangeConstraint.java b/src/main/java/somehussar/gui/annotationHandling/constraints/NumericRangeConstraint.java new file mode 100644 index 000000000..198888d25 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/constraints/NumericRangeConstraint.java @@ -0,0 +1,35 @@ +package somehussar.gui.annotationHandling.constraints; + +import somehussar.gui.annotationHandling.FieldConstraint; + +public final class NumericRangeConstraint implements FieldConstraint { + + private final double min; + private final double max; + + public NumericRangeConstraint(double min, double max) { + this.min = min; + this.max = max; + } + + @Override + public void validate(Object value) { + if (!(value instanceof Number)) { + throw new ConstraintViolationException("Expected number, got " + value); + } + + double v = ((Number) value).doubleValue(); + if (v < min || v > max) { + throw new ConstraintViolationException( + "Value " + v + " must be between " + min + " and " + max + ); + } + } + + public static final class ConstraintViolationException extends RuntimeException { + public ConstraintViolationException(String message) { + super(message); + } + } + +} diff --git a/src/main/java/somehussar/gui/annotationHandling/field/EditableField.java b/src/main/java/somehussar/gui/annotationHandling/field/EditableField.java new file mode 100644 index 000000000..73172ef42 --- /dev/null +++ b/src/main/java/somehussar/gui/annotationHandling/field/EditableField.java @@ -0,0 +1,85 @@ +package somehussar.gui.annotationHandling.field; + +import somehussar.gui.annotationHandling.FieldConstraints; +import somehussar.gui.annotationHandling.GuiEditable; + +import java.lang.invoke.MethodHandle; + +public final class EditableField { + + private final String name; + private final Class type; + private final MethodHandle getter; + private final MethodHandle setter; + private final FieldConstraints constraints; + private final int order; + private final String group; + private final GuiEditable.Size size; + + public String getName() { + return name; + } + + public Class getType() { + return type; + } + + @SuppressWarnings({"unchecked"}) + public T read(T instance) { + try { + return (T) getter.invoke(instance); + } catch (Throwable t) { + throw new RuntimeException("Failed to read field " + name, t); + } + } + + public void write(T instance, T value) { + constraints.validate(value); + try { + setter.invoke(instance, value); + } catch (Throwable t) { + throw new RuntimeException("Failed to write field " + name, t); + } + } + + public FieldConstraints getConstraints() { + return this.constraints; + } + + public int getOrder() { return this.order; } + + EditableField(Builder b) { + this.name = b.name; + this.type = b.type; + this.getter = b.getter; + this.setter = b.setter; + this.constraints = b.constraints; + this.order = b.order; + this.group = b.group; + this.size = b.size; + } + + public static class Builder { + private String name; + private Class type; + private MethodHandle getter; + private MethodHandle setter; + private FieldConstraints constraints; + private int order; + private String group = null; + private GuiEditable.Size size; + + public Builder name(String v) { this.name = v; return this; } + public Builder type(Class v) { this.type = v; return this; } + public Builder getter(MethodHandle v) { this.getter = v; return this; } + public Builder setter(MethodHandle v) { this.setter = v; return this; } + public Builder constraints(FieldConstraints v) { this.constraints = v; return this; } + public Builder order(int order) { this.order = order; return this; } + public Builder group(String value) { this.group = value; return this; } + public Builder size(GuiEditable.Size size) { this.size = size; return this; } + + public EditableField build() { + return new EditableField<>(this); + } + } +} diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index ab6ee1904..a95b71f67 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1537,6 +1537,48 @@ ability.target.aggro_target=Target ability.target.self=Self ability.target.aoe_self=AOE Self ability.target.aoe_target=AOE Target +ability.syncWindup=Sync Windup + +# Anchor Point +ability.anchor.front=Front +ability.anchor.center=Center +ability.anchor.rightHand=Right Hand +ability.anchor.leftHand=Left Hand +ability.anchor.aboveHead=Above Head +ability.anchor.chest=Chest + +# Sweep Mode +ability.sweep.swipe=Swipe +ability.sweep.spin=Spin + +# Dash Mode +ability.dash.aggressive=Aggressive +ability.dash.defensive=Defensive + +# Counter Type +ability.counter.flat=Flat +ability.counter.percent=Percent + +# Hazard Shape +ability.shape.circle=Circle +ability.shape.ring=Ring +ability.shape.cone=Cone + +# Placement Mode +ability.placement.atCaster=At Caster +ability.placement.atTarget=At Target +ability.placement.followCaster=Follow Caster +ability.placement.followTarget=Follow Target + +# Teleport Mode +ability.teleport.blink=Blink +ability.teleport.behind=Behind +ability.teleport.single=Single + +# Trap Placement +ability.trapPlace.atCaster=At Caster +ability.trapPlace.atTarget=At Target +ability.trapPlace.aheadOfCaster=Ahead of Caster telegraph.circle=Circle telegraph.ring=Ring @@ -1580,118 +1622,186 @@ ability.cnpc.disc_dual=Disc Dual ability.cnpc.laser_shot=Laser Shot ability.cnpc.sweeper=Sweeper -# Ability GUI - Type Tab +# ═══════════════════════════════════════════════════════════════ +# Ability Config GUI +# ═══════════════════════════════════════════════════════════════ + +# General Tab +ability.weight=Weight +ability.windUpTicks=Wind Up +ability.cooldownTicks=Cooldown +ability.lockMovement=Lock Movement +ability.interruptible=Interruptible +ability.dazedTicks=Dazed Ticks +ability.targetingMode=Targeting + +# Target Tab +ability.minRange=Min Range +ability.maxRange=Max Range +ability.conditions=Conditions + +# Effects Tab +ability.windUpSound=Wind Up Sound +ability.activeSound=Active Sound +ability.windUpAnimation=Wind Up Animation +ability.activeAnimation=Active Animation +ability.showTelegraph=Show Telegraph +ability.windUpColor=Wind Up Color +ability.activeColor=Active Color + +# Section Headers +ability.section.timing=Timing +ability.section.movement=Movement +ability.section.sounds=Sounds +ability.section.animations=Animations +ability.section.telegraph=Telegraph +ability.section.beam=Beam +ability.section.sweep=Sweep +ability.section.push=Push +ability.section.leap=Leap +ability.section.disc=Disc +ability.section.homing=Homing +ability.section.boomerang=Boomerang +ability.section.explosive=Explosive +ability.section.colors=Colors +ability.section.effects=Effects +ability.section.dual=Dual +ability.section.beam1=Beam 1 +ability.section.beam2=Beam 2 +ability.section.disc1=Disc 1 +ability.section.disc2=Disc 2 +ability.section.orb1=Orb 1 +ability.section.orb2=Orb 2 +ability.section.counter=Counter +ability.section.area=Area +ability.section.damage=Damage +ability.section.debuffs=Debuffs +ability.section.healing=Healing +ability.section.trigger=Trigger +ability.section.aoe=AOE +ability.section.pullDamage=Pull Damage + +# Shared Sub-Section Labels (used under section headers) +gui.radius=Radius +gui.thickness=Thickness +gui.rotationSpeed=Rotation Speed +gui.strength=Strength +gui.range=Range +gui.delay=Delay +gui.density=Density +gui.length=Length +gui.width=Width +gui.height=Height +gui.value=Value +gui.chance=Chance +gui.sound=Sound +gui.animation=Animation +gui.duration=Duration +gui.amp=Amp +gui.speed=Speed # Common Type Settings ability.radius=Radius ability.knockback=Knockback -ability.knockbackUp=KB Up -ability.maxDist=Max Dist -ability.minDist=Min Dist +ability.knockbackUp=Knockback Up ability.distance=Distance +ability.maxDistance=Max Distance ability.lifetime=Lifetime -ability.stunTicks=Stun -ability.leapHeight=Leap Height +ability.stunTicks=Stun Ticks ability.hitWidth=Hit Width ability.effects=Effects -gui.duration=Duration -gui.amp=Amp +ability.mode=Mode +ability.duration=Duration +ability.anchorPoint=Anchor Point +ability.rotationSpeed=Rotation Speed -# Slam Settings +# Slam ability.leapSpeed=Leap Speed +ability.leapHeight=Leap Height -# Charge Settings -ability.hitRadius=Hit Radius - -# Cutter Settings +# Cutter +ability.range=Range +ability.sweepMode=Sweep Mode +ability.spinDuration=Spin Duration ability.arcAngle=Arc Angle -ability.sweepWaves=Waves -ability.rotSpeed=Rot Speed -ability.piercing=Piercing +ability.innerRadius=Inner Radius + +# Projectile +ability.projectileType=Projectile Type # Orb Settings ability.homing=Homing ability.explosive=Explosive +ability.firingSpeed=Firing Speed +ability.amount=Amount +ability.dualCharge=Dual Charging -# Vortex Settings -ability.pullRadius=Radius -ability.pullStrength=Strength -ability.pullTo=Pull To -ability.aoe=AOE +# Charge +ability.chargeSpeed=Charge Speed + +# Dash +ability.dashMode=Dash Mode +ability.dashDistance=Dash Distance +ability.dashSpeed=Dash Speed + +# Teleport +ability.blinkRadius=Blink Radius +ability.blinkCount=Blink Count +ability.blinkDelay=Blink Delay +ability.behindDistance=Behind Distance +ability.lineOfSight=Line of Sight +ability.damageAtStart=Damage At Start +ability.damageAtEnd=Damage At End + +# Vortex +ability.pullRadius=Pull Radius +ability.pullStrength=Pull Strength ability.maxTargets=Max Targets -# Dash Settings -ability.dash.aggressive=Aggressive -ability.dash.defensive=Defensive -ability.mode=Mode -ability.behindDistance=Behind Dist +# Shockwave +ability.pushStrength=Push Strength -# Teleport Settings -ability.blinkCount=Blinks -ability.blinkDelay=Delay -ability.blinkRadius=Radius -ability.minRadius=Min Rad -ability.dmgRadius=Dmg Radius -ability.lineOfSight=Line Sight -ability.dmgAtStart=Dmg Start +# Guard +ability.damageReduction=Damage Reduction -# Projectile Settings -ability.explRadius=Expl Rad - -# Beam Settings -ability.beamLength=Length -ability.beamWidth=Width -ability.beamHeight=Height -ability.dmgInterval=Interval -ability.sweepAngle=Sweep Ang -ability.sweepSpeed=Sweep Spd -ability.lockTarget=Lock Tgt -ability.rotations=Rotations - -# Guard Settings -ability.dmgReduce=Dmg Reduce -ability.counterDmg=Counter Dmg -ability.canCounter=Counter -ability.counterChance=Counter % -ability.counterType=Counter Type -ability.counterValue=Counter Value -ability.counterSound=Counter Sound -ability.counterAnim=Counter Anim - -# Heal Settings -ability.healAmount=Amount -ability.healPercent=Percent -ability.healRadius=Radius +# Heal +ability.instantHeal=Instant Heal +ability.healAmount=Heal Amount +ability.healPercent=Heal Percent +ability.healRadius=Heal Radius ability.healSelf=Heal Self ability.healAllies=Heal Allies -# Hazard Settings -ability.dmgPerSec=Dmg/Sec -ability.debuffDur=Debuff Dur +# Hazard ability.shape=Shape ability.placement=Placement -ability.affectsCaster=Hit Caster -ability.ignoreInvuln=Ign Invuln -ability.place.caster=At Caster -ability.place.target=At Target -ability.place.followCaster=Follow Caster -ability.place.followTarget=Follow Target -ability.place.ahead=Ahead +ability.damagePerSecond=Damage/Sec +ability.damageInterval=Damage Interval +ability.slownessLevel=Slowness Level +ability.debuffDuration=Debuff Duration +ability.poisonLevel=Poison Level +ability.affectsCaster=Affects Caster -# Trap Settings -ability.triggerRadius=Trig Rad +# Trap ability.armTime=Arm Time -ability.maxTriggers=Max Trig +ability.maxTriggers=Max Triggers +ability.triggerCooldown=Trigger Cooldown -# Disc Settings -ability.discRadius=Disc Rad -ability.discThickness=Thickness -ability.boomerang=Boomerang -ability.boomerangDelay=Return Delay -ability.homingStr=Homing Str -ability.homingRange=Homing Rng -ability.explosionRad=Expl Rad -ability.rotationSpeed=Rot Speed +# Sweeper +ability.sweepSpeed=Sweep Speed +ability.rotations=Rotations +ability.piercing=Piercing +ability.lockTarget=Lock Target + +# Beam / Laser +ability.beamWidth=Beam Width +ability.headSize=Head Size +ability.attachedToOwner=Attached to Owner +ability.laserWidth=Laser Width +ability.expansionSpeed=Expansion Speed +ability.lingerTicks=Linger Ticks + +# Visual Settings ability.innerColor=Inner Color ability.outerColor=Outer Color ability.outerEnabled=Outer Glow @@ -1700,22 +1810,11 @@ ability.outerAlpha=Outer Alpha ability.lightning=Lightning ability.lightningDensity=Density ability.lightningRadius=Radius -ability.anchorPoint=Anchor Point -ability.noVisualSettings=No visual settings for this ability type # Dual Energy Projectile Settings ability.dualFire=Dual Fire ability.dualFireDelay=Fire Delay -# Laser Shot Settings -ability.laserWidth=Laser Width -ability.expansionSpeed=Expansion Spd -ability.lingerTicks=Linger Ticks - -# Energy Beam Settings -ability.headSize=Head Size -ability.attachedToOwner=Attached - # Ability Save/Load ability.save.confirm=Save ability preset ability.save.overwrite=Overwrite existing preset @@ -1729,23 +1828,17 @@ ability.manager.title=Ability Manager # Explosive Hover Text ability.explosive.noBlockDamage=Explosions do not destroy blocks -# Additional Orb Settings -ability.explRadius=Expl Radius - -# Telegraph Colors (for abilities that support separate colors) -ability.windUpColor=Wind Up Color -ability.activeColor=Active Color - -# Shockwave Settings -ability.pushRadius=Push Radius -ability.pushStrength=Push Str +# Shockwave Settings (dev) ability.shockwaveFalloff=Damage/knockback drop off with distance -# Ability Config GUI +# Ability Config GUI (dev) ability.typeId=Type ID -ability.conditions=Conditions ability.noTypeSettings=No type-specific settings +# ═══════════════════════════════════════════════════════════════ +# Ability Hover Tooltips +# ═══════════════════════════════════════════════════════════════ + ability.hover.weight=Higher weight = more likely to be chosen when multiple abilities available ability.hover.lockMove=Prevents NPC from moving while ability is charging or active ability.hover.interruptible=If enabled, ability can be interrupted by taking damage @@ -1768,6 +1861,7 @@ ability.hover.piercing=Hits multiple targets instead of stopping on first hit ability.hover.lightning=Add electrical effect to visuals ability.hover.outerGlow=Enable outer glow layer around projectile ability.hover.anchorPoint=Where on the NPC the ability spawns from +ability.hover.dualCharge=Whether or not should create two anchor points ability.hover.damage=Base damage dealt to targets ability.hover.speed=Movement speed of projectile ability.hover.lifetime=Maximum ticks before despawning diff --git a/tools/bukkit-api/Vault-1.4.1.jar b/tools/bukkit-api/Vault-1.4.1.jar new file mode 100644 index 000000000..d4d4ecc76 Binary files /dev/null and b/tools/bukkit-api/Vault-1.4.1.jar differ diff --git a/tools/bukkit-api/spigot-api-ONLY.jar b/tools/bukkit-api/spigot-api-ONLY.jar new file mode 100644 index 000000000..a8028aeab Binary files /dev/null and b/tools/bukkit-api/spigot-api-ONLY.jar differ