From d45bfde1626b7a4af52a99b29fc4435fbef51c60 Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 24 Feb 2026 15:27:30 -0500 Subject: [PATCH] Potion Effect Amplifier --- .../data/effect/AbilityPotionEffect.java | 6 ++-- .../data/ability/gui/AbilityFieldBuilder.java | 32 +++++++++++++++---- .../client/gui/SubGuiNpcMeleeProperties.java | 16 ++++++++-- .../npcs/client/gui/SubGuiNpcProjectiles.java | 16 ++++++++-- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/data/effect/AbilityPotionEffect.java b/src/main/java/kamkeel/npcs/controllers/data/ability/data/effect/AbilityPotionEffect.java index 7fe6422f0..52a05a8af 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/data/effect/AbilityPotionEffect.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/data/effect/AbilityPotionEffect.java @@ -14,7 +14,7 @@ public class AbilityPotionEffect { private EnumPotionType type = EnumPotionType.None; private int manualPotionId = 0; private int durationTicks = 60; - private int amplifier = 0; // 0-10 + private int amplifier = 0; // 0-255 (Manual), 0-10 (preset) public AbilityPotionEffect() { } @@ -22,7 +22,7 @@ public class AbilityPotionEffect { public AbilityPotionEffect(EnumPotionType type, int durationTicks, int amplifier) { this.type = type; this.durationTicks = Math.max(1, durationTicks); - this.amplifier = Math.max(0, Math.min(10, amplifier)); + this.amplifier = Math.max(0, Math.min(255, amplifier)); } /** @@ -120,7 +120,7 @@ public class AbilityPotionEffect { } public void setAmplifier(int amplifier) { - this.amplifier = Math.max(0, Math.min(10, amplifier)); + this.amplifier = Math.max(0, Math.min(255, amplifier)); } /** 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 index 0a05bc3d6..6438f6ba1 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/gui/AbilityFieldBuilder.java @@ -112,11 +112,22 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { widgetId++; if (effect.getType() != EnumPotionType.Fire) { - 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++; + if (effect.getType() == EnumPotionType.Manual) { + GuiNpcTextField ampField = new GuiNpcTextField(widgetId, parent, fontRenderer, + colLLabel + 158, y, 40, 20, String.valueOf(effect.getAmplifier())); + ampField.setIntegersOnly(); + ampField.setMinMaxDefault(0, 255, 0); + sw.addTextField(ampField); + textFieldMap.put(widgetId, def); + effectWidgetMeta.put(widgetId, new int[]{e, 2}); + widgetId++; + } else { + 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++; + } } else { widgetId++; } @@ -367,8 +378,14 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { if (effects == null) return false; switch (action) { case 0: - if (idx < effects.size()) - effects.get(idx).setType(EnumPotionType.fromIndexNoNone(((GuiNpcButton) button).getValue())); + if (idx < effects.size()) { + EnumPotionType oldType = effects.get(idx).getType(); + EnumPotionType newType = EnumPotionType.fromIndexNoNone(((GuiNpcButton) button).getValue()); + if (oldType == EnumPotionType.Manual && newType != EnumPotionType.Manual) { + effects.get(idx).setAmplifier(0); + } + effects.get(idx).setType(newType); + } return true; case 2: if (idx < effects.size()) @@ -471,6 +488,7 @@ public class AbilityFieldBuilder extends GuiFieldBuilder { List effects = (List) def.getValue(); if (effects != null && idx < effects.size()) { if (action == 1) effects.get(idx).setDurationTicks(field.getInteger()); + else if (action == 2) effects.get(idx).setAmplifier(field.getInteger()); else if (action == 5) effects.get(idx).setManualPotionId(field.getInteger()); } return true; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java index 36cbfff37..c40c009fe 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java @@ -58,7 +58,13 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi if (stats.potionType != EnumPotionType.Fire) { y += 30; addLabel(new GuiNpcLabel(7, "stats.amplify", guiLeft + 5, y + 5)); - addButton(new GuiButtonBiDirectional(7, guiLeft + 85, y, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.potionAmp)); + if (stats.potionType == EnumPotionType.Manual) { + addTextField(new GuiNpcTextField(7, this, fontRendererObj, guiLeft + 85, y, 52, 18, stats.potionAmp + "")); + getTextField(7).integersOnly = true; + getTextField(7).setMinMaxDefault(0, 255, 0); + } else { + addButton(new GuiButtonBiDirectional(7, guiLeft + 85, y, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.potionAmp)); + } } } @@ -76,6 +82,8 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi stats.knockback = textfield.getInteger(); } else if (textfield.id == 6) { stats.potionDuration = textfield.getInteger(); + } else if (textfield.id == 7) { + stats.potionAmp = textfield.getInteger(); } else if (textfield.id == 8) { stats.potionManualId = textfield.getInteger(); } @@ -84,7 +92,11 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; if (button.id == 5) { - stats.potionType = EnumPotionType.fromOrdinal(button.getValue()); + EnumPotionType newType = EnumPotionType.fromOrdinal(button.getValue()); + if (stats.potionType == EnumPotionType.Manual && newType != EnumPotionType.Manual) { + stats.potionAmp = 0; + } + stats.potionType = newType; initGui(); } if (button.id == 7) { diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java index e0806a538..eee99a12e 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java @@ -97,7 +97,13 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL } else { internalY += 30; addLabel(new GuiNpcLabel(70, "stats.amplify", guiLeft + 210, internalY + 5)); - addButton(new GuiButtonBiDirectional(10, guiLeft + 280, internalY, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.pEffAmp)); + if (stats.pEffect == EnumPotionType.Manual) { + addTextField(new GuiNpcTextField(10, this, fontRendererObj, guiLeft + 280, internalY, 52, 20, stats.pEffAmp + "")); + getTextField(10).integersOnly = true; + getTextField(10).setMinMaxDefault(0, 255, 0); + } else { + addButton(new GuiButtonBiDirectional(10, guiLeft + 280, internalY, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.pEffAmp)); + } } } @@ -132,6 +138,8 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL stats.pSpeed = textfield.getInteger(); } else if (textfield.id == 5) { stats.pDur = textfield.getInteger(); + } else if (textfield.id == 10) { + stats.pEffAmp = textfield.getInteger(); } else if (textfield.id == 11) { stats.pManualId = textfield.getInteger(); } @@ -154,7 +162,11 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL stats.pArea = button.getValue(); } if (button.id == 4) { - stats.pEffect = EnumPotionType.fromOrdinal(button.getValue()); + EnumPotionType newType = EnumPotionType.fromOrdinal(button.getValue()); + if (stats.pEffect == EnumPotionType.Manual && newType != EnumPotionType.Manual) { + stats.pEffAmp = 0; + } + stats.pEffect = newType; initGui(); } if (button.id == 5) {