From aeb0093b4d9ded959e0327c2d70214d3c1f40712 Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 27 Jan 2026 18:04:46 -0500 Subject: [PATCH 1/9] Add Tooltips --- .../gui/advanced/SubGuiConditionEdit.java | 7 +- .../ability/SubGuiAbilityEffects.java | 9 +- .../npcs/client/gui/util/GuiNPCInterface.java | 5 + .../npcs/client/gui/util/GuiNpcButton.java | 27 ++- .../npcs/client/gui/util/GuiNpcTextField.java | 157 ++++++++++++++++++ .../assets/customnpcs/lang/en_US.lang | 16 ++ 6 files changed, 210 insertions(+), 11 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java index 3d2874dbc..f45858a99 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java @@ -88,7 +88,9 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi // Condition Type selector addLabel(new GuiNpcLabel(1, "gui.type", labelX, y + 5)); - addButton(new GuiNpcButton(1, fieldX, y, 115, 20, CONDITION_TYPES, selectedTypeIndex)); + GuiNpcButton typeBtn = new GuiNpcButton(1, fieldX, y, 115, 20, CONDITION_TYPES, selectedTypeIndex); + typeBtn.setHoverText("condition.hover.type"); + addButton(typeBtn); y += 26; // Type-specific fields @@ -99,6 +101,7 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi GuiNpcTextField hitsField = new GuiNpcTextField(2, this, fontRendererObj, fieldX, y, 40, 20, String.valueOf(requiredHits)); hitsField.setIntegersOnly(); hitsField.setMinMaxDefault(1, 100, 3); + hitsField.setHoverText("condition.hover.hits"); addTextField(hitsField); y += 24; @@ -106,6 +109,7 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi GuiNpcTextField ticksField = new GuiNpcTextField(3, this, fontRendererObj, fieldX, y, 40, 20, String.valueOf(withinTicks)); ticksField.setIntegersOnly(); ticksField.setMinMaxDefault(1, 1200, 60); + ticksField.setHoverText("condition.hover.within"); addTextField(ticksField); } else { // HP threshold field (as percentage) @@ -114,6 +118,7 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi GuiNpcTextField thresholdField = new GuiNpcTextField(4, this, fontRendererObj, fieldX, y, 40, 20, String.valueOf(percent)); thresholdField.setIntegersOnly(); thresholdField.setMinMaxDefault(1, 99, 50); + thresholdField.setHoverText("condition.hover.threshold"); addTextField(thresholdField); addLabel(new GuiNpcLabel(4, "%", fieldX + 45, y + 5)); } 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 index 103d87224..b4eced168 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEffects.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEffects.java @@ -74,13 +74,16 @@ public class SubGuiAbilityEffects extends SubGuiInterface implements ITextfieldL // Type selector button int typeIndex = effect.getType().ordinal(); - addButton(new GuiNpcButton(baseId, guiLeft + 8, y, 100, 20, EFFECT_TYPE_NAMES, typeIndex)); + 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, String.valueOf(effect.getDurationTicks())); durField.setIntegersOnly(); durField.setMinMaxDefault(1, 12000, 60); + durField.setHoverText("effect.hover.duration"); addTextField(durField); // Amplifier selector (0-10) @@ -88,7 +91,9 @@ public class SubGuiAbilityEffects extends SubGuiInterface implements ITextfieldL for (int a = 0; a <= 10; a++) { ampValues[a] = String.valueOf(a); } - addButton(new GuiNpcButton(baseId + 2, guiLeft + 168, y, 40, 20, ampValues, effect.getAmplifier())); + 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")); diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java index 11bbaf451..4ddd820c0 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java @@ -409,6 +409,11 @@ public abstract class GuiNPCInterface extends GuiScreen { button.drawHover(i, j, subGui); } } + for (GuiNpcTextField textField : textfields.values()) { + if (textField.hasHoverText()) { + textField.drawHover(i, j, subGui); + } + } for (GuiScreen gui : extra.values()) gui.drawScreen(i, j, f); 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 c14d0da83..d09bddecf 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java @@ -3,6 +3,7 @@ package noppes.npcs.client.gui.util; import kamkeel.npcs.util.TextSplitter; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; @@ -217,17 +218,27 @@ public class GuiNpcButton extends GuiButton { maxHeight += 2 + (textLines.size() - 1) * 10; } - int gameWidth = mc.displayWidth; - int maxTooltipX = gameWidth - maxWidth - 4; + // Get scaled screen dimensions + ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + int screenWidth = scaledRes.getScaledWidth(); + int screenHeight = scaledRes.getScaledHeight(); - if (j2 > maxTooltipX) { - int diff = j2 - maxTooltipX; - j2 -= diff; - GL11.glTranslatef(-300, 0, 0); + // If tooltip would go off right edge, draw on left side of mouse + if (j2 + maxWidth + 6 > screenWidth) { + j2 = x - maxWidth - 16; } - if (k2 + maxHeight + 6 > mc.displayHeight) { - k2 = mc.displayHeight - maxHeight - 6; + // Keep tooltip on screen horizontally + if (j2 < 4) { + j2 = 4; + } + + // Keep tooltip on screen vertically + if (k2 + maxHeight + 6 > screenHeight) { + k2 = screenHeight - maxHeight - 6; + } + if (k2 < 4) { + k2 = 4; } this.zLevel = 300.0F; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java index 91f3ca142..436b47bb5 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java @@ -4,6 +4,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; +import net.minecraft.util.StatCollector; +import net.minecraft.client.gui.ScaledResolution; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import net.minecraft.client.renderer.RenderHelper; +import kamkeel.npcs.util.TextSplitter; +import java.util.List; +import java.util.Iterator; public class GuiNpcTextField extends GuiTextField { public boolean enabled = true; @@ -18,6 +26,9 @@ public class GuiNpcTextField extends GuiTextField { public float minFloat = 0, maxFloat = Float.MAX_VALUE, defFloat = 0; protected static GuiNpcTextField activeTextfield = null; public boolean canEdit = true; + public String hoverableText = ""; + private boolean wasHovered = false; + private int hoverCount = 0; private final int[] allowedSpecialChars = {14, 211, 203, 205}; @@ -203,5 +214,151 @@ public class GuiNpcTextField extends GuiTextField { return this; } + public void setHoverText(String text) { + this.hoverableText = StatCollector.translateToLocal(text); + } + public boolean hasHoverText() { + return hoverableText != null && !hoverableText.isEmpty(); + } + + public boolean isMouseOver(int mouseX, int mouseY) { + return mouseX >= xPosition && mouseX < xPosition + width && + mouseY >= yPosition && mouseY < yPosition + height; + } + + public void drawHover(int mouseX, int mouseY, boolean hasSubGui) { + if (hasSubGui || !enabled || hoverableText.isEmpty()) + return; + + boolean isHovered = isMouseOver(mouseX, mouseY); + if (!isHovered) { + wasHovered = false; + hoverCount = 0; + return; + } + + if (!wasHovered) { + wasHovered = true; + hoverCount = 0; + } else if (hoverCount < 65) { + hoverCount++; + } + + if (hoverCount > 60) { + GL11.glPushMatrix(); + Minecraft mc = Minecraft.getMinecraft(); + GL11.glColor4f(1, 1, 1, 1); + List lines = TextSplitter.splitText(hoverableText, 30); + drawHoveringText(lines, mouseX, mouseY, mc); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + + 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; + for (String s : textLines) { + 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; + } + + // Get scaled screen dimensions + ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + int screenWidth = scaledRes.getScaledWidth(); + int screenHeight = scaledRes.getScaledHeight(); + + // If tooltip would go off right edge, draw on left side of mouse + if (j2 + maxWidth + 6 > screenWidth) { + j2 = x - maxWidth - 16; + } + + // Keep tooltip on screen horizontally + if (j2 < 4) { + j2 = 4; + } + + // Keep tooltip on screen vertically + if (k2 + maxHeight + 6 > screenHeight) { + k2 = screenHeight - maxHeight - 6; + } + if (k2 < 4) { + k2 = 4; + } + + int zLevel = 300; + int bgColor = 0xF0100010; + int borderColor1 = 0x505000FF; + int borderColor2 = (borderColor1 & 0xFEFEFE) >> 1 | borderColor1 & 0xFF000000; + + drawGradientRect(j2 - 3, k2 - 4, j2 + maxWidth + 3, k2 - 3, bgColor, bgColor, zLevel); + drawGradientRect(j2 - 3, k2 + maxHeight + 3, j2 + maxWidth + 3, k2 + maxHeight + 4, bgColor, bgColor, zLevel); + drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 + maxHeight + 3, bgColor, bgColor, zLevel); + drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + maxHeight + 3, bgColor, bgColor, zLevel); + drawGradientRect(j2 + maxWidth + 3, k2 - 3, j2 + maxWidth + 4, k2 + maxHeight + 3, bgColor, bgColor, zLevel); + drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + maxHeight + 3 - 1, borderColor1, borderColor2, zLevel); + drawGradientRect(j2 + maxWidth + 2, k2 - 3 + 1, j2 + maxWidth + 3, k2 + maxHeight + 3 - 1, borderColor1, borderColor2, zLevel); + drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 - 3 + 1, borderColor1, borderColor1, zLevel); + drawGradientRect(j2 - 3, k2 + maxHeight + 2, j2 + maxWidth + 3, k2 + maxHeight + 3, borderColor2, borderColor2, zLevel); + + for (int l = 0; l < textLines.size(); ++l) { + String s1 = textLines.get(l); + mc.fontRenderer.drawStringWithShadow(s1, j2, k2, -1); + if (l == 0) { + k2 += 2; + } + k2 += 10; + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderHelper.enableStandardItemLighting(); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + } + + protected void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, int zLevel) { + float f = (float)(startColor >> 24 & 255) / 255.0F; + float f1 = (float)(startColor >> 16 & 255) / 255.0F; + float f2 = (float)(startColor >> 8 & 255) / 255.0F; + float f3 = (float)(startColor & 255) / 255.0F; + float f4 = (float)(endColor >> 24 & 255) / 255.0F; + float f5 = (float)(endColor >> 16 & 255) / 255.0F; + float f6 = (float)(endColor >> 8 & 255) / 255.0F; + float f7 = (float)(endColor & 255) / 255.0F; + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + net.minecraft.client.renderer.Tessellator tessellator = net.minecraft.client.renderer.Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F(f1, f2, f3, f); + tessellator.addVertex((double)right, (double)top, (double)zLevel); + tessellator.addVertex((double)left, (double)top, (double)zLevel); + tessellator.setColorRGBA_F(f5, f6, f7, f4); + tessellator.addVertex((double)left, (double)bottom, (double)zLevel); + tessellator.addVertex((double)right, (double)bottom, (double)zLevel); + tessellator.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } } diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 750a75f54..d4f75d883 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1783,6 +1783,22 @@ condition.percent=Threshold condition.hits=Required Hits condition.within=Within (ticks) +# Condition Hover Tooltips +condition.hover.type=Condition type that must be met for ability to activate +condition.hover.hpAbove=Activates when NPC health is above this percentage +condition.hover.hpBelow=Activates when NPC health is below this percentage +condition.hover.targetHpAbove=Activates when target's health is above this percentage +condition.hover.targetHpBelow=Activates when target's health is below this percentage +condition.hover.hitCount=Activates after receiving X hits within the time window +condition.hover.hits=Number of hits required to trigger condition +condition.hover.within=Time window in ticks (20 ticks = 1 second) +condition.hover.threshold=Health percentage threshold (1-99%) + +# Effect Hover Tooltips +effect.hover.type=Potion effect type to apply to targets +effect.hover.duration=Effect duration in ticks (20 ticks = 1 second) +effect.hover.amplifier=Effect strength level (higher = stronger) + # ========================================= # Auction House # ========================================= From e599ed67f5a9186b47db3be7168af592b67499e3 Mon Sep 17 00:00:00 2001 From: Vidal Date: Tue, 27 Jan 2026 22:19:26 -0300 Subject: [PATCH 2/9] Added animations to these abilities --- .../data/ability/AbilityAnimation.java | 17 +- .../data/ability/type/AbilityEnergyBeam.java | 20 ++ .../data/ability/type/AbilityOrb.java | 12 + .../ABILITYBEAM/Ability_Beam_Active.json | 230 ++++++++++++++++++ .../ABILITYBEAM/Ability_Beam_Windup.json | 158 ++++++++++++ .../ABILITYORB/Ability_Orb_Windup.json | 192 +++++++++++++++ 6 files changed, 621 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Active.json create mode 100644 src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Windup.json create mode 100644 src/main/resources/internal/animations/ABILITYORB/Ability_Orb_Windup.json diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java index 3aea051f3..190be70d3 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java @@ -2,7 +2,6 @@ package kamkeel.npcs.controllers.data.ability; import noppes.npcs.CustomNpcs; import noppes.npcs.LogWriter; -import noppes.npcs.api.handler.data.IAnimation; import noppes.npcs.controllers.data.Animation; import noppes.npcs.util.NBTJsonUtil; import org.apache.commons.io.FileUtils; @@ -13,7 +12,9 @@ import java.util.HashMap; import static kamkeel.npcs.controllers.data.ability.AbilityPhase.*; -public enum AbilityAnimation {; +public enum AbilityAnimation { + ABILITYORB("Ability_Orb_Windup", WINDUP), + ABILITYBEAM("Ability_Beam_Windup", "Ability_Beam_Active"); private final HashMap animationNames = new HashMap<>(); AbilityAnimation(String idle, String windUp, String active, String recovery) { @@ -49,7 +50,7 @@ public enum AbilityAnimation {; return getFileFromName(animationNames.get(phase)); } - public IAnimation getAnimation(AbilityPhase phase) { + public Animation getAnimation(AbilityPhase phase) { try { File file = getFile(phase); @@ -68,24 +69,24 @@ public enum AbilityAnimation {; return null; } - public IAnimation idle() { + public Animation idle() { return getAnimation(IDLE); } - public IAnimation windUp() { + public Animation windUp() { return getAnimation(WINDUP); } - public IAnimation active() { + public Animation active() { return getAnimation(ACTIVE); } - public IAnimation dazed() { + public Animation dazed() { return getAnimation(DAZED); } private File getFileFromName(String fileName) { - try (InputStream stream = CustomNpcs.class.getResourceAsStream("/internal/data/animations/" + name() + "/" + fileName + ".json")) { + try (InputStream stream = CustomNpcs.class.getResourceAsStream("/internal/animations/" + name() + "/" + fileName + ".json")) { File file = new File("temp"); 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 3bcc5072c..2dea02f5a 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 @@ -3,6 +3,7 @@ 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.AbilityAnimation; import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.telegraph.Telegraph; @@ -17,6 +18,7 @@ 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.controllers.data.Animation; import noppes.npcs.entity.EntityNPCInterface; /** @@ -70,6 +72,8 @@ public class AbilityEnergyBeam extends Ability { // Anchor point for charging position private AnchorPoint anchorPoint = AnchorPoint.FRONT; + private final AbilityAnimation animation = AbilityAnimation.ABILITYBEAM; + // Transient state for beam entity (used during windup charging) private transient EntityAbilityBeam beamEntity = null; @@ -308,4 +312,20 @@ public class AbilityEnergyBeam extends Ability { public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; } public AnchorPoint getAnchorPoint() { return anchorPoint; } public void setAnchorPoint(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } + + @Override + public Animation getWindUpAnimation() { + if (windUpAnimationId == -1) + return animation.windUp(); + + return super.getWindUpAnimation(); + } + + @Override + public Animation getActiveAnimation() { + if (activeAnimationId == -1) + return animation.active(); + + return super.getActiveAnimation(); + } } 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 6bc6da964..4832c2281 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 @@ -3,6 +3,7 @@ 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.AbilityAnimation; import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.telegraph.Telegraph; @@ -17,6 +18,7 @@ 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.controllers.data.Animation; import noppes.npcs.entity.EntityNPCInterface; /** @@ -71,6 +73,8 @@ public class AbilityOrb extends Ability { // Transient state for orb entity (used during windup charging) private transient EntityAbilityOrb orbEntity = null; + private final AbilityAnimation animation = AbilityAnimation.ABILITYORB; + public AbilityOrb() { this.typeId = "ability.cnpc.orb"; this.name = "Orb"; @@ -459,4 +463,12 @@ public class AbilityOrb extends Ability { public void setAnchorPoint(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } + + @Override + public Animation getWindUpAnimation() { + if (windUpAnimationId != -1) + return super.getWindUpAnimation(); + + return animation.windUp(); + } } diff --git a/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Active.json b/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Active.json new file mode 100644 index 000000000..eb9516f38 --- /dev/null +++ b/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Active.json @@ -0,0 +1,230 @@ +{ + "Loop": -1, + "Speed": 1.0f, + "Frames": [ + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 1.0f, + "FrameParts": [ + { + "Pivot2": -5.0f, + "Part": "LEFT_ARM", + "Rotation1": 107.0f, + "Rotation0": -94.0f, + "Pivot0": -5.0f, + "Pivot1": 3.0f, + "Rotation2": -31.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_ARM", + "Rotation1": 88.0f, + "Rotation0": -56.0f, + "Pivot0": 1.0f, + "Pivot1": 0.0f, + "Rotation2": -18.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 12.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_LEG", + "Rotation1": 56.0f, + "Rotation0": 6.0f, + "Pivot0": -2.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 25.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -5.0f, + "Part": "LEFT_LEG", + "Rotation1": -25.0f, + "Rotation0": 12.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 25.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 5 + }, + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 2.0f, + "FrameParts": [ + { + "Pivot2": -5.0f, + "Part": "LEFT_ARM", + "Rotation1": 12.0f, + "Rotation0": -75.0f, + "Pivot0": -2.0f, + "Pivot1": 3.0f, + "Rotation2": 50.0f + }, + { + "Pivot2": -5.0f, + "Part": "RIGHT_ARM", + "Rotation1": -18.0f, + "Rotation0": -107.0f, + "Pivot0": -1.0f, + "Pivot1": 2.0f, + "Rotation2": 50.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -4.0f, + "Part": "RIGHT_LEG", + "Rotation1": 56.0f, + "Rotation0": 18.0f, + "Pivot0": -4.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -6.0f, + "Part": "LEFT_LEG", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 5 + }, + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 0.75f, + "FrameParts": [ + { + "Pivot2": -5.0f, + "Part": "LEFT_ARM", + "Rotation1": 12.0f, + "Rotation0": -75.0f, + "Pivot0": -2.0f, + "Pivot1": 3.0f, + "Rotation2": 50.0f + }, + { + "Pivot2": -5.0f, + "Part": "RIGHT_ARM", + "Rotation1": -18.0f, + "Rotation0": -107.0f, + "Pivot0": -1.0f, + "Pivot1": 2.0f, + "Rotation2": 50.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -4.0f, + "Part": "RIGHT_LEG", + "Rotation1": 56.0f, + "Rotation0": 18.0f, + "Pivot0": -4.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -6.0f, + "Part": "LEFT_LEG", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 20 + } + ], + "CurrentFrameTime": 0, + "CurrentFrame": 0, + "Smooth": 0b, + "ID": 2, + "WhileAttacking": 1b, + "WhileWalking": 1b, + "Name": "Ability_Beam_Active", + "WhileStanding": 1b +} diff --git a/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Windup.json b/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Windup.json new file mode 100644 index 000000000..6c53e1eab --- /dev/null +++ b/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Windup.json @@ -0,0 +1,158 @@ +{ + "Loop": -1, + "Speed": 1.0f, + "Frames": [ + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 0.5f, + "FrameParts": [ + { + "Pivot2": -5.0f, + "Part": "LEFT_ARM", + "Rotation1": 94.0f, + "Rotation0": -94.0f, + "Pivot0": -4.0f, + "Pivot1": 3.0f, + "Rotation2": -31.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_ARM", + "Rotation1": 75.0f, + "Rotation0": -56.0f, + "Pivot0": 1.0f, + "Pivot1": 0.0f, + "Rotation2": -18.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 0.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_LEG", + "Rotation1": 50.0f, + "Rotation0": 6.0f, + "Pivot0": -2.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 18.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -5.0f, + "Part": "LEFT_LEG", + "Rotation1": -25.0f, + "Rotation0": 12.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 25.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 5 + }, + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 0.5f, + "FrameParts": [ + { + "Pivot2": -5.0f, + "Part": "LEFT_ARM", + "Rotation1": 107.0f, + "Rotation0": -94.0f, + "Pivot0": -5.0f, + "Pivot1": 3.0f, + "Rotation2": -31.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_ARM", + "Rotation1": 88.0f, + "Rotation0": -56.0f, + "Pivot0": 1.0f, + "Pivot1": 0.0f, + "Rotation2": -18.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 12.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_LEG", + "Rotation1": 56.0f, + "Rotation0": 6.0f, + "Pivot0": -2.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 25.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -5.0f, + "Part": "LEFT_LEG", + "Rotation1": -25.0f, + "Rotation0": 12.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 25.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 35 + } + ], + "CurrentFrameTime": 0, + "CurrentFrame": 0, + "Smooth": 0b, + "ID": 1, + "WhileAttacking": 1b, + "WhileWalking": 1b, + "Name": "Ability_Beam_Windup", + "WhileStanding": 1b +} diff --git a/src/main/resources/internal/animations/ABILITYORB/Ability_Orb_Windup.json b/src/main/resources/internal/animations/ABILITYORB/Ability_Orb_Windup.json new file mode 100644 index 000000000..77f21f941 --- /dev/null +++ b/src/main/resources/internal/animations/ABILITYORB/Ability_Orb_Windup.json @@ -0,0 +1,192 @@ +{ + "Loop": -1, + "Speed": 1.0f, + "Frames": [ + { + "ColorMarker": 16777215, + "Comment": "", + "FrameParts": [ + { + "Pivot2": 0.0f, + "Part": "BODY", + "Rotation1": 31.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 3.0f, + "Part": "RIGHT_LEG", + "Rotation1": 69.0f, + "Rotation0": 12.0f, + "Pivot0": -2.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 5.0f, + "Part": "RIGHT_ARM", + "Rotation1": 37.0f, + "Rotation0": -101.0f, + "Pivot0": 2.0f, + "Pivot1": 1.0f, + "Rotation2": -25.0f + }, + { + "Pivot2": 0.0f, + "Part": "LEFT_ARM", + "Rotation1": 0.0f, + "Rotation0": -88.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": -90.0f + }, + { + "Pivot2": -3.0f, + "Part": "LEFT_LEG", + "Rotation1": -18.0f, + "Rotation0": 12.0f, + "Pivot0": 1.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Duration": 20 + }, + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 1.0f, + "FrameParts": [ + { + "Pivot2": 0.0f, + "Part": "BODY", + "Rotation1": -44.0f, + "Rotation0": 12.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "RIGHT_LEG", + "Rotation1": -18.0f, + "Rotation0": 12.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 0.0f, + "Part": "HEAD", + "Rotation1": -37.0f, + "Rotation0": 25.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -6.0f, + "Part": "RIGHT_ARM", + "Rotation1": 0.0f, + "Rotation0": -90.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 4.0f, + "Part": "LEFT_ARM", + "Rotation1": -50.0f, + "Rotation0": 50.0f, + "Pivot0": -3.0f, + "Pivot1": 0.0f, + "Rotation2": -56.0f + }, + { + "Pivot2": 4.0f, + "Part": "LEFT_LEG", + "Rotation1": -75.0f, + "Rotation0": 12.0f, + "Pivot0": -1.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 5 + }, + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 0.5f, + "FrameParts": [ + { + "Pivot2": 0.0f, + "Part": "BODY", + "Rotation1": -44.0f, + "Rotation0": 12.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "RIGHT_LEG", + "Rotation1": -18.0f, + "Rotation0": 12.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 0.0f, + "Part": "HEAD", + "Rotation1": -37.0f, + "Rotation0": 25.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -6.0f, + "Part": "RIGHT_ARM", + "Rotation1": 0.0f, + "Rotation0": -90.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 4.0f, + "Part": "LEFT_ARM", + "Rotation1": -50.0f, + "Rotation0": 50.0f, + "Pivot0": -3.0f, + "Pivot1": 0.0f, + "Rotation2": -56.0f + }, + { + "Pivot2": 4.0f, + "Part": "LEFT_LEG", + "Rotation1": -75.0f, + "Rotation0": 12.0f, + "Pivot0": -1.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + } + ], + "Smooth": 0b, + "Duration": 5 + } + ], + "CurrentFrameTime": 0, + "CurrentFrame": 0, + "Smooth": 0b, + "ID": 3, + "WhileAttacking": 1b, + "WhileWalking": 1b, + "Name": "Ability_Orb_Windup", + "WhileStanding": 1b +} From 83ccd25b33949c4a597651cc401dfa8734188e8c Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 28 Jan 2026 14:44:19 -0500 Subject: [PATCH 3/9] Merge Conflicts + Scripting for Abilities --- src/api | 2 +- .../data/ability/type/AbilityCharge.java | 4 +- .../data/ability/type/AbilityCutter.java | 19 +- .../data/ability/type/AbilityDash.java | 19 +- .../data/ability/type/AbilityDisc.java | 13 +- .../data/ability/type/AbilityEnergyBeam.java | 18 +- .../data/ability/type/AbilityGuard.java | 24 ++- .../data/ability/type/AbilityHazard.java | 34 +++- .../data/ability/type/AbilityHeal.java | 4 +- .../data/ability/type/AbilityHeavyHit.java | 3 +- .../data/ability/type/AbilityLaserShot.java | 3 +- .../data/ability/type/AbilityOrb.java | 16 +- .../data/ability/type/AbilityProjectile.java | 4 +- .../data/ability/type/AbilityShockwave.java | 4 +- .../data/ability/type/AbilitySlam.java | 4 +- .../data/ability/type/AbilitySweeper.java | 3 +- .../data/ability/type/AbilityTeleport.java | 19 +- .../data/ability/type/AbilityTrap.java | 19 +- .../data/ability/type/AbilityVortex.java | 4 +- src/main/java/noppes/npcs/DataAbilities.java | 44 +++++ .../advanced/ability/SubGuiAbilityCutter.java | 6 +- .../advanced/ability/SubGuiAbilityDash.java | 4 +- .../advanced/ability/SubGuiAbilityDisc.java | 4 +- .../ability/SubGuiAbilityEnergyBeam.java | 4 +- .../advanced/ability/SubGuiAbilityGuard.java | 4 +- .../advanced/ability/SubGuiAbilityHazard.java | 8 +- .../advanced/ability/SubGuiAbilityOrb.java | 4 +- .../ability/SubGuiAbilityTeleport.java | 6 +- .../advanced/ability/SubGuiAbilityTrap.java | 4 +- .../npcs/scripted/entity/ScriptNpc.java | 4 + .../scripted/wrapper/ScriptDataAbilities.java | 163 ++++++++++++++++++ 31 files changed, 408 insertions(+), 63 deletions(-) create mode 100644 src/main/java/noppes/npcs/scripted/wrapper/ScriptDataAbilities.java diff --git a/src/api b/src/api index 2054012fa..3050910ef 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 2054012fae799fa233b99824b4f649d311eff86f +Subproject commit 3050910efbc6e301e4ef18fefc20529c507a7bae 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 7a1d9babf..d87ed05ee 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 @@ -18,6 +18,8 @@ import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCharge; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.api.ability.type.IAbilityCharge; + import java.util.HashSet; import java.util.List; import java.util.Set; @@ -25,7 +27,7 @@ import java.util.Set; /** * Charge ability: Rush attack where NPC charges in a line, damaging all targets hit. */ -public class AbilityCharge extends Ability { +public class AbilityCharge extends Ability implements IAbilityCharge { // Type-specific parameters private float chargeSpeed = 0.8f; 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 b3052eeac..1d77e9219 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 @@ -15,6 +15,8 @@ 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 java.util.HashSet; import java.util.List; import java.util.Set; @@ -24,7 +26,7 @@ import java.util.Set; * Deals damage to all entities in a cone/arc in front of the caster. * Can sweep outward over time or hit instantly. */ -public class AbilityCutter extends Ability { +public class AbilityCutter extends Ability implements IAbilityCutter { public enum SweepMode { SWIPE, @@ -254,14 +256,25 @@ public class AbilityCutter extends Ability { this.knockback = knockback; } - public SweepMode getSweepMode() { + public SweepMode getSweepModeEnum() { return sweepMode; } - public void setSweepMode(SweepMode sweepMode) { + public void setSweepModeEnum(SweepMode sweepMode) { this.sweepMode = sweepMode; } + @Override + public int getSweepMode() { + return sweepMode.ordinal(); + } + + @Override + public void setSweepMode(int mode) { + SweepMode[] values = SweepMode.values(); + this.sweepMode = mode >= 0 && mode < values.length ? values[mode] : SweepMode.SWIPE; + } + public float getSweepSpeed() { return sweepSpeed; } 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 cd4d42ac7..677578745 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 @@ -14,13 +14,15 @@ import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDash; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.api.ability.type.IAbilityDash; + import java.util.Random; /** * Dash ability: Quick evasive sidestep with NO telegraph. * Defensive repositioning move to evade attacks. */ -public class AbilityDash extends Ability { +public class AbilityDash extends Ability implements IAbilityDash { /** * Dash behavior mode. @@ -245,14 +247,25 @@ public class AbilityDash extends Ability { } // Getters & Setters - public DashMode getDashMode() { + public DashMode getDashModeEnum() { return dashMode; } - public void setDashMode(DashMode dashMode) { + public void setDashModeEnum(DashMode dashMode) { this.dashMode = dashMode; } + @Override + public int getDashMode() { + return dashMode.ordinal(); + } + + @Override + public void setDashMode(int mode) { + DashMode[] values = DashMode.values(); + this.dashMode = mode >= 0 && mode < values.length ? values[mode] : DashMode.AGGRESSIVE; + } + public float getDashDistance() { return dashDistance; } 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 67fa23cdf..2c7b8e43c 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,13 +17,14 @@ 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.api.ability.type.IAbilityDisc; import noppes.npcs.entity.EntityNPCInterface; /** * Disc ability: Spawns a flat spinning disc projectile. * Has optional boomerang behavior to return to owner. */ -public class AbilityDisc extends Ability { +public class AbilityDisc extends Ability implements IAbilityDisc { // Movement properties private float speed = 0.6f; @@ -312,6 +313,12 @@ public class AbilityDisc extends Ability { public void setLightningDensity(float lightningDensity) { this.lightningDensity = lightningDensity; } public float getLightningRadius() { return lightningRadius; } public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; } - public AnchorPoint getAnchorPoint() { return anchorPoint; } - public void setAnchorPoint(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } + public AnchorPoint getAnchorPointEnum() { return anchorPoint; } + public void setAnchorPointEnum(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } + + @Override + public int getAnchorPoint() { return anchorPoint.getId(); } + + @Override + public void setAnchorPoint(int point) { this.anchorPoint = AnchorPoint.fromId(point); } } 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 2dea02f5a..790489b2c 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 @@ -12,12 +12,12 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import kamkeel.npcs.entity.EntityAbilityBeam; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; +import net.minecraft.nbt.NBTTagCompound;; 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.api.ability.type.IAbilityEnergyBeam; import noppes.npcs.controllers.data.Animation; import noppes.npcs.entity.EntityNPCInterface; @@ -26,7 +26,7 @@ import noppes.npcs.entity.EntityNPCInterface; * The beam stays attached to the origin and curves as it homes in on target. * Cannot cross over itself (self-intersection prevention). */ -public class AbilityEnergyBeam extends Ability { +public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { // Movement properties private float speed = 0.4f; @@ -310,9 +310,8 @@ public class AbilityEnergyBeam extends Ability { public void setLightningDensity(float lightningDensity) { this.lightningDensity = lightningDensity; } public float getLightningRadius() { return lightningRadius; } public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; } - public AnchorPoint getAnchorPoint() { return anchorPoint; } - public void setAnchorPoint(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } + @Override public Animation getWindUpAnimation() { if (windUpAnimationId == -1) @@ -328,4 +327,13 @@ public class AbilityEnergyBeam extends Ability { return super.getActiveAnimation(); } + + public AnchorPoint getAnchorPointEnum() { return anchorPoint; } + public void setAnchorPointEnum(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } + + @Override + public int getAnchorPoint() { return anchorPoint.getId(); } + + @Override + public void setAnchorPoint(int point) { this.anchorPoint = AnchorPoint.fromId(point); } } 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 fd9f25a24..84701b79e 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 @@ -14,13 +14,15 @@ 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 java.util.Random; /** * Guard ability: Defensive stance that reduces incoming damage. * Can optionally counter-attack when hit. */ -public class AbilityGuard extends Ability { +public class AbilityGuard extends Ability implements IAbilityGuard { private static final Random RANDOM = new Random(); @@ -228,18 +230,34 @@ public class AbilityGuard extends Ability { return canCounter; } + @Override + public boolean canCounter() { + return canCounter; + } + public void setCanCounter(boolean canCounter) { this.canCounter = canCounter; } - public CounterType getCounterType() { + public CounterType getCounterTypeEnum() { return counterType; } - public void setCounterType(CounterType counterType) { + public void setCounterTypeEnum(CounterType counterType) { this.counterType = counterType; } + @Override + public int getCounterType() { + return counterType.ordinal(); + } + + @Override + public void setCounterType(int type) { + CounterType[] values = CounterType.values(); + this.counterType = type >= 0 && type < values.length ? values[type] : CounterType.FLAT; + } + public float getCounterValue() { return counterValue; } 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 3e9998f6f..79e43e2cc 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 @@ -18,6 +18,8 @@ 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 java.util.HashSet; import java.util.List; import java.util.Random; @@ -27,7 +29,7 @@ import java.util.Set; * Hazard ability: Creates persistent ground effect zones. * Deals damage and/or applies debuffs to entities in the zone over time. */ -public class AbilityHazard extends Ability { +public class AbilityHazard extends Ability implements IAbilityHazard { public enum HazardShape { CIRCLE, @@ -443,22 +445,44 @@ public class AbilityHazard extends Ability { this.coneAngle = coneAngle; } - public HazardShape getShape() { + public HazardShape getShapeEnum() { return shape; } - public void setShape(HazardShape shape) { + public void setShapeEnum(HazardShape shape) { this.shape = shape; } - public PlacementMode getPlacement() { + @Override + public int getShape() { + return shape.ordinal(); + } + + @Override + public void setShape(int shape) { + HazardShape[] values = HazardShape.values(); + this.shape = shape >= 0 && shape < values.length ? values[shape] : HazardShape.CIRCLE; + } + + public PlacementMode getPlacementEnum() { return placement; } - public void setPlacement(PlacementMode placement) { + public void setPlacementEnum(PlacementMode placement) { this.placement = placement; } + @Override + public int getPlacement() { + return placement.ordinal(); + } + + @Override + public void setPlacement(int placement) { + PlacementMode[] values = PlacementMode.values(); + this.placement = placement >= 0 && placement < values.length ? values[placement] : PlacementMode.AT_CASTER; + } + public float getDamagePerSecond() { return damagePerSecond; } 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 f19a7cb02..11aed6c47 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 @@ -15,6 +15,8 @@ import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeal; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.api.ability.type.IAbilityHeal; + import java.util.ArrayList; import java.util.List; @@ -22,7 +24,7 @@ import java.util.List; * Heal ability: Restore health to self or allies. * Can heal a fixed amount or percentage of max health. */ -public class AbilityHeal extends Ability { +public class AbilityHeal extends Ability implements IAbilityHeal { // Type-specific parameters private int durationTicks = 60; 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 32335daeb..82091c041 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 @@ -11,13 +11,14 @@ 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.api.ability.type.IAbilityHeavyHit; import noppes.npcs.entity.EntityNPCInterface; /** * Heavy Hit ability: Single-target melee attack with optional stun. * Deals high damage to one target and can stun them. */ -public class AbilityHeavyHit extends Ability { +public class AbilityHeavyHit extends Ability implements IAbilityHeavyHit { private float damage = 8.0f; private float knockback = 2.0f; 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 8084aaad4..44b6bc0b5 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 @@ -13,13 +13,14 @@ 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 noppes.npcs.entity.EntityNPCInterface; /** * Laser Shot ability: Fast expanding thin line that pierces through targets. * Travels in a straight line from origin, damaging all entities it passes through. */ -public class AbilityLaserShot extends Ability { +public class AbilityLaserShot extends Ability implements IAbilityLaserShot { // Laser properties private float laserWidth = 0.3f; 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 4832c2281..fabdf6ab0 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 @@ -19,6 +19,7 @@ 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.controllers.data.Animation; +import noppes.npcs.api.ability.type.IAbilityOrb; import noppes.npcs.entity.EntityNPCInterface; /** @@ -26,7 +27,7 @@ import noppes.npcs.entity.EntityNPCInterface; * The EntityAbilityOrb handles all movement, collision, and damage logic. * This ability just configures and spawns the orb entity. */ -public class AbilityOrb extends Ability { +public class AbilityOrb extends Ability implements IAbilityOrb { // Movement properties private float orbSpeed = 0.5f; @@ -456,11 +457,11 @@ public class AbilityOrb extends Ability { this.lightningFadeTime = lightningFadeTime; } - public AnchorPoint getAnchorPoint() { + public AnchorPoint getAnchorPointEnum() { return anchorPoint; } - public void setAnchorPoint(AnchorPoint anchorPoint) { + public void setAnchorPointEnum(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } @@ -471,4 +472,13 @@ public class AbilityOrb extends Ability { return animation.windUp(); } + + public int getAnchorPoint() { + return anchorPoint.getId(); + } + + @Override + public void setAnchorPoint(int point) { + this.anchorPoint = AnchorPoint.fromId(point); + } } 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 4a12ae4eb..56b12028e 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 @@ -14,13 +14,15 @@ 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 java.util.List; /** * Projectile ability: Ranged attack that deals damage to target. * Currently instant damage - can be enhanced with custom projectile entities. */ -public class AbilityProjectile extends Ability { +public class AbilityProjectile extends Ability implements IAbilityProjectile { // Type-specific parameters private float damage = 6.0f; 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 71d888978..c6b93134a 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 @@ -15,13 +15,15 @@ import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityShockwave; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.api.ability.type.IAbilityShockwave; + import java.util.List; /** * Shockwave ability: Pushes targets away from the caster with damage. * Opposite of Vortex - instant knockback rather than gradual pull. */ -public class AbilityShockwave extends Ability { +public class AbilityShockwave extends Ability implements IAbilityShockwave { private float pushRadius = 8.0f; private float pushStrength = 1.5f; 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 dcb914a96..ba49ffb2c 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 @@ -17,6 +17,8 @@ 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 java.util.List; /** @@ -28,7 +30,7 @@ import java.util.List; * - Landing: When NPC hits ground, deal AOE damage * - RECOVERY: Landing recovery animation */ -public class AbilitySlam extends Ability { +public class AbilitySlam extends Ability implements IAbilitySlam { // Type-specific config private float damage = 10.0f; 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 5a61c5dce..66f589a00 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 @@ -15,6 +15,7 @@ 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 noppes.npcs.entity.EntityNPCInterface; /** @@ -25,7 +26,7 @@ import noppes.npcs.entity.EntityNPCInterface; * All damage logic is handled by the EntityAbilitySweeper entity to ensure * visual and damage hitbox alignment. */ -public class AbilitySweeper extends Ability { +public class AbilitySweeper extends Ability implements IAbilitySweeper { // Type-specific parameters private float beamLength = 10.0f; 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 218432fc9..05293a467 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 @@ -18,13 +18,15 @@ 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 java.util.List; import java.util.Random; /** * Teleport ability: Instant reposition with wall/line-of-sight checks. */ -public class AbilityTeleport extends Ability { +public class AbilityTeleport extends Ability implements IAbilityTeleport { /** * Teleport behavior mode. @@ -440,14 +442,25 @@ public class AbilityTeleport extends Ability { } // Getters & Setters - public TeleportMode getMode() { + public TeleportMode getModeEnum() { return mode; } - public void setMode(TeleportMode mode) { + public void setModeEnum(TeleportMode mode) { this.mode = mode; } + @Override + public int getMode() { + return mode.ordinal(); + } + + @Override + public void setMode(int mode) { + TeleportMode[] values = TeleportMode.values(); + this.mode = mode >= 0 && mode < values.length ? values[mode] : TeleportMode.BLINK; + } + public int getBlinkCount() { return blinkCount; } 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 dbb7273cd..b14a9ad67 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 @@ -16,6 +16,8 @@ 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 java.util.HashSet; import java.util.List; import java.util.Random; @@ -26,7 +28,7 @@ import java.util.UUID; * Trap ability: Places a proximity-triggered trap. * Features arm time, trigger radius, and various effects on trigger. */ -public class AbilityTrap extends Ability { +public class AbilityTrap extends Ability implements IAbilityTrap { public enum TrapPlacement { AT_CASTER, @@ -330,14 +332,25 @@ public class AbilityTrap extends Ability { this.durationTicks = Math.max(1, durationTicks); } - public TrapPlacement getPlacement() { + public TrapPlacement getPlacementEnum() { return placement; } - public void setPlacement(TrapPlacement placement) { + public void setPlacementEnum(TrapPlacement placement) { this.placement = placement; } + @Override + public int getPlacement() { + return placement.ordinal(); + } + + @Override + public void setPlacement(int placement) { + TrapPlacement[] values = TrapPlacement.values(); + this.placement = placement >= 0 && placement < values.length ? values[placement] : TrapPlacement.AT_TARGET; + } + public float getPlacementDistance() { return placementDistance; } 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 fef61779e..a85bbc442 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 @@ -14,6 +14,8 @@ import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.api.ability.type.IAbilityVortex; + import java.util.HashSet; import java.util.List; import java.util.Set; @@ -23,7 +25,7 @@ import java.util.UUID; * Vortex ability: Pulls targets toward the caster. * Can pull single target or AOE, with optional damage and stun on arrival. */ -public class AbilityVortex extends Ability { +public class AbilityVortex extends Ability implements IAbilityVortex { private float pullRadius = 8.0f; private float pullStrength = 0.8f; diff --git a/src/main/java/noppes/npcs/DataAbilities.java b/src/main/java/noppes/npcs/DataAbilities.java index 0ff0aa8a1..2ddabc588 100644 --- a/src/main/java/noppes/npcs/DataAbilities.java +++ b/src/main/java/noppes/npcs/DataAbilities.java @@ -604,6 +604,50 @@ public class DataAbilities { } } + /** + * Force start a specific ability, bypassing normal selection and cooldown. + * If an ability is currently executing, it will be cancelled. + * + * @param ability The ability to start + * @param target The target entity (can be null for self-targeted abilities) + * @return true if the ability was started successfully + */ + public boolean forceStartAbility(Ability ability, EntityLivingBase target) { + if (ability == null || npc.worldObj.isRemote) { + return false; + } + + // Stop any currently executing ability + stopCurrentAbility(); + + // Reset the ability state + ability.reset(); + + // Start the ability directly + return startAbility(ability, target); + } + + /** + * Execute a preset ability on this NPC. + * The NPC does NOT need to have this ability assigned. + * + * @param presetName The name of the saved ability preset + * @param target The target entity (can be null for self-targeted abilities) + * @return true if the ability was started successfully + */ + public boolean executePresetAbility(String presetName, EntityLivingBase target) { + if (presetName == null || presetName.isEmpty() || npc.worldObj.isRemote) { + return false; + } + + Ability preset = AbilityController.Instance.getSavedAbility(presetName); + if (preset == null) { + return false; + } + + return forceStartAbility(preset, target); + } + // ═══════════════════════════════════════════════════════════════════ // SCRIPT EVENTS // ═══════════════════════════════════════════════════════════════════ 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 index f10c63eef..a1539536d 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java @@ -61,7 +61,7 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig { // 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.getSweepMode().ordinal()); + GuiNpcButton sweepModeBtn = new GuiNpcButton(106, fieldX, y, 70, 20, sweepModes, cutter.getSweepModeEnum().ordinal()); sweepModeBtn.setHoverText("ability.hover.sweepMode"); addButton(sweepModeBtn); @@ -73,7 +73,7 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig { y += 24; // Row 5: Spin Duration (only for SPIN mode) + Effects button - if (cutter.getSweepMode() == AbilityCutter.SweepMode.SPIN) { + 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); @@ -88,7 +88,7 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig { int value = button.getValue(); switch (id) { case 106: - cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]); + cutter.setSweepModeEnum(AbilityCutter.SweepMode.values()[value]); initGui(); // Refresh to show/hide duration field break; case 107: 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 index f113b3c1c..9d7bd63b6 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java @@ -30,7 +30,7 @@ public class SubGuiAbilityDash extends SubGuiAbilityConfig { // 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.getDashMode().ordinal()); + GuiNpcButton modeBtn = new GuiNpcButton(100, fieldX, y, 80, 20, dashModes, dash.getDashModeEnum().ordinal()); modeBtn.setHoverText("ability.hover.dashMode"); addButton(modeBtn); @@ -47,7 +47,7 @@ public class SubGuiAbilityDash extends SubGuiAbilityConfig { @Override protected void handleTypeButton(int id, GuiNpcButton button) { if (id == 100) { - dash.setDashMode(AbilityDash.DashMode.values()[button.getValue()]); + dash.setDashModeEnum(AbilityDash.DashMode.values()[button.getValue()]); } } 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 index 2b804d99b..00383853f 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java @@ -122,7 +122,7 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig { // 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.getAnchorPoint().getId()); + GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), disc.getAnchorPointEnum().getId()); anchorBtn.setHoverText("ability.hover.anchorPoint"); addButton(anchorBtn); @@ -227,7 +227,7 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig { initGui(); break; case 210: - disc.setAnchorPoint(AnchorPoint.fromId(value)); + disc.setAnchorPointEnum(AnchorPoint.fromId(value)); break; } } 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 index 6e90428ce..d878c9381 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java @@ -118,7 +118,7 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { // 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.getAnchorPoint().getId()); + GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), beam.getAnchorPointEnum().getId()); anchorBtn.setHoverText("ability.hover.anchorPoint"); addButton(anchorBtn); @@ -219,7 +219,7 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { initGui(); break; case 210: - beam.setAnchorPoint(AnchorPoint.fromId(value)); + beam.setAnchorPointEnum(AnchorPoint.fromId(value)); 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 index a975a97fc..0d2ec667b 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java @@ -50,7 +50,7 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig { addLabel(new GuiNpcLabel(102, "ability.counterType", col2LabelX, y + 5)); String[] types = {"Flat", "Percent"}; - GuiNpcButton counterTypeButton = new GuiNpcButton(102, col2FieldX, y, 60, 20, types, guard.getCounterType().ordinal()); + GuiNpcButton counterTypeButton = new GuiNpcButton(102, col2FieldX, y, 60, 20, types, guard.getCounterTypeEnum().ordinal()); counterTypeButton.setHoverText("ability.hover.counterType"); counterTypeButton.setEnabled(guard.isCanCounter()); addButton(counterTypeButton); @@ -97,7 +97,7 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig { initGui(); break; case 102: - guard.setCounterType(AbilityGuard.CounterType.values()[button.getValue()]); + guard.setCounterTypeEnum(AbilityGuard.CounterType.values()[button.getValue()]); break; case 150: setSubGui(new SubGuiAbilityEffects(guard.getEffects())); 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 index 9822d9f90..5b8be7976 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java @@ -39,7 +39,7 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig { 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.getShape().ordinal()); + GuiNpcButton shapeBtn = new GuiNpcButton(100, col2FieldX, y, 55, 20, shapes, hazard.getShapeEnum().ordinal()); shapeBtn.setHoverText("ability.hover.shape"); addButton(shapeBtn); @@ -48,7 +48,7 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig { // 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.getPlacement().ordinal()); + GuiNpcButton placementBtn = new GuiNpcButton(101, fieldX, y, 70, 20, placements, hazard.getPlacementEnum().ordinal()); placementBtn.setHoverText("ability.hover.placement"); addButton(placementBtn); @@ -101,10 +101,10 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig { int value = button.getValue(); switch (id) { case 100: - hazard.setShape(AbilityHazard.HazardShape.values()[value]); + hazard.setShapeEnum(AbilityHazard.HazardShape.values()[value]); break; case 101: - hazard.setPlacement(AbilityHazard.PlacementMode.values()[value]); + hazard.setPlacementEnum(AbilityHazard.PlacementMode.values()[value]); break; case 109: hazard.setAffectsCaster(value == 1); 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 index 858eeefa7..40cff112f 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java @@ -106,7 +106,7 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { // 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.getAnchorPoint().getId()); + GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), orb.getAnchorPointEnum().getId()); anchorBtn.setHoverText("ability.hover.anchorPoint"); addButton(anchorBtn); @@ -207,7 +207,7 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { initGui(); break; case 210: - orb.setAnchorPoint(AnchorPoint.fromId(value)); + orb.setAnchorPointEnum(AnchorPoint.fromId(value)); 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 index e39918d2d..4b23b0ca0 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java @@ -34,11 +34,11 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig { // 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.getMode().ordinal())); + addButton(new GuiNpcButton(100, fieldX, y, 80, 20, modes, teleport.getModeEnum().ordinal())); y += 24; - switch (teleport.getMode()) { + switch (teleport.getModeEnum()) { case BLINK: // Row 2: Blink Radius + Blink Count addLabel(new GuiNpcLabel(101, "ability.blinkRadius", labelX, y + 5)); @@ -109,7 +109,7 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig { int value = button.getValue(); switch (id) { case 100: - teleport.setMode(AbilityTeleport.TeleportMode.values()[value]); + teleport.setModeEnum(AbilityTeleport.TeleportMode.values()[value]); initGui(); break; case 105: 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 index edeb59635..5c9c52558 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java @@ -39,7 +39,7 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig { 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.getPlacement().ordinal()); + GuiNpcButton placementBtn = new GuiNpcButton(100, col2FieldX, y, 55, 20, placements, trap.getPlacementEnum().ordinal()); placementBtn.setHoverText("ability.hover.placement"); addButton(placementBtn); @@ -79,7 +79,7 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig { @Override protected void handleTypeButton(int id, GuiNpcButton button) { if (id == 100) { - trap.setPlacement(AbilityTrap.TrapPlacement.values()[button.getValue()]); + trap.setPlacementEnum(AbilityTrap.TrapPlacement.values()[button.getValue()]); } else if (id == 150) { setSubGui(new SubGuiAbilityEffects(trap.getEffects())); } diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 8b632f7ce..26f7a1ba7 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1457,4 +1457,8 @@ public class ScriptNpc extends ScriptLiving imp public IMagicData getMagicData() { return npc.stats.magicData; } + + public noppes.npcs.api.ability.IDataAbilities getAbilityData() { + return new noppes.npcs.scripted.wrapper.ScriptDataAbilities(npc); + } } diff --git a/src/main/java/noppes/npcs/scripted/wrapper/ScriptDataAbilities.java b/src/main/java/noppes/npcs/scripted/wrapper/ScriptDataAbilities.java new file mode 100644 index 000000000..d097a892c --- /dev/null +++ b/src/main/java/noppes/npcs/scripted/wrapper/ScriptDataAbilities.java @@ -0,0 +1,163 @@ +package noppes.npcs.scripted.wrapper; + +import kamkeel.npcs.controllers.data.ability.Ability; +import kamkeel.npcs.controllers.data.ability.AbilityController; +import net.minecraft.entity.EntityLivingBase; +import noppes.npcs.DataAbilities; +import noppes.npcs.api.ability.IAbility; +import noppes.npcs.api.ability.IDataAbilities; +import noppes.npcs.entity.EntityNPCInterface; + +/** + * Script wrapper for DataAbilities providing API access to NPC abilities. + */ +public class ScriptDataAbilities implements IDataAbilities { + + private final DataAbilities data; + private final EntityNPCInterface npc; + + public ScriptDataAbilities(EntityNPCInterface npc) { + this.npc = npc; + this.data = npc.abilities; + } + + @Override + public boolean isEnabled() { + return data.enabled; + } + + @Override + public void setEnabled(boolean enabled) { + data.enabled = enabled; + } + + @Override + public IAbility[] getAbilities() { + return data.getAbilities().toArray(new IAbility[0]); + } + + @Override + public void addAbility(IAbility ability) { + if (ability instanceof Ability) { + data.addAbility((Ability) ability); + } + } + + @Override + public void removeAbility(String abilityId) { + data.removeAbility(abilityId); + } + + @Override + public IAbility getAbility(String abilityId) { + return data.getAbility(abilityId); + } + + @Override + public boolean hasAbility(String abilityId) { + return data.getAbility(abilityId) != null; + } + + @Override + public void clearAbilities() { + data.clearAbilities(); + } + + @Override + public IAbility getCurrentAbility() { + return data.getCurrentAbility(); + } + + @Override + public boolean isExecutingAbility() { + return data.isExecutingAbility(); + } + + @Override + public void interruptCurrentAbility() { + data.interruptCurrentAbility(null, 0); + } + + @Override + public int getGlobalCooldown() { + return (int) data.getRemainingCooldown(); + } + + @Override + public void setGlobalCooldown(int ticks) { + // Set the cooldown by manipulating the internal cooldown end time + // Not directly exposed, but we can reset and let it tick down + data.resetCooldown(); + // This is a best-effort implementation + } + + @Override + public void resetCooldowns() { + data.resetCooldown(); + } + + @Override + public boolean forceStartAbility(String abilityId) { + return forceStartAbility(abilityId, null); + } + + @Override + public boolean forceStartAbility(String abilityId, Object target) { + // Find the ability + Ability ability = data.getAbility(abilityId); + if (ability == null) { + return false; + } + + // Resolve target + EntityLivingBase targetEntity = resolveTarget(target); + + // Use the direct force start method + return data.forceStartAbility(ability, targetEntity); + } + + @Override + public boolean executePresetAbility(String presetName) { + return executePresetAbility(presetName, null); + } + + @Override + public boolean executePresetAbility(String presetName, Object target) { + // Resolve target + EntityLivingBase targetEntity = resolveTarget(target); + + // Use the direct preset execution method + return data.executePresetAbility(presetName, targetEntity); + } + + @Override + public IAbility createAbility(String typeId) { + if (AbilityController.Instance == null) { + return null; + } + return AbilityController.Instance.create(typeId); + } + + /** + * Resolve a target object to an EntityLivingBase. + */ + private EntityLivingBase resolveTarget(Object target) { + if (target == null) { + // Try to use the NPC's current attack target + return npc.getAttackTarget(); + } + + if (target instanceof EntityLivingBase) { + return (EntityLivingBase) target; + } + + if (target instanceof noppes.npcs.api.entity.IEntityLivingBase) { + Object mcEntity = ((noppes.npcs.api.entity.IEntityLivingBase) target).getMCEntity(); + if (mcEntity instanceof EntityLivingBase) { + return (EntityLivingBase) mcEntity; + } + } + + return null; + } +} From 7d2bba7b95e9cda41dcb6c20033c0f428377cab5 Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 28 Jan 2026 15:16:28 -0500 Subject: [PATCH 4/9] Better Lock Movement handling --- src/api | 2 +- .../controllers/data/ability/Ability.java | 58 +++++++++++-- .../data/ability/LockMovementType.java | 83 +++++++++++++++++++ .../data/ability/type/AbilityCharge.java | 3 +- .../data/ability/type/AbilityCutter.java | 3 +- .../data/ability/type/AbilityDash.java | 3 +- .../data/ability/type/AbilityDisc.java | 2 + .../data/ability/type/AbilityEnergyBeam.java | 6 +- .../data/ability/type/AbilityGuard.java | 3 +- .../data/ability/type/AbilityHazard.java | 3 +- .../data/ability/type/AbilityHeal.java | 3 +- .../data/ability/type/AbilityHeavyHit.java | 3 +- .../data/ability/type/AbilityLaserShot.java | 2 + .../data/ability/type/AbilityOrb.java | 2 + .../data/ability/type/AbilityProjectile.java | 2 + .../data/ability/type/AbilityShockwave.java | 3 +- .../data/ability/type/AbilitySlam.java | 3 +- .../data/ability/type/AbilitySweeper.java | 3 +- .../data/ability/type/AbilityTeleport.java | 2 + .../data/ability/type/AbilityTrap.java | 3 +- .../data/ability/type/AbilityVortex.java | 3 +- src/main/java/noppes/npcs/DataAbilities.java | 78 +++++++++-------- .../gui/advanced/SubGuiAbilityConfig.java | 11 +-- .../assets/customnpcs/lang/en_US.lang | 3 + 24 files changed, 227 insertions(+), 60 deletions(-) create mode 100644 src/main/java/kamkeel/npcs/controllers/data/ability/LockMovementType.java diff --git a/src/api b/src/api index 3050910ef..2b21264ad 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 3050910efbc6e301e4ef18fefc20529c507a7bae +Subproject commit 2b21264ada69ec5e800977a000e892bc82d7c61f 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 e5dc7e493..a82a8fc6e 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java @@ -55,7 +55,7 @@ public abstract class Ability implements IAbility { protected boolean interruptible = true; // Feedback - protected boolean lockMovement = true; + protected LockMovementType lockMovement = LockMovementType.WINDUP; protected int windUpColor = 0x80FF4400; // Telegraph color during wind up protected int activeColor = 0xC0FF0000; // Telegraph warning/active color @@ -662,7 +662,7 @@ public abstract class Ability implements IAbility { nbt.setInteger("windUp", windUpTicks); nbt.setInteger("recovery", dazedTicks); nbt.setBoolean("interruptible", interruptible); - nbt.setBoolean("lockMovement", lockMovement); + nbt.setInteger("lockMovement", lockMovement.ordinal()); nbt.setInteger("windUpColor", windUpColor); nbt.setInteger("activeColor", activeColor); nbt.setString("windUpSound", windUpSound); @@ -707,7 +707,7 @@ public abstract class Ability implements IAbility { windUpTicks = nbt.getInteger("windUp"); dazedTicks = nbt.getInteger("recovery"); interruptible = nbt.getBoolean("interruptible"); - lockMovement = nbt.getBoolean("lockMovement"); + lockMovement = LockMovementType.fromOrdinal(nbt.getInteger("lockMovement")); // Support old telegraphColor key for backwards compatibility if (nbt.hasKey("windUpColor")) { windUpColor = nbt.getInteger("windUpColor"); @@ -868,14 +868,62 @@ public abstract class Ability implements IAbility { this.interruptible = interruptible; } - public boolean isLockMovement() { + public LockMovementType getLockMovement() { return lockMovement; } - public void setLockMovement(boolean lockMovement) { + public void setLockMovement(LockMovementType lockMovement) { this.lockMovement = lockMovement; } + /** + * API method: Get lock movement type as integer. + * @return 0=NO, 1=WINDUP, 2=ACTIVE, 3=WINDUP_AND_ACTIVE + */ + @Override + public int getLockMovementType() { + return lockMovement.ordinal(); + } + + /** + * API method: Set lock movement type from integer. + * @param type 0=NO, 1=WINDUP, 2=ACTIVE, 3=WINDUP_AND_ACTIVE + */ + @Override + public void setLockMovementType(int type) { + this.lockMovement = LockMovementType.fromOrdinal(type); + } + + /** + * Check if movement should be locked during WINDUP phase. + */ + @Override + public boolean isMovementLockedDuringWindup() { + return lockMovement.locksWindup(); + } + + /** + * Check if movement should be locked during ACTIVE phase. + */ + @Override + public boolean isMovementLockedDuringActive() { + return lockMovement.locksActive(); + } + + /** + * Check if movement should be locked during the current phase. + */ + public boolean isMovementLockedForCurrentPhase() { + switch (phase) { + case WINDUP: + return lockMovement.locksWindup(); + case ACTIVE: + return lockMovement.locksActive(); + default: + return false; + } + } + public int getWindUpColor() { return windUpColor; } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/LockMovementType.java b/src/main/java/kamkeel/npcs/controllers/data/ability/LockMovementType.java new file mode 100644 index 000000000..1b81a3bb3 --- /dev/null +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/LockMovementType.java @@ -0,0 +1,83 @@ +package kamkeel.npcs.controllers.data.ability; + +/** + * Defines when an ability locks NPC movement and rotation. + */ +public enum LockMovementType { + /** + * No movement lock - NPC can move freely during both phases. + */ + NO, + + /** + * Lock movement during WINDUP phase only. + * NPC can move during ACTIVE phase. + */ + WINDUP, + + /** + * Lock movement during ACTIVE phase only. + * NPC can move during WINDUP phase. + */ + ACTIVE, + + /** + * Lock movement during both WINDUP and ACTIVE phases. + */ + WINDUP_AND_ACTIVE; + + /** + * Check if movement should be locked during WINDUP phase. + */ + public boolean locksWindup() { + return this == WINDUP || this == WINDUP_AND_ACTIVE; + } + + /** + * Check if movement should be locked during ACTIVE phase. + */ + public boolean locksActive() { + return this == ACTIVE || this == WINDUP_AND_ACTIVE; + } + + /** + * Get display name for GUI. + */ + public String getDisplayKey() { + switch (this) { + case NO: + return "gui.no"; + case WINDUP: + return "ability.lockMove.windup"; + case ACTIVE: + return "ability.lockMove.active"; + case WINDUP_AND_ACTIVE: + return "ability.lockMove.both"; + default: + return "gui.no"; + } + } + + /** + * Get all display keys for GUI dropdown. + */ + public static String[] getDisplayKeys() { + return new String[]{ + "gui.no", + "ability.lockMove.windup", + "ability.lockMove.active", + "ability.lockMove.both" + }; + } + + /** + * Get LockMovementType from ordinal, with fallback to WINDUP. + */ + public static LockMovementType fromOrdinal(int ordinal) { + LockMovementType[] values = values(); + if (ordinal >= 0 && ordinal < values.length) { + return values[ordinal]; + } + return WINDUP; + } +} 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 d87ed05ee..1f6f31250 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; @@ -47,7 +48,7 @@ public class AbilityCharge extends Ability implements IAbilityCharge { this.targetingMode = TargetingMode.AGGRO_TARGET; this.maxRange = 20.0f; this.minRange = 4.0f; - this.lockMovement = false; // Movement IS the ability + this.lockMovement = LockMovementType.WINDUP; this.cooldownTicks = 0; this.windUpTicks = 20; // LINE telegraph showing charge path 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 1d77e9219..9db9d7700 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; @@ -54,7 +55,7 @@ public class AbilityCutter extends Ability implements IAbilityCutter { this.name = "Cutter"; this.targetingMode = TargetingMode.AOE_SELF; this.maxRange = 8.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.NO; this.cooldownTicks = 0; this.windUpTicks = 20; this.telegraphType = TelegraphType.CONE; 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 677578745..2c03de4c2 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; @@ -88,7 +89,7 @@ public class AbilityDash extends Ability implements IAbilityDash { this.targetingMode = TargetingMode.AGGRO_TARGET; this.maxRange = 20.0f; this.minRange = 0.0f; - this.lockMovement = false; + this.lockMovement = LockMovementType.NO; this.cooldownTicks = 0; this.windUpTicks = 5; // No telegraph for dash - it's a quick evasive move 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 2c7b8e43c..a68e38cd6 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 @@ -4,6 +4,7 @@ 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.AnchorPoint; +import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; @@ -83,6 +84,7 @@ public class AbilityDisc extends Ability implements IAbilityDisc { this.minRange = 5.0f; this.cooldownTicks = 0; this.windUpTicks = 20; + this.lockMovement = LockMovementType.WINDUP; this.telegraphType = TelegraphType.CIRCLE; this.showTelegraph = true; } 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 790489b2c..b8946306a 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 @@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.AbilityAnimation; 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.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; @@ -85,6 +86,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { this.minRange = 5.0f; this.cooldownTicks = 0; this.windUpTicks = 40; + this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE; this.telegraphType = TelegraphType.CIRCLE; this.showTelegraph = true; } @@ -145,7 +147,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, lightningEffect, lightningDensity, lightningRadius, - lockMovement, // Anchored mode + lockMovement.locksActive(), // Anchored mode during firing windUpTicks, // Charge duration = windup duration offsetDist, // Offset distance (used by FRONT anchor) anchorPoint // Anchor point for charging position @@ -311,7 +313,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { public float getLightningRadius() { return lightningRadius; } public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; } - + @Override public Animation getWindUpAnimation() { if (windUpAnimationId == -1) 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 84701b79e..92c7ca58e 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; @@ -50,7 +51,7 @@ public class AbilityGuard extends Ability implements IAbilityGuard { this.typeId = "ability.cnpc.guard"; this.name = "Guard"; this.targetingMode = TargetingMode.SELF; - this.lockMovement = true; + this.lockMovement = LockMovementType.ACTIVE; this.cooldownTicks = 0; this.windUpTicks = 10; this.interruptible = false; // Hard to interrupt while guarding 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 79e43e2cc..61841ded4 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; @@ -83,7 +84,7 @@ public class AbilityHazard extends Ability implements IAbilityHazard { this.name = "Hazard"; this.targetingMode = TargetingMode.AGGRO_TARGET; this.maxRange = 15.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP; this.cooldownTicks = 0; this.windUpTicks = 30; this.telegraphType = TelegraphType.CIRCLE; 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 11aed6c47..406be2f3a 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.Entity; @@ -49,7 +50,7 @@ public class AbilityHeal extends Ability implements IAbilityHeal { this.typeId = "ability.cnpc.heal"; this.name = "Heal"; this.targetingMode = TargetingMode.SELF; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP; this.cooldownTicks = 0; this.windUpTicks = 30; // No telegraph for heal - it's a self/ally buff 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 82091c041..4ed4a0e78 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; @@ -29,7 +30,7 @@ public class AbilityHeavyHit extends Ability implements IAbilityHeavyHit { this.targetingMode = TargetingMode.AGGRO_TARGET; this.maxRange = 3.0f; this.minRange = 0.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.NO; this.cooldownTicks = 0; this.windUpTicks = 30; this.telegraphType = TelegraphType.POINT; 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 44b6bc0b5..da9f07780 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import kamkeel.npcs.entity.EntityAbilityLaser; @@ -63,6 +64,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { this.minRange = 3.0f; this.cooldownTicks = 0; this.windUpTicks = 15; + this.lockMovement = LockMovementType.WINDUP; this.telegraphType = TelegraphType.LINE; this.showTelegraph = true; } 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 fabdf6ab0..336f54e7c 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 @@ -5,6 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.AbilityAnimation; 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.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; @@ -84,6 +85,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb { this.minRange = 5.0f; this.cooldownTicks = 0; this.windUpTicks = 30; + this.lockMovement = LockMovementType.WINDUP; this.telegraphType = TelegraphType.CIRCLE; this.showTelegraph = true; } 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 56b12028e..6b81fabe7 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.Entity; @@ -42,6 +43,7 @@ public class AbilityProjectile extends Ability implements IAbilityProjectile { this.maxRange = 20.0f; this.cooldownTicks = 0; this.windUpTicks = 15; + this.lockMovement = LockMovementType.NO; // No telegraph for projectile - it's a ranged attack this.telegraphType = TelegraphType.NONE; this.showTelegraph = false; 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 c6b93134a..006084f5e 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; @@ -35,7 +36,7 @@ public class AbilityShockwave extends Ability implements IAbilityShockwave { this.name = "Shockwave"; this.targetingMode = TargetingMode.AOE_SELF; this.maxRange = 15.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE; this.cooldownTicks = 0; this.windUpTicks = 25; this.telegraphType = TelegraphType.CIRCLE; 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 ba49ffb2c..b9da81dc5 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; @@ -52,7 +53,7 @@ public class AbilitySlam extends Ability implements IAbilitySlam { this.targetingMode = TargetingMode.AOE_SELF; // Can also be AOE_TARGET to leap to target this.windUpTicks = 30; this.cooldownTicks = 0; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP; this.minRange = 2.0f; this.maxRange = 15.0f; this.telegraphType = TelegraphType.CIRCLE; 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 66f589a00..2abbbbb48 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.Telegraph; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; @@ -54,7 +55,7 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper { this.targetingMode = TargetingMode.AGGRO_TARGET; this.maxRange = 15.0f; this.minRange = 0.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE; this.cooldownTicks = 0; this.windUpTicks = 60; // Circle telegraph to show range 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 05293a467..1fef00a55 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.block.Block; @@ -63,6 +64,7 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport { this.minRange = 5.0f; this.cooldownTicks = 0; this.windUpTicks = 10; + this.lockMovement = LockMovementType.NO; // No telegraph for teleport - it's instant repositioning this.telegraphType = TelegraphType.NONE; this.showTelegraph = false; 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 b14a9ad67..6bf69a60b 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; @@ -66,7 +67,7 @@ public class AbilityTrap extends Ability implements IAbilityTrap { this.name = "Trap"; this.targetingMode = TargetingMode.AGGRO_TARGET; this.maxRange = 15.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP; this.cooldownTicks = 0; this.windUpTicks = 20; this.telegraphType = TelegraphType.CIRCLE; 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 a85bbc442..1bcfb7cbc 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 @@ -3,6 +3,7 @@ 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; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import net.minecraft.entity.EntityLivingBase; @@ -53,7 +54,7 @@ public class AbilityVortex extends Ability implements IAbilityVortex { this.name = "Vortex"; this.targetingMode = TargetingMode.AOE_SELF; this.maxRange = 15.0f; - this.lockMovement = true; + this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE; this.cooldownTicks = 0; this.windUpTicks = 30; this.telegraphType = TelegraphType.CIRCLE; diff --git a/src/main/java/noppes/npcs/DataAbilities.java b/src/main/java/noppes/npcs/DataAbilities.java index 2ddabc588..538829cef 100644 --- a/src/main/java/noppes/npcs/DataAbilities.java +++ b/src/main/java/noppes/npcs/DataAbilities.java @@ -79,7 +79,7 @@ public class DataAbilities { private transient List recentHitTimes = new ArrayList<>(); /** - * Locked rotation values for ACTIVE phase with lockMovement. + * Locked rotation values for ACTIVE phase when movement is locked. * Stored when entering ACTIVE phase, applied every tick to prevent rotation changes. */ private transient boolean rotationLocked = false; @@ -146,9 +146,9 @@ public class DataAbilities { // Remove telegraph - it has served its purpose removeTelegraph(currentAbility); - // Lock rotation if lockMovement is true + // Lock rotation if movement is locked during ACTIVE phase // Capture current rotation values to force them every tick - if (currentAbility.isLockMovement()) { + if (currentAbility.isMovementLockedDuringActive()) { captureLockedRotation(); } @@ -191,6 +191,32 @@ public class DataAbilities { handleAbilityCompletion(target); break; } + + // Apply movement control if ability is still executing + if (currentAbility != null && currentAbility.isExecuting()) { + applyMovementControl(); + } + } + + /** + * Apply movement control based on lock movement settings. + * Called every tick during ability execution. + */ + private void applyMovementControl() { + if (currentAbility == null) return; + + // Check if movement should be locked for the current phase + if (currentAbility.isMovementLockedForCurrentPhase()) { + // Clear navigator to prevent AI pathfinding + npc.getNavigator().clearPathEntity(); + + // Zero motion if ability doesn't have its own movement + // This allows abilities like Charge/Slam to control their own motion + if (!currentAbility.hasAbilityMovement()) { + npc.motionX = 0; + npc.motionZ = 0; + } + } } /** @@ -210,29 +236,11 @@ public class DataAbilities { npc.wrappedNPC, currentAbility, target); NpcAPI.EVENT_BUS.post(completeEvent); - // Clean up and roll cooldown + // Release rotation lock before cleanup + releaseLockedRotation(); + + // Clean up and roll cooldown (this sets currentAbility to null) onAbilityComplete(); - - // Clear AI pathfinding if ability is controlling movement - // But DON'T zero motion - let the ability set it if needed - if (currentAbility != null && currentAbility.isExecuting()) { - if (isAbilityControllingMovement()) { - // Clear navigator so AI doesn't fight with ability movement - npc.getNavigator().clearPathEntity(); - - // Only zero motion if lockMovement is true AND ability doesn't have its own movement - // This allows stationary abilities to freeze the NPC, while movement abilities can set their own motion - if (currentAbility.isLockMovement() && !currentAbility.hasAbilityMovement()) { - npc.motionX = 0; - npc.motionZ = 0; - } - } - - // Unlock rotation when leaving ACTIVE phase - if (rotationLocked && currentAbility.getPhase() != AbilityPhase.ACTIVE) { - releaseLockedRotation(); - } - } } /** @@ -787,8 +795,8 @@ public class DataAbilities { * Called by AI tasks to determine if they should try to path. *

* Rules: - * - WINDUP phase: Block AI if lockMovement is true - * - ACTIVE phase: Block AI if lockMovement OR hasAbilityMovement is true + * - WINDUP phase: Block AI if movement is locked during windup + * - ACTIVE phase: Block AI if movement is locked during active OR hasAbilityMovement is true * - DAZED phase: Always block AI (NPC is stunned) */ public boolean isAbilityControllingMovement() { @@ -800,15 +808,15 @@ public class DataAbilities { switch (phase) { case WINDUP: - // During windup, only block if lockMovement is set - // This allows NPC to keep chasing while winding up if lockMovement=false - return currentAbility.isLockMovement(); + // During windup, only block if movement is locked during windup + // This allows NPC to keep chasing while winding up if not locked + return currentAbility.isMovementLockedDuringWindup(); case ACTIVE: // During active phase, block if either: - // - lockMovement is true (stationary ability) + // - movement is locked during active (stationary ability) // - hasAbilityMovement is true (ability is moving the NPC itself) - return currentAbility.isLockMovement() || currentAbility.hasAbilityMovement(); + return currentAbility.isMovementLockedDuringActive() || currentAbility.hasAbilityMovement(); case DAZED: // During dazed phase, always block - NPC is stunned from interrupt @@ -821,7 +829,7 @@ public class DataAbilities { /** * Check if NPC's look direction should be locked to target. - * Only locks during ACTIVE phase when lockMovement is true. + * Only locks during ACTIVE phase when movement is locked during active. * This allows the NPC to freely track target during WINDUP and DAZED. */ public boolean shouldLockLookDirection() { @@ -834,7 +842,7 @@ public class DataAbilities { return false; } - return currentAbility.isLockMovement(); + return currentAbility.isMovementLockedDuringActive(); } /** @@ -854,7 +862,7 @@ public class DataAbilities { /** * Capture current rotation values to lock NPC's look direction. - * Called when entering ACTIVE phase with lockMovement enabled. + * Called when entering ACTIVE phase with movement locked during active. */ private void captureLockedRotation() { lockedYaw = npc.rotationYaw; 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 831420473..11dbcbc85 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java @@ -2,6 +2,7 @@ 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; @@ -58,7 +59,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi protected String name; protected boolean enabled; protected int weight; - protected boolean lockMovement; + protected LockMovementType lockMovement; protected boolean interruptible; // Timing @@ -111,7 +112,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi this.name = ability.getName() != null ? ability.getName() : ""; this.enabled = ability.isEnabled(); this.weight = ability.getWeight(); - this.lockMovement = ability.isLockMovement(); + this.lockMovement = ability.getLockMovement(); this.interruptible = ability.isInterruptible(); // Timing @@ -251,7 +252,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi addTextField(weightField); addLabel(new GuiNpcLabel(5, "ability.lockMove", col2LabelX, y + 5)); - GuiNpcButton lockMoveBtn = new GuiNpcButton(16, col2FieldX, y, 40, 20, new String[]{"gui.no", "gui.yes"}, lockMovement ? 1 : 0); + GuiNpcButton lockMoveBtn = new GuiNpcButton(16, col2FieldX, y, 60, 20, LockMovementType.getDisplayKeys(), lockMovement.ordinal()); lockMoveBtn.setHoverText("ability.hover.lockMove"); addButton(lockMoveBtn); @@ -644,7 +645,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi interruptible = ((GuiNpcButton) guibutton).getValue() == 1; initGui(); // Refresh to show/hide dazed ticks field } else if (id == 16) { - lockMovement = ((GuiNpcButton) guibutton).getValue() == 1; + lockMovement = LockMovementType.fromOrdinal(((GuiNpcButton) guibutton).getValue()); } else if (id == 17) { // Sync windup ticks with animation duration syncWindupWithAnimation(); @@ -920,7 +921,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi this.name = ability.getName() != null ? ability.getName() : ""; this.enabled = ability.isEnabled(); this.weight = ability.getWeight(); - this.lockMovement = ability.isLockMovement(); + this.lockMovement = ability.getLockMovement(); this.interruptible = ability.isInterruptible(); this.cooldownTicks = ability.getCooldownTicks(); diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index d4f75d883..fd148ea08 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1519,6 +1519,9 @@ ability.dazed=Dazed Ticks ability.interruptible=Interruptible ability.threshold=Threshold ability.lockMove=Lock Move +ability.lockMove.windup=Windup +ability.lockMove.active=Active +ability.lockMove.both=Both ability.telegraph=Telegraph ability.telegraphType=Telegraph Type From e73054a529e7d50f3d2fc75089651bb477b48795 Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 28 Jan 2026 16:31:26 -0500 Subject: [PATCH 5/9] Built In Animation System + Fixes to Defaults for Energy Projectile Abilities --- src/api | 2 +- .../controllers/data/ability/Ability.java | 56 ++++- .../data/ability/AbilityAnimation.java | 101 --------- .../data/ability/type/AbilityDisc.java | 14 +- .../data/ability/type/AbilityEnergyBeam.java | 42 ++-- .../data/ability/type/AbilityLaserShot.java | 30 ++- .../data/ability/type/AbilityOrb.java | 31 ++- .../data/ability/type/AbilitySweeper.java | 15 +- .../animation/AnimationsGetPacket.java | 1 + src/main/java/noppes/npcs/DataAbilities.java | 2 +- .../java/noppes/npcs/NoppesUtilServer.java | 11 +- .../gui/advanced/SubGuiAbilityConfig.java | 70 +++++-- .../gui/select/GuiAnimationSelection.java | 196 +++++++++++++----- .../noppes/npcs/constants/EnumScrollData.java | 4 +- .../npcs/controllers/AnimationController.java | 189 ++++++++++++++++- .../controllers/data/BuiltInAnimation.java | 94 +++++++++ .../animations}/Ability_Beam_Active.json | 0 .../animations}/Ability_Beam_Windup.json | 0 .../animations}/Ability_Orb_Windup.json | 0 .../assets/customnpcs/lang/en_US.lang | 2 + 20 files changed, 622 insertions(+), 238 deletions(-) delete mode 100644 src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java create mode 100644 src/main/java/noppes/npcs/controllers/data/BuiltInAnimation.java rename src/main/resources/{internal/animations/ABILITYBEAM => assets/customnpcs/animations}/Ability_Beam_Active.json (100%) rename src/main/resources/{internal/animations/ABILITYBEAM => assets/customnpcs/animations}/Ability_Beam_Windup.json (100%) rename src/main/resources/{internal/animations/ABILITYORB => assets/customnpcs/animations}/Ability_Orb_Windup.json (100%) diff --git a/src/api b/src/api index 2b21264ad..b8ba682e9 160000 --- a/src/api +++ b/src/api @@ -1 +1 @@ -Subproject commit 2b21264ada69ec5e800977a000e892bc82d7c61f +Subproject commit b8ba682e9dd4e542a5ccf0de231ab5e5ebdad448 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 a82a8fc6e..08eed148b 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java @@ -64,8 +64,12 @@ public abstract class Ability implements IAbility { protected String activeSound = ""; // Sound to play when active phase starts // Animations (global animation IDs, -1 = none) - protected int windUpAnimationId = -1; // Animation to play during wind up - protected int activeAnimationId = -1; // Animation to play during active phase + protected int windUpAnimationId = -1; // Animation to play during wind up (user animations) + protected int activeAnimationId = -1; // Animation to play during active phase (user animations) + + // Built-in animation names (empty = none, takes priority over IDs if set) + protected String windUpAnimationName = ""; // Built-in animation name for wind up + protected String activeAnimationName = ""; // Built-in animation name for active phase // Telegraph configuration protected boolean showTelegraph = true; @@ -669,6 +673,8 @@ public abstract class Ability implements IAbility { nbt.setString("activeSound", activeSound); nbt.setInteger("windUpAnimationId", windUpAnimationId); nbt.setInteger("activeAnimationId", activeAnimationId); + nbt.setString("windUpAnimationName", windUpAnimationName); + nbt.setString("activeAnimationName", activeAnimationName); nbt.setBoolean("showTelegraph", showTelegraph); nbt.setString("telegraphType", telegraphType.name()); nbt.setFloat("telegraphHeightOffset", telegraphHeightOffset); @@ -738,6 +744,8 @@ public abstract class Ability implements IAbility { windUpAnimationId = -1; } activeAnimationId = nbt.hasKey("activeAnimationId") ? nbt.getInteger("activeAnimationId") : -1; + windUpAnimationName = nbt.hasKey("windUpAnimationName") ? nbt.getString("windUpAnimationName") : ""; + activeAnimationName = nbt.hasKey("activeAnimationName") ? nbt.getString("activeAnimationName") : ""; showTelegraph = !nbt.hasKey("showTelegraph") || nbt.getBoolean("showTelegraph"); if (nbt.hasKey("telegraphType")) { try { @@ -959,23 +967,63 @@ public abstract class Ability implements IAbility { public Animation getWindUpAnimation() { if (AnimationController.Instance == null) return null; - return (Animation) AnimationController.Instance.get(windUpAnimationId); + // Built-in animation by name takes priority + if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) { + return (Animation) AnimationController.Instance.get(windUpAnimationName); + } + // Fall back to user animation by ID + if (windUpAnimationId >= 0) { + return (Animation) AnimationController.Instance.get(windUpAnimationId); + } + return null; + } + + public int getWindUpAnimationId() { + return windUpAnimationId; } public void setWindUpAnimationId(int windUpAnimationId) { this.windUpAnimationId = windUpAnimationId; } + public String getWindUpAnimationName() { + return windUpAnimationName; + } + + public void setWindUpAnimationName(String windUpAnimationName) { + this.windUpAnimationName = windUpAnimationName != null ? windUpAnimationName : ""; + } + public Animation getActiveAnimation() { if (AnimationController.Instance == null) return null; - return (Animation) AnimationController.Instance.get(activeAnimationId); + // Built-in animation by name takes priority + if (activeAnimationName != null && !activeAnimationName.isEmpty()) { + return (Animation) AnimationController.Instance.get(activeAnimationName); + } + // Fall back to user animation by ID + if (activeAnimationId >= 0) { + return (Animation) AnimationController.Instance.get(activeAnimationId); + } + return null; + } + + public int getActiveAnimationId() { + return activeAnimationId; } public void setActiveAnimationId(int activeAnimationId) { this.activeAnimationId = activeAnimationId; } + public String getActiveAnimationName() { + return activeAnimationName; + } + + public void setActiveAnimationName(String activeAnimationName) { + this.activeAnimationName = activeAnimationName != null ? activeAnimationName : ""; + } + public boolean isShowTelegraph() { return showTelegraph; } diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java deleted file mode 100644 index 190be70d3..000000000 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityAnimation.java +++ /dev/null @@ -1,101 +0,0 @@ -package kamkeel.npcs.controllers.data.ability; - -import noppes.npcs.CustomNpcs; -import noppes.npcs.LogWriter; -import noppes.npcs.controllers.data.Animation; -import noppes.npcs.util.NBTJsonUtil; -import org.apache.commons.io.FileUtils; - -import java.io.File; -import java.io.InputStream; -import java.util.HashMap; - -import static kamkeel.npcs.controllers.data.ability.AbilityPhase.*; - -public enum AbilityAnimation { - ABILITYORB("Ability_Orb_Windup", WINDUP), - ABILITYBEAM("Ability_Beam_Windup", "Ability_Beam_Active"); - private final HashMap animationNames = new HashMap<>(); - - AbilityAnimation(String idle, String windUp, String active, String recovery) { - animationNames.put(IDLE, idle); - animationNames.put(WINDUP, windUp); - animationNames.put(ACTIVE, active); - animationNames.put(DAZED, recovery); - } - - AbilityAnimation(String idle, String windUp, String active) { - animationNames.put(IDLE, idle); - animationNames.put(WINDUP, windUp); - animationNames.put(ACTIVE, active); - } - - AbilityAnimation(String windUp, String active) { - animationNames.put(WINDUP, windUp); - animationNames.put(ACTIVE, active); - } - - AbilityAnimation(String anim, AbilityPhase phase) { - animationNames.put(phase, anim); - } - - public String fileName(AbilityPhase phase) { - return animationNames.get(phase); - } - - public File getFile(AbilityPhase phase) { - if (animationNames.get(phase).isEmpty() || animationNames.get(phase).equals("N/A")) - return null; - - return getFileFromName(animationNames.get(phase)); - } - - public Animation getAnimation(AbilityPhase phase) { - try { - File file = getFile(phase); - - if (file == null) { - return null; - } - - Animation animation = new Animation(); - animation.readFromNBT(NBTJsonUtil.LoadFile(file)); - - return animation; - } catch (Exception e) { - LogWriter.except(e); - } - - return null; - } - - public Animation idle() { - return getAnimation(IDLE); - } - - public Animation windUp() { - return getAnimation(WINDUP); - } - - public Animation active() { - return getAnimation(ACTIVE); - } - - public Animation dazed() { - return getAnimation(DAZED); - } - - private File getFileFromName(String fileName) { - try (InputStream stream = CustomNpcs.class.getResourceAsStream("/internal/animations/" + name() + "/" + fileName + ".json")) { - - File file = new File("temp"); - - FileUtils.copyInputStreamToFile(stream, file); - - return file; - } catch (Exception i) { - LogWriter.except(i); - } - return null; - } -} 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 a68e38cd6..d85720b6e 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 @@ -121,10 +121,13 @@ public class AbilityDisc extends Ability implements IAbilityDisc { if (discEntity != null && !discEntity.isDead) { discEntity.startMoving(target); } - discEntity = null; - // Disc entity manages itself - ability is done - signalCompletion(); + // If movement is locked during active phase, keep ability active until entity dies + // Otherwise signal completion immediately + if (!lockMovement.locksActive()) { + discEntity = null; + signalCompletion(); + } } @Override @@ -154,6 +157,11 @@ public class AbilityDisc extends Ability implements IAbilityDisc { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { + // If we're tracking the entity for movement lock, check if it's dead + if (discEntity != null && discEntity.isDead) { + discEntity = null; + signalCompletion(); + } } @Override 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 b8946306a..7ebd4bb7b 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 @@ -3,7 +3,6 @@ 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.AbilityAnimation; import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -13,13 +12,12 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import kamkeel.npcs.entity.EntityAbilityBeam; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.nbt.NBTTagCompound;; +import net.minecraft.nbt.NBTTagCompound; 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.api.ability.type.IAbilityEnergyBeam; -import noppes.npcs.controllers.data.Animation; import noppes.npcs.entity.EntityNPCInterface; /** @@ -71,9 +69,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { private float lightningRadius = 0.5f; // Anchor point for charging position - private AnchorPoint anchorPoint = AnchorPoint.FRONT; - - private final AbilityAnimation animation = AbilityAnimation.ABILITYBEAM; + private AnchorPoint anchorPoint = AnchorPoint.RIGHT_HAND; // Transient state for beam entity (used during windup charging) private transient EntityAbilityBeam beamEntity = null; @@ -89,6 +85,9 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE; this.telegraphType = TelegraphType.CIRCLE; this.showTelegraph = true; + // Default built-in animations + this.windUpAnimationName = "Ability_Beam_Windup"; + this.activeAnimationName = "Ability_Beam_Active"; } @Override @@ -123,10 +122,13 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { if (beamEntity != null && !beamEntity.isDead) { beamEntity.startFiring(target); } - beamEntity = null; - // Beam entity manages itself - ability is done - signalCompletion(); + // If movement is locked during active phase, keep ability active until entity dies + // Otherwise signal completion immediately + if (!lockMovement.locksActive()) { + beamEntity = null; + signalCompletion(); + } } @Override @@ -159,6 +161,11 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { + // If we're tracking the entity for movement lock, check if it's dead + if (beamEntity != null && beamEntity.isDead) { + beamEntity = null; + signalCompletion(); + } } @Override @@ -313,23 +320,6 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { public float getLightningRadius() { return lightningRadius; } public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; } - - @Override - public Animation getWindUpAnimation() { - if (windUpAnimationId == -1) - return animation.windUp(); - - return super.getWindUpAnimation(); - } - - @Override - public Animation getActiveAnimation() { - if (activeAnimationId == -1) - return animation.active(); - - return super.getActiveAnimation(); - } - public AnchorPoint getAnchorPointEnum() { return anchorPoint; } public void setAnchorPointEnum(AnchorPoint anchorPoint) { this.anchorPoint = anchorPoint; } 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 da9f07780..a9cf74473 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 @@ -56,6 +56,9 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { private float lightningDensity = 0.15f; private float lightningRadius = 0.5f; + // Transient state for laser entity (used for movement locking) + private transient EntityAbilityLaser laserEntity = null; + public AbilityLaserShot() { this.typeId = "ability.cnpc.laser_shot"; this.name = "Laser Shot"; @@ -111,7 +114,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { double spawnY = npc.posY + npc.getEyeHeight() * 0.8; double spawnZ = npc.posZ; - EntityAbilityLaser laser = new EntityAbilityLaser( + laserEntity = new EntityAbilityLaser( world, npc, target, spawnX, spawnY, spawnZ, laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, @@ -123,15 +126,23 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { lightningEffect, lightningDensity, lightningRadius ); - world.spawnEntityInWorld(laser); + world.spawnEntityInWorld(laserEntity); - // Laser entity manages itself - ability is done - signalCompletion(); + // If movement is locked during active phase, keep ability active until entity dies + // Otherwise signal completion immediately + if (!lockMovement.locksActive()) { + laserEntity = null; + signalCompletion(); + } } @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // Laser entity manages itself + // If we're tracking the entity for movement lock, check if it's dead + if (laserEntity != null && laserEntity.isDead) { + laserEntity = null; + signalCompletion(); + } } @Override @@ -142,6 +153,15 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) { } + @Override + public void cleanup() { + // Despawn laser entity if still alive + if (laserEntity != null && !laserEntity.isDead) { + laserEntity.setDead(); + } + laserEntity = null; + } + @Override public void writeTypeNBT(NBTTagCompound nbt) { nbt.setFloat("laserWidth", laserWidth); 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 336f54e7c..d69a5c944 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 @@ -3,7 +3,6 @@ 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.AbilityAnimation; import kamkeel.npcs.controllers.data.ability.AnchorPoint; import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; @@ -19,7 +18,6 @@ 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.controllers.data.Animation; import noppes.npcs.api.ability.type.IAbilityOrb; import noppes.npcs.entity.EntityNPCInterface; @@ -70,13 +68,11 @@ public class AbilityOrb extends Ability implements IAbilityOrb { private int lightningFadeTime = 6; // Ticks before lightning fades out // Anchor point for charging position - private AnchorPoint anchorPoint = AnchorPoint.FRONT; + private AnchorPoint anchorPoint = AnchorPoint.RIGHT_HAND; // Transient state for orb entity (used during windup charging) private transient EntityAbilityOrb orbEntity = null; - private final AbilityAnimation animation = AbilityAnimation.ABILITYORB; - public AbilityOrb() { this.typeId = "ability.cnpc.orb"; this.name = "Orb"; @@ -88,6 +84,8 @@ public class AbilityOrb extends Ability implements IAbilityOrb { this.lockMovement = LockMovementType.WINDUP; this.telegraphType = TelegraphType.CIRCLE; this.showTelegraph = true; + // Default built-in animation + this.windUpAnimationName = "Ability_Orb_Windup"; } @Override @@ -122,10 +120,13 @@ public class AbilityOrb extends Ability implements IAbilityOrb { if (orbEntity != null && !orbEntity.isDead) { orbEntity.startMoving(target); } - orbEntity = null; - // Orb entity manages itself - ability is done - signalCompletion(); + // If movement is locked during active phase, keep ability active until entity dies + // Otherwise signal completion immediately + if (!lockMovement.locksActive()) { + orbEntity = null; + signalCompletion(); + } } @Override @@ -154,7 +155,11 @@ public class AbilityOrb extends Ability implements IAbilityOrb { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // Nothing to do - entity manages itself + // If we're tracking the entity for movement lock, check if it's dead + if (orbEntity != null && orbEntity.isDead) { + orbEntity = null; + signalCompletion(); + } } @Override @@ -467,14 +472,6 @@ public class AbilityOrb extends Ability implements IAbilityOrb { this.anchorPoint = anchorPoint; } - @Override - public Animation getWindUpAnimation() { - if (windUpAnimationId != -1) - return super.getWindUpAnimation(); - - return animation.windUp(); - } - public int getAnchorPoint() { return anchorPoint.getId(); } 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 2abbbbb48..78dae4fdc 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 @@ -91,8 +91,6 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper { return; } - LogWriter.info("[Sweeper] onExecute called at NPC pos " + npc.posX + ", " + npc.posY + ", " + npc.posZ); - // Spawn the entity that handles BOTH visuals AND damage activeEntity = new EntityAbilitySweeper(world, npc, target, beamLength, beamWidth, beamHeight, @@ -102,14 +100,19 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper { lockOnTarget); world.spawnEntityInWorld(activeEntity); - LogWriter.info("[Sweeper] Spawned sweeper entity"); - // Entity manages itself - completion signaled from onActiveTick when entity dies + // If movement is locked during active phase, keep ability active until entity dies + // Otherwise signal completion immediately + if (!lockMovement.locksActive()) { + activeEntity = null; + signalCompletion(); + } } @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // Entity handles everything - check if entity finished its rotations - if (activeEntity == null || activeEntity.isDead) { + // If we're tracking the entity for movement lock, check if it's dead + if (activeEntity != null && activeEntity.isDead) { + activeEntity = null; signalCompletion(); } } diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java index a2bc51d0a..39b60a40f 100644 --- a/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/AnimationsGetPacket.java @@ -44,5 +44,6 @@ public final class AnimationsGetPacket extends AbstractPacket { return; NoppesUtilServer.sendAnimationDataAll((EntityPlayerMP) player); + NoppesUtilServer.sendBuiltInAnimationData((EntityPlayerMP) player); } } diff --git a/src/main/java/noppes/npcs/DataAbilities.java b/src/main/java/noppes/npcs/DataAbilities.java index 538829cef..526a3bdd7 100644 --- a/src/main/java/noppes/npcs/DataAbilities.java +++ b/src/main/java/noppes/npcs/DataAbilities.java @@ -412,7 +412,7 @@ public class DataAbilities { * @param animation The animation to play, or null if none */ public void playAbilityAnimation(Animation animation) { - if (animation == null || animation.id < 0) return; + if (animation == null) return; if (AnimationController.Instance == null) return; npc.display.animationData.setEnabled(true); diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index ffc778eb0..6a33cb2c0 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -163,7 +163,16 @@ public class NoppesUtilServer { for (Animation animation : AnimationController.getInstance().animations.values()) { map.put(animation.name, animation.id); } - sendScrollData(player, map, EnumScrollData.OPTIONAL); + sendScrollData(player, map, EnumScrollData.ANIMATIONS); + } + + public static void sendBuiltInAnimationData(EntityPlayerMP player) { + Map map = new HashMap(); + for (String name : AnimationController.getInstance().builtInAnimations.keySet()) { + // Use -1 as a marker for built-in animations (they have no ID) + map.put(AnimationController.getInstance().builtInAnimations.get(name).getName(), -1); + } + sendScrollData(player, map, EnumScrollData.BUILTIN_ANIMATIONS); } public static void sendTagDataAll(EntityPlayerMP player) { 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 11dbcbc85..a4fef92ef 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java @@ -129,8 +129,11 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi // Effects this.windUpSound = ability.getWindUpSound(); this.activeSound = ability.getActiveSound(); - this.windUpAnimationId = ability.getWindUpAnimation() != null ? ability.getWindUpAnimation().getID() : -1; - this.activeAnimationId = ability.getActiveAnimation() != null ? ability.getActiveAnimation().getID() : -1; + // 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(); @@ -286,8 +289,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi windupField.setMinMaxDefault(0, 1000, 20); addTextField(windupField); - // Sync button - only show if windup animation is selected - if (windUpAnimationId >= 0) { + // Sync button - only show if windup animation is selected (either by name or ID) + if (windUpAnimationId >= 0 || (windUpAnimationName != null && !windUpAnimationName.isEmpty())) { GuiNpcButton syncBtn = new GuiNpcButton(17, guiLeft + 115, y, 40, 20, "gui.sync"); syncBtn.setHoverText("ability.hover.sync"); addButton(syncBtn); @@ -591,12 +594,16 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi } private String getAnimationName(int animId, boolean isWindUp) { - if (animId < 0) return StatCollector.translateToLocal("gui.none"); - String cachedName = isWindUp ? windUpAnimationName : activeAnimationName; - if (cachedName != null && !cachedName.isEmpty()) { - return truncateString(cachedName, 8); + String animName = isWindUp ? windUpAnimationName : activeAnimationName; + // Check if we have a built-in animation (by name) + if (animName != null && !animName.isEmpty()) { + return truncateString(animName, 8); } - return "ID: " + animId; + // Check if we have a user animation (by ID) + if (animId >= 0) { + return "ID: " + animId; + } + return StatCollector.translateToLocal("gui.none"); } // ═══════════════════════════════════════════════════════════════════════════ @@ -726,19 +733,19 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi // Animation buttons else if (id == 32) { editingAnimationId = 32; - setSubGui(new GuiAnimationSelection(windUpAnimationId)); + setSubGui(new GuiAnimationSelection(windUpAnimationId, windUpAnimationName)); } else if (id == 33) { editingAnimationId = 33; - setSubGui(new GuiAnimationSelection(activeAnimationId)); + setSubGui(new GuiAnimationSelection(activeAnimationId, activeAnimationName)); } // Animation clear buttons else if (id == 37) { windUpAnimationId = -1; - windUpAnimationName = null; + windUpAnimationName = ""; initGui(); } else if (id == 38) { activeAnimationId = -1; - activeAnimationName = null; + activeAnimationName = ""; initGui(); } @@ -824,11 +831,25 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi } else if (subgui instanceof GuiAnimationSelection) { GuiAnimationSelection animSelector = (GuiAnimationSelection) subgui; if (editingAnimationId == 32) { - windUpAnimationId = animSelector.selectedAnimationId; - windUpAnimationName = animSelector.getSelectedName(); + 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) { - activeAnimationId = animSelector.selectedAnimationId; - activeAnimationName = animSelector.getSelectedName(); + 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(); @@ -896,6 +917,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi ability.setActiveSound(activeSound); ability.setWindUpAnimationId(windUpAnimationId); ability.setActiveAnimationId(activeAnimationId); + ability.setWindUpAnimationName(windUpAnimationName != null ? windUpAnimationName : ""); + ability.setActiveAnimationName(activeAnimationName != null ? activeAnimationName : ""); // Telegraph ability.setShowTelegraph(showTelegraph); @@ -948,11 +971,20 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi * Syncs windup ticks with the selected windup animation's total duration. */ private void syncWindupWithAnimation() { - if (windUpAnimationId < 0 || AnimationController.Instance == null) { + if (AnimationController.Instance == null) { return; } - Animation animation = (Animation) AnimationController.Instance.get(windUpAnimationId); + Animation animation = null; + // Check for built-in animation (by name) first + if (windUpAnimationName != null && !windUpAnimationName.isEmpty()) { + animation = (Animation) AnimationController.Instance.get(windUpAnimationName); + } + // Fall back to user animation (by ID) + else if (windUpAnimationId >= 0) { + animation = (Animation) AnimationController.Instance.get(windUpAnimationId); + } + if (animation == null || animation.frames.isEmpty()) { return; } 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 cc3e06cca..2a1f04344 100644 --- a/src/main/java/noppes/npcs/client/gui/select/GuiAnimationSelection.java +++ b/src/main/java/noppes/npcs/client/gui/select/GuiAnimationSelection.java @@ -19,20 +19,42 @@ import java.util.Vector; /** * Animation selection dialog for choosing global animations. - * Requests animation data from the server via packets. + * Toggle between Built-in animations (by name) and Custom animations (by ID). */ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScrollListener, IScrollData { private GuiCustomScroll scrollAnimations; - private HashMap animationData = new HashMap(); + // Built-in animations (name only, no ID) + private HashMap builtInData = new HashMap<>(); + // Custom/user animations (name -> ID) + private HashMap customData = new HashMap<>(); + + // View mode: true = built-in, false = custom + private boolean showingBuiltIn = true; + + // Initial values passed in private int initialAnimationId; - public int selectedAnimationId = -1; - private String selectedName = null; + private String initialAnimationName; + // Selected values to return + public int selectedAnimationId = -1; + public String selectedBuiltInName = ""; + + private String selectedCustomName = null; private String search = ""; + /** + * Constructor for selecting by ID (user animations). + */ public GuiAnimationSelection(int animationId) { + this(animationId, ""); + } + + /** + * Constructor for selecting by name (built-in) or ID (user). + */ + public GuiAnimationSelection(int animationId, String animationName) { drawDefaultBackground = false; title = ""; setBackground("menubg.png"); @@ -40,7 +62,12 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr ySize = 226; this.initialAnimationId = animationId; + this.initialAnimationName = animationName != null ? animationName : ""; this.selectedAnimationId = animationId; + this.selectedBuiltInName = this.initialAnimationName; + + // Start showing built-in if we have a built-in name, otherwise custom + this.showingBuiltIn = !this.initialAnimationName.isEmpty(); // Request animation data from server PacketClient.sendClient(new AnimationsGetPacket()); @@ -50,56 +77,87 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr public void initGui() { super.initGui(); - this.addLabel(new GuiNpcLabel(0, "menu.animations", guiLeft + 8, guiTop + 4)); + int y = guiTop + 4; - this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + ySize - 35, 50, 20, "gui.clear")); - this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, guiTop + ySize - 35, 50, 20, "gui.done")); - this.addButton(new GuiNpcButton(3, guiLeft + xSize - 108, guiTop + ySize - 35, 50, 20, "gui.cancel")); + // Toggle button for switching views + String viewLabel = showingBuiltIn ? "gui.builtinAnimations" : "gui.customAnimations"; + this.addButton(new GuiNpcButton(10, guiLeft + 4, y, 212, 20, viewLabel)); + y += 24; + // Animation scroll list if (scrollAnimations == null) { scrollAnimations = new GuiCustomScroll(this, 0, 0); - scrollAnimations.setSize(212, 150); + scrollAnimations.setSize(212, 130); } scrollAnimations.setList(getSearchList()); - if (selectedName != null) { - scrollAnimations.setSelected(selectedName); - } - scrollAnimations.guiLeft = guiLeft + 4; - scrollAnimations.guiTop = guiTop + 14; - this.addScroll(scrollAnimations); - // Search textbox - moved up to avoid overlapping with buttons - addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 4, guiTop + 166, 212, 20, search)); + // Set selection based on current mode + if (showingBuiltIn && !selectedBuiltInName.isEmpty()) { + scrollAnimations.setSelected(selectedBuiltInName); + } else if (!showingBuiltIn && selectedCustomName != null) { + scrollAnimations.setSelected(selectedCustomName); + } + + scrollAnimations.guiLeft = guiLeft + 4; + scrollAnimations.guiTop = y; + this.addScroll(scrollAnimations); + y += 134; + + // Search textbox + addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 4, y, 212, 20, search)); + y += 24; + + // Buttons + this.addButton(new GuiNpcButton(1, guiLeft + 4, y, 50, 20, "gui.clear")); + this.addButton(new GuiNpcButton(3, guiLeft + xSize - 108, y, 50, 20, "gui.cancel")); + this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, y, 50, 20, "gui.done")); } @Override public void setData(Vector list, HashMap data, EnumScrollData type) { - this.animationData = data; + if (type == EnumScrollData.BUILTIN_ANIMATIONS) { + this.builtInData = data; - // Find the name for our initial animation ID - if (initialAnimationId >= 0) { - for (String name : data.keySet()) { - if (data.get(name) == initialAnimationId) { - selectedName = name; - break; + // Check if initial name matches a built-in animation + if (!initialAnimationName.isEmpty()) { + for (String name : builtInData.keySet()) { + if (name.equalsIgnoreCase(initialAnimationName)) { + selectedBuiltInName = name; + selectedAnimationId = -1; + selectedCustomName = null; + showingBuiltIn = true; + break; + } + } + } + } else if (type == EnumScrollData.ANIMATIONS) { + this.customData = data; + + // Find the name for our initial animation ID (if not using built-in) + if (selectedBuiltInName.isEmpty() && initialAnimationId >= 0) { + for (String name : data.keySet()) { + if (data.get(name) == initialAnimationId) { + selectedCustomName = name; + showingBuiltIn = false; + break; + } } } } if (scrollAnimations != null) { scrollAnimations.setList(getSearchList()); - if (selectedName != null) { - scrollAnimations.setSelected(selectedName); + if (showingBuiltIn && !selectedBuiltInName.isEmpty()) { + scrollAnimations.setSelected(selectedBuiltInName); + } else if (!showingBuiltIn && selectedCustomName != null) { + scrollAnimations.setSelected(selectedCustomName); } } } @Override public void setSelected(String selected) { - this.selectedName = selected; - if (scrollAnimations != null) { - scrollAnimations.setSelected(selected); - } + // Not used in this implementation } @Override @@ -110,18 +168,22 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr if (search.equals(getTextField(55).getText())) return; search = getTextField(55).getText().toLowerCase(); - scrollAnimations.resetScroll(); - scrollAnimations.setList(getSearchList()); + if (scrollAnimations != null) { + scrollAnimations.resetScroll(); + scrollAnimations.setList(getSearchList()); + } } } } private List getSearchList() { + HashMap sourceData = showingBuiltIn ? builtInData : customData; + if (search.isEmpty()) { - return new ArrayList(animationData.keySet()); + return new ArrayList<>(sourceData.keySet()); } - List list = new ArrayList(); - for (String name : animationData.keySet()) { + List list = new ArrayList<>(); + for (String name : sourceData.keySet()) { if (name.toLowerCase().contains(search)) list.add(name); } @@ -130,11 +192,20 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { - if (guiCustomScroll.id == 0) { - String selected = scrollAnimations.getSelected(); - if (selected != null && animationData.containsKey(selected)) { - selectedName = selected; - selectedAnimationId = animationData.get(selected); + String selected = scrollAnimations.getSelected(); + if (selected == null) return; + + if (showingBuiltIn) { + if (builtInData.containsKey(selected)) { + selectedBuiltInName = selected; + selectedAnimationId = -1; + selectedCustomName = null; + } + } else { + if (customData.containsKey(selected)) { + selectedCustomName = selected; + selectedAnimationId = customData.get(selected); + selectedBuiltInName = ""; } } initGui(); @@ -142,27 +213,40 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr @Override public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { - if (selectedAnimationId < 0) - return; - close(); + // Double-click to confirm selection + if (!selectedBuiltInName.isEmpty() || selectedAnimationId >= 0) { + close(); + } } @Override protected void actionPerformed(GuiButton guibutton) { int id = guibutton.id; - if (id == 1) { - // Clear selection - selectedName = null; + + // Toggle view button + if (id == 10) { + showingBuiltIn = !showingBuiltIn; + search = ""; + if (scrollAnimations != null) { + scrollAnimations.resetScroll(); + } + initGui(); + } + // Clear + else if (id == 1) { + selectedBuiltInName = ""; selectedAnimationId = -1; + selectedCustomName = null; close(); } - if (id == 2) { - // Done - keep selection + // Done + else if (id == 2) { close(); } - if (id == 3) { - // Cancel - restore initial value + // Cancel + else if (id == 3) { selectedAnimationId = initialAnimationId; + selectedBuiltInName = initialAnimationName; close(); } } @@ -171,6 +255,16 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr * Get the name of the selected animation (for display purposes). */ public String getSelectedName() { - return selectedName; + if (!selectedBuiltInName.isEmpty()) { + return selectedBuiltInName; + } + return selectedCustomName; + } + + /** + * Check if a built-in animation was selected. + */ + public boolean isBuiltInSelected() { + return !selectedBuiltInName.isEmpty(); } } diff --git a/src/main/java/noppes/npcs/constants/EnumScrollData.java b/src/main/java/noppes/npcs/constants/EnumScrollData.java index abf55a84e..235f2719b 100644 --- a/src/main/java/noppes/npcs/constants/EnumScrollData.java +++ b/src/main/java/noppes/npcs/constants/EnumScrollData.java @@ -6,5 +6,7 @@ public enum EnumScrollData { MAGIC_CYCLES, DIALOG_GROUP, QUEST_GROUP, - ABILITY_TYPES + ABILITY_TYPES, + ANIMATIONS, + BUILTIN_ANIMATIONS } diff --git a/src/main/java/noppes/npcs/controllers/AnimationController.java b/src/main/java/noppes/npcs/controllers/AnimationController.java index e3caddce5..e5e11d666 100644 --- a/src/main/java/noppes/npcs/controllers/AnimationController.java +++ b/src/main/java/noppes/npcs/controllers/AnimationController.java @@ -8,23 +8,43 @@ import noppes.npcs.LogWriter; import noppes.npcs.api.handler.IAnimationHandler; import noppes.npcs.api.handler.data.IAnimation; import noppes.npcs.controllers.data.Animation; +import noppes.npcs.controllers.data.BuiltInAnimation; import noppes.npcs.util.NBTJsonUtil; import java.io.BufferedInputStream; +import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.stream.Stream; import java.util.zip.GZIPInputStream; public class AnimationController implements IAnimationHandler { public HashMap animations; private HashMap bootOrder; + // Built-in animations loaded from assets folder (read-only, keyed by name) + public HashMap builtInAnimations = new HashMap<>(); + private static final String BUILTIN_ANIMATIONS_PATH = "/assets/customnpcs/animations"; + private static final String BUILTIN_ANIMATIONS_RESOURCE = "assets/customnpcs/animations"; + public static AnimationController Instance; private int lastUsedID = 0; @@ -42,12 +62,94 @@ public class AnimationController implements IAnimationHandler { public void load() { bootOrder = new HashMap<>(); animations = new HashMap<>(); + builtInAnimations = new HashMap<>(); LogWriter.info("Loading animations..."); + loadBuiltInAnimations(); readAnimationMap(); loadAnimations(); LogWriter.info("Done loading animations."); } + /** + * Load built-in animations from assets/customnpcs/animations/ folder. + * These animations are read-only and accessed by name only (no IDs). + * Scans the folder directly instead of using a manifest. + */ + private void loadBuiltInAnimations() { + try { + URL resourceUrl = CustomNpcs.class.getResource(BUILTIN_ANIMATIONS_PATH); + if (resourceUrl == null) { + LogWriter.info("Built-in animations folder not found: " + BUILTIN_ANIMATIONS_PATH); + return; + } + + URI uri = resourceUrl.toURI(); + Path animationsPath; + + if (uri.getScheme().equals("jar")) { + // Running from JAR - need to create a FileSystem to access it + FileSystem fileSystem = null; + try { + fileSystem = FileSystems.getFileSystem(uri); + } catch (Exception e) { + fileSystem = FileSystems.newFileSystem(uri, Collections.emptyMap()); + } + animationsPath = fileSystem.getPath(BUILTIN_ANIMATIONS_PATH); + } else { + // Running from file system (dev environment) + animationsPath = Paths.get(uri); + } + + // Scan the directory for .json files + try (Stream paths = Files.walk(animationsPath, 1)) { + paths.filter(path -> path.toString().endsWith(".json")) + .forEach(path -> { + String fileName = path.getFileName().toString(); + String animName = fileName.substring(0, fileName.length() - 5); // Remove .json + try { + loadBuiltInAnimation(animName); + } catch (Exception e) { + LogWriter.error("Error loading built-in animation: " + animName, e); + } + }); + } + + LogWriter.info("Loaded " + builtInAnimations.size() + " built-in animations."); + } catch (Exception e) { + LogWriter.error("Error scanning built-in animations folder", e); + } + } + + /** + * Load a single built-in animation by name from assets folder. + */ + private void loadBuiltInAnimation(String animName) throws Exception { + String resourcePath = BUILTIN_ANIMATIONS_PATH + "/" + animName + ".json"; + try (InputStream stream = CustomNpcs.class.getResourceAsStream(resourcePath)) { + if (stream == null) { + return; + } + + // Read JSON content + StringBuilder content = new StringBuilder(); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + String line; + while ((line = reader.readLine()) != null) { + content.append(line); + } + reader.close(); + + // Parse NBT from JSON + NBTTagCompound nbt = NBTJsonUtil.Convert(content.toString()); + + BuiltInAnimation animation = new BuiltInAnimation(animName); + animation.readFromNBT(nbt); + + // Store with lowercase key for case-insensitive lookup + builtInAnimations.put(animName.toLowerCase(), animation); + } + } + private void loadAnimations() { animations.clear(); @@ -110,6 +212,12 @@ public class AnimationController implements IAnimationHandler { } public IAnimation saveAnimation(IAnimation animation) { + // Reject saving built-in animations + if (animation instanceof BuiltInAnimation) { + LogWriter.info("Cannot save built-in animation: " + animation.getName()); + return animation; + } + if (animation.getID() < 0) { animation.setID(getUnusedId()); while (hasName(animation.getName())) @@ -157,6 +265,12 @@ public class AnimationController implements IAnimationHandler { public void delete(String name) { Animation delete = getAnimationFromName(name); if (delete != null) { + // Reject deleting built-in animations + if (delete instanceof BuiltInAnimation) { + LogWriter.info("Cannot delete built-in animation: " + name); + return; + } + Animation foundAnimation = this.animations.remove(delete.getID()); if (foundAnimation != null && foundAnimation.name != null) { File dir = this.getDir(); @@ -175,7 +289,8 @@ public class AnimationController implements IAnimationHandler { } public void delete(int id) { - if (!this.animations.containsKey(id)) + // Only user animations have valid IDs (>= 0) + if (id < 0 || !this.animations.containsKey(id)) return; Animation foundAnimation = this.animations.remove(id); @@ -199,20 +314,83 @@ public class AnimationController implements IAnimationHandler { } public IAnimation get(String name) { + // Check built-in animations first (by name) + BuiltInAnimation builtIn = builtInAnimations.get(name.toLowerCase()); + if (builtIn != null) { + return builtIn; + } + // Then check user animations return getAnimationFromName(name); } + /** + * Get a user animation by ID. + * Built-in animations have no IDs and cannot be retrieved this way. + */ public IAnimation get(int id) { + // Only user animations have valid IDs + if (id < 0) { + return null; + } return this.animations.get(id); } + /** + * Get a built-in animation by name. + * @param name The animation name (case-insensitive) + * @return The built-in animation, or null if not found + */ + public BuiltInAnimation getBuiltInAnimation(String name) { + return builtInAnimations.get(name.toLowerCase()); + } + public IAnimation[] getAnimations() { ArrayList animations = new ArrayList<>(this.animations.values()); return animations.toArray(new IAnimation[0]); } + /** + * Get all built-in animations. + */ + public IAnimation[] getBuiltInAnimations() { + return builtInAnimations.values().toArray(new IAnimation[0]); + } + + /** + * Get all animations (both built-in and user-created). + */ + public IAnimation[] getAllAnimations() { + ArrayList all = new ArrayList<>(); + all.addAll(builtInAnimations.values()); + all.addAll(animations.values()); + return all.toArray(new IAnimation[0]); + } + + /** + * Check if an animation name is a built-in animation. + * @param name The animation name to check + * @return true if this is a built-in animation + */ + public boolean isBuiltIn(String name) { + return builtInAnimations.containsKey(name.toLowerCase()); + } + + /** + * @deprecated Built-in animations no longer use IDs. Use isBuiltIn(String name) instead. + */ + @Deprecated + public boolean isBuiltIn(int id) { + return false; // Built-in animations have no IDs + } + public Animation getAnimationFromName(String animation) { - for (Map.Entry entryAnimation : AnimationController.getInstance().animations.entrySet()) { + // Check built-in animations first (by name) + BuiltInAnimation builtIn = builtInAnimations.get(animation.toLowerCase()); + if (builtIn != null) { + return builtIn; + } + // Then check user animations + for (Map.Entry entryAnimation : animations.entrySet()) { if (entryAnimation.getValue().name.equalsIgnoreCase(animation)) { return entryAnimation.getValue(); } @@ -220,6 +398,13 @@ public class AnimationController implements IAnimationHandler { return null; } + /** + * Get names of all built-in animations. + */ + public String[] getBuiltInAnimationNames() { + return builtInAnimations.keySet().toArray(new String[0]); + } + public String[] getNames() { String[] names = new String[animations.size()]; int i = 0; diff --git a/src/main/java/noppes/npcs/controllers/data/BuiltInAnimation.java b/src/main/java/noppes/npcs/controllers/data/BuiltInAnimation.java new file mode 100644 index 000000000..a30923eac --- /dev/null +++ b/src/main/java/noppes/npcs/controllers/data/BuiltInAnimation.java @@ -0,0 +1,94 @@ +package noppes.npcs.controllers.data; + +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.api.handler.data.IAnimation; + +/** + * A read-only animation loaded from mod assets. + * Built-in animations are identified by name only, never by ID. + * They cannot be saved, deleted, or modified. + */ +public class BuiltInAnimation extends Animation { + + public BuiltInAnimation() { + super(); + this.id = -1; // No valid ID for built-in animations + } + + public BuiltInAnimation(String name) { + super(); + this.name = name; + this.id = -1; + } + + /** + * Built-in animations cannot be saved. + * @return this animation unchanged + */ + @Override + public IAnimation save() { + // Do nothing - built-in animations are read-only + return this; + } + + /** + * Built-in animations have no valid ID. + * @return always -1 + */ + @Override + public int getID() { + return -1; + } + + /** + * Built-in animations cannot have their ID changed. + */ + @Override + public void setID(int newID) { + // Ignore - built-in animations don't use IDs + } + + /** + * Check if this is a built-in animation. + * @return always true for BuiltInAnimation + */ + public boolean isBuiltIn() { + return true; + } + + /** + * Read animation data from NBT. + * Preserves the name set in constructor (from filename) rather than reading from NBT. + */ + @Override + public void readFromNBT(NBTTagCompound compound) { + // Preserve the name set in constructor - don't read from NBT + // (filename is the source of truth for built-in animations) + String preservedName = this.name; + + speed = compound.getFloat("Speed"); + smooth = compound.getByte("Smooth"); + loop = compound.getInteger("Loop"); + + frames.clear(); + net.minecraft.nbt.NBTTagList list = compound.getTagList("Frames", 10); + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound item = list.getCompoundTagAt(i); + Frame frame = new Frame(); + frame.parent = this; + frame.readFromNBT(item); + frames.add(frame); + } + + this.whileStanding = compound.getBoolean("WhileStanding"); + this.whileMoving = compound.getBoolean("WhileWalking"); + this.whileAttacking = compound.getBoolean("WhileAttacking"); + + this.currentFrame = compound.getInteger("CurrentFrame"); + this.currentFrameTime = compound.getInteger("CurrentFrameTime"); + + // Ensure name and ID are preserved + this.name = preservedName; + this.id = -1; + } +} diff --git a/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Active.json b/src/main/resources/assets/customnpcs/animations/Ability_Beam_Active.json similarity index 100% rename from src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Active.json rename to src/main/resources/assets/customnpcs/animations/Ability_Beam_Active.json diff --git a/src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Windup.json b/src/main/resources/assets/customnpcs/animations/Ability_Beam_Windup.json similarity index 100% rename from src/main/resources/internal/animations/ABILITYBEAM/Ability_Beam_Windup.json rename to src/main/resources/assets/customnpcs/animations/Ability_Beam_Windup.json diff --git a/src/main/resources/internal/animations/ABILITYORB/Ability_Orb_Windup.json b/src/main/resources/assets/customnpcs/animations/Ability_Orb_Windup.json similarity index 100% rename from src/main/resources/internal/animations/ABILITYORB/Ability_Orb_Windup.json rename to src/main/resources/assets/customnpcs/animations/Ability_Orb_Windup.json diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index fd148ea08..8e3f6a606 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -120,6 +120,8 @@ gui.range=Range gui.partly=Partially gui.copy=Copy gui.clear=Clear +gui.builtinAnimations=Built-in Animations +gui.customAnimations=Custom Animations gui.done=Done gui.paste=Paste gui.test=Test From c339e5edbcfe57c80a85704cc94b2bd62d10b3c8 Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 28 Jan 2026 16:57:49 -0500 Subject: [PATCH 6/9] Fix Built In Animation --- .../data/ability/type/AbilityDisc.java | 12 +- .../data/ability/type/AbilityEnergyBeam.java | 12 +- .../data/ability/type/AbilityLaserShot.java | 12 +- .../data/ability/type/AbilityOrb.java | 12 +- .../data/ability/type/AbilitySweeper.java | 12 +- .../kamkeel/npcs/network/PacketHandler.java | 2 + .../npcs/network/enums/EnumRequestPacket.java | 1 + .../animation/BuiltInAnimationGetPacket.java | 72 +++++++++++ .../gui/global/GuiNPCManageAnimations.java | 118 ++++++++++++++---- .../npcs/controllers/AnimationController.java | 23 ++-- .../assets/customnpcs/lang/en_US.lang | 2 + 11 files changed, 205 insertions(+), 73 deletions(-) create mode 100644 src/main/java/kamkeel/npcs/network/packets/request/animation/BuiltInAnimationGetPacket.java 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 d85720b6e..72b97839d 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 @@ -122,12 +122,8 @@ public class AbilityDisc extends Ability implements IAbilityDisc { discEntity.startMoving(target); } - // If movement is locked during active phase, keep ability active until entity dies - // Otherwise signal completion immediately - if (!lockMovement.locksActive()) { - discEntity = null; - signalCompletion(); - } + // Ability stays active until entity dies (prevents firing another while projectile is alive) + // Movement locking is handled separately by the base class } @Override @@ -157,8 +153,8 @@ public class AbilityDisc extends Ability implements IAbilityDisc { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // If we're tracking the entity for movement lock, check if it's dead - if (discEntity != null && discEntity.isDead) { + // Signal completion when entity dies + if (discEntity == null || discEntity.isDead) { discEntity = null; signalCompletion(); } 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 7ebd4bb7b..d4620c2bb 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 @@ -123,12 +123,8 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { beamEntity.startFiring(target); } - // If movement is locked during active phase, keep ability active until entity dies - // Otherwise signal completion immediately - if (!lockMovement.locksActive()) { - beamEntity = null; - signalCompletion(); - } + // Ability stays active until entity dies (prevents firing another while projectile is alive) + // Movement locking is handled separately by the base class } @Override @@ -161,8 +157,8 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // If we're tracking the entity for movement lock, check if it's dead - if (beamEntity != null && beamEntity.isDead) { + // Signal completion when entity dies + if (beamEntity == null || beamEntity.isDead) { beamEntity = null; signalCompletion(); } 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 a9cf74473..eeeebfa74 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 @@ -128,18 +128,14 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { world.spawnEntityInWorld(laserEntity); - // If movement is locked during active phase, keep ability active until entity dies - // Otherwise signal completion immediately - if (!lockMovement.locksActive()) { - laserEntity = null; - signalCompletion(); - } + // Ability stays active until entity dies (prevents firing another while projectile is alive) + // Movement locking is handled separately by the base class } @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // If we're tracking the entity for movement lock, check if it's dead - if (laserEntity != null && laserEntity.isDead) { + // Signal completion when entity dies + if (laserEntity == null || laserEntity.isDead) { laserEntity = null; signalCompletion(); } 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 d69a5c944..badd4aec8 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 @@ -121,12 +121,8 @@ public class AbilityOrb extends Ability implements IAbilityOrb { orbEntity.startMoving(target); } - // If movement is locked during active phase, keep ability active until entity dies - // Otherwise signal completion immediately - if (!lockMovement.locksActive()) { - orbEntity = null; - signalCompletion(); - } + // Ability stays active until entity dies (prevents firing another while projectile is alive) + // Movement locking is handled separately by the base class } @Override @@ -155,8 +151,8 @@ public class AbilityOrb extends Ability implements IAbilityOrb { @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // If we're tracking the entity for movement lock, check if it's dead - if (orbEntity != null && orbEntity.isDead) { + // Signal completion when entity dies + if (orbEntity == null || orbEntity.isDead) { orbEntity = null; signalCompletion(); } 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 78dae4fdc..d2dced201 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 @@ -100,18 +100,14 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper { lockOnTarget); world.spawnEntityInWorld(activeEntity); - // If movement is locked during active phase, keep ability active until entity dies - // Otherwise signal completion immediately - if (!lockMovement.locksActive()) { - activeEntity = null; - signalCompletion(); - } + // Ability stays active until entity dies (prevents firing another while projectile is alive) + // Movement locking is handled separately by the base class } @Override public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) { - // If we're tracking the entity for movement lock, check if it's dead - if (activeEntity != null && activeEntity.isDead) { + // Signal completion when entity dies + if (activeEntity == null || activeEntity.isDead) { activeEntity = null; signalCompletion(); } diff --git a/src/main/java/kamkeel/npcs/network/PacketHandler.java b/src/main/java/kamkeel/npcs/network/PacketHandler.java index d09882cfc..e659fef74 100644 --- a/src/main/java/kamkeel/npcs/network/PacketHandler.java +++ b/src/main/java/kamkeel/npcs/network/PacketHandler.java @@ -96,6 +96,7 @@ import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket; import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket; import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket; import kamkeel.npcs.network.packets.request.animation.AnimationsGetPacket; +import kamkeel.npcs.network.packets.request.animation.BuiltInAnimationGetPacket; import kamkeel.npcs.network.packets.request.bank.BankGetPacket; import kamkeel.npcs.network.packets.request.bank.BankRemovePacket; import kamkeel.npcs.network.packets.request.bank.BankSavePacket; @@ -469,6 +470,7 @@ public class PacketHandler { REQUEST_PACKET.registerPacket(new AnimationGetPacket()); REQUEST_PACKET.registerPacket(new AnimationRemovePacket()); REQUEST_PACKET.registerPacket(new AnimationSavePacket()); + REQUEST_PACKET.registerPacket(new BuiltInAnimationGetPacket()); // Moving Path REQUEST_PACKET.registerPacket(new MovingPathSavePacket()); diff --git a/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java b/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java index 005da40a7..bdd566785 100644 --- a/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java +++ b/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java @@ -93,6 +93,7 @@ public enum EnumRequestPacket { AnimationGet, AnimationRemove, AnimationSave, + BuiltInAnimationGet, RemoteNpcsGet, RemoteTpToNpc, diff --git a/src/main/java/kamkeel/npcs/network/packets/request/animation/BuiltInAnimationGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/animation/BuiltInAnimationGetPacket.java new file mode 100644 index 000000000..e214689d8 --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/request/animation/BuiltInAnimationGetPacket.java @@ -0,0 +1,72 @@ +package kamkeel.npcs.network.packets.request.animation; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumRequestPacket; +import kamkeel.npcs.network.packets.data.large.GuiDataPacket; +import kamkeel.npcs.util.ByteBufUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.controllers.AnimationController; +import noppes.npcs.controllers.data.Animation; +import noppes.npcs.controllers.data.BuiltInAnimation; + +import java.io.IOException; + +/** + * Packet to request a built-in animation by name. + * Built-in animations don't have IDs, so we fetch by name. + */ +public final class BuiltInAnimationGetPacket extends AbstractPacket { + public static String packetName = "Request|BuiltInAnimationGet"; + + private String animationName; + + public BuiltInAnimationGetPacket() { + } + + public BuiltInAnimationGetPacket(String animationName) { + this.animationName = animationName; + } + + @Override + public Enum getType() { + return EnumRequestPacket.BuiltInAnimationGet; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.REQUEST_PACKET; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + ByteBufUtils.writeString(out, animationName); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) + return; + + String name = ByteBufUtils.readString(in); + BuiltInAnimation animation = AnimationController.getInstance().getBuiltInAnimation(name); + if (animation != null) { + NBTTagCompound compound = animation.writeToNBT(); + // Mark as built-in so client knows + compound.setBoolean("BuiltIn", true); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java index 7d1fa84be..0141e931a 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageAnimations.java @@ -5,6 +5,7 @@ import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket; import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket; import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket; import kamkeel.npcs.network.packets.request.animation.AnimationsGetPacket; +import kamkeel.npcs.network.packets.request.animation.BuiltInAnimationGetPacket; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; @@ -37,13 +38,19 @@ import java.util.Vector; public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrollData, ICustomScrollListener, ITextfieldListener, IGuiData, ISubGuiListener, GuiYesNoCallback { private GuiCustomScroll scrollAnimations; - private HashMap data = new HashMap(); + private HashMap customData = new HashMap(); + private HashMap builtInData = new HashMap(); private Animation animation = new Animation(); public boolean playingAnimation = false; private long prevTick; private String selected = null; private String search = ""; + // Toggle between Custom (false) and Built-in (true) animations + private boolean showingBuiltIn = false; + // Track if current animation is built-in + private boolean currentIsBuiltIn = false; + public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save) { super(npc); this.setSave(save); @@ -58,8 +65,15 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol public void initGui() { super.initGui(); - this.addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); - this.addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); + // Add/Remove buttons - only show for custom animations + if (!showingBuiltIn) { + this.addButton(new GuiNpcButton(0, guiLeft + 368, guiTop + 8, 45, 20, "gui.add")); + this.addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 32, 45, 20, "gui.remove")); + } + + // Toggle button for Custom/Built-in - under Remove button + String toggleLabel = showingBuiltIn ? "gui.builtin" : "gui.custom"; + this.addButton(new GuiNpcButton(10, guiLeft + 368, guiTop + 56, 45, 20, toggleLabel)); if (scrollAnimations == null) { scrollAnimations = new GuiCustomScroll(this, 0, 0); @@ -68,13 +82,23 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol scrollAnimations.guiLeft = guiLeft + 220; scrollAnimations.guiTop = guiTop + 4; addScroll(scrollAnimations); + + // Search field addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 192, 143, 20, search)); - if (animation.id == -1) + // Update scroll list based on current view + scrollAnimations.setList(getSearchList()); + + if (animation.id == -1 && !currentIsBuiltIn) return; - addLabel(new GuiNpcLabel(10, "ID", guiLeft + 368, guiTop + 192)); - addLabel(new GuiNpcLabel(11, animation.id + "", guiLeft + 368, guiTop + 192 + 10)); + // ID label - only for custom animations + if (!currentIsBuiltIn) { + addLabel(new GuiNpcLabel(10, "ID", guiLeft + 368, guiTop + 192)); + addLabel(new GuiNpcLabel(11, animation.id + "", guiLeft + 368, guiTop + 192 + 10)); + } else { + addLabel(new GuiNpcLabel(10, "gui.builtin", guiLeft + 368, guiTop + 192)); + } AnimationData data = npc.display.animationData; if (!playingAnimation) { @@ -90,12 +114,13 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } } - if (animation != null) { + // Edit button - only for custom animations + if (animation != null && !currentIsBuiltIn) { this.addButton(new GuiNpcButton(100, guiLeft + 10, guiTop + 192, 45, 20, "gui.edit")); } String animTexture = "customnpcs:textures/gui/animation.png"; - int playButtonOffsetX = 140; + int playButtonOffsetX = currentIsBuiltIn ? 80 : 140; if (animation != null && !animation.frames.isEmpty()) { if (!this.playingAnimation || data.animation.paused) {//Play this.addLabel(new GuiNpcLabel(90, data.animation.paused ? "animation.paused" : "animation.stopped", guiLeft + playButtonOffsetX - 15, guiTop + 198)); @@ -151,12 +176,17 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol } } + private HashMap getCurrentData() { + return showingBuiltIn ? builtInData : customData; + } + private List getSearchList() { + HashMap data = getCurrentData(); if (search.isEmpty()) { - return new ArrayList(this.data.keySet()); + return new ArrayList(data.keySet()); } List list = new ArrayList(); - for (String name : this.data.keySet()) { + for (String name : data.keySet()) { if (name.toLowerCase().contains(search)) list.add(name); } @@ -167,16 +197,31 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol protected void actionPerformed(GuiButton guibutton) { GuiNpcButton button = (GuiNpcButton) guibutton; - if (button.id == 0) { + // Toggle button + if (button.id == 10) { + showingBuiltIn = !showingBuiltIn; + // Clear selection when switching views + selected = null; + animation = new Animation(); + currentIsBuiltIn = false; + scrollAnimations.clear(); + initGui(); + return; + } + + // Add button - only for custom + if (button.id == 0 && !showingBuiltIn) { save(); String name = "New"; - while (data.containsKey(name)) + while (customData.containsKey(name)) name += "_"; Animation animation = new Animation(-1, name); PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT())); } - if (button.id == 1) { - if (data.containsKey(scrollAnimations.getSelected())) { + + // Remove button - only for custom + if (button.id == 1 && !showingBuiltIn) { + if (customData.containsKey(scrollAnimations.getSelected())) { GuiYesNo guiyesno = new GuiYesNo(this, scrollAnimations.getSelected(), StatCollector.translateToLocal("gui.delete"), 1); displayGuiScreen(guiyesno); } @@ -204,7 +249,8 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol data.animation.paused = false; } - if (guibutton.id == 100) { + // Edit button - only for custom + if (guibutton.id == 100 && !currentIsBuiltIn) { NoppesUtil.openGUI(player, new GuiNPCEditAnimation(this, this.animation, npc)); } @@ -215,6 +261,10 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol public void setGuiData(NBTTagCompound compound) { this.animation = new Animation(); animation.readFromNBT(compound); + + // Check if this is a built-in animation + currentIsBuiltIn = compound.hasKey("BuiltIn") && compound.getBoolean("BuiltIn"); + setSelected(animation.name); npc.display.animationData.setAnimation(this.animation); this.playingAnimation = false; @@ -225,7 +275,13 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol @Override public void setData(Vector list, HashMap data, EnumScrollData type) { String name = scrollAnimations.getSelected(); - this.data = data; + + if (type == EnumScrollData.ANIMATIONS) { + this.customData = data; + } else if (type == EnumScrollData.BUILTIN_ANIMATIONS) { + this.builtInData = data; + } + scrollAnimations.setList(getSearchList()); if (name != null) @@ -242,28 +298,40 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) { if (guiCustomScroll.id == 0) { selected = scrollAnimations.getSelected(); - PacketClient.sendClient(new AnimationGetPacket(data.get(selected))); + HashMap data = getCurrentData(); + + if (showingBuiltIn) { + // Fetch built-in animation by name + PacketClient.sendClient(new BuiltInAnimationGetPacket(selected)); + } else { + // Fetch custom animation by ID + if (data.containsKey(selected)) { + PacketClient.sendClient(new AnimationGetPacket(data.get(selected))); + } + } } } public void save() { - if (selected != null && data.containsKey(selected) && animation != null) { + // Only save custom animations + if (selected != null && customData.containsKey(selected) && animation != null && !currentIsBuiltIn) { PacketClient.sendClient(new AnimationSavePacket(animation.writeToNBT())); } } @Override public void unFocused(GuiNpcTextField guiNpcTextField) { - if (animation.id == -1) + // Don't allow renaming built-in animations + if (animation.id == -1 || currentIsBuiltIn) return; if (guiNpcTextField.id == 0) { String name = guiNpcTextField.getText(); - if (!name.isEmpty() && !data.containsKey(name)) { + if (!name.isEmpty() && !customData.containsKey(name)) { String old = animation.name; - data.remove(animation.name); + customData.remove(animation.name); animation.name = name; - data.put(animation.name, animation.id); + customData.put(animation.name, animation.id); selected = name; scrollAnimations.replace(old, animation.name); } @@ -280,10 +348,12 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol if (!result) return; if (id == 1) { - if (data.containsKey(scrollAnimations.getSelected())) { - PacketClient.sendClient(new AnimationRemovePacket(data.get(selected))); + // Only delete custom animations + if (customData.containsKey(scrollAnimations.getSelected()) && !showingBuiltIn) { + PacketClient.sendClient(new AnimationRemovePacket(customData.get(selected))); scrollAnimations.clear(); animation = new Animation(); + currentIsBuiltIn = false; initGui(); } } diff --git a/src/main/java/noppes/npcs/controllers/AnimationController.java b/src/main/java/noppes/npcs/controllers/AnimationController.java index e5e11d666..c6837b6c7 100644 --- a/src/main/java/noppes/npcs/controllers/AnimationController.java +++ b/src/main/java/noppes/npcs/controllers/AnimationController.java @@ -314,13 +314,18 @@ public class AnimationController implements IAnimationHandler { } public IAnimation get(String name) { - // Check built-in animations first (by name) + // Check user/custom animations first (allows overriding built-in) + for (Map.Entry entry : animations.entrySet()) { + if (entry.getValue().name.equalsIgnoreCase(name)) { + return entry.getValue(); + } + } + // Then check built-in animations BuiltInAnimation builtIn = builtInAnimations.get(name.toLowerCase()); if (builtIn != null) { return builtIn; } - // Then check user animations - return getAnimationFromName(name); + return null; } /** @@ -384,17 +389,17 @@ public class AnimationController implements IAnimationHandler { } public Animation getAnimationFromName(String animation) { - // Check built-in animations first (by name) - BuiltInAnimation builtIn = builtInAnimations.get(animation.toLowerCase()); - if (builtIn != null) { - return builtIn; - } - // Then check user animations + // Check user/custom animations first (allows overriding built-in) for (Map.Entry entryAnimation : animations.entrySet()) { if (entryAnimation.getValue().name.equalsIgnoreCase(animation)) { return entryAnimation.getValue(); } } + // Then check built-in animations + BuiltInAnimation builtIn = builtInAnimations.get(animation.toLowerCase()); + if (builtIn != null) { + return builtIn; + } return null; } diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 8e3f6a606..de60eda25 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -120,6 +120,8 @@ gui.range=Range gui.partly=Partially gui.copy=Copy gui.clear=Clear +gui.builtin=Built-in +gui.custom=Custom gui.builtinAnimations=Built-in Animations gui.customAnimations=Custom Animations gui.done=Done From 67237e794fc7b39ce4da4d75554fca7b5e446a7c Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 28 Jan 2026 17:16:59 -0500 Subject: [PATCH 7/9] Fix Defaults / Syncing --- .../npcs/entity/EntityAbilityBeam.java | 8 +- .../npcs/entity/EntityAbilityDisc.java | 6 +- .../npcs/entity/EntityAbilityLaser.java | 3 +- .../kamkeel/npcs/entity/EntityAbilityOrb.java | 6 +- .../npcs/entity/EntityAbilityProjectile.java | 6 - .../gui/advanced/SubGuiAbilityConfig.java | 45 +++- .../animations/Ability_Beam_Active.json | 202 +++-------------- .../animations/Ability_Beam_Windup.json | 206 ++++++++++++------ .../assets/customnpcs/lang/en_US.lang | 2 + 9 files changed, 219 insertions(+), 265 deletions(-) diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java index 70aaf5254..60f7fd656 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java @@ -68,7 +68,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { private static final int DW_CHARGING = 20; // Debug logging - private static final boolean DEBUG_LOGGING = true; + private static final boolean DEBUG_LOGGING = false; public EntityAbilityBeam(World world) { super(world); @@ -560,12 +560,10 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { Vec3 currentPos = Vec3.createVectorHelper(prevHeadWorldX, prevHeadWorldY, prevHeadWorldZ); Vec3 nextPos = Vec3.createVectorHelper(headX, headY, headZ); - MovingObjectPosition blockHit = worldObj.rayTraceBlocks(currentPos, nextPos); + // Use full raytrace that doesn't stop at liquids and checks all blocks + MovingObjectPosition blockHit = worldObj.func_147447_a(currentPos, nextPos, false, true, false); if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - if (DEBUG_LOGGING) { - LogWriter.info("[Beam] DEAD: Block collision at tick " + ticksExisted); - } hasHit = true; if (explosive) { posX = blockHit.hitVec.xCoord; diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java index b1f57f9c9..0c5b10ccb 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java @@ -413,11 +413,15 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { private void checkBlockCollision() { Vec3 currentPos = Vec3.createVectorHelper(posX, posY, posZ); Vec3 nextPos = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition blockHit = worldObj.rayTraceBlocks(currentPos, nextPos); + // Use full raytrace that doesn't stop at liquids and checks all blocks + MovingObjectPosition blockHit = worldObj.func_147447_a(currentPos, nextPos, false, true, false); if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { hasHit = true; if (explosive) { + posX = blockHit.hitVec.xCoord; + posY = blockHit.hitVec.yCoord; + posZ = blockHit.hitVec.zCoord; doExplosion(); } this.setDead(); diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java index 7ad1f0d45..256a4faf7 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java @@ -163,7 +163,8 @@ public class EntityAbilityLaser extends EntityAbilityProjectile { private void checkBlockCollision() { Vec3 start = Vec3.createVectorHelper(startX, startY, startZ); Vec3 end = Vec3.createVectorHelper(endX, endY, endZ); - MovingObjectPosition blockHit = worldObj.rayTraceBlocks(start, end); + // Use full raytrace that doesn't stop at liquids and checks all blocks + MovingObjectPosition blockHit = worldObj.func_147447_a(start, end, false, true, false); if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { // Laser stops at block diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java index 18a0c8503..24ca69ef8 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java @@ -298,11 +298,15 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { private void checkBlockCollision() { Vec3 currentPos = Vec3.createVectorHelper(posX, posY, posZ); Vec3 nextPos = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - MovingObjectPosition blockHit = worldObj.rayTraceBlocks(currentPos, nextPos); + // Use full raytrace that doesn't stop at liquids and checks all blocks + MovingObjectPosition blockHit = worldObj.func_147447_a(currentPos, nextPos, false, true, false); if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { hasHit = true; if (explosive) { + posX = blockHit.hitVec.xCoord; + posY = blockHit.hitVec.yCoord; + posZ = blockHit.hitVec.zCoord; doExplosion(); } this.setDead(); diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java index 32c5796bd..5c418d640 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java @@ -215,9 +215,6 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA // Check lifespan using world time (survives chunk unload/reload) if (deathWorldTime > 0 && worldObj.getTotalWorldTime() >= deathWorldTime) { - if (!worldObj.isRemote) { - noppes.npcs.LogWriter.info("[Projectile:" + this.getClass().getSimpleName() + "] DEAD: Lifetime exceeded. worldTime=" + worldObj.getTotalWorldTime() + " deathTime=" + deathWorldTime); - } this.setDead(); return; } @@ -229,9 +226,6 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA } if (hasHit) { - if (!worldObj.isRemote) { - noppes.npcs.LogWriter.info("[Projectile:" + this.getClass().getSimpleName() + "] DEAD: hasHit=true at tick " + ticksExisted); - } this.setDead(); return; } 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 a4fef92ef..684138891 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java @@ -66,6 +66,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi protected int cooldownTicks; protected int windUpTicks; protected int dazedTicks; + protected boolean syncWindupWithAnimation = true; // Sync windup ticks with animation duration // ═══════════════════════════════════════════════════════════════════════════ // CACHED VALUES - Target Tab @@ -282,16 +283,27 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi 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)); - GuiNpcTextField windupField = new GuiNpcTextField(11, this, fontRendererObj, col1FieldX, y, 40, 20, String.valueOf(windUpTicks)); - windupField.setIntegersOnly(); - windupField.setMinMaxDefault(0, 1000, 20); - addTextField(windupField); - // Sync button - only show if windup animation is selected (either by name or ID) - if (windUpAnimationId >= 0 || (windUpAnimationName != null && !windUpAnimationName.isEmpty())) { - GuiNpcButton syncBtn = new GuiNpcButton(17, guiLeft + 115, y, 40, 20, "gui.sync"); + // 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, String.valueOf(windUpTicks)); + windupField.setIntegersOnly(); + windupField.setMinMaxDefault(0, 1000, 20); + addTextField(windupField); + } else { + // Show calculated value as label when synced + addLabel(new GuiNpcLabel(11, String.valueOf(windUpTicks), col1FieldX + 5, y + 5)); + } + + // 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); } @@ -654,8 +666,13 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi } else if (id == 16) { lockMovement = LockMovementType.fromOrdinal(((GuiNpcButton) guibutton).getValue()); } else if (id == 17) { - // Sync windup ticks with animation duration - syncWindupWithAnimation(); + // Toggle sync on/off + syncWindupWithAnimation = !syncWindupWithAnimation; + if (syncWindupWithAnimation) { + // Calculate windup ticks from animation when turning sync on + calculateWindupFromAnimation(); + } + initGui(); } // Target tab - Targeting mode @@ -896,6 +913,12 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi 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); @@ -968,9 +991,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi // ═══════════════════════════════════════════════════════════════════════════ /** - * Syncs windup ticks with the selected windup animation's total duration. + * Calculates windup ticks from the selected windup animation's total duration. */ - private void syncWindupWithAnimation() { + private void calculateWindupFromAnimation() { if (AnimationController.Instance == null) { return; } diff --git a/src/main/resources/assets/customnpcs/animations/Ability_Beam_Active.json b/src/main/resources/assets/customnpcs/animations/Ability_Beam_Active.json index eb9516f38..466b9163c 100644 --- a/src/main/resources/assets/customnpcs/animations/Ability_Beam_Active.json +++ b/src/main/resources/assets/customnpcs/animations/Ability_Beam_Active.json @@ -1,5 +1,5 @@ { - "Loop": -1, + "Loop": 0, "Speed": 1.0f, "Frames": [ { @@ -7,87 +7,6 @@ "Comment": "", "Speed": 1.0f, "FrameParts": [ - { - "Pivot2": -5.0f, - "Part": "LEFT_ARM", - "Rotation1": 107.0f, - "Rotation0": -94.0f, - "Pivot0": -5.0f, - "Pivot1": 3.0f, - "Rotation2": -31.0f - }, - { - "Pivot2": 0.0f, - "Part": "RIGHT_ARM", - "Rotation1": 88.0f, - "Rotation0": -56.0f, - "Pivot0": 1.0f, - "Pivot1": 0.0f, - "Rotation2": -18.0f - }, - { - "Pivot2": -3.0f, - "Part": "HEAD", - "Rotation1": 12.0f, - "Rotation0": 18.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": -6.0f - }, - { - "Pivot2": 0.0f, - "Part": "RIGHT_LEG", - "Rotation1": 56.0f, - "Rotation0": 6.0f, - "Pivot0": -2.0f, - "Pivot1": 0.0f, - "Rotation2": 0.0f - }, - { - "Pivot2": -3.0f, - "Part": "BODY", - "Rotation1": 25.0f, - "Rotation0": 18.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": 0.0f - }, - { - "Pivot2": -5.0f, - "Part": "LEFT_LEG", - "Rotation1": -25.0f, - "Rotation0": 12.0f, - "Pivot0": 2.0f, - "Pivot1": 0.0f, - "Rotation2": -6.0f - }, - { - "Pivot2": 0.0f, - "Part": "FULL_MODEL", - "Rotation1": 25.0f, - "Rotation0": 0.0f, - "Pivot0": 0.0f, - "Pivot1": 0.0f, - "Rotation2": 0.0f - } - ], - "Smooth": 0b, - "Duration": 5 - }, - { - "ColorMarker": 16777215, - "Comment": "", - "Speed": 2.0f, - "FrameParts": [ - { - "Pivot2": -5.0f, - "Part": "LEFT_ARM", - "Rotation1": 12.0f, - "Rotation0": -75.0f, - "Pivot0": -2.0f, - "Pivot1": 3.0f, - "Rotation2": 50.0f - }, { "Pivot2": -5.0f, "Part": "RIGHT_ARM", @@ -97,6 +16,33 @@ "Pivot1": 2.0f, "Rotation2": 50.0f }, + { + "Pivot2": -6.0f, + "Part": "LEFT_LEG", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, { "Pivot2": -3.0f, "Part": "HEAD", @@ -115,42 +61,6 @@ "Pivot1": 0.0f, "Rotation2": 0.0f }, - { - "Pivot2": -3.0f, - "Part": "BODY", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": 0.0f - }, - { - "Pivot2": -6.0f, - "Part": "LEFT_LEG", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": 0.0f, - "Pivot1": 0.0f, - "Rotation2": -6.0f - }, - { - "Pivot2": 0.0f, - "Part": "FULL_MODEL", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": 0.0f, - "Pivot1": 0.0f, - "Rotation2": 0.0f - } - ], - "Smooth": 0b, - "Duration": 5 - }, - { - "ColorMarker": 16777215, - "Comment": "", - "Speed": 0.75f, - "FrameParts": [ { "Pivot2": -5.0f, "Part": "LEFT_ARM", @@ -159,64 +69,10 @@ "Pivot0": -2.0f, "Pivot1": 3.0f, "Rotation2": 50.0f - }, - { - "Pivot2": -5.0f, - "Part": "RIGHT_ARM", - "Rotation1": -18.0f, - "Rotation0": -107.0f, - "Pivot0": -1.0f, - "Pivot1": 2.0f, - "Rotation2": 50.0f - }, - { - "Pivot2": -3.0f, - "Part": "HEAD", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": 0.0f - }, - { - "Pivot2": -4.0f, - "Part": "RIGHT_LEG", - "Rotation1": 56.0f, - "Rotation0": 18.0f, - "Pivot0": -4.0f, - "Pivot1": 0.0f, - "Rotation2": 0.0f - }, - { - "Pivot2": -3.0f, - "Part": "BODY", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": 0.0f - }, - { - "Pivot2": -6.0f, - "Part": "LEFT_LEG", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": 0.0f, - "Pivot1": 0.0f, - "Rotation2": -6.0f - }, - { - "Pivot2": 0.0f, - "Part": "FULL_MODEL", - "Rotation1": 0.0f, - "Rotation0": 0.0f, - "Pivot0": 0.0f, - "Pivot1": 0.0f, - "Rotation2": 0.0f } ], "Smooth": 0b, - "Duration": 20 + "Duration": 30 } ], "CurrentFrameTime": 0, diff --git a/src/main/resources/assets/customnpcs/animations/Ability_Beam_Windup.json b/src/main/resources/assets/customnpcs/animations/Ability_Beam_Windup.json index 6c53e1eab..62e54167a 100644 --- a/src/main/resources/assets/customnpcs/animations/Ability_Beam_Windup.json +++ b/src/main/resources/assets/customnpcs/animations/Ability_Beam_Windup.json @@ -7,33 +7,6 @@ "Comment": "", "Speed": 0.5f, "FrameParts": [ - { - "Pivot2": -5.0f, - "Part": "LEFT_ARM", - "Rotation1": 94.0f, - "Rotation0": -94.0f, - "Pivot0": -4.0f, - "Pivot1": 3.0f, - "Rotation2": -31.0f - }, - { - "Pivot2": 0.0f, - "Part": "RIGHT_ARM", - "Rotation1": 75.0f, - "Rotation0": -56.0f, - "Pivot0": 1.0f, - "Pivot1": 0.0f, - "Rotation2": -18.0f - }, - { - "Pivot2": -3.0f, - "Part": "HEAD", - "Rotation1": 0.0f, - "Rotation0": 18.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": -6.0f - }, { "Pivot2": 0.0f, "Part": "RIGHT_LEG", @@ -54,11 +27,20 @@ }, { "Pivot2": -5.0f, - "Part": "LEFT_LEG", - "Rotation1": -25.0f, - "Rotation0": 12.0f, - "Pivot0": 2.0f, - "Pivot1": 0.0f, + "Part": "LEFT_ARM", + "Rotation1": 94.0f, + "Rotation0": -94.0f, + "Pivot0": -4.0f, + "Pivot1": 3.0f, + "Rotation2": -31.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 0.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, "Rotation2": -6.0f }, { @@ -69,6 +51,24 @@ "Pivot0": 0.0f, "Pivot1": 0.0f, "Rotation2": 0.0f + }, + { + "Pivot2": -5.0f, + "Part": "LEFT_LEG", + "Rotation1": -25.0f, + "Rotation0": 12.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_ARM", + "Rotation1": 75.0f, + "Rotation0": -56.0f, + "Pivot0": 1.0f, + "Pivot1": 0.0f, + "Rotation2": -18.0f } ], "Smooth": 0b, @@ -77,35 +77,8 @@ { "ColorMarker": 16777215, "Comment": "", - "Speed": 0.5f, + "Speed": 0.25f, "FrameParts": [ - { - "Pivot2": -5.0f, - "Part": "LEFT_ARM", - "Rotation1": 107.0f, - "Rotation0": -94.0f, - "Pivot0": -5.0f, - "Pivot1": 3.0f, - "Rotation2": -31.0f - }, - { - "Pivot2": 0.0f, - "Part": "RIGHT_ARM", - "Rotation1": 88.0f, - "Rotation0": -56.0f, - "Pivot0": 1.0f, - "Pivot1": 0.0f, - "Rotation2": -18.0f - }, - { - "Pivot2": -3.0f, - "Part": "HEAD", - "Rotation1": 12.0f, - "Rotation0": 18.0f, - "Pivot0": -1.0f, - "Pivot1": 1.0f, - "Rotation2": -6.0f - }, { "Pivot2": 0.0f, "Part": "RIGHT_LEG", @@ -126,11 +99,20 @@ }, { "Pivot2": -5.0f, - "Part": "LEFT_LEG", - "Rotation1": -25.0f, - "Rotation0": 12.0f, - "Pivot0": 2.0f, - "Pivot1": 0.0f, + "Part": "LEFT_ARM", + "Rotation1": 107.0f, + "Rotation0": -94.0f, + "Pivot0": -5.0f, + "Pivot1": 3.0f, + "Rotation2": -31.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 12.0f, + "Rotation0": 18.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, "Rotation2": -6.0f }, { @@ -141,14 +123,104 @@ "Pivot0": 0.0f, "Pivot1": 0.0f, "Rotation2": 0.0f + }, + { + "Pivot2": -5.0f, + "Part": "LEFT_LEG", + "Rotation1": -25.0f, + "Rotation0": 12.0f, + "Pivot0": 2.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": 0.0f, + "Part": "RIGHT_ARM", + "Rotation1": 88.0f, + "Rotation0": -56.0f, + "Pivot0": 1.0f, + "Pivot1": 0.0f, + "Rotation2": -18.0f } ], "Smooth": 0b, - "Duration": 35 + "Duration": 30 + }, + { + "ColorMarker": 16777215, + "Comment": "", + "Speed": 2.0f, + "FrameParts": [ + { + "Pivot2": -4.0f, + "Part": "RIGHT_LEG", + "Rotation1": 56.0f, + "Rotation0": 18.0f, + "Pivot0": -4.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -3.0f, + "Part": "BODY", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -5.0f, + "Part": "LEFT_ARM", + "Rotation1": 12.0f, + "Rotation0": -75.0f, + "Pivot0": -2.0f, + "Pivot1": 3.0f, + "Rotation2": 50.0f + }, + { + "Pivot2": -3.0f, + "Part": "HEAD", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": -1.0f, + "Pivot1": 1.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": 0.0f, + "Part": "FULL_MODEL", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": 0.0f + }, + { + "Pivot2": -6.0f, + "Part": "LEFT_LEG", + "Rotation1": 0.0f, + "Rotation0": 0.0f, + "Pivot0": 0.0f, + "Pivot1": 0.0f, + "Rotation2": -6.0f + }, + { + "Pivot2": -5.0f, + "Part": "RIGHT_ARM", + "Rotation1": -18.0f, + "Rotation0": -107.0f, + "Pivot0": -1.0f, + "Pivot1": 2.0f, + "Rotation2": 50.0f + } + ], + "Smooth": 0b, + "Duration": 5 } ], "CurrentFrameTime": 0, - "CurrentFrame": 0, + "CurrentFrame": 1, "Smooth": 0b, "ID": 1, "WhileAttacking": 1b, diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index de60eda25..50c150624 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -1519,6 +1519,8 @@ ability.maxRange=Max Range ability.timing=Timing (ticks) ability.cooldown=Cooldown ability.windup=Wind Up +ability.syncOn=Sync: On +ability.syncOff=Sync: Off ability.dazed=Dazed Ticks ability.interruptible=Interruptible ability.threshold=Threshold From 216a3dbbf8f088f1075c33f42c2764b322c6b431 Mon Sep 17 00:00:00 2001 From: Vidal Date: Wed, 28 Jan 2026 20:49:16 -0300 Subject: [PATCH 8/9] Added alpha to all abilities except beam --- .../client/renderer/RenderAbilityDisc.java | 2 +- .../data/ability/type/AbilityDisc.java | 7 +++- .../data/ability/type/AbilityEnergyBeam.java | 7 +++- .../data/ability/type/AbilityLaserShot.java | 7 +++- .../data/ability/type/AbilityOrb.java | 13 +++++- .../npcs/entity/EntityAbilityBeam.java | 16 ++++---- .../npcs/entity/EntityAbilityDisc.java | 12 +++--- .../npcs/entity/EntityAbilityLaser.java | 8 ++-- .../kamkeel/npcs/entity/EntityAbilityOrb.java | 12 +++--- .../npcs/entity/EntityAbilityProjectile.java | 14 +++++-- .../advanced/ability/SubGuiAbilityDisc.java | 40 ++++++++++++------- .../ability/SubGuiAbilityEnergyBeam.java | 31 +++++++++----- .../ability/SubGuiAbilityLaserShot.java | 27 ++++++++----- .../advanced/ability/SubGuiAbilityOrb.java | 39 +++++++++++------- 14 files changed, 154 insertions(+), 81 deletions(-) diff --git a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityDisc.java b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityDisc.java index fdd80689a..20486d70e 100644 --- a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityDisc.java +++ b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityDisc.java @@ -54,7 +54,7 @@ public class RenderAbilityDisc extends RenderAbilityProjectile { if (disc.isOuterColorEnabled()) { float outerScale = innerScale + disc.getOuterColorWidth(); GL11.glDepthMask(false); - renderFlatSquare(disc.getOuterColor(), 0.5f, radius * outerScale, thickness); + renderFlatSquare(disc.getOuterColor(), disc.getOuterColorAlpha(), radius * outerScale, thickness); GL11.glDepthMask(true); } 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 72b97839d..e783b3a42 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 @@ -62,6 +62,7 @@ public class AbilityDisc extends Ability implements IAbilityDisc { private int innerColor = 0xFFFFFF; private int outerColor = 0xFF8800; private float outerColorWidth = 0.4f; // Additive offset from inner size + private float outerColorAlpha = 0.5f; // Additive offset from inner size private boolean outerColorEnabled = true; private float rotationSpeed = 5.0f; @@ -135,7 +136,7 @@ public class AbilityDisc extends Ability implements IAbilityDisc { // Create disc in charging mode - follows NPC based on anchor point during windup discEntity = EntityAbilityDisc.createCharging( world, npc, target, - discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, boomerang, boomerangDelay, @@ -224,6 +225,7 @@ public class AbilityDisc extends Ability implements IAbilityDisc { nbt.setInteger("innerColor", innerColor); nbt.setInteger("outerColor", outerColor); nbt.setFloat("outerColorWidth", outerColorWidth); + nbt.setFloat("outerColorAlpha", outerColorAlpha); nbt.setBoolean("outerColorEnabled", outerColorEnabled); nbt.setFloat("rotationSpeed", rotationSpeed); nbt.setBoolean("lightningEffect", lightningEffect); @@ -256,6 +258,7 @@ public class AbilityDisc extends Ability implements IAbilityDisc { this.innerColor = nbt.hasKey("innerColor") ? nbt.getInteger("innerColor") : 0xFFFFFF; this.outerColor = nbt.hasKey("outerColor") ? nbt.getInteger("outerColor") : 0xFF8800; this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f; + this.outerColorAlpha = nbt.hasKey("outerColorAlpha") ? nbt.getFloat("outerColorAlpha") : 0.5f; this.outerColorEnabled = !nbt.hasKey("outerColorEnabled") || nbt.getBoolean("outerColorEnabled"); this.rotationSpeed = nbt.hasKey("rotationSpeed") ? nbt.getFloat("rotationSpeed") : 5.0f; this.lightningEffect = nbt.hasKey("lightningEffect") && nbt.getBoolean("lightningEffect"); @@ -309,6 +312,8 @@ public class AbilityDisc extends Ability implements IAbilityDisc { public void setOuterColor(int outerColor) { this.outerColor = outerColor; } public float getOuterColorWidth() { return outerColorWidth; } public void setOuterColorWidth(float outerColorWidth) { this.outerColorWidth = outerColorWidth; } + public float getOuterColorAlpha() { return outerColorAlpha; } + public void setOuterColorAlpha(float outerColorAlpha) { this.outerColorAlpha = outerColorAlpha; } public boolean isOuterColorEnabled() { return outerColorEnabled; } public void setOuterColorEnabled(boolean outerColorEnabled) { this.outerColorEnabled = outerColorEnabled; } public float getRotationSpeed() { return rotationSpeed; } 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 d4620c2bb..7a81da548 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 @@ -60,6 +60,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { private int innerColor = 0xFFFFFF; private int outerColor = 0x00AAFF; private float outerColorWidth = 0.4f; // Additive offset from inner size + private float outerColorAlpha = 0.5f; private boolean outerColorEnabled = true; private float rotationSpeed = 6.0f; @@ -138,7 +139,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { // Create beam in charging mode - follows NPC based on anchor point during windup beamEntity = EntityAbilityBeam.createCharging( world, npc, target, - beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, @@ -226,6 +227,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { nbt.setInteger("innerColor", innerColor); nbt.setInteger("outerColor", outerColor); nbt.setFloat("outerColorWidth", outerColorWidth); + nbt.setFloat("outerColorAlpha", outerColorAlpha); nbt.setBoolean("outerColorEnabled", outerColorEnabled); nbt.setFloat("rotationSpeed", rotationSpeed); nbt.setBoolean("lightningEffect", lightningEffect); @@ -256,6 +258,7 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { this.innerColor = nbt.hasKey("innerColor") ? nbt.getInteger("innerColor") : 0xFFFFFF; this.outerColor = nbt.hasKey("outerColor") ? nbt.getInteger("outerColor") : 0x00AAFF; this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f; + this.outerColorAlpha = nbt.hasKey("outerColorAlpha") ? nbt.getFloat("outerColorAlpha") : 0.5f; this.outerColorEnabled = !nbt.hasKey("outerColorEnabled") || nbt.getBoolean("outerColorEnabled"); this.rotationSpeed = nbt.hasKey("rotationSpeed") ? nbt.getFloat("rotationSpeed") : 6.0f; this.lightningEffect = nbt.hasKey("lightningEffect") && nbt.getBoolean("lightningEffect"); @@ -305,6 +308,8 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { public void setOuterColor(int outerColor) { this.outerColor = outerColor; } public float getOuterColorWidth() { return outerColorWidth; } public void setOuterColorWidth(float outerColorWidth) { this.outerColorWidth = outerColorWidth; } + public float getOuterColorAlpha() { return outerColorAlpha; } + public void setOuterColorAlpha(float outerColorAlpha) { this.outerColorAlpha = outerColorAlpha; } public boolean isOuterColorEnabled() { return outerColorEnabled; } public void setOuterColorEnabled(boolean outerColorEnabled) { this.outerColorEnabled = outerColorEnabled; } public float getRotationSpeed() { return rotationSpeed; } 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 eeeebfa74..7ead64c8e 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 @@ -49,6 +49,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { private int innerColor = 0xFFFFFF; private int outerColor = 0xFF0000; private float outerColorWidth = 0.4f; // Additive offset from inner width + private float outerColorAlpha = 0.5f; private boolean outerColorEnabled = true; // Lightning effect properties @@ -117,7 +118,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { laserEntity = new EntityAbilityLaser( world, npc, target, spawnX, spawnY, spawnZ, - laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, + laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, damage, knockback, knockbackUp, expansionSpeed, lingerTicks, explosive, explosionRadius, explosionDamageFalloff, @@ -177,6 +178,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { nbt.setInteger("innerColor", innerColor); nbt.setInteger("outerColor", outerColor); nbt.setFloat("outerColorWidth", outerColorWidth); + nbt.setFloat("outerColorAlpha", outerColorAlpha); nbt.setBoolean("outerColorEnabled", outerColorEnabled); nbt.setBoolean("lightningEffect", lightningEffect); nbt.setFloat("lightningDensity", lightningDensity); @@ -202,6 +204,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { this.innerColor = nbt.hasKey("innerColor") ? nbt.getInteger("innerColor") : 0xFFFFFF; this.outerColor = nbt.hasKey("outerColor") ? nbt.getInteger("outerColor") : 0xFF0000; this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f; + this.outerColorAlpha = nbt.hasKey("outerColorAlpha") ? nbt.getFloat("outerColorAlpha") : 0.5f; this.outerColorEnabled = !nbt.hasKey("outerColorEnabled") || nbt.getBoolean("outerColorEnabled"); this.lightningEffect = nbt.hasKey("lightningEffect") && nbt.getBoolean("lightningEffect"); this.lightningDensity = nbt.hasKey("lightningDensity") ? nbt.getFloat("lightningDensity") : 0.15f; @@ -243,6 +246,8 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { public void setOuterColor(int outerColor) { this.outerColor = outerColor; } public float getOuterColorWidth() { return outerColorWidth; } public void setOuterColorWidth(float outerColorWidth) { this.outerColorWidth = outerColorWidth; } + public float getOuterColorAlpha() { return outerColorAlpha; } + public void setOuterColorAlpha(float outerColorAlpha) { this.outerColorAlpha = outerColorAlpha; } public boolean isOuterColorEnabled() { return outerColorEnabled; } public void setOuterColorEnabled(boolean outerColorEnabled) { this.outerColorEnabled = outerColorEnabled; } public boolean hasLightningEffect() { return lightningEffect; } 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 badd4aec8..4ccbdcf12 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 @@ -58,6 +58,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb { private int innerColor = 0xFFFFFF; // White core private int outerColor = 0x8888FF; // Light blue glow private float outerColorWidth = 0.4f; // Additive offset from inner size + private float outerColorAlpha = 0.5f; private boolean outerColorEnabled = true; // Whether to render outer glow private float rotationSpeed = 4.0f; // Degrees per tick @@ -134,7 +135,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb { // Create orb in charging mode - follows NPC based on anchor point during windup orbEntity = EntityAbilityOrb.createCharging( world, npc, target, - orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, orbSpeed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, @@ -220,6 +221,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb { nbt.setInteger("innerColor", innerColor); nbt.setInteger("outerColor", outerColor); nbt.setFloat("outerColorWidth", outerColorWidth); + nbt.setFloat("outerColorAlpha", outerColorAlpha); nbt.setBoolean("outerColorEnabled", outerColorEnabled); nbt.setFloat("rotationSpeed", rotationSpeed); nbt.setBoolean("lightningEffect", lightningEffect); @@ -250,6 +252,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb { this.innerColor = nbt.hasKey("innerColor") ? nbt.getInteger("innerColor") : 0xFFFFFF; this.outerColor = nbt.hasKey("outerColor") ? nbt.getInteger("outerColor") : 0x8888FF; this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f; + this.outerColorAlpha = nbt.hasKey("outerColorAlpha") ? nbt.getFloat("outerColorAlpha") : 0.5f; this.outerColorEnabled = !nbt.hasKey("outerColorEnabled") || nbt.getBoolean("outerColorEnabled"); this.rotationSpeed = nbt.hasKey("rotationSpeed") ? nbt.getFloat("rotationSpeed") : 4.0f; this.lightningEffect = nbt.hasKey("lightningEffect") && nbt.getBoolean("lightningEffect"); @@ -412,6 +415,14 @@ public class AbilityOrb extends Ability implements IAbilityOrb { this.outerColorWidth = outerColorWidth; } + public float getOuterColorAlpha() { + return outerColorAlpha; + } + + public void setOuterColorAlpha(float outerColorAlpha) { + this.outerColorAlpha = outerColorAlpha; + } + public boolean isOuterColorEnabled() { return outerColorEnabled; } diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java index 60f7fd656..2e5926e67 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java @@ -104,14 +104,14 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { public EntityAbilityBeam(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float beamWidth, float headSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, int stunDuration, int slowDuration, int slowLevel, float maxDistance, int maxLifetime) { this(world, owner, target, x, y, z, - beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, @@ -124,7 +124,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { public EntityAbilityBeam(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float beamWidth, float headSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, @@ -132,7 +132,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { float maxDistance, int maxLifetime, boolean lightningEffect, float lightningDensity, float lightningRadius) { this(world, owner, target, x, y, z, - beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, @@ -148,7 +148,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { public EntityAbilityBeam(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float beamWidth, float headSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, @@ -160,7 +160,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { // Initialize base properties with lightning initProjectile(owner, target, x, y, z, - headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, @@ -221,7 +221,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { */ public static EntityAbilityBeam createCharging(World world, EntityNPCInterface owner, EntityLivingBase target, float beamWidth, float headSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, @@ -239,7 +239,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { EntityAbilityBeam beam = new EntityAbilityBeam( world, owner, target, spawnX, spawnY, spawnZ, - beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java index 0c5b10ccb..f63014158 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java @@ -82,7 +82,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { public EntityAbilityDisc(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float discRadius, float discThickness, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean boomerang, int boomerangDelay, @@ -90,7 +90,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { int stunDuration, int slowDuration, int slowLevel, float maxDistance, int maxLifetime) { this(world, owner, target, x, y, z, - discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, boomerang, boomerangDelay, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, @@ -103,7 +103,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { public EntityAbilityDisc(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float discRadius, float discThickness, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean boomerang, int boomerangDelay, @@ -115,7 +115,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { // Initialize base properties with lightning (use discRadius as size for base) initProjectile(owner, target, x, y, z, - discRadius, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + discRadius, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, @@ -161,7 +161,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { */ public static EntityAbilityDisc createCharging(World world, EntityNPCInterface owner, EntityLivingBase target, float discRadius, float discThickness, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean boomerang, int boomerangDelay, @@ -179,7 +179,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { EntityAbilityDisc disc = new EntityAbilityDisc( world, owner, target, spawnX, spawnY, spawnZ, - discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, boomerang, boomerangDelay, explosive, explosionRadius, explosionDamageFalloff, diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java index 256a4faf7..7a1f97d0f 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java @@ -50,14 +50,14 @@ public class EntityAbilityLaser extends EntityAbilityProjectile { public EntityAbilityLaser(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float laserWidth, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float damage, float knockback, float knockbackUp, float expansionSpeed, int lingerTicks, boolean explosive, float explosionRadius, float explosionDamageFalloff, int stunDuration, int slowDuration, int slowLevel, float maxDistance, int maxLifetime) { this(world, owner, target, x, y, z, - laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, + laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, damage, knockback, knockbackUp, expansionSpeed, lingerTicks, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, @@ -70,7 +70,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile { public EntityAbilityLaser(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float laserWidth, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float damage, float knockback, float knockbackUp, float expansionSpeed, int lingerTicks, boolean explosive, float explosionRadius, float explosionDamageFalloff, @@ -81,7 +81,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile { // Initialize base properties with lightning initProjectile(owner, target, x, y, z, - laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, 0.0f, // No rotation for laser + laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, 0.0f, // No rotation for laser damage, knockback, knockbackUp, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java index 24ca69ef8..04e59a240 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java @@ -71,14 +71,14 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { public EntityAbilityOrb(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float orbSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, int stunDuration, int slowDuration, int slowLevel, float maxDistance, int maxLifetime) { this(world, owner, target, x, y, z, - orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, @@ -93,7 +93,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { public EntityAbilityOrb(World world, EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float orbSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, @@ -104,7 +104,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { // Initialize base properties with lightning initProjectile(owner, target, x, y, z, - orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + orbSize, innerColor, outerColor, outerColorEnabled, outerColorAlpha, outerColorWidth, rotationSpeed, damage, knockback, knockbackUp, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, @@ -145,7 +145,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { */ public static EntityAbilityOrb createCharging(World world, EntityNPCInterface owner, EntityLivingBase target, float orbSize, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, float speed, boolean homing, float homingStrength, float homingRange, boolean explosive, float explosionRadius, float explosionDamageFalloff, @@ -162,7 +162,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { EntityAbilityOrb orb = new EntityAbilityOrb( world, owner, target, spawnX, spawnY, spawnZ, - orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime, diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java index 5c418d640..4b0f1e6a5 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java @@ -31,6 +31,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA protected int outerColor = 0x8888FF; protected boolean outerColorEnabled = true; protected float outerColorWidth = 0.4f; // Additive offset from inner size + protected float outerColorAlpha = 0.5f; protected float rotationSpeed = 4.0f; // ==================== COMBAT PROPERTIES ==================== @@ -98,13 +99,13 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA protected void initProjectile(EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float size, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, boolean explosive, float explosionRadius, float explosionDamageFalloff, int stunDuration, int slowDuration, int slowLevel, float maxDistance, int maxLifetime) { initProjectile(owner, target, x, y, z, - size, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed, + size, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed, damage, knockback, knockbackUp, explosive, explosionRadius, explosionDamageFalloff, stunDuration, slowDuration, slowLevel, @@ -118,7 +119,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA protected void initProjectile(EntityNPCInterface owner, EntityLivingBase target, double x, double y, double z, float size, int innerColor, int outerColor, - boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean outerColorEnabled, float outerColorWidth, float outerColorAlpha, float rotationSpeed, float damage, float knockback, float knockbackUp, boolean explosive, float explosionRadius, float explosionDamageFalloff, int stunDuration, int slowDuration, int slowLevel, @@ -138,6 +139,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA this.outerColor = outerColor; this.outerColorEnabled = outerColorEnabled; this.outerColorWidth = outerColorWidth; + this.outerColorAlpha = outerColorAlpha; this.rotationSpeed = rotationSpeed; // Combat @@ -428,6 +430,10 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA return outerColorWidth; } + public float getOuterColorAlpha() { + return outerColorAlpha; + } + public float getRotationSpeed() { return rotationSpeed; } @@ -501,6 +507,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA this.innerColor = nbt.getInteger("InnerColor"); this.outerColor = nbt.getInteger("OuterColor"); this.outerColorEnabled = !nbt.hasKey("OuterColorEnabled") || nbt.getBoolean("OuterColorEnabled"); + this.outerColorAlpha = nbt.hasKey("OuterColorAlpha") ? nbt.getFloat("OuterColorAlpha") : 0.5f; this.outerColorWidth = nbt.hasKey("OuterColorWidth") ? nbt.getFloat("OuterColorWidth") : 0.4f; this.rotationSpeed = nbt.hasKey("RotationSpeed") ? nbt.getFloat("RotationSpeed") : 4.0f; @@ -552,6 +559,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA nbt.setInteger("OuterColor", outerColor); nbt.setBoolean("OuterColorEnabled", outerColorEnabled); nbt.setFloat("OuterColorWidth", outerColorWidth); + nbt.setFloat("OuterColorAlpha", outerColorAlpha); nbt.setFloat("RotationSpeed", rotationSpeed); nbt.setFloat("Damage", damage); 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 index 00383853f..5faf662b0 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDisc.java @@ -155,15 +155,24 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig { y += 24; - // Row 3: Rotation Speed - addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", labelX, y + 5)); - addTextField(createFloatField(204, fieldX, y, 50, disc.getRotationSpeed())); + // 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: Lightning Effect Enabled - addLabel(new GuiNpcLabel(205, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(205, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.hasLightningEffect() ? 1 : 0); + // 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); @@ -171,14 +180,14 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig { if (disc.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, String.valueOf(disc.getLightningDensity())); + // Row 6: Density + Radius + addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); + GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, String.valueOf(disc.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, String.valueOf(disc.getLightningRadius())); + addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); + GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, String.valueOf(disc.getLightningRadius())); radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); addTextField(radiusField); } @@ -222,7 +231,7 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig { disc.setOuterColorEnabled(value == 1); initGui(); break; - case 205: + case 206: disc.setLightningEffect(value == 1); initGui(); break; @@ -298,12 +307,15 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig { 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 206: + case 207: disc.setLightningDensity(parseFloat(field, disc.getLightningDensity())); break; - case 207: + case 208: disc.setLightningRadius(parseFloat(field, disc.getLightningRadius())); break; } 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 index d878c9381..49ab42e5d 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityEnergyBeam.java @@ -152,14 +152,20 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { y += 24; // Row 3: Rotation Speed - addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", labelX, y + 5)); - addTextField(createFloatField(204, fieldX, y, 50, beam.getRotationSpeed())); + 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(205, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(205, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.hasLightningEffect() ? 1 : 0); + 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); @@ -168,13 +174,13 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { 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, String.valueOf(beam.getLightningDensity())); + addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); + GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, String.valueOf(beam.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, String.valueOf(beam.getLightningRadius())); + addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); + GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, String.valueOf(beam.getLightningRadius())); radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); addTextField(radiusField); } @@ -214,7 +220,7 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { beam.setOuterColorEnabled(value == 1); initGui(); break; - case 205: + case 206: beam.setLightningEffect(value == 1); initGui(); break; @@ -290,12 +296,15 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig { 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 206: + case 207: beam.setLightningDensity(parseFloat(field, beam.getLightningDensity())); break; - case 207: + case 208: beam.setLightningRadius(parseFloat(field, beam.getLightningRadius())); 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 index 50e8fa92c..e5184a3bb 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityLaserShot.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityLaserShot.java @@ -127,8 +127,14 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig { y += 24; // Row 3: Lightning Effect Enabled - addLabel(new GuiNpcLabel(204, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(204, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, laser.hasLightningEffect() ? 1 : 0); + 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); @@ -137,13 +143,13 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig { y += 24; // Row 4: Density + Radius - addLabel(new GuiNpcLabel(205, "ability.lightningDensity", labelX, y + 5)); - GuiNpcTextField densityField = new GuiNpcTextField(205, this, fontRendererObj, fieldX, y, 55, 18, String.valueOf(laser.getLightningDensity())); + addLabel(new GuiNpcLabel(206, "ability.lightningDensity", labelX, y + 5)); + GuiNpcTextField densityField = new GuiNpcTextField(206, this, fontRendererObj, fieldX, y, 55, 18, String.valueOf(laser.getLightningDensity())); densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f); addTextField(densityField); - addLabel(new GuiNpcLabel(206, "ability.lightningRadius", col2LabelX, y + 5)); - GuiNpcTextField radiusField = new GuiNpcTextField(206, this, fontRendererObj, col2FieldX, y, 55, 18, String.valueOf(laser.getLightningRadius())); + addLabel(new GuiNpcLabel(207, "ability.lightningRadius", col2LabelX, y + 5)); + GuiNpcTextField radiusField = new GuiNpcTextField(207, this, fontRendererObj, col2FieldX, y, 55, 18, String.valueOf(laser.getLightningRadius())); radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); addTextField(radiusField); } @@ -179,7 +185,7 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig { laser.setOuterColorEnabled(value == 1); initGui(); break; - case 204: + case 205: laser.setLightningEffect(value == 1); initGui(); break; @@ -215,10 +221,13 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig { case 203: laser.setOuterColorWidth(parseFloat(field, laser.getOuterColorWidth())); break; - case 205: - laser.setLightningDensity(parseFloat(field, laser.getLightningDensity())); + 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; } 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 index 40cff112f..7cc0f9f2f 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java @@ -119,20 +119,26 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { innerColorBtn.setTextColor(orb.getInnerColor() & 0xFFFFFF); addButton(innerColorBtn); - addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", col2LabelX, y + 5)); - addTextField(createFloatField(204, col2FieldX, y, 55, orb.getRotationSpeed())); + addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", col2LabelX, y + 5)); + addTextField(createFloatField(205, col2FieldX, y, 55, orb.getRotationSpeed())); y += 24; - // Row 2: Outer Glow Enabled + // 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 3: Outer Color + Outer Width + // 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); @@ -145,9 +151,9 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { y += 24; - // Row 4: Lightning Effect Enabled - addLabel(new GuiNpcLabel(205, "ability.lightning", labelX, y + 5)); - GuiNpcButton lightningBtn = new GuiNpcButton(205, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.hasLightningEffect() ? 1 : 0); + // 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); @@ -155,14 +161,14 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { if (orb.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, String.valueOf(orb.getLightningDensity())); + // Row 61: Density + Radius + addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5)); + GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, String.valueOf(orb.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, String.valueOf(orb.getLightningRadius())); + addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5)); + GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, String.valueOf(orb.getLightningRadius())); radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f); addTextField(radiusField); } @@ -202,7 +208,7 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { orb.setOuterColorEnabled(value == 1); initGui(); break; - case 205: + case 206: orb.setLightningEffect(value == 1); initGui(); break; @@ -272,12 +278,15 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig { 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 206: + case 207: orb.setLightningDensity(parseFloat(field, orb.getLightningDensity())); break; - case 207: + case 208: orb.setLightningRadius(parseFloat(field, orb.getLightningRadius())); break; } From 55658a795651cc5e767c346e58f918e7b19ffa7a Mon Sep 17 00:00:00 2001 From: Kam Date: Wed, 28 Jan 2026 20:43:32 -0500 Subject: [PATCH 9/9] Ability Preview GUI --- .../renderer/RenderAbilityProjectile.java | 5 + .../client/renderer/RenderAbilitySweeper.java | 4 + .../client/renderer/TelegraphRenderer.java | 79 ++++ .../controllers/data/ability/Ability.java | 89 ++++ .../data/ability/type/AbilityCharge.java | 63 +++ .../data/ability/type/AbilityDash.java | 63 +++ .../data/ability/type/AbilityDisc.java | 19 + .../data/ability/type/AbilityEnergyBeam.java | 19 + .../data/ability/type/AbilityLaserShot.java | 25 ++ .../data/ability/type/AbilityOrb.java | 19 + .../data/ability/type/AbilitySlam.java | 94 +++++ .../npcs/entity/EntityAbilityBeam.java | 138 +++++++ .../npcs/entity/EntityAbilityDisc.java | 108 +++++ .../npcs/entity/EntityAbilityLaser.java | 52 +++ .../kamkeel/npcs/entity/EntityAbilityOrb.java | 109 +++++ .../npcs/entity/EntityAbilityProjectile.java | 76 +++- .../kamkeel/npcs/network/PacketHandler.java | 8 + .../npcs/network/enums/EnumRequestPacket.java | 4 + .../ability/SavedAbilitiesGetPacket.java | 51 +++ .../ability/SavedAbilityGetPacket.java | 68 +++ .../ability/SavedAbilityRemovePacket.java | 69 ++++ .../ability/SavedAbilitySavePacket.java | 76 ++++ .../noppes/npcs/CustomNpcsPermissions.java | 1 + .../java/noppes/npcs/NoppesUtilServer.java | 12 + .../java/noppes/npcs/client/ClientProxy.java | 15 + .../client/gui/advanced/GuiNPCAbilities.java | 7 + .../advanced/SubGuiAbilityDeleteConfirm.java | 22 +- .../gui/advanced/SubGuiAbilityLoad.java | 111 +++-- .../advanced/SubGuiAbilitySaveConfirm.java | 32 +- .../gui/global/GuiNpcManageAbilities.java | 342 +++++++++++---- .../gui/mainmenu/GuiNPCGlobalMainMenu.java | 11 +- .../gui/util/AbilityPreviewExecutor.java | 368 +++++++++++++++++ .../client/gui/util/GuiAbilityInterface.java | 391 ++++++++++++++++++ .../client/gui/util/GuiModelInterface2.java | 4 +- .../noppes/npcs/constants/EnumScrollData.java | 1 + .../assets/customnpcs/lang/en_US.lang | 3 +- .../assets/customnpcs/textures/gui/icons.png | Bin 5249 -> 11934 bytes 37 files changed, 2396 insertions(+), 162 deletions(-) create mode 100644 src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitiesGetPacket.java create mode 100644 src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityGetPacket.java create mode 100644 src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityRemovePacket.java create mode 100644 src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitySavePacket.java create mode 100644 src/main/java/noppes/npcs/client/gui/util/AbilityPreviewExecutor.java create mode 100644 src/main/java/noppes/npcs/client/gui/util/GuiAbilityInterface.java diff --git a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java index 4180783bf..cce9bbe58 100644 --- a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java +++ b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilityProjectile.java @@ -2,6 +2,7 @@ package kamkeel.npcs.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; @@ -26,6 +27,7 @@ public abstract class RenderAbilityProjectile extends Render { /** * Setup GL state for translucent, self-illuminated rendering. + * Forces full brightness so world lighting does not affect projectiles. */ protected void setupRenderState() { GL11.glPushMatrix(); @@ -37,6 +39,9 @@ public abstract class RenderAbilityProjectile extends Render { GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_TEXTURE_2D); + + // Force full brightness - prevents world lighting from darkening projectiles + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); } /** diff --git a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilitySweeper.java b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilitySweeper.java index 0a24f1773..10705d762 100644 --- a/src/main/java/kamkeel/npcs/client/renderer/RenderAbilitySweeper.java +++ b/src/main/java/kamkeel/npcs/client/renderer/RenderAbilitySweeper.java @@ -3,6 +3,7 @@ package kamkeel.npcs.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import kamkeel.npcs.entity.EntityAbilitySweeper; +import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; @@ -52,6 +53,9 @@ public class RenderAbilitySweeper extends Render { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_LIGHTING); GL11.glShadeModel(GL11.GL_SMOOTH); + + // Force full brightness - prevents world lighting from darkening sweeper + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); } private void restoreRenderState() { diff --git a/src/main/java/kamkeel/npcs/client/renderer/TelegraphRenderer.java b/src/main/java/kamkeel/npcs/client/renderer/TelegraphRenderer.java index 5f4e815b7..3b5e49e2d 100644 --- a/src/main/java/kamkeel/npcs/client/renderer/TelegraphRenderer.java +++ b/src/main/java/kamkeel/npcs/client/renderer/TelegraphRenderer.java @@ -257,4 +257,83 @@ public class TelegraphRenderer { tessellator.draw(); } + + // ==================== GUI PREVIEW RENDERING ==================== + + /** + * Render a telegraph in GUI space for ability preview. + * This is used by the Manage Abilities GUI to show telegraph shapes. + * + * @param instance The telegraph instance to render + * @param centerX X center position in GUI space + * @param centerY Y center position in GUI space + * @param centerZ Z center position in GUI space + * @param scale Scale factor for the telegraph + * @param partialTicks Partial ticks for interpolation + */ + public void renderTelegraphInGUI(TelegraphInstance instance, + double centerX, double centerY, double centerZ, + float scale, float partialTicks) { + if (instance == null) return; + + Telegraph telegraph = instance.getTelegraph(); + if (telegraph == null || telegraph.getType() == TelegraphType.NONE) { + return; + } + + // Get animated color + int color = instance.getAnimatedColor(partialTicks); + float alpha = ((color >> 24) & 0xFF) / 255.0f; + float red = ((color >> 16) & 0xFF) / 255.0f; + float green = ((color >> 8) & 0xFF) / 255.0f; + float blue = (color & 0xFF) / 255.0f; + + // Setup GL state + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + + GL11.glTranslated(centerX, centerY, centerZ); + GL11.glScalef(scale, scale, scale); + + // Rotate for directional shapes + GL11.glRotatef(-instance.getInterpolatedYaw(partialTicks), 0, 1, 0); + + // Render based on type + switch (telegraph.getType()) { + case CIRCLE: + renderCircle(telegraph.getRadius(), red, green, blue, alpha); + break; + case RING: + renderRing(telegraph.getRadius(), telegraph.getInnerRadius(), red, green, blue, alpha); + break; + case LINE: + renderLine(telegraph.getLength(), telegraph.getWidth(), red, green, blue, alpha); + break; + case CONE: + renderCone(telegraph.getLength(), telegraph.getAngle(), red, green, blue, alpha); + break; + case POINT: + renderPoint(red, green, blue, alpha); + break; + default: + break; + } + + // Restore GL state + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_TEXTURE_2D); + + 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 08eed148b..eb59edf7c 100644 --- a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java +++ b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java @@ -26,6 +26,8 @@ import noppes.npcs.scripted.event.AbilityEvent; import java.util.ArrayList; import java.util.List; +import net.minecraft.entity.Entity; + public abstract class Ability implements IAbility { // ═══════════════════════════════════════════════════════════════════ @@ -636,6 +638,93 @@ public abstract class Ability implements IAbility { // Override in subclasses to clean up spawned entities, etc. } + // ═══════════════════════════════════════════════════════════════════ + // CLIENT-SIDE PREVIEW METHODS + // ═══════════════════════════════════════════════════════════════════ + + /** + * Get total active phase duration for preview (in ticks). + * Override in subclasses to provide accurate preview duration. + * + * @return Duration of active phase in ticks (default: 40 = 2 seconds) + */ + public int getPreviewActiveDuration() { + return 40; + } + + /** + * Called during preview windup tick (client-side only). + * Override for visual updates during windup preview. + * Do NOT apply damage or world effects here. + * + * @param npc The preview NPC + * @param tick Current tick within windup phase + */ + @SideOnly(Side.CLIENT) + public void onPreviewWindUpTick(EntityNPCInterface npc, int tick) { + // Default: no-op. Override in subclasses for visual effects. + } + + /** + * Called during preview active tick (client-side only). + * Override for visual updates during active preview. + * Do NOT apply damage or world effects here. + * + * @param npc The preview NPC + * @param tick Current tick within active phase + */ + @SideOnly(Side.CLIENT) + public void onPreviewActiveTick(EntityNPCInterface npc, int tick) { + // Default: no-op. Override in subclasses for visual effects. + } + + /** + * Create a preview entity for GUI display (client-side only). + * The entity should be in preview mode and not apply damage. + * Override in abilities that spawn entities (Beam, Orb, Disc, etc.) + * + * @param npc The preview NPC + * @return Preview entity, or null if ability doesn't spawn entities + */ + @SideOnly(Side.CLIENT) + public Entity createPreviewEntity(EntityNPCInterface npc) { + return null; // Override in entity-spawning abilities + } + + /** + * Whether to spawn preview entity during WINDUP phase (true) or ACTIVE phase (false). + * Most abilities (Orb, Beam, Disc) spawn during windup for charging effect. + * Laser spawns at active phase since it has no charging state. + */ + public boolean spawnPreviewDuringWindup() { + return true; // Default: spawn during windup for charging + } + + // ── Preview target (set by executor for abilities that need targeting) ── + + protected transient EntityLivingBase previewTarget; + + /** + * Set the fake target entity for preview mode. + * Called by AbilityPreviewExecutor before starting preview. + */ + public void setPreviewTarget(EntityLivingBase target) { + this.previewTarget = target; + } + + public EntityLivingBase getPreviewTarget() { + return previewTarget; + } + + /** + * Called once when transitioning from WINDUP to ACTIVE in preview mode. + * Override in movement-based abilities to initiate movement. + */ + @SideOnly(Side.CLIENT) + public void onPreviewExecute(EntityNPCInterface npc) { + // Default: no-op. Override in movement abilities. + } + // ═══════════════════════════════════════════════════════════════════ // CONDITION CHECKING // ═══════════════════════════════════════════════════════════════════ 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 1f6f31250..25941e0a5 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 @@ -288,6 +288,69 @@ public class AbilityCharge extends Ability implements IAbilityCharge { return instance; } + // ==================== PREVIEW MODE ==================== + + private transient double previewDirX, previewDirZ; + private transient double previewStartX, previewStartZ; + private transient boolean previewCharging = false; + + @Override + @SideOnly(Side.CLIENT) + public void onPreviewExecute(EntityNPCInterface npc) { + previewStartX = npc.posX; + previewStartZ = npc.posZ; + previewCharging = false; + + // Calculate direction toward fake target + if (previewTarget != null) { + double dx = previewTarget.posX - npc.posX; + double dz = previewTarget.posZ - npc.posZ; + double len = Math.sqrt(dx * dx + dz * dz); + if (len > 0) { + previewDirX = dx / len; + previewDirZ = dz / len; + } else { + float yaw = (float) Math.toRadians(npc.rotationYaw); + previewDirX = -Math.sin(yaw); + previewDirZ = Math.cos(yaw); + } + } else { + float yaw = (float) Math.toRadians(npc.rotationYaw); + previewDirX = -Math.sin(yaw); + previewDirZ = Math.cos(yaw); + } + previewCharging = true; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPreviewActiveTick(EntityNPCInterface npc, int tick) { + if (!previewCharging) return; + + // Check distance traveled + double distTraveled = Math.sqrt( + Math.pow(npc.posX - previewStartX, 2) + + Math.pow(npc.posZ - previewStartZ, 2) + ); + + if (distTraveled >= maxRange) { + previewCharging = false; + return; + } + + npc.prevPosX = npc.posX; + npc.prevPosY = npc.posY; + npc.prevPosZ = npc.posZ; + + npc.posX += previewDirX * chargeSpeed; + npc.posZ += previewDirZ * chargeSpeed; + } + + @Override + public int getPreviewActiveDuration() { + return (int) Math.ceil(maxRange / chargeSpeed) + 5; + } + @Override public void writeTypeNBT(NBTTagCompound nbt) { nbt.setFloat("chargeSpeed", chargeSpeed); 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 2c03de4c2..054176a7b 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 @@ -224,6 +224,69 @@ public class AbilityDash extends Ability implements IAbilityDash { return !npc.worldObj.getCollidingBoundingBoxes(npc, npc.boundingBox.copy().offset(nextX, 0, nextZ)).isEmpty(); } + // ==================== PREVIEW MODE ==================== + + private transient double previewDirX, previewDirZ; + private transient double previewStartX, previewStartZ; + private transient boolean previewDashing = false; + + @Override + @SideOnly(Side.CLIENT) + public void onPreviewExecute(EntityNPCInterface npc) { + previewStartX = npc.posX; + previewStartZ = npc.posZ; + previewDashing = false; + + // Pick a random direction based on mode + DashDirection[] directions = dashMode == DashMode.AGGRESSIVE + ? AGGRESSIVE_DIRECTIONS + : DEFENSIVE_DIRECTIONS; + DashDirection dir = directions[RANDOM.nextInt(directions.length)]; + + float baseYaw; + if (previewTarget != null) { + double dx = previewTarget.posX - npc.posX; + double dz = previewTarget.posZ - npc.posZ; + baseYaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); + } else { + baseYaw = npc.rotationYaw; + } + + float dashYaw = baseYaw + dir.getAngleOffset(); + float yawRad = (float) Math.toRadians(dashYaw); + previewDirX = -Math.sin(yawRad); + previewDirZ = Math.cos(yawRad); + previewDashing = true; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPreviewActiveTick(EntityNPCInterface npc, int tick) { + if (!previewDashing) return; + + double distTraveled = Math.sqrt( + Math.pow(npc.posX - previewStartX, 2) + + Math.pow(npc.posZ - previewStartZ, 2) + ); + + if (distTraveled >= dashDistance) { + previewDashing = false; + return; + } + + npc.prevPosX = npc.posX; + npc.prevPosY = npc.posY; + npc.prevPosZ = npc.posZ; + + npc.posX += previewDirX * dashSpeed; + npc.posZ += previewDirZ * dashSpeed; + } + + @Override + public int getPreviewActiveDuration() { + return (int) Math.ceil(dashDistance / dashSpeed) + 5; + } + @Override public float getTelegraphRadius() { return 0; // No telegraph for dash 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 e783b3a42..e5c15e010 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 @@ -332,4 +332,23 @@ public class AbilityDisc extends Ability implements IAbilityDisc { @Override public void setAnchorPoint(int point) { this.anchorPoint = AnchorPoint.fromId(point); } + + @Override + @SideOnly(Side.CLIENT) + public Entity createPreviewEntity(EntityNPCInterface npc) { + if (npc == null || npc.worldObj == null) return null; + + return EntityAbilityDisc.createPreview( + npc.worldObj, npc, + discRadius, discThickness, innerColor, outerColor, + outerColorEnabled, outerColorWidth, rotationSpeed, + lightningEffect, lightningDensity, lightningRadius, + anchorPoint, windUpTicks + ); + } + + @Override + public int getPreviewActiveDuration() { + return maxLifetime > 0 ? Math.min(maxLifetime, 100) : 100; + } } 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 7a81da548..c2b452339 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 @@ -329,4 +329,23 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam { @Override public void setAnchorPoint(int point) { this.anchorPoint = AnchorPoint.fromId(point); } + + @Override + @SideOnly(Side.CLIENT) + public Entity createPreviewEntity(EntityNPCInterface npc) { + if (npc == null || npc.worldObj == null) return null; + + return EntityAbilityBeam.createPreview( + npc.worldObj, npc, + beamWidth, headSize, innerColor, outerColor, + outerColorEnabled, outerColorWidth, rotationSpeed, + lightningEffect, lightningDensity, lightningRadius, + anchorPoint, windUpTicks, 1.0f + ); + } + + @Override + public int getPreviewActiveDuration() { + return maxLifetime > 0 ? Math.min(maxLifetime, 100) : 100; + } } 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 7ead64c8e..c1a94e657 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,7 @@ import kamkeel.npcs.controllers.data.ability.LockMovementType; import kamkeel.npcs.controllers.data.ability.TargetingMode; import kamkeel.npcs.controllers.data.telegraph.TelegraphType; import kamkeel.npcs.entity.EntityAbilityLaser; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; @@ -256,4 +257,28 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot { public void setLightningDensity(float lightningDensity) { this.lightningDensity = lightningDensity; } public float getLightningRadius() { return lightningRadius; } public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; } + + @Override + @SideOnly(Side.CLIENT) + public Entity createPreviewEntity(EntityNPCInterface npc) { + if (npc == null || npc.worldObj == null) return null; + + return EntityAbilityLaser.createPreview( + npc.worldObj, npc, + laserWidth, innerColor, outerColor, + outerColorEnabled, outerColorWidth, + expansionSpeed, maxDistance, + lightningEffect, lightningDensity, lightningRadius + ); + } + + @Override + public int getPreviewActiveDuration() { + return maxLifetime > 0 ? Math.min(maxLifetime, 60) : 60; + } + + @Override + public boolean spawnPreviewDuringWindup() { + return false; // Laser has no charging, spawns at active phase + } } 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 4ccbdcf12..13c57478a 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 @@ -487,4 +487,23 @@ public class AbilityOrb extends Ability implements IAbilityOrb { public void setAnchorPoint(int point) { this.anchorPoint = AnchorPoint.fromId(point); } + + @Override + @SideOnly(Side.CLIENT) + public Entity createPreviewEntity(EntityNPCInterface npc) { + if (npc == null || npc.worldObj == null) return null; + + return EntityAbilityOrb.createPreview( + npc.worldObj, npc, + orbSize, innerColor, outerColor, + outerColorEnabled, outerColorWidth, rotationSpeed, + lightningEffect, lightningDensity, lightningRadius, lightningFadeTime, + anchorPoint, windUpTicks + ); + } + + @Override + public int getPreviewActiveDuration() { + return maxLifetime > 0 ? Math.min(maxLifetime, 100) : 100; + } } 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 b9da81dc5..a46100c96 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 @@ -361,6 +361,100 @@ public class AbilitySlam extends Ability implements IAbilitySlam { airTicks = 0; } + // ==================== PREVIEW MODE ==================== + + private transient double previewVelX, previewVelY, previewVelZ; + private transient boolean previewLaunched = false; + private transient double previewGroundY; + + @Override + @SideOnly(Side.CLIENT) + public void onPreviewExecute(EntityNPCInterface npc) { + previewLaunched = false; + + double tx, ty, tz; + if (previewTarget != null && targetingMode == TargetingMode.AOE_TARGET) { + tx = previewTarget.posX; + ty = previewTarget.posY; + tz = previewTarget.posZ; + } else { + tx = npc.posX; + ty = npc.posY; + tz = npc.posZ; + } + + previewGroundY = npc.posY; + + double dx = tx - npc.posX; + double dz = tz - npc.posZ; + double horizontalDist = Math.sqrt(dx * dx + dz * dz); + + if (horizontalDist < 0.5) { + previewVelX = 0; + previewVelZ = 0; + previewVelY = 0.8 * leapSpeed; + } else { + if (horizontalDist > maxRange) { + double scale = maxRange / horizontalDist; + dx *= scale; + dz *= scale; + horizontalDist = maxRange; + } + + int flightTicks = (int) Math.max(15, Math.min(horizontalDist * 1.5, 30)); + double drag = 0.91; + double dragPowN = Math.pow(drag, flightTicks); + double vHorizontal = horizontalDist * (1.0 - drag) / (1.0 - dragPowN) * leapSpeed; + + double arcHeight = Math.max(1.0, leapHeight) * leapSpeed; + double peakTicks = flightTicks * 0.4; + double vy = (arcHeight * 2.0 / peakTicks) + (0.08 * peakTicks * 0.5); + vy = Math.max(vy, 0.6 * leapSpeed); + + double dirX = dx / horizontalDist; + double dirZ = dz / horizontalDist; + previewVelX = dirX * vHorizontal; + previewVelZ = dirZ * vHorizontal; + previewVelY = vy; + } + previewLaunched = true; + } + + @Override + @SideOnly(Side.CLIENT) + public void onPreviewActiveTick(EntityNPCInterface npc, int tick) { + if (!previewLaunched) return; + + // Apply velocity + npc.prevPosX = npc.posX; + npc.prevPosY = npc.posY; + npc.prevPosZ = npc.posZ; + + npc.posX += previewVelX; + npc.posY += previewVelY; + npc.posZ += previewVelZ; + + // Gravity and drag + previewVelY -= 0.08; + previewVelY *= 0.98; + previewVelX *= 0.91; + previewVelZ *= 0.91; + + // Ground clamp - stop falling below starting Y + if (npc.posY < previewGroundY && previewVelY < 0) { + npc.posY = previewGroundY; + previewVelY = 0; + previewVelX = 0; + previewVelZ = 0; + previewLaunched = false; + } + } + + @Override + public int getPreviewActiveDuration() { + return 60; + } + @Override public TelegraphInstance createTelegraph(EntityNPCInterface npc, EntityLivingBase target) { // Check if telegraph should be shown diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java index 2e5926e67..c841ee0f9 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityBeam.java @@ -83,8 +83,12 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { /** * Check if beam is in charging state (synced via data watcher). + * In preview mode, uses local field since data watcher isn't synced. */ public boolean isCharging() { + if (previewMode) { + return this.charging; + } return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1; } @@ -264,6 +268,103 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { return beam; } + /** + * Create a beam in preview mode for GUI display. + * Follows anchor point and animations like in the real game. + * Can be fired when transitioning to active phase. + */ + public static EntityAbilityBeam createPreview(World world, EntityNPCInterface owner, + float beamWidth, float headSize, int innerColor, int outerColor, + boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean lightningEffect, float lightningDensity, float lightningRadius, + AnchorPoint anchorPoint, int chargeDuration, float chargeOffsetDistance) { + EntityAbilityBeam beam = new EntityAbilityBeam(world); + beam.setPreviewMode(true); + beam.setPreviewOwner(owner); + + // Set visual properties + beam.beamWidth = beamWidth; + beam.headSize = headSize; + beam.size = headSize; + beam.innerColor = innerColor; + beam.outerColor = outerColor; + beam.outerColorEnabled = outerColorEnabled; + beam.outerColorWidth = outerColorWidth; + beam.rotationSpeed = rotationSpeed; + beam.lightningEffect = lightningEffect; + beam.lightningDensity = lightningDensity; + beam.lightningRadius = lightningRadius; + + // Set charging state + beam.setCharging(true); + beam.chargeDuration = chargeDuration; + beam.chargeTick = 0; + beam.chargeOffsetDistance = chargeOffsetDistance; + beam.anchorPoint = anchorPoint; + + // Initial position at anchor point + Vec3 pos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint, chargeOffsetDistance); + beam.setPosition(pos.xCoord, pos.yCoord, pos.zCoord); + beam.prevPosX = pos.xCoord; + beam.prevPosY = pos.yCoord; + beam.prevPosZ = pos.zCoord; + beam.startX = pos.xCoord; + beam.startY = pos.yCoord; + beam.startZ = pos.zCoord; + + // Initialize head offsets + beam.headOffsetX = 0; + beam.headOffsetY = 0; + beam.headOffsetZ = 0; + beam.prevHeadOffsetX = 0; + beam.prevHeadOffsetY = 0; + beam.prevHeadOffsetZ = 0; + + // Attach to owner for anchor following + beam.attachedToOwner = true; + beam.renderTailOrb = true; + + // Clear motion while charging + beam.motionX = 0; + beam.motionY = 0; + beam.motionZ = 0; + + return beam; + } + + /** + * Start preview firing (simulates firing toward a point in front of NPC). + */ + public void startPreviewFiring() { + if (!isCharging()) return; + + setCharging(false); + + // Update start position to current position + startX = posX; + startY = posY; + startZ = posZ; + + // Sync prev position to prevent visual jump on first frame + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + // Fire forward based on owner facing direction + Entity owner = getOwner(); + if (owner != null) { + float yaw = (float) Math.toRadians(owner.rotationYaw); + float pitch = 0; // Fire horizontally + motionX = -Math.sin(yaw) * Math.cos(pitch) * speed; + motionY = -Math.sin(pitch) * speed; + motionZ = Math.cos(yaw) * Math.cos(pitch) * speed; + } else { + motionX = speed; + motionY = 0; + motionZ = 0; + } + } + /** * Start the beam firing (exit charging mode). * Called by ability when windup ends. @@ -361,6 +462,12 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { ageTrailPoints(); } + // In preview mode, run movement on client (no server) + if (previewMode) { + updatePreviewMovement(); + return; + } + if (worldObj.isRemote) { // Client: interpolate entity position handleClientInterpolation(); @@ -510,6 +617,37 @@ public class EntityAbilityBeam extends EntityAbilityProjectile { } } + /** + * Update movement in preview mode (client-side only, no damage). + */ + private void updatePreviewMovement() { + // Move head offset + headOffsetX += motionX; + headOffsetY += motionY; + headOffsetZ += motionZ; + + // Update origin if attached to owner + if (attachedToOwner) { + Entity owner = getOwner(); + if (owner != null) { + startX = owner.posX; + startY = owner.posY + owner.getEyeHeight() * 0.7; + startZ = owner.posZ; + } + } + + // Calculate world position of head + double headWorldX = startX + headOffsetX; + double headWorldY = startY + headOffsetY; + double headWorldZ = startZ + headOffsetZ; + + // Update entity position to head + this.setPosition(headWorldX, headWorldY, headWorldZ); + + // Add trail point + addTrailPoint(); + } + private void updateHoming() { if (!homing) return; diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java index f63014158..e3896a839 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityDisc.java @@ -61,8 +61,12 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { /** * Check if disc is in charging state (synced via data watcher). + * In preview mode, uses local field since data watcher isn't synced. */ public boolean isCharging() { + if (previewMode) { + return this.charging; + } return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1; } @@ -209,6 +213,94 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { return disc; } + /** + * Create a disc in preview mode for GUI display. + * Follows anchor point and animations like in the real game. + * Can be fired when transitioning to active phase. + */ + public static EntityAbilityDisc createPreview(World world, EntityNPCInterface owner, + float discRadius, float discThickness, int innerColor, int outerColor, + boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean lightningEffect, float lightningDensity, float lightningRadius, + AnchorPoint anchorPoint, int chargeDuration) { + EntityAbilityDisc disc = new EntityAbilityDisc(world); + disc.setPreviewMode(true); + disc.setPreviewOwner(owner); + + // Set visual properties + disc.innerColor = innerColor; + disc.outerColor = outerColor; + disc.outerColorEnabled = outerColorEnabled; + disc.outerColorWidth = outerColorWidth; + disc.rotationSpeed = rotationSpeed; + disc.lightningEffect = lightningEffect; + disc.lightningDensity = lightningDensity; + disc.lightningRadius = lightningRadius; + + // Set charging state + disc.setCharging(true); + disc.chargeDuration = chargeDuration; + disc.chargeTick = 0; + disc.anchorPoint = anchorPoint; + + // Store target size and start at 0 for grow effect + disc.targetDiscRadius = discRadius; + disc.targetDiscThickness = discThickness; + disc.discRadius = 0.01f; + disc.discThickness = 0.01f; + disc.size = 0.01f; + + // Initial position at anchor point + Vec3 pos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint); + disc.setPosition(pos.xCoord, pos.yCoord, pos.zCoord); + disc.prevPosX = pos.xCoord; + disc.prevPosY = pos.yCoord; + disc.prevPosZ = pos.zCoord; + disc.startX = pos.xCoord; + disc.startY = pos.yCoord; + disc.startZ = pos.zCoord; + + // Clear motion while charging + disc.motionX = 0; + disc.motionY = 0; + disc.motionZ = 0; + + return disc; + } + + /** + * Start preview firing (simulates firing toward a point in front of NPC). + */ + public void startPreviewFiring() { + if (!isCharging()) return; + + setCharging(false); + + // Update start position to current position + startX = posX; + startY = posY; + startZ = posZ; + + // Sync prev position to prevent visual jump on first frame + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + // Fire forward based on owner facing direction + Entity owner = getOwner(); + if (owner != null) { + float yaw = (float) Math.toRadians(owner.rotationYaw); + float pitch = 0; // Fire horizontally + motionX = -Math.sin(yaw) * Math.cos(pitch) * speed; + motionY = -Math.sin(pitch) * speed; + motionZ = Math.cos(yaw) * Math.cos(pitch) * speed; + } else { + motionX = speed; + motionY = 0; + motionZ = 0; + } + } + /** * Start the disc moving (exit charging mode). * Called by ability when windup ends. @@ -261,6 +353,12 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { return; } + // In preview mode, run movement on client (no server) + if (previewMode) { + updatePreviewMovement(); + return; + } + if (worldObj.isRemote) { handleClientInterpolation(); } else { @@ -332,6 +430,16 @@ public class EntityAbilityDisc extends EntityAbilityProjectile { return distTraveled >= maxDistance; } + /** + * Update movement in preview mode (client-side only, no damage). + */ + private void updatePreviewMovement() { + // Simple movement - just apply motion + this.posX += motionX; + this.posY += motionY; + this.posZ += motionZ; + } + private void updateHoming() { if (!homing) return; diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java index 7a1f97d0f..ec208e2cf 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityLaser.java @@ -347,4 +347,56 @@ public class EntityAbilityLaser extends EntityAbilityProjectile { nbt.setDouble("EndY", endY); nbt.setDouble("EndZ", endZ); } + + /** + * Create a laser in preview mode for GUI display. + * Laser doesn't have charging state - spawns at active phase and fires immediately. + */ + public static EntityAbilityLaser createPreview(World world, EntityNPCInterface owner, + float laserWidth, int innerColor, int outerColor, + boolean outerColorEnabled, float outerColorWidth, + float expansionSpeed, float maxDistance, + boolean lightningEffect, float lightningDensity, float lightningRadius) { + EntityAbilityLaser laser = new EntityAbilityLaser(world); + laser.setPreviewMode(true); + laser.setPreviewOwner(owner); + + // Set visual properties + laser.laserWidth = laserWidth; + laser.size = laserWidth; + laser.innerColor = innerColor; + laser.outerColor = outerColor; + laser.outerColorEnabled = outerColorEnabled; + laser.outerColorWidth = outerColorWidth; + laser.expansionSpeed = expansionSpeed; + laser.maxDistance = Math.min(maxDistance, 5.0f); // Limit for GUI preview + laser.lightningEffect = lightningEffect; + laser.lightningDensity = lightningDensity; + laser.lightningRadius = lightningRadius; + + // Position at chest height + double x = owner.posX; + double y = owner.posY + owner.height * 0.7; + double z = owner.posZ; + laser.setPosition(x, y, z); + laser.prevPosX = x; + laser.prevPosY = y; + laser.prevPosZ = z; + laser.startX = x; + laser.startY = y; + laser.startZ = z; + + // Fire in owner's facing direction + float yaw = (float) Math.toRadians(owner.rotationYaw); + laser.dirX = -Math.sin(yaw); + laser.dirY = 0; + laser.dirZ = Math.cos(yaw); + + // Initialize end point (same as start, will expand) + laser.endX = x; + laser.endY = y; + laser.endZ = z; + + return laser; + } } diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java index 04e59a240..bad2bc955 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityOrb.java @@ -50,8 +50,12 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { /** * Check if orb is in charging state (synced via data watcher). + * In preview mode, uses local field since data watcher isn't synced. */ public boolean isCharging() { + if (previewMode) { + return this.charging; + } return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1; } @@ -188,6 +192,95 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { return orb; } + /** + * Create an orb in preview mode for GUI display. + * Follows anchor point and animations like in the real game. + * Can be fired when transitioning to active phase. + */ + public static EntityAbilityOrb createPreview(World world, EntityNPCInterface owner, + float orbSize, int innerColor, int outerColor, + boolean outerColorEnabled, float outerColorWidth, float rotationSpeed, + boolean lightningEffect, float lightningDensity, float lightningRadius, int lightningFadeTime, + AnchorPoint anchorPoint, int chargeDuration) { + EntityAbilityOrb orb = new EntityAbilityOrb(world); + orb.setPreviewMode(true); + orb.setPreviewOwner(owner); + + // Set visual properties + orb.innerColor = innerColor; + orb.outerColor = outerColor; + orb.outerColorEnabled = outerColorEnabled; + orb.outerColorWidth = outerColorWidth; + orb.rotationSpeed = rotationSpeed; + orb.lightningEffect = lightningEffect; + orb.lightningDensity = lightningDensity; + orb.lightningRadius = lightningRadius; + orb.lightningFadeTime = lightningFadeTime; + + // Set charging state (like createCharging does) + orb.setCharging(true); + orb.chargeDuration = chargeDuration; + orb.chargeTick = 0; + orb.anchorPoint = anchorPoint; + + // Store target size and start at 0 for grow effect + orb.targetSize = orbSize; + orb.size = 0.01f; + orb.renderCurrentSize = 0.01f; + orb.prevRenderSize = 0.01f; + + // Initial position at anchor point + Vec3 pos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint); + orb.setPosition(pos.xCoord, pos.yCoord, pos.zCoord); + orb.prevPosX = pos.xCoord; + orb.prevPosY = pos.yCoord; + orb.prevPosZ = pos.zCoord; + orb.startX = pos.xCoord; + orb.startY = pos.yCoord; + orb.startZ = pos.zCoord; + + // Clear motion while charging + orb.motionX = 0; + orb.motionY = 0; + orb.motionZ = 0; + + return orb; + } + + /** + * Start preview firing (simulates firing toward a point in front of NPC). + */ + public void startPreviewFiring() { + if (!isCharging()) return; + + setCharging(false); + + // Update start position to current position + startX = posX; + startY = posY; + startZ = posZ; + + // Sync prev position to prevent visual jump on first frame + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + // Fire forward based on owner facing direction + Entity owner = getOwner(); + if (owner != null) { + float yaw = (float) Math.toRadians(owner.rotationYaw); + float pitch = (float) Math.toRadians(0); // Fire horizontally + motionX = -Math.sin(yaw) * Math.cos(pitch) * speed; + motionY = -Math.sin(pitch) * speed; + motionZ = Math.cos(yaw) * Math.cos(pitch) * speed; + } else { + // Default: fire forward (positive X in model space) + motionX = speed; + motionY = 0; + motionZ = 0; + } + } + /** * Start the orb moving (exit charging mode). * Called by ability when windup ends. @@ -232,6 +325,12 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { return; } + // In preview mode, run movement on client (no server) + if (previewMode) { + updatePreviewMovement(); + return; + } + if (worldObj.isRemote) { handleClientInterpolation(); } else { @@ -254,6 +353,16 @@ public class EntityAbilityOrb extends EntityAbilityProjectile { } } + /** + * Update movement in preview mode (client-side only, no damage). + */ + private void updatePreviewMovement() { + // Simple movement - just apply motion + this.posX += motionX; + this.posY += motionY; + this.posZ += motionZ; + } + private void updateHoming() { if (!homing) return; diff --git a/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java b/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java index 4b0f1e6a5..149ffd329 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java +++ b/src/main/java/kamkeel/npcs/entity/EntityAbilityProjectile.java @@ -71,6 +71,8 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA // ==================== STATE ==================== protected boolean hasHit = false; + protected boolean previewMode = false; // Client-side preview mode (no damage/effects) + protected EntityNPCInterface previewOwner = null; // Direct reference for GUI preview (no world lookup) // ==================== ROTATION INTERPOLATION ==================== public float prevRotationValX, prevRotationValY, prevRotationValZ; @@ -202,7 +204,10 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA this.prevRotationValZ = this.rotationValZ; this.prevRenderSize = this.renderCurrentSize; - super.onUpdate(); + // Skip super.onUpdate() in preview mode to avoid world checks + if (!previewMode) { + super.onUpdate(); + } // Update rotation updateRotation(); @@ -210,26 +215,29 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA // Lerp render size toward actual size this.renderCurrentSize = this.renderCurrentSize + (this.size - this.renderCurrentSize) * 0.15f; - // Set death time on first tick if not already set (handles chunk load/unload) - if (deathWorldTime < 0 && worldObj != null) { - deathWorldTime = worldObj.getTotalWorldTime() + maxLifetime; - } + // Skip lifetime/distance checks in preview mode + if (!previewMode) { + // Set death time on first tick if not already set (handles chunk load/unload) + if (deathWorldTime < 0 && worldObj != null) { + deathWorldTime = worldObj.getTotalWorldTime() + maxLifetime; + } - // Check lifespan using world time (survives chunk unload/reload) - if (deathWorldTime > 0 && worldObj.getTotalWorldTime() >= deathWorldTime) { - this.setDead(); - return; - } + // Check lifespan using world time (survives chunk unload/reload) + if (deathWorldTime > 0 && worldObj.getTotalWorldTime() >= deathWorldTime) { + this.setDead(); + return; + } - // Check max distance (subclass can override if needed) - if (checkMaxDistance()) { - this.setDead(); - return; - } + // Check max distance (subclass can override if needed) + if (checkMaxDistance()) { + this.setDead(); + return; + } - if (hasHit) { - this.setDead(); - return; + if (hasHit) { + this.setDead(); + return; + } } // Subclass-specific update @@ -310,13 +318,32 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA } } + // ==================== PREVIEW MODE ==================== + + /** + * Set preview mode for GUI display. + * In preview mode, no damage or world effects are applied. + */ + public void setPreviewMode(boolean preview) { + this.previewMode = preview; + } + + /** + * Check if entity is in preview mode. + */ + public boolean isPreviewMode() { + return previewMode; + } + // ==================== DAMAGE & EFFECTS ==================== protected void applyDamage(EntityLivingBase target) { + if (previewMode) return; // Skip damage in preview mode applyDamage(target, this.damage, this.knockback); } protected void applyDamage(EntityLivingBase target, float dmg, float kb) { + if (previewMode) return; // Skip damage in preview mode Entity owner = getOwner(); EntityNPCInterface npc = (owner instanceof EntityNPCInterface) ? (EntityNPCInterface) owner : null; @@ -353,6 +380,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA } protected void doExplosion() { + if (previewMode) return; // Skip explosion in preview mode worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 1.0f, 1.0f); Entity owner = getOwner(); @@ -384,10 +412,22 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA // ==================== ENTITY HELPERS ==================== protected Entity getOwner() { + // In preview mode, use direct reference (no world lookup) + if (previewMode && previewOwner != null) { + return previewOwner; + } if (ownerEntityId == -1) return null; return worldObj.getEntityByID(ownerEntityId); } + /** + * Set the preview owner for GUI preview mode. + * This allows anchor point calculations without world entity lookup. + */ + public void setPreviewOwner(EntityNPCInterface owner) { + this.previewOwner = owner; + } + protected Entity getTarget() { if (targetEntityId == -1) return null; return worldObj.getEntityByID(targetEntityId); diff --git a/src/main/java/kamkeel/npcs/network/PacketHandler.java b/src/main/java/kamkeel/npcs/network/PacketHandler.java index e659fef74..68c021559 100644 --- a/src/main/java/kamkeel/npcs/network/PacketHandler.java +++ b/src/main/java/kamkeel/npcs/network/PacketHandler.java @@ -92,6 +92,10 @@ import kamkeel.npcs.network.packets.request.TraderMarketSavePacket; import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket; import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket; import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilitiesGetPacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilityGetPacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilityRemovePacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilitySavePacket; import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket; import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket; import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket; @@ -501,6 +505,10 @@ public class PacketHandler { REQUEST_PACKET.registerPacket(new AbilitiesGetAllPacket()); REQUEST_PACKET.registerPacket(new AbilitiesNpcGetPacket()); REQUEST_PACKET.registerPacket(new AbilitiesNpcSavePacket()); + REQUEST_PACKET.registerPacket(new SavedAbilitiesGetPacket()); + REQUEST_PACKET.registerPacket(new SavedAbilityGetPacket()); + REQUEST_PACKET.registerPacket(new SavedAbilityRemovePacket()); + REQUEST_PACKET.registerPacket(new SavedAbilitySavePacket()); // Other Packets REQUEST_PACKET.registerPacket(new IsGuiOpenInform()); diff --git a/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java b/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java index bdd566785..d4968bc5c 100644 --- a/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java +++ b/src/main/java/kamkeel/npcs/network/enums/EnumRequestPacket.java @@ -198,6 +198,10 @@ public enum EnumRequestPacket { NpcAbilitiesGet, NpcAbilitiesSave, AbilitiesGetAll, + SavedAbilitiesGet, + SavedAbilityGet, + SavedAbilityRemove, + SavedAbilitySave, Hammer, RecipeScript, diff --git a/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitiesGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitiesGetPacket.java new file mode 100644 index 000000000..0e8b547a3 --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitiesGetPacket.java @@ -0,0 +1,51 @@ +package kamkeel.npcs.network.packets.request.ability; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumRequestPacket; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import noppes.npcs.NoppesUtilServer; + +import java.io.IOException; + +/** + * Request packet to get list of all saved ability preset names. + */ +public final class SavedAbilitiesGetPacket extends AbstractPacket { + public static String packetName = "Request|SavedAbilitiesGet"; + + public SavedAbilitiesGetPacket() { + } + + @Override + public Enum getType() { + return EnumRequestPacket.SavedAbilitiesGet; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.REQUEST_PACKET; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) + return; + + NoppesUtilServer.sendSavedAbilitiesData((EntityPlayerMP) player); + } +} diff --git a/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityGetPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityGetPacket.java new file mode 100644 index 000000000..7bb2f1826 --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityGetPacket.java @@ -0,0 +1,68 @@ +package kamkeel.npcs.network.packets.request.ability; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.controllers.data.ability.Ability; +import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumRequestPacket; +import kamkeel.npcs.network.packets.data.large.GuiDataPacket; +import kamkeel.npcs.util.ByteBufUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; + +import java.io.IOException; + +/** + * Request packet to get a specific saved ability by name. + */ +public final class SavedAbilityGetPacket extends AbstractPacket { + public static String packetName = "Request|SavedAbilityGet"; + + private String abilityName; + + public SavedAbilityGetPacket() { + } + + public SavedAbilityGetPacket(String abilityName) { + this.abilityName = abilityName; + } + + @Override + public Enum getType() { + return EnumRequestPacket.SavedAbilityGet; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.REQUEST_PACKET; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + ByteBufUtils.writeString(out, abilityName); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) + return; + + String name = ByteBufUtils.readString(in); + Ability ability = AbilityController.Instance.getSavedAbility(name); + if (ability != null) { + NBTTagCompound compound = ability.writeNBT(); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound); + } + } +} diff --git a/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityRemovePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityRemovePacket.java new file mode 100644 index 000000000..3fe4f5a0c --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilityRemovePacket.java @@ -0,0 +1,69 @@ +package kamkeel.npcs.network.packets.request.ability; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumRequestPacket; +import kamkeel.npcs.util.ByteBufUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import noppes.npcs.CustomNpcsPermissions; +import noppes.npcs.NoppesUtilServer; + +import java.io.IOException; + +/** + * Request packet to remove a saved ability by name. + */ +public final class SavedAbilityRemovePacket extends AbstractPacket { + public static String packetName = "Request|SavedAbilityRemove"; + + private String abilityName; + + public SavedAbilityRemovePacket() { + } + + public SavedAbilityRemovePacket(String abilityName) { + this.abilityName = abilityName; + } + + @Override + public Enum getType() { + return EnumRequestPacket.SavedAbilityRemove; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.REQUEST_PACKET; + } + + @Override + public CustomNpcsPermissions.Permission getPermission() { + return CustomNpcsPermissions.GLOBAL_ABILITY; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + ByteBufUtils.writeString(out, abilityName); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) + return; + + String name = ByteBufUtils.readString(in); + AbilityController.Instance.deleteAbility(name); + NoppesUtilServer.sendSavedAbilitiesData((EntityPlayerMP) player); + } +} diff --git a/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitySavePacket.java b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitySavePacket.java new file mode 100644 index 000000000..2cf2fa489 --- /dev/null +++ b/src/main/java/kamkeel/npcs/network/packets/request/ability/SavedAbilitySavePacket.java @@ -0,0 +1,76 @@ +package kamkeel.npcs.network.packets.request.ability; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import kamkeel.npcs.controllers.data.ability.Ability; +import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.network.AbstractPacket; +import kamkeel.npcs.network.PacketChannel; +import kamkeel.npcs.network.PacketHandler; +import kamkeel.npcs.network.PacketUtil; +import kamkeel.npcs.network.enums.EnumItemPacketType; +import kamkeel.npcs.network.enums.EnumRequestPacket; +import kamkeel.npcs.network.packets.data.large.GuiDataPacket; +import kamkeel.npcs.util.ByteBufUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.CustomNpcsPermissions; +import noppes.npcs.NoppesUtilServer; + +import java.io.IOException; + +/** + * Request packet to save an ability preset. + */ +public final class SavedAbilitySavePacket extends AbstractPacket { + public static String packetName = "Request|SavedAbilitySave"; + + private NBTTagCompound abilityNBT; + + public SavedAbilitySavePacket() { + } + + public SavedAbilitySavePacket(NBTTagCompound abilityNBT) { + this.abilityNBT = abilityNBT; + } + + @Override + public Enum getType() { + return EnumRequestPacket.SavedAbilitySave; + } + + @Override + public PacketChannel getChannel() { + return PacketHandler.REQUEST_PACKET; + } + + @Override + public CustomNpcsPermissions.Permission getPermission() { + return CustomNpcsPermissions.GLOBAL_ABILITY; + } + + @SideOnly(Side.CLIENT) + @Override + public void sendData(ByteBuf out) throws IOException { + ByteBufUtils.writeNBT(out, abilityNBT); + } + + @Override + public void receiveData(ByteBuf in, EntityPlayer player) throws IOException { + if (!(player instanceof EntityPlayerMP)) + return; + + if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player)) + return; + + NBTTagCompound compound = ByteBufUtils.readNBT(in); + Ability ability = AbilityController.Instance.fromNBT(compound); + if (ability != null) { + AbilityController.Instance.saveAbility(ability); + NoppesUtilServer.sendSavedAbilitiesData((EntityPlayerMP) player); + GuiDataPacket.sendGuiData((EntityPlayerMP) player, ability.writeNBT()); + } + } +} diff --git a/src/main/java/noppes/npcs/CustomNpcsPermissions.java b/src/main/java/noppes/npcs/CustomNpcsPermissions.java index 0d758ad41..5e7c2924e 100644 --- a/src/main/java/noppes/npcs/CustomNpcsPermissions.java +++ b/src/main/java/noppes/npcs/CustomNpcsPermissions.java @@ -66,6 +66,7 @@ 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_EFFECT = new Permission("customnpcs.global.effect"); diff --git a/src/main/java/noppes/npcs/NoppesUtilServer.java b/src/main/java/noppes/npcs/NoppesUtilServer.java index 6a33cb2c0..ae97f70b4 100644 --- a/src/main/java/noppes/npcs/NoppesUtilServer.java +++ b/src/main/java/noppes/npcs/NoppesUtilServer.java @@ -785,6 +785,18 @@ public class NoppesUtilServer { sendScrollData(player, map, EnumScrollData.ABILITY_TYPES); } + public static void sendSavedAbilitiesData(EntityPlayerMP player) { + HashMap map = new HashMap(); + kamkeel.npcs.controllers.data.ability.AbilityController controller = kamkeel.npcs.controllers.data.ability.AbilityController.Instance; + if (controller != null) { + int index = 0; + for (String name : controller.getSavedAbilityNames()) { + map.put(name, index++); + } + } + sendScrollData(player, map, EnumScrollData.ABILITIES); + } + public static DialogOption setNpcDialog(int slot, int dialogId, EntityPlayer player) throws IOException { return setNpcDialog(slot, dialogId, getEditingNpc(player)); } diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 9a0044191..01c226812 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -87,6 +87,7 @@ import noppes.npcs.client.gui.global.GuiNPCManageAnimations; import noppes.npcs.client.gui.global.GuiNPCManageBanks; import noppes.npcs.client.gui.global.GuiNPCManageDialogs; import noppes.npcs.client.gui.global.GuiNPCManageEffects; +import noppes.npcs.client.gui.global.GuiNpcManageAbilities; import noppes.npcs.client.gui.global.GuiNPCManageFactions; import noppes.npcs.client.gui.global.GuiNPCManageLinked; import noppes.npcs.client.gui.global.GuiNPCManageQuest; @@ -497,6 +498,20 @@ public class ClientProxy extends CommonProxy { else if (gui == EnumGuiType.ManageEffects) return new GuiNPCManageEffects(npc); + else if (gui == EnumGuiType.ManageAbilities) { + EntityCustomNpc abilityNpc; + if (npc != null) { + abilityNpc = new EntityCustomNpc(npc.worldObj); + abilityNpc.copyDataFrom(npc, true); + abilityNpc.display.showName = 1; + abilityNpc.display.showBossBar = 0; + } else { + abilityNpc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld); + abilityNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png"; + } + return new GuiNpcManageAbilities(abilityNpc); + } + else if (gui == EnumGuiType.MainMenuGlobal) return new GuiNPCGlobalMainMenu(npc); diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java index 9abcebbe7..750fe282e 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java @@ -281,6 +281,13 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC @Override public void setGuiData(NBTTagCompound compound) { + // Only process NPC ability data, not saved ability preset data + // SubGuiAbilityLoad also implements IGuiData and may receive responses + // that get forwarded here - ignore those by checking for expected keys + if (!compound.hasKey("Abilities")) { + return; + } + abilitiesEnabled = compound.getBoolean("AbilitiesEnabled"); // Support old globalCooldown for backwards compatibility diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityDeleteConfirm.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityDeleteConfirm.java index ee2561b4e..3760666b4 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityDeleteConfirm.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityDeleteConfirm.java @@ -1,6 +1,7 @@ package noppes.npcs.client.gui.advanced; -import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.request.ability.SavedAbilityRemovePacket; import net.minecraft.client.gui.GuiButton; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; @@ -8,15 +9,20 @@ import noppes.npcs.client.gui.util.SubGuiInterface; /** * Confirmation dialog for deleting an ability preset. + * Uses packet-based communication for proper client-server architecture. */ public class SubGuiAbilityDeleteConfirm extends SubGuiInterface { private final String abilityName; - private final SubGuiAbilityLoad loadGui; + private final Runnable onDeleted; - public SubGuiAbilityDeleteConfirm(String abilityName, SubGuiAbilityLoad loadGui) { + public SubGuiAbilityDeleteConfirm(String abilityName) { + this(abilityName, null); + } + + public SubGuiAbilityDeleteConfirm(String abilityName, Runnable onDeleted) { this.abilityName = abilityName; - this.loadGui = loadGui; + this.onDeleted = onDeleted; setBackground("menubg.png"); xSize = 200; @@ -44,9 +50,11 @@ public class SubGuiAbilityDeleteConfirm extends SubGuiInterface { int id = guibutton.id; if (id == 0) { - // Delete the ability - AbilityController.Instance.deleteAbility(abilityName); - loadGui.onAbilityDeleted(abilityName); + // Delete the ability via packet + PacketClient.sendClient(new SavedAbilityRemovePacket(abilityName)); + if (onDeleted != null) { + onDeleted.run(); + } close(); } else if (id == 1) { close(); diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java index c48683070..1e9133d9d 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java @@ -2,28 +2,39 @@ package noppes.npcs.client.gui.advanced; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.request.ability.SavedAbilitiesGetPacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilityGetPacket; import net.minecraft.client.gui.GuiButton; +import net.minecraft.nbt.NBTTagCompound; import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; import noppes.npcs.client.gui.util.ICustomScrollListener; +import noppes.npcs.client.gui.util.IGuiData; +import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.client.gui.util.SubGuiInterface; +import noppes.npcs.constants.EnumScrollData; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Set; +import java.util.Vector; /** * Dialog for loading a saved ability preset. - * Can be opened from SubGuiAbilityConfig (to load into editing ability) - * or from GuiNPCAbilities (to add ability directly to NPC). + * Uses packet-based communication for proper client-server architecture. */ -public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollListener { +public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollListener, IScrollData, IGuiData { private final SubGuiAbilityConfig parentConfig; private final GuiNPCAbilities parentAbilities; private String selectedName = null; - private List abilityNames = new ArrayList<>(); + private HashMap abilityData = new HashMap<>(); + private GuiCustomScroll scroll; + + // Track if we're waiting for a load + private boolean waitingForLoad = false; public SubGuiAbilityLoad(SubGuiAbilityConfig parentConfig) { this.parentConfig = parentConfig; @@ -32,6 +43,9 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL setBackground("menubg.png"); xSize = 220; ySize = 180; + + // Request ability list from server + PacketClient.sendClient(new SavedAbilitiesGetPacket()); } public SubGuiAbilityLoad(GuiNPCAbilities parentAbilities) { @@ -41,28 +55,29 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL setBackground("menubg.png"); xSize = 220; ySize = 180; + + // Request ability list from server + PacketClient.sendClient(new SavedAbilitiesGetPacket()); } @Override public void initGui() { super.initGui(); - // Load ability names - Set names = AbilityController.Instance.getSavedAbilityNames(); - abilityNames = new ArrayList<>(names); - int y = guiTop + 5; addLabel(new GuiNpcLabel(0, "ability.load.select", guiLeft + 10, y)); y += 14; // Scroll list of saved abilities - GuiCustomScroll scroll = new GuiCustomScroll(this, 0); - scroll.setSize(200, 110); + if (scroll == null) { + scroll = new GuiCustomScroll(this, 0); + scroll.setSize(200, 110); + } scroll.guiLeft = guiLeft + 10; scroll.guiTop = y; - scroll.setUnsortedList(abilityNames); - if (selectedName != null && abilityNames.contains(selectedName)) { + scroll.setList(getFilteredList()); + if (selectedName != null && abilityData.containsKey(selectedName)) { scroll.setSelected(selectedName); } addScroll(scroll); @@ -70,13 +85,15 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL y += 115; // Buttons - addButton(new GuiNpcButton(0, guiLeft + 10, y, 60, 20, "gui.load")); - addButton(new GuiNpcButton(1, guiLeft + 80, y, 60, 20, "gui.delete")); - addButton(new GuiNpcButton(2, guiLeft + 150, y, 60, 20, "gui.cancel")); + addButton(new GuiNpcButton(0, guiLeft + 10, y, 95, 20, "gui.load")); + addButton(new GuiNpcButton(2, guiLeft + 115, y, 95, 20, "gui.cancel")); - // Disable load/delete if nothing selected + // Disable load if nothing selected getButton(0).setEnabled(selectedName != null && !selectedName.isEmpty()); - getButton(1).setEnabled(selectedName != null && !selectedName.isEmpty()); + } + + private List getFilteredList() { + return new ArrayList<>(abilityData.keySet()); } @Override @@ -84,19 +101,9 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL int id = guibutton.id; if (id == 0 && selectedName != null) { - // Load the selected ability - Ability loaded = AbilityController.Instance.getSavedAbility(selectedName); - if (loaded != null) { - if (parentConfig != null) { - parentConfig.loadAbility(loaded); - } else if (parentAbilities != null) { - parentAbilities.loadAbility(loaded); - } - } - close(); - } else if (id == 1 && selectedName != null) { - // Delete confirmation - setSubGui(new SubGuiAbilityDeleteConfirm(selectedName, this)); + // Request ability data from server + waitingForLoad = true; + PacketClient.sendClient(new SavedAbilityGetPacket(selectedName)); } else if (id == 2) { close(); } @@ -113,8 +120,34 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL @Override public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { if (scroll.id == 0 && selection != null && !selection.isEmpty()) { - // Double-click to load immediately - Ability loaded = AbilityController.Instance.getSavedAbility(selection); + // Double-click to load - request from server + selectedName = selection; + waitingForLoad = true; + PacketClient.sendClient(new SavedAbilityGetPacket(selection)); + } + } + + @Override + public void setData(Vector list, HashMap data, EnumScrollData type) { + if (type == EnumScrollData.ABILITIES) { + String name = scroll != null ? scroll.getSelected() : null; + this.abilityData = data; + if (scroll != null) { + scroll.setList(getFilteredList()); + if (name != null && abilityData.containsKey(name)) { + scroll.setSelected(name); + } + } + initGui(); + } + } + + @Override + public void setGuiData(NBTTagCompound compound) { + // Received ability data from server + if (waitingForLoad) { + waitingForLoad = false; + Ability loaded = AbilityController.Instance.fromNBT(compound); if (loaded != null) { if (parentConfig != null) { parentConfig.loadAbility(loaded); @@ -126,13 +159,11 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL } } - /** - * Called after an ability is deleted to refresh the list. - */ - public void onAbilityDeleted(String name) { - if (name.equals(selectedName)) { - selectedName = null; + @Override + public void setSelected(String selected) { + this.selectedName = selected; + if (scroll != null) { + scroll.setSelected(selected); } - initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySaveConfirm.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySaveConfirm.java index 3be13f0be..760f3eb9b 100644 --- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySaveConfirm.java +++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilitySaveConfirm.java @@ -1,23 +1,30 @@ package noppes.npcs.client.gui.advanced; import kamkeel.npcs.controllers.data.ability.Ability; -import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.request.ability.SavedAbilitySavePacket; 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.IAbilityConfigCallback; import noppes.npcs.client.gui.util.SubGuiInterface; /** * Confirmation dialog for saving an ability preset. + * Uses packet-based communication for proper client-server architecture. */ public class SubGuiAbilitySaveConfirm extends SubGuiInterface { private final Ability ability; - private final boolean exists; + private final IAbilityConfigCallback callback; public SubGuiAbilitySaveConfirm(Ability ability) { + this(ability, null); + } + + public SubGuiAbilitySaveConfirm(Ability ability, IAbilityConfigCallback callback) { this.ability = ability; - this.exists = AbilityController.Instance.hasSavedAbility(ability.getName()); + this.callback = callback; setBackground("menubg.png"); xSize = 200; @@ -30,15 +37,9 @@ public class SubGuiAbilitySaveConfirm extends SubGuiInterface { int y = guiTop + 10; - if (exists) { - addLabel(new GuiNpcLabel(0, "ability.save.overwrite", guiLeft + 10, y)); - y += 12; - addLabel(new GuiNpcLabel(1, "'" + ability.getName() + "'?", guiLeft + 10, y)); - } else { - addLabel(new GuiNpcLabel(0, "ability.save.confirm", guiLeft + 10, y)); - y += 12; - addLabel(new GuiNpcLabel(1, "'" + ability.getName() + "'?", guiLeft + 10, y)); - } + addLabel(new GuiNpcLabel(0, "ability.save.confirm", guiLeft + 10, y)); + y += 12; + addLabel(new GuiNpcLabel(1, "'" + ability.getName() + "'?", guiLeft + 10, y)); y += 30; @@ -51,8 +52,11 @@ public class SubGuiAbilitySaveConfirm extends SubGuiInterface { int id = guibutton.id; if (id == 0) { - // Save the ability - AbilityController.Instance.saveAbility(ability); + // Save the ability via packet + PacketClient.sendClient(new SavedAbilitySavePacket(ability.writeNBT())); + if (callback != null) { + callback.onAbilitySaved(ability); + } close(); } else if (id == 1) { close(); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java index 22d0f3103..cb5220d54 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java @@ -1,122 +1,266 @@ package noppes.npcs.client.gui.global; +import kamkeel.npcs.client.renderer.TelegraphRenderer; import kamkeel.npcs.controllers.data.ability.Ability; import kamkeel.npcs.controllers.data.ability.AbilityController; +import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.request.ability.SavedAbilitiesGetPacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilityGetPacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilityRemovePacket; +import kamkeel.npcs.network.packets.request.ability.SavedAbilitySavePacket; import net.minecraft.client.gui.GuiButton; -import noppes.npcs.client.gui.advanced.SubGuiAbilityDeleteConfirm; +import net.minecraft.client.gui.GuiYesNo; +import net.minecraft.client.gui.GuiYesNoCallback; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import noppes.npcs.client.NoppesUtil; +import noppes.npcs.client.gui.util.AbilityPreviewExecutor; +import noppes.npcs.client.gui.util.GuiAbilityInterface; import noppes.npcs.client.gui.util.GuiCustomScroll; -import noppes.npcs.client.gui.util.GuiNPCInterface2; 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.GuiTexturedButton; import noppes.npcs.client.gui.util.IAbilityConfigCallback; import noppes.npcs.client.gui.util.ICustomScrollListener; +import noppes.npcs.client.gui.util.IGuiData; +import noppes.npcs.client.gui.util.IScrollData; import noppes.npcs.client.gui.util.ISubGuiListener; +import noppes.npcs.client.gui.util.ITextfieldListener; import noppes.npcs.client.gui.util.SubGuiInterface; +import noppes.npcs.constants.EnumScrollData; +import noppes.npcs.controllers.data.AnimationData; import noppes.npcs.entity.EntityNPCInterface; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.Set; +import java.util.Vector; /** - * Global GUI for managing saved ability presets. - * Allows viewing, editing, and deleting saved abilities. + * Global GUI for managing saved ability presets with 3D preview. + * + * Features: + * - Left side: 3D preview of NPC with ability effects + * - Right side: Ability list with search + * - Play/Pause/Stop buttons to preview abilities */ -public class GuiNpcManageAbilities extends GuiNPCInterface2 implements ICustomScrollListener, ISubGuiListener, IAbilityConfigCallback { +public class GuiNpcManageAbilities extends GuiAbilityInterface + implements ICustomScrollListener, ISubGuiListener, IAbilityConfigCallback, + ITextfieldListener, GuiYesNoCallback, IScrollData, IGuiData { + // ==================== DATA ==================== private GuiCustomScroll scroll; - private String selectedName = null; - private List abilityNames = new ArrayList<>(); + private HashMap abilityData = new HashMap<>(); + private String selected = null; private String search = ""; + private Ability selectedAbility = null; + + // ==================== PREVIEW ==================== + private AbilityPreviewExecutor previewExecutor; + private long prevTick = 0; public GuiNpcManageAbilities(EntityNPCInterface npc) { super(npc); - loadAbilityNames(); - } - private void loadAbilityNames() { - Set names = AbilityController.Instance.getSavedAbilityNames(); - abilityNames = new ArrayList<>(names); + // Layout offset + this.xOffset = -148 + 110; + this.yOffset = -170 + 167; + + // Initialize preview executor + previewExecutor = new AbilityPreviewExecutor(); + previewExecutor.setParentGui(this); + + // Request ability data from server + PacketClient.sendClient(new SavedAbilitiesGetPacket()); + + // Enable animation data + AnimationData data = npc.display.animationData; + data.setEnabled(true); } @Override public void initGui() { super.initGui(); - int y = guiTop + 10; + // Edit button (above Remove) + addButton(new GuiNpcButton(100, guiLeft + 368, guiTop + 8, 45, 20, "gui.edit")); + getButton(100).setEnabled(selected != null && !selected.isEmpty() && selectedAbility != null); - // Title label - addLabel(new GuiNpcLabel(0, "ability.manager.title", guiLeft + 10, y)); - y += 20; + // Remove button + addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 30, 45, 20, "gui.remove")); + getButton(1).setEnabled(selected != null && !selected.isEmpty() && abilityData.containsKey(selected)); - // Scroll list of saved abilities + // Scroll list of saved abilities (right side) if (scroll == null) { scroll = new GuiCustomScroll(this, 0); + scroll.setSize(143, 185); } - scroll.setSize(xSize - 90, 160); - scroll.guiLeft = guiLeft + 10; - scroll.guiTop = y; - scroll.setUnsortedList(getFilteredList()); - if (selectedName != null && abilityNames.contains(selectedName)) { - scroll.setSelected(selectedName); - } + scroll.guiLeft = guiLeft + 220; + scroll.guiTop = guiTop + 4; addScroll(scroll); + // Update scroll list + scroll.setList(getSearchList()); + if (selected != null && abilityData.containsKey(selected)) { + scroll.setSelected(selected); + } + // Search bar - addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 10, y + 163, xSize - 90, 18, search)); + addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 220, guiTop + 192, 143, 20, search)); - // Right side buttons - int btnX = guiLeft + xSize - 70; - addButton(new GuiNpcButton(1, btnX, y, 60, 20, "gui.edit")); - addButton(new GuiNpcButton(2, btnX, y + 25, 60, 20, "gui.delete")); - addButton(new GuiNpcButton(3, btnX, y + 60, 60, 20, "selectServer.refresh")); + // Show ability info only if one is selected + if (selectedAbility == null || selected == null) { + return; + } - // Enable/disable buttons based on selection - getButton(1).setEnabled(selectedName != null && !selectedName.isEmpty()); - getButton(2).setEnabled(selectedName != null && !selectedName.isEmpty()); + // ID/Name label (below search bar) + addLabel(new GuiNpcLabel(10, "ID: " + selectedAbility.getId(), guiLeft + 220, guiTop + 215)); + + // Play/Pause/Stop buttons (below model preview area) + String animTexture = "customnpcs:textures/gui/animation.png"; + int playButtonOffsetX = 60; + + boolean isPlaying = previewExecutor.isPlaying() && !previewExecutor.isPaused(); + boolean isPaused = previewExecutor.isPaused(); + boolean isActive = previewExecutor.isActive(); + + if (!isPlaying || isPaused) { + // Show Play button + String statusKey = isPaused ? "animation.paused" : "animation.stopped"; + addLabel(new GuiNpcLabel(90, statusKey, guiLeft + playButtonOffsetX, guiTop + 198)); + addButton(new GuiTexturedButton(91, "", guiLeft + playButtonOffsetX + 70, guiTop + 192, 11, 20, animTexture, 18, 71)); + } else { + // Show Pause button + addLabel(new GuiNpcLabel(90, "animation.playing", guiLeft + playButtonOffsetX, guiTop + 198)); + addButton(new GuiTexturedButton(92, "", guiLeft + playButtonOffsetX + 70, guiTop + 192, 14, 20, animTexture, 0, 71)); + } + if (isActive) { + // Show Stop button + addButton(new GuiTexturedButton(93, "", guiLeft + playButtonOffsetX + 90, guiTop + 192, 14, 20, animTexture, 33, 71)); + } } - private List getFilteredList() { + private List getSearchList() { if (search.isEmpty()) { - return new ArrayList<>(abilityNames); + return new ArrayList<>(abilityData.keySet()); } - List filtered = new ArrayList<>(); - for (String name : abilityNames) { + List list = new ArrayList<>(); + for (String name : abilityData.keySet()) { if (name.toLowerCase().contains(search.toLowerCase())) { - filtered.add(name); + list.add(name); } } - return filtered; + return list; } @Override - public void buttonEvent(GuiButton guibutton) { + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + // IMPORTANT: Set NPC rotation BEFORE ticking entities + // This ensures anchor point calculations use the correct facing direction + npc.prevRenderYawOffset = npc.renderYawOffset = NPC_FACING_YAW; + npc.prevRotationYaw = npc.rotationYaw = NPC_FACING_YAW; + npc.prevRotationYawHead = npc.rotationYawHead = NPC_FACING_YAW; + + // Tick preview executor (entities will use the rotation set above) + tickPreview(); + + // Draw base (includes 3D preview via parent class) + super.drawScreen(mouseX, mouseY, partialTicks); + + // Draw status text + if (previewExecutor.isActive()) { + String status = previewExecutor.getStatusString(); + fontRendererObj.drawString(status, guiLeft + 12, guiTop + 175, 0xFFFFFF); + } + } + + /** + * Tick the preview executor and animations. + */ + private void tickPreview() { + if (previewExecutor.isPlaying() && !previewExecutor.isPaused()) { + long time = mc.theWorld != null ? mc.theWorld.getTotalWorldTime() : System.currentTimeMillis() / 50; + if (time != prevTick) { + // Advance animation + npc.display.animationData.increaseTime(); + + // Tick preview + previewExecutor.tick(); + + // Sync telegraph to GUI for rendering + setPreviewTelegraph(previewExecutor.getTelegraph()); + + prevTick = time; + + // Check if preview finished + if (!previewExecutor.isActive()) { + initGui(); + } + } + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + int id = guibutton.id; - if (id == 1 && selectedName != null) { + if (id == 1 && selected != null && abilityData.containsKey(selected)) { + // Remove - show confirmation + GuiYesNo guiyesno = new GuiYesNo(this, selected, StatCollector.translateToLocal("gui.delete"), 1); + displayGuiScreen(guiyesno); + } else if (id == 100 && selectedAbility != null) { // Edit - Ability ability = AbilityController.Instance.getSavedAbility(selectedName); - if (ability != null) { - setSubGui(ability.createConfigGui(this)); + previewExecutor.stop(); + setSubGui(selectedAbility.createConfigGui(this)); + } else if (id == 91) { + // Play button + if (selectedAbility != null) { + if (previewExecutor.isPaused()) { + previewExecutor.play(); + } else { + previewExecutor.startPreview(selectedAbility, npc); + } + initGui(); } - } else if (id == 2 && selectedName != null) { - // Delete - setSubGui(new SubGuiAbilityDeleteConfirm(selectedName, null)); - } else if (id == 3) { - // Refresh - AbilityController.Instance.load(); - loadAbilityNames(); - selectedName = null; + } else if (id == 92) { + // Pause button + previewExecutor.pause(); initGui(); + } else if (id == 93) { + // Stop button + previewExecutor.stop(); + initGui(); + } + } + + @Override + public void keyTyped(char c, int i) { + super.keyTyped(c, i); + if (getTextField(55) != null && getTextField(55).isFocused()) { + if (!search.equals(getTextField(55).getText())) { + search = getTextField(55).getText(); + scroll.resetScroll(); + scroll.setList(getSearchList()); + } } } @Override public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) { if (scroll.id == 0) { - selectedName = scroll.getSelected(); - initGui(); + String newSelection = scroll.getSelected(); + if (newSelection != null && !newSelection.equals(selected)) { + // Stop any playing preview + previewExecutor.stop(); + + selected = newSelection; + // Request ability data from server + PacketClient.sendClient(new SavedAbilityGetPacket(selected)); + } } } @@ -124,48 +268,90 @@ public class GuiNpcManageAbilities extends GuiNPCInterface2 implements ICustomSc public void customScrollDoubleClicked(String selection, GuiCustomScroll scroll) { if (scroll.id == 0 && selection != null && !selection.isEmpty()) { // Double-click to edit - Ability ability = AbilityController.Instance.getSavedAbility(selection); - if (ability != null) { - setSubGui(ability.createConfigGui(this)); + if (selectedAbility != null) { + previewExecutor.stop(); + setSubGui(selectedAbility.createConfigGui(this)); } } } @Override - public void keyTyped(char c, int i) { - super.keyTyped(c, i); - if (getTextField(1) != null && getTextField(1).isFocused()) { - if (!search.equals(getTextField(1).getText())) { - search = getTextField(1).getText(); - scroll.setUnsortedList(getFilteredList()); - scroll.resetScroll(); + public void setData(Vector list, HashMap data, EnumScrollData type) { + if (type == EnumScrollData.ABILITIES) { + String name = scroll != null ? scroll.getSelected() : null; + this.abilityData = data; + if (scroll != null) { + scroll.setList(getSearchList()); + if (name != null && abilityData.containsKey(name)) { + scroll.setSelected(name); + } } + initGui(); + } + } + + @Override + public void setGuiData(NBTTagCompound compound) { + // Received ability data from server + selectedAbility = AbilityController.Instance.fromNBT(compound); + if (selectedAbility != null) { + selected = selectedAbility.getName(); + if (scroll != null) { + scroll.setSelected(selected); + } + } + previewExecutor.stop(); + initGui(); + } + + @Override + public void setSelected(String selected) { + this.selected = selected; + if (scroll != null) { + scroll.setSelected(selected); } } @Override public void subGuiClosed(SubGuiInterface subgui) { - // Refresh list after any sub gui closes - loadAbilityNames(); - if (subgui instanceof SubGuiAbilityDeleteConfirm) { - // After delete, clear selection if it was deleted - if (selectedName != null && !abilityNames.contains(selectedName)) { - selectedName = null; - } - } initGui(); } + @Override + public void confirmClicked(boolean result, int id) { + NoppesUtil.openGUI(player, this); + if (!result) return; + + if (id == 1 && selected != null && abilityData.containsKey(selected)) { + // Delete ability via packet + PacketClient.sendClient(new SavedAbilityRemovePacket(selected)); + scroll.clear(); + selected = null; + selectedAbility = null; + initGui(); + } + } + @Override public void onAbilitySaved(Ability ability) { - // Save the edited ability - AbilityController.Instance.saveAbility(ability); - loadAbilityNames(); - initGui(); + // Save the edited ability via packet + PacketClient.sendClient(new SavedAbilitySavePacket(ability.writeNBT())); + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + // Search field handling is done in keyTyped } @Override public void save() { - // Nothing to save - abilities are saved individually + // Nothing to save - abilities are saved individually via packets + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + // Stop preview when GUI closes + previewExecutor.stop(); } } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java index bca447b1f..b055cbf43 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCGlobalMainMenu.java @@ -39,6 +39,7 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 { private GuiNpcSquareButton effectsButton; private GuiNpcSquareButton magicsButton; private GuiNpcSquareButton abilitiesButton; + private GuiNpcSquareButton auctionsButton; public GuiNPCGlobalMainMenu(EntityNPCInterface npc) { super(npc, 5); @@ -96,7 +97,10 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 { magicsButton.setIconPos(24, 24, 48, 56).setIconTexture(specialIcons); registerButton(abilitiesButton = new GuiNpcSquareButton(21, 0, 0, 20, "global.abilities", 0xFF333333)); - abilitiesButton.setIconPos(24, 24, 72, 56).setIconTexture(specialIcons); // Placeholder icon position + abilitiesButton.setIconPos(24, 24, 72, 56).setIconTexture(specialIcons); + + registerButton(auctionsButton = new GuiNpcSquareButton(22, 0, 0, 20, "global.auction", 0xFF333333)); + auctionsButton.setIconPos(24, 24, 96, 56).setIconTexture(specialIcons); // Layout composite buttons optimally. layoutButtons(); @@ -240,7 +244,10 @@ public class GuiNPCGlobalMainMenu extends GuiNPCInterface2 { NoppesUtil.requestOpenGUI(EnumGuiType.ManageEffects); } if (id == 21) { - NoppesUtil.openGUI(player, new noppes.npcs.client.gui.global.GuiNpcManageAbilities(npc)); + NoppesUtil.requestOpenGUI(EnumGuiType.ManageAbilities); + } + if (id == 22) { + // NoppesUtil.requestOpenGUI(EnumGuiType.ManageAuction); } } diff --git a/src/main/java/noppes/npcs/client/gui/util/AbilityPreviewExecutor.java b/src/main/java/noppes/npcs/client/gui/util/AbilityPreviewExecutor.java new file mode 100644 index 000000000..3dce761d5 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/util/AbilityPreviewExecutor.java @@ -0,0 +1,368 @@ +package noppes.npcs.client.gui.util; + +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.AbilityPhase; +import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; +import kamkeel.npcs.entity.EntityAbilityBeam; +import kamkeel.npcs.entity.EntityAbilityDisc; +import kamkeel.npcs.entity.EntityAbilityLaser; +import kamkeel.npcs.entity.EntityAbilityOrb; +import kamkeel.npcs.entity.EntityAbilityProjectile; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; +import noppes.npcs.controllers.data.Animation; +import noppes.npcs.controllers.data.AnimationData; +import noppes.npcs.entity.EntityCustomNpc; +import noppes.npcs.entity.EntityNPCInterface; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Client-side executor for previewing abilities in the GUI. + * + * Lifecycle: + * 1. WINDUP phase - plays windup animation, entities spawn and charge + * 2. ACTIVE phase - plays active animation, entities fire and move + * 3. EXTENDED phase - continues for +100 ticks after animations to see results + * 4. IDLE - preview complete + * + * Features: + * - Invisible fake target NPC placed in front of the preview NPC for targeting + * - NPC movement tracking for abilities that move the NPC (e.g. slam) + */ +@SideOnly(Side.CLIENT) +public class AbilityPreviewExecutor { + + // ==================== PREVIEW STATE ==================== + private Ability previewAbility; + private EntityNPCInterface previewNpc; + private AbilityPhase phase = AbilityPhase.IDLE; + private int currentTick = 0; + private boolean playing = false; + private boolean paused = false; + + // ==================== TIMING ==================== + private static final int EXTENDED_DURATION = 100; + private int activeDuration = 40; + + // ==================== FAKE TARGET ==================== + /** Invisible fake target NPC for ability targeting (placed 5 blocks in front of preview NPC) */ + private EntityNPCInterface fakeTarget; + private static final double TARGET_DISTANCE = 5.0; + + // ==================== NPC START POSITION ==================== + /** Saved NPC position for restoring after movement abilities */ + private double npcStartX, npcStartY, npcStartZ; + + // ==================== PREVIEW CONTENT ==================== + private TelegraphInstance previewTelegraph; + private List previewEntities = new ArrayList<>(); + + // ==================== CALLBACKS ==================== + private GuiAbilityInterface parentGui; + + public AbilityPreviewExecutor() { + } + + public void setParentGui(GuiAbilityInterface gui) { + this.parentGui = gui; + } + + /** + * Start previewing an ability. + */ + public void startPreview(Ability ability, EntityNPCInterface npc) { + stop(); + + this.previewAbility = ability; + this.previewNpc = npc; + this.phase = AbilityPhase.WINDUP; + this.currentTick = 0; + this.playing = true; + this.paused = false; + this.activeDuration = ability.getPreviewActiveDuration(); + + // Save NPC start position for restoring later + this.npcStartX = npc.posX; + this.npcStartY = npc.posY; + this.npcStartZ = npc.posZ; + + // Create invisible fake target NPC for targeting + createFakeTarget(npc); + + // Set preview target on the ability + ability.setPreviewTarget(fakeTarget); + + // Start tracking NPC movement + if (parentGui != null) { + parentGui.startTrackingMovement(); + } + + // Create telegraph for preview + previewTelegraph = ability.createTelegraph(npc, fakeTarget); + + // Start windup animation + Animation windUpAnim = ability.getWindUpAnimation(); + if (windUpAnim != null) { + AnimationData data = npc.display.animationData; + data.setEnabled(true); + data.setAnimation(windUpAnim); + data.animation.paused = false; + } + + // Spawn preview entity on first tick if ability spawns during windup + if (ability.spawnPreviewDuringWindup()) { + spawnPreviewEntity(); + } + } + + /** + * Create an invisible fake target NPC placed in front of the preview NPC. + * This entity is NOT rendered - it only exists for ability targeting logic. + */ + private void createFakeTarget(EntityNPCInterface npc) { + if (npc.worldObj == null) return; + + try { + fakeTarget = new EntityCustomNpc(npc.worldObj); + // Position target in front of NPC based on its facing direction + float facingYaw = GuiAbilityInterface.NPC_FACING_YAW; + double yawRad = Math.toRadians(facingYaw); + double targetX = npc.posX - Math.sin(yawRad) * TARGET_DISTANCE; + double targetY = npc.posY; + double targetZ = npc.posZ + Math.cos(yawRad) * TARGET_DISTANCE; + fakeTarget.setPosition(targetX, targetY, targetZ); + fakeTarget.prevPosX = targetX; + fakeTarget.prevPosY = targetY; + fakeTarget.prevPosZ = targetZ; + } catch (Exception e) { + fakeTarget = null; + } + } + + /** + * Get the fake target entity for abilities that need a target. + */ + public EntityLivingBase getFakeTarget() { + return fakeTarget; + } + + public void play() { + if (previewAbility == null || phase == AbilityPhase.IDLE) { + return; + } + playing = true; + paused = false; + + if (previewNpc != null) { + AnimationData data = previewNpc.display.animationData; + if (data.animation != null) { + data.animation.paused = false; + } + } + } + + public void pause() { + paused = true; + + if (previewNpc != null) { + AnimationData data = previewNpc.display.animationData; + if (data.animation != null) { + data.animation.paused = true; + } + } + } + + public void stop() { + playing = false; + paused = false; + phase = AbilityPhase.IDLE; + currentTick = 0; + + previewTelegraph = null; + + if (parentGui != null) { + for (Entity entity : previewEntities) { + parentGui.removePreviewEntity(entity); + } + parentGui.stopTrackingMovement(); + parentGui.setPreviewTelegraph(null); + } + previewEntities.clear(); + + // Reset NPC position to start position (undo movement from Slam/Charge/Dash) + if (previewNpc != null && npcStartX != 0 && npcStartY != 0 && npcStartZ != 0) { + previewNpc.posX = npcStartX; + previewNpc.posY = npcStartY; + previewNpc.posZ = npcStartZ; + previewNpc.prevPosX = npcStartX; + previewNpc.prevPosY = npcStartY; + previewNpc.prevPosZ = npcStartZ; + } + + // Remove fake target + fakeTarget = null; + + if (previewNpc != null) { + AnimationData data = previewNpc.display.animationData; + data.setAnimation(new Animation()); + data.animation.paused = false; + } + } + + /** + * Tick the preview forward. + */ + public void tick() { + if (!playing || paused || previewAbility == null || previewNpc == null) { + return; + } + + currentTick++; + + if (previewTelegraph != null) { + previewTelegraph.tick(null); + } + + tickEntities(); + + switch (phase) { + case WINDUP: + tickWindup(); + break; + case ACTIVE: + tickActive(); + break; + case IDLE: + tickExtended(); + break; + default: + break; + } + } + + private void tickWindup() { + previewAbility.onPreviewWindUpTick(previewNpc, currentTick); + + if (currentTick >= previewAbility.getWindUpTicks()) { + transitionToActive(); + } + } + + private void tickActive() { + previewAbility.onPreviewActiveTick(previewNpc, currentTick); + + if (currentTick == 1 && !previewAbility.spawnPreviewDuringWindup()) { + spawnPreviewEntity(); + fireEntities(); + } + + if (currentTick >= activeDuration) { + transitionToExtended(); + } + } + + private void tickExtended() { + if (currentTick >= EXTENDED_DURATION) { + playing = false; + } + } + + private void transitionToActive() { + phase = AbilityPhase.ACTIVE; + currentTick = 0; + + previewTelegraph = null; + + // Notify ability of execution (for movement abilities like Slam/Charge/Dash) + previewAbility.onPreviewExecute(previewNpc); + + fireEntities(); + + Animation activeAnim = previewAbility.getActiveAnimation(); + if (activeAnim != null && previewNpc != null) { + AnimationData data = previewNpc.display.animationData; + data.setAnimation(activeAnim); + data.animation.paused = false; + } + } + + private void transitionToExtended() { + phase = AbilityPhase.IDLE; + currentTick = 0; + + if (previewNpc != null) { + AnimationData data = previewNpc.display.animationData; + data.setAnimation(new Animation()); + } + } + + private void spawnPreviewEntity() { + Entity entity = previewAbility.createPreviewEntity(previewNpc); + if (entity != null) { + previewEntities.add(entity); + if (parentGui != null) { + parentGui.addPreviewEntity(entity); + } + } + } + + private void fireEntities() { + for (Entity entity : previewEntities) { + if (entity instanceof EntityAbilityOrb) { + ((EntityAbilityOrb) entity).startPreviewFiring(); + } else if (entity instanceof EntityAbilityBeam) { + ((EntityAbilityBeam) entity).startPreviewFiring(); + } else if (entity instanceof EntityAbilityDisc) { + ((EntityAbilityDisc) entity).startPreviewFiring(); + } + } + } + + private void tickEntities() { + Iterator iter = previewEntities.iterator(); + while (iter.hasNext()) { + Entity entity = iter.next(); + if (entity == null || entity.isDead) { + if (parentGui != null) { + parentGui.removePreviewEntity(entity); + } + iter.remove(); + continue; + } + entity.onUpdate(); + } + } + + // ==================== GETTERS ==================== + + public boolean isPlaying() { return playing; } + public boolean isPaused() { return paused; } + public boolean isActive() { return playing || paused; } + public AbilityPhase getPhase() { return phase; } + public int getCurrentTick() { return currentTick; } + public TelegraphInstance getTelegraph() { return previewTelegraph; } + public List getPreviewEntities() { return previewEntities; } + public Ability getPreviewAbility() { return previewAbility; } + public EntityNPCInterface getPreviewNpc() { return previewNpc; } + + public String getStatusString() { + if (!playing && !paused) { + return "Stopped"; + } else if (paused) { + return "Paused"; + } else if (phase == AbilityPhase.WINDUP) { + return "Windup: " + currentTick + "/" + (previewAbility != null ? previewAbility.getWindUpTicks() : 0); + } else if (phase == AbilityPhase.ACTIVE) { + return "Active: " + currentTick + "/" + activeDuration; + } else if (phase == AbilityPhase.IDLE && playing) { + return "Extended: " + currentTick + "/" + EXTENDED_DURATION; + } + return ""; + } +} diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiAbilityInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiAbilityInterface.java new file mode 100644 index 000000000..c9c44ff93 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/util/GuiAbilityInterface.java @@ -0,0 +1,391 @@ +package noppes.npcs.client.gui.util; + +import kamkeel.npcs.client.renderer.TelegraphRenderer; +import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import noppes.npcs.client.ClientEventHandler; +import noppes.npcs.client.EntityUtil; +import noppes.npcs.entity.EntityCustomNpc; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.entity.data.ModelData; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.ArrayList; +import java.util.List; + +/** + * Base GUI class for ability preview with fixed camera. + * + * Key concepts: + * - NPC positioned on left side of preview area + * - NPC faces a fixed direction (NPC_FACING_YAW) + * - Viewing direction can be rotated (rotates entire 3D space) + * - Fixed zoom level + * - Preview entities rendered in same coordinate space as NPC + * - NPC position changes (e.g. slam jump) tracked and rendered + */ +public class GuiAbilityInterface extends GuiNPCInterface2 { + + // ==================== FIXED CAMERA SETTINGS ==================== + /** Fixed camera zoom level (higher = more zoomed in) */ + protected static float CAMERA_ZOOM = 45.0f; + /** NPC facing direction - affects anchor points and visual facing */ + protected static float NPC_FACING_YAW = 160.0f; + /** Camera pitch (slight downward angle) */ + protected static float CAMERA_PITCH = 10.0f; + + // ==================== VIEWING ROTATION ==================== + /** Viewing direction rotation (rotates entire 3D space) */ + protected static float viewRotation = 0.0f; + + private GuiNpcButton btnLeft, btnRight; + + // ==================== NPC STATE ==================== + public ModelData playerdata; + public EntityNPCInterface npc; + + /** NPC starting position (saved when preview starts, used to track movement) */ + protected double npcStartX, npcStartY, npcStartZ; + /** Whether we're tracking NPC movement */ + protected boolean trackingNpcMovement = false; + + /** Entities to render in preview space */ + protected List previewEntities = new ArrayList<>(); + + /** Current telegraph to render in preview */ + protected TelegraphInstance previewTelegraph; + + // ==================== LAYOUT ==================== + /** Preview area bounds */ + protected int previewX, previewY, previewWidth, previewHeight; + /** NPC render position on screen */ + protected int npcScreenX, npcScreenY; + + public int xOffset = 0; + public int yOffset = 0; + + public GuiAbilityInterface(EntityNPCInterface npc) { + super(npc); + this.npc = npc; + this.playerdata = ((EntityCustomNpc) npc).modelData; + this.drawDefaultBackground = false; + + CAMERA_ZOOM = 30f; + NPC_FACING_YAW = 310f; + CAMERA_PITCH = 5f; + } + + @Override + public void initGui() { + super.initGui(); + + // Calculate preview area (left side of GUI) + previewX = guiLeft + 10; + previewY = guiTop + 10; + previewWidth = 200; + previewHeight = 180; + + // NPC position: left side of preview, slightly below center + npcScreenX = previewX + (int)(previewWidth * 0.33f) + xOffset; + npcScreenY = previewY + (int)(previewHeight * 0.85f) + yOffset; + + // Viewing rotation buttons (below preview area) + int btnY = guiTop + 192; + addButton(btnLeft = new GuiNpcButton(680, guiLeft + 10, btnY, 20, 20, "<")); + addButton(btnRight = new GuiNpcButton(681, guiLeft + 32, btnY, 20, 20, ">")); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + // Handle held rotation buttons + if (Mouse.isButtonDown(0)) { + if (btnLeft != null && btnLeft.mousePressed(mc, mouseX, mouseY)) { + viewRotation += partialTicks * 2; + } else if (btnRight != null && btnRight.mousePressed(mc, mouseX, mouseY)) { + viewRotation -= partialTicks * 2; + } + } + + // Draw background and UI elements + super.drawScreen(mouseX, mouseY, partialTicks); + + // Draw the 3D preview + drawPreview(mouseX, mouseY, partialTicks); + } + + /** + * Draw the 3D preview with NPC and entities. + */ + protected void drawPreview(int mouseX, int mouseY, float partialTicks) { + GL11.glColor4f(1, 1, 1, 1); + + // Enable scissor to clip rendering to preview area + GL11.glEnable(GL11.GL_SCISSOR_TEST); + setScissorClip(previewX, previewY, previewWidth, previewHeight); + + // Get the entity to render (could be transformed player model) + EntityLivingBase renderEntity = playerdata.getEntity(npc); + if (renderEntity == null) { + renderEntity = this.npc; + } + + // Sync NPC properties to render entity + EntityUtil.Copy(npc, renderEntity); + + // Set NPC facing direction (affects anchor points and visual facing) + npc.prevRenderYawOffset = npc.renderYawOffset = NPC_FACING_YAW; + npc.prevRotationYaw = npc.rotationYaw = NPC_FACING_YAW; + npc.prevRotationYawHead = npc.rotationYawHead = NPC_FACING_YAW; + + // Also set on render entity + renderEntity.prevRenderYawOffset = renderEntity.renderYawOffset = NPC_FACING_YAW; + renderEntity.prevRotationYaw = renderEntity.rotationYaw = NPC_FACING_YAW; + renderEntity.prevRotationYawHead = renderEntity.rotationYawHead = NPC_FACING_YAW; + renderEntity.rotationPitch = 0; + + // Calculate NPC position delta for movement rendering (e.g. slam jump) + // Interpolate with partial ticks for smooth movement between frames + double npcDeltaX = 0, npcDeltaY = 0, npcDeltaZ = 0; + if (trackingNpcMovement) { + double interpX = npc.prevPosX + (npc.posX - npc.prevPosX) * partialTicks; + double interpY = npc.prevPosY + (npc.posY - npc.prevPosY) * partialTicks; + double interpZ = npc.prevPosZ + (npc.posZ - npc.prevPosZ) * partialTicks; + npcDeltaX = interpX - npcStartX; + npcDeltaY = interpY - npcStartY; + npcDeltaZ = interpZ - npcStartZ; + } + + // ==================== BEGIN 3D RENDERING ==================== + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glPushMatrix(); + + // Move to NPC render position on screen + GL11.glTranslatef(npcScreenX, npcScreenY, 50F); + + // Apply zoom (scale) + GL11.glScalef(-CAMERA_ZOOM, CAMERA_ZOOM, CAMERA_ZOOM); + + // Flip for screen coordinates (Y is inverted) + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + + // Apply slight camera pitch (looking down at scene) + GL11.glRotatef(CAMERA_PITCH, 1.0F, 0.0F, 0.0F); + + // Apply VIEWING rotation (rotates entire space, not just NPC) + GL11.glRotatef(viewRotation, 0.0F, 1.0F, 0.0F); + + // Setup lighting (standard item lighting for consistent colors) + GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F); + RenderHelper.enableStandardItemLighting(); + GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F); + + // Adjust for entity offset + GL11.glTranslatef(0.0F, renderEntity.yOffset, 0.0F); + + RenderManager.instance.playerViewY = 180F; + ClientEventHandler.renderingEntityInGUI = true; + + // Render the NPC at its position delta (for movement like slam jumps) + try { + RenderManager.instance.renderEntityWithPosYaw(renderEntity, npcDeltaX, npcDeltaY, npcDeltaZ, 0.0F, partialTicks); + } catch (Exception e) { + playerdata.setEntityClass(null); + } + + // Render preview entities at their positions relative to NPC start position + renderPreviewEntities(partialTicks); + + // Render telegraph in preview space + renderPreviewTelegraph(partialTicks); + + ClientEventHandler.renderingEntityInGUI = false; + + GL11.glPopMatrix(); + + // Cleanup GL state + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + + // Disable scissor + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + // Clear depth buffer so UI renders on top + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + } + + /** + * Render preview entities in the same coordinate space as the NPC. + * Called WITHIN the 3D matrix transformation. + */ + protected void renderPreviewEntities(float partialTicks) { + // Save current GL state that NPC render may have changed + boolean lightingWasEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING); + + // Use the start position as the reference point for entity offsets + double refX = trackingNpcMovement ? npcStartX : npc.posX; + double refY = trackingNpcMovement ? npcStartY : npc.posY; + double refZ = trackingNpcMovement ? npcStartZ : npc.posZ; + + for (Entity entity : previewEntities) { + if (entity == null || entity.isDead) continue; + + // Calculate entity position relative to reference (NPC start position) + double offsetX = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks - refX; + double offsetY = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks - refY; + double offsetZ = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks - refZ; + + // The NPC model was translated by npc.yOffset, so we need to subtract it + offsetY -= npc.yOffset; + + // Reset GL state before each entity to ensure colors render correctly + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(GL11.GL_LIGHTING); + + try { + RenderManager.instance.renderEntityWithPosYaw(entity, offsetX, offsetY, offsetZ, entity.rotationYaw, partialTicks); + } catch (Exception e) { + // Ignore rendering errors + } + } + + // Restore lighting state for any subsequent rendering + if (lightingWasEnabled) { + GL11.glEnable(GL11.GL_LIGHTING); + } + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } + + /** + * Render the telegraph in the 3D preview space. + * Called within the GL matrix transformation. + */ + protected void renderPreviewTelegraph(float partialTicks) { + if (previewTelegraph == null) return; + if (TelegraphRenderer.Instance == null) return; + + // Telegraph position is in world coords - convert to preview space + double refX = trackingNpcMovement ? npcStartX : npc.posX; + double refY = trackingNpcMovement ? npcStartY : npc.posY; + double refZ = trackingNpcMovement ? npcStartZ : npc.posZ; + + double offsetX = previewTelegraph.getInterpolatedX(partialTicks) - refX; + double offsetY = previewTelegraph.getInterpolatedY(partialTicks) - refY; + double offsetZ = previewTelegraph.getInterpolatedZ(partialTicks) - refZ; + + // Adjust for NPC yOffset (same as entities) + offsetY -= npc.yOffset; + + TelegraphRenderer.Instance.renderTelegraphInGUI(previewTelegraph, offsetX, offsetY, offsetZ, 1.0f, partialTicks); + } + + public void setPreviewTelegraph(TelegraphInstance telegraph) { + this.previewTelegraph = telegraph; + } + + /** + * Set scissor clip for preview area. + */ + protected void setScissorClip(int x, int y, int width, int height) { + ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + int scale = sr.getScaleFactor(); + int scaledY = mc.displayHeight - (y + height) * scale; + GL11.glScissor(x * scale, scaledY, width * scale, height * scale); + } + + // ==================== MOVEMENT TRACKING ==================== + + /** + * Start tracking NPC movement from current position. + */ + public void startTrackingMovement() { + npcStartX = npc.posX; + npcStartY = npc.posY; + npcStartZ = npc.posZ; + trackingNpcMovement = true; + } + + /** + * Stop tracking NPC movement. + */ + public void stopTrackingMovement() { + trackingNpcMovement = false; + } + + // ==================== PREVIEW ENTITY MANAGEMENT ==================== + + public void addPreviewEntity(Entity entity) { + if (entity != null && !previewEntities.contains(entity)) { + previewEntities.add(entity); + } + } + + public void removePreviewEntity(Entity entity) { + previewEntities.remove(entity); + } + + public void clearPreviewEntities() { + previewEntities.clear(); + } + + public List getPreviewEntities() { + return previewEntities; + } + + public float getNpcFacingYaw() { + return NPC_FACING_YAW; + } + + // ==================== BACKGROUND ==================== + + @Override + protected void drawBackground() { + super.drawBackground(); + + drawGradientRect(previewX, previewY, previewX + previewWidth, previewY + previewHeight, + 0xc0101010, 0xd0101010); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + // ==================== STANDARD OVERRIDES ==================== + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + public void keyTyped(char par1, int par2) { + super.keyTyped(par1, par2); + if (par2 == 1) { + close(); + } + } + + public void close() { + this.mc.displayGuiScreen((GuiScreen) null); + this.mc.setIngameFocus(); + } + + @Override + public void save() { + } + + @Override + protected void actionPerformed(GuiButton btn) { + if (btn.id == 670) { + close(); + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java index 8a1d015d0..cef818647 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiModelInterface2.java @@ -18,11 +18,11 @@ import org.lwjgl.opengl.GL12; public class GuiModelInterface2 extends GuiNPCInterface2 { public ModelData playerdata; - private static float rotation = 0; + protected static float rotation = 0; private GuiNpcButton left, right, zoom, unzoom; - private static float zoomed = 60; + protected static float zoomed = 60; public int xOffset = 0; public int yOffset = 0; diff --git a/src/main/java/noppes/npcs/constants/EnumScrollData.java b/src/main/java/noppes/npcs/constants/EnumScrollData.java index 235f2719b..baf994b4e 100644 --- a/src/main/java/noppes/npcs/constants/EnumScrollData.java +++ b/src/main/java/noppes/npcs/constants/EnumScrollData.java @@ -7,6 +7,7 @@ public enum EnumScrollData { DIALOG_GROUP, QUEST_GROUP, ABILITY_TYPES, + ABILITIES, ANIMATIONS, BUILTIN_ANIMATIONS } diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 50c150624..fef02e070 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -689,6 +689,8 @@ global.naturalspawn=Spawns global.linked=Linked global.customeffects=Effects global.magic=Magic +global.abilities=Abilities +global.auction=Auction bank.slot=Slot bank.unlock=Unlock @@ -1714,7 +1716,6 @@ ability.delete.confirm=Delete ability preset gui.load=Load # Global Abilities Manager -global.abilities=Abilities ability.manager.title=Ability Manager # Explosive Hover Text diff --git a/src/main/resources/assets/customnpcs/textures/gui/icons.png b/src/main/resources/assets/customnpcs/textures/gui/icons.png index 86bf094c4c9681be9d316b9dced36f8b635d2a81..6f2993cd1eeadf33e09f0723f3f0746d1ff045c6 100644 GIT binary patch literal 11934 zcmeHt=T}qF+vQC{?;;4&k=~mWX+cm>EEH+d1qJE73L!M90*Vv?DIx+QU3v>h6O`Vh z22kk`dLkj2%WvM9HETZ1djEj=aFg7u+??|~=RD=?z2o#B>d;cLQ2_uzd-u*QLjZt) zA0Yq*8Te-DUE*+Y=VPd&2~-SmYybccaQD_tqrjYw|~xVz8$T_6$fLCs{ddbd0sg0fJUlRp=a3gL_ne8J;I5X=C+ zz*`X`z-8E?l6*|LRSVhe+dTjZt3dOHArQTlxW8VjVp(tFwAIyPCBQXoWp^D~R3y2l zm=aZ0kpB)>ogMS4srs#NKkWk<2>;Mhx9nf_sKs3qK*Q8RO<8JT@QZOvD`I&8#s$R3 z$1i&-{qB48NT|!9wlkLF(_0cj_4GmC-as6pN?Sq*;`TY$!(s7_M#HZ}|1xF(!;iw> zg|bs+{hH@Lw{3v{&MoBbLNRxTi}*F%pIVCn6=mg%dn`U=aEG4*;op{#-tWMkB;?qUVa;$ik9kVut0n%uVY>c+2RE>jvlNQyd`P=>CmxM z{N};!2hWM4oF%2D-Cs|KpPc_taus!c!%cjtPLY>=1_8Dldz<)Sn(ju{mjRFSqPc;a zV&3)ZiR5A6ke|zjVF1lbv!ITH1H&0*WhRTCwy%`Y^Z+k5Xp0_bu9EI31AvRa&y*J< zXM4paaQXl`Gz0KribOjTjURnv45Y@o)YlYWXEv- z-1XDd66kLkNHuW}TrKq4u!NeQW>I;ZZBtWF|9~viPyjVA2I0bo`jdYmt~|`apQ=gz zfdfk7{yp^9>Iok#R#(s2SXd8<1bV>&YQV7p&Hj()1}62oAtq83IFRQJfCRT#{J8=L zH=lxn*R>R-OT15B14z*|RPKyC!#;X%ds{z5Rp1%bS91w)4QHZ9Lo0@NJ+B@;TJgZ- z*&EvLsY{|-NaHK_3sv$*OI~MZ$3&b7@|G?NHsCGaA5;qce#smWE}}jav_WlF=3lCv z-16?Wz_8ytQvKQF4vIY@Ov8Ee*2hl|Z#{TWG~eaIcWq|2&P87zLpm^c4}#iKLc)Wi zZg~cUi27T9N#Co~FB_d*ptUk%<>4pKWpaO&oYAo7t0cYfD~q^BSUqrYowx(X@$hhy zqbbA5fbY}M^Q5fVpi!lAs^-C79H>zEDL<+Y;;N86@#e~JIl!#x;3gAO2(KymZf6*w zfmBqTnkS2ppz>$VZfmcd3$5u29mI6p+S$?&FE*rRJBhGc+(*)KF_SVh0NOIpMw)FsRdw{yS)6f$A&MBX+{2>5FRDgmHM!+^}%=o zKW&P~Yeq;(kq{Be)CVXbY;wqs()a`O4`uV{v7Abn09?Bvkz13QfvtT1-#@i0Ejn9E z3k%Wy4RxftojX5!=gpXHD6!U$Y+)~S(%GJ0VrVM(PKjC~g9M`N+Wu;hHXDY!(}y`ps@NuW3Cey- zTQI(p@7=TF;;4wyH!5Lkdw|vQ|l`Ux9NNdN*%+eb!Ou6 zlNuo*t((EdfE^|w!_5XRM;AM8uXR)IO!N(EJb96isJ3TAqylWGE9f!boj!06XK0+2?Vdmc(oUElV*XY0&b17&ub&fF^-f?Sw{xn?Zg%C|^weFDuIZ7%hW zU}esw@O#dLzE8G72vJ!pG3$y*U1eZ8d1U1AzQ-`n-3#}@YO$(x%te|v1~qaUQGlero7Oxc`3*OOjjXi&XTJN912X= zYn$%EI`_QQUbYGLrlMNg1pOr{CoxBbr&WEsu^D^Q3JOpFQT5lLVJT?UQr`R_po;Ao zblOjFqBCX2z&$$D)^}W@g(#|Zkqq14zaMkmjhs6ThFl@?u!IJZG2e!<(A~hyKAzls zciC*?BejwRCBFn!cwGfcvzKzg(cbNQdSZg>sntN;wm#>XZe$#}3Q?qE89bf{}Y}8MORH=Rcw#(rRRZtZXOpQgh*L1yBq?cU~_7C`Td6*b^pHr(L$ ztLB-o)Xum){TEf3m9hb4)nP zn^c4_cv>%0B10tl-o6!)X03}wDN*3T{e8P zkJf~pjo(b&JPttgJhC5OvS1CqxP|6&<1VZ2`9{fbKKX=1s3T z)eX4>W~if!?TDao*!FKDHRrOQW)VtHS)0Ryftv+NZd6*mIWiY-S}j)HprTBXrYK0+*6oVR(6U%TWsAaM^-K=nZ@m?-wv#ci~vnVJieYjoK|7=Jry~@ z?5T|ZFg&f|6?}wxKW+*DH+~gXpQjlmcl_F9DeHLikpT*1^cCB!^*95_Q5fC+cT*HIe;R*}?AI$XaKrttOXD_zqc z;`+YuM#4T$IphSVybj4BS_X^5J7~WHQ^n-f4~)+t9rZ?wI{nXx`>R5hqELz=I6cCH z#h-a{a+=R=Q58pc$ETC>Hk0C~(ngDY$5WI06oi9x608QVv}as^(&a9F#&APSwpfy# zBGS=R_pFfw&SMGCoRdO$4G1$QJ9Fpl-5Cx1 zD_kQXG{`dopJ7G`gUniYj=$%%^q(_6$PhBF zp#R!-q@wbcUa0HwD*G=Vp=U(x@$T7WK3T$Y5Ie~{O)cq>rwAUl$#jsB7Xx}wKWu~Q2+gHSnZ+g7C z>_M2rDQ>{-gEr(eAb(w|Q`p;``Z_jf!vj3?fu|s^4ZZkh6^!a8sA9?nkEJ1eDLg|vF_~lop(l3^;-~ayO7U)&{`X4j!61Z=vg-(EX+RV}32U0vB7yfIUe8Gr@ zh41h0f3B&KO@AXxDlebrP0SUFa2ihp)1{SeXv+dGIbofGQ(2|ehHH^ikEC^S$ux*e zZ@wPDj2f57Dz3Ju1c)K%Jnq`syMJ-c^HONN(}pICXcMKhn__WE8} zd+1^P`#Z9W;R`xD-lr%JJ9LYOk6^gtlw`MFm|B&_-o{xk?N;VZ2EaEUpkM))hd7Ct z-5L_hC_-W1E8uMMyOHH(J`#EJ|LVD}FE5Wo#qcRBn|qatw$dzmtz6G_ z=W)U-XcUvF&&k-k{s+C6>7nrqcc~=95jJ$Cqk(b;cXHFn#0ae;)pt$l23_IU(yimE z%$s64#~U}dyOJgD(4|7*ODk;nRrqe|o=+4%fU{!y99Y*XcQX(>!5Mu^>2_IyCZ=*<_gq<7eqp-k`GKGHAyo zxq)o&8Xd7AL7Fr>QowPG==u8XC<5+di@+z%`FcOYe5*U(&hQ{#Y`8csK8tc>L9)Ac zrYIG9%6}Bm7)A!z81b)!4=)&TCl1Z6nE~Lz&kTr$`$AAva?%K|r2m(d!=BRH zqjLcZknx1AON{&yFK@J(XL)~-vDn9Ji9PAyC-u?Lx1>=wz?@R53~Fd6ae*{EcB8*beIS8sMAbal_uf(6Yj zL)qOE)$Gc$7skwV8EN*9J%e>0(`QI|u&HBsh1fRXrhR`x81K2moFP>Sr|bj)6{qXY z>RsD1MZR^^FS|+AR+Iq%yJVvSjqQGIKh{cA^niZS^W!A<)T3~Ws^LanZ(F+$HJ*I6 zen&N8J<}}Y-AqhTthTXVAwCd{Q}=csTiTnRHAm_k%!V1ZVEbx+H(1>1T+wWpOK0Nu zV*uIEMM$z|elW9;5nb}V){-l-O7iA>??T9$*YBMT`+)P_&10fwp}`;@K^1~}$C{NT zMb95QQ|g!te4(3Qh<>F!^h9 zSiSaFLQz-l0cl!*CXl}{CFn@Z>Mg~d?>-tU6d9vmW#s#@;9xdaM9hroAVGXdT^!+T zxEubYu735jMGL^5YS-2zaxDN})eOa7pO>^3bnej$SHOT3Oj!WA?%Ez)ma8MUfijQd zwYGfgD~M+ZDw#Z>F9i1K=}#>%V3qtcmOo7d8W}6Dd=;UA|6-%gzZ7E~V5K!;Dt1l? ztz-d!zvqIq@8lv=Y9&Y?$zI7nI10M|Ju}vHZOd!l)I?Qr$J+H*4e6Qr$#Sm6Zm$jT zL~-8dbRlr}PhH?fQ3hsy5Z;$AVS&LP4zCtvSa%JF5qw&Y#-0E{@p(^{2+390lNP{{ zam1OAoXeN2#f)=e!f2ot`18k5%kxV<05FLmdmfER>$1e0t@U&wz9)+M)EW`;d>1@g z%VAZ1{pIke&aOPdVTz5hz}|Smc-Z16iXMJ+Leomgd`1AhYxOpFMhXoV{@;%#KwNT_ zY%%s`In$A683S}vmL}Ye)bn46CZ`Hds8#~84JA`3Vbdz`y|U38usj5R_91EI!ZI3e?I9_R zC&y|=Voaxaly2NZBsIQ7h2AbO`l~ZgE=_zaqiybu?}f!w^7o z1?%iAx{s&Uvmg9he&DZe)-P7Kz3o~V#_fe5CKTsB9ZVO8=Ey-`sAJjPvlYn;>n_3c z7~ES-!PX@pYDs`n*q8L8f`F}RmtEdC(&E>i`mEGW7*qdAB@{hx5q!F{dw1D15q1Y7=N*<{F(3wyA1&-Eup#DJY&>B-SFq$3l)B0W#!qm8?e^$wYBa}4Pg#; zbn@p-?HiOBD&UZ|u~eNEjN%gEO`Wlj(xTzP1mDM6DL3Q>> zs=VW@j4GuW0`@R@4CVxxyFL&{O{6|ARt4w}a#>C@KdWqoGB}b%43mGGy9woM`v`NS-6rQGKGMSK1;S8dJ(lduM$V<2MXFjg}dpjzkr_D~5Ke!7=?OI_T< zSYi+g_T^7f%*As_wD;gI*PW{Gh*bB3xqE_B(wEY={iQ~B{u>Wi3i;Mo+AznwP{Hzp zjqT^r<%LU4)=<}__RxzXwy2&*j|DATV$ulZnV;~k5FIq0S;N=&>$E+t?$RY!a1)H3 z(R!A848`;N+c~};^l@K2N#CRwOP5nRJ9cS5_t5wAT}6Gj3;LW4C%AC*=^VDl#B440 zvgoOOhdvgeXb|a|btehYPkF(Jl&)$BntO=f$iI7hR9GQqn`iZoH~A`wEa`J+cjgS} zSy7MMm1m7K<`7i*F-y-98yqu}YFpocSJ4JxcFGQ-eK)CAh-0^(w~AE-on?d8o8G zgln)%D{hDnQw%$Wz4SatTC)jcTOux=Le2NWKqH+;o4@}spDxU#3BlPLis+N8TAnHp z7|x~XCYZ?&{GZt|2HIP50kv2|YT=@9Gh&E~Yh5>k}0EB?`+k-Ze z!&QVr!x#EUyL_LZQY)^GEk&VUjYaSltx|x{izj?s&uIR7hTOT4Y3@z$n%+ORc=R(5 ze8RYdOdyQYlWw#-u(0IEn)xt|+Xisi_kFRZOvijapAPm{7NJ9G`R5BB!nt9~PC*aI z;Fg((3T}gsw?2vvs9|v>?Mi5&EYs^;FODY14%0FMu@7=N8QuV4iR8p2s^M?(O&1&W zbK4LPTt@_pO9X5<*Y(hqh-&jX@NAWyIx6C^`W?mo$Vcq{PgJTHa&eq`e@|>7Nr;t9 z6kt_Rc)jm!*y;v0!<)UvgDPdFC8NjBSU?+Nb1z8{B)MWwFpizVbpmUS0{LCFtzqg%T51#yvKd|kYjZT0<63H(H==# zWv=WU)a5z9p?ctw^%8&TwLwP_LfQeJ*Q2_2U@YOOOHRP9-uk7n!a9_OG$hJh)07lh zxU3Nnz;cnaA;?_|irddeZNF)2rq zj|vNuC4by)lX1xhF!%d&x62d8S4UY5xnG~Xik3Xl#IH?fJj1t*Gj+UW2}q;a7_8qp zNZ2l|t}JO?=(zIo%vI)_TbJ1@--sb$`A=EqGE%6{MZWhakw`khGT&`N^x(;*V_bj# zZy&Z4azaVJ=krHa#ci&W4!HdS!3bK%-Dj=G#KE1^$0p{Y1H*S}>6U)MRar*S;lp~Y z%k7~`mm%=^>GQA4ghtO_6~U@(G=eG!RVpM5d!P2GqKSUI_)g)_=x`eyP}RB*15n=w zw4+)N)!n^-hD4~fe4U-BF@zt8zdW|O_rAAxN#)h6c$z+N7VC-o6jP14LK==B^^>!= zw3N~O;k>ZA1&V{pZ-qtZ zaC*m-viA+iYU1xD>dTF@wyZHReZSX^esNYAXL}Wu5AHc58wk&6t-gFJy}T;99T0>c zi<*M~0Yf8YSOSnD>p+Fyki?*eFJDQYXp%Tu_31WMQKWH%-U$j6`RAOiAJ8bBFN)rO zUKLarZV~lpH}n%(jSc(r4VG41`=AevA8Dxs`Zw_BsrS>>)`iQGl(>su%@aP0tw7u57>W)T6WR;Q z2iK^Na9*F+JMsI`7Dk?Qc(vo`uXvyHgAH%ozl*7_AbGj9^t&vG{I8g>c9?0!cLqyO z)Azo;6J}gJGPNSbxR6`Zay62--Bxh-|o^ASD%oks{~{xKwr>a0a>rCZ`a6 z>5+HgZyUpdr0mC7lly`&32`VJ5cB^hSljmn+3}VP+kF5R-Y#DMCfA>H_2UdJ#xJX) zQ{OXn`L8VP`eHKomt&UFLV0h-#w*w^-mplU(&0+}lwIV^^jZ8IQzw*p~jvW4Z9yvsY;paIyPSYh4cJm-z zH-IfVmJc6FmRv|Z&s^19>W&AfgKoVPmT%THlyNah3TfW`vCnILI_acU)iH9P5=k>q z1obrA)~B`y2uFKCW$?FCdBew!LQ!QWOxahXUK5W8i^~*t)W4$@xTIP4-;P>(XELoX zGQ#jQ2qhMrk%z?FROHNo7B6O52LnS9G;23ceg%^OHaY%knVVhDR1zO`cBhs!@4)~? z$8}axIAv5H4-Y-!^dRh?)b3l4gz}COAtb;4)JV^LpRp%dsYzu1QaWXY5`N-G=AK8DU=MXy}r@e&R$e~ zMM@B|U$4Z6_Slm0)`N0%46~5n*zvorv_GCP7__EC;rCAq`wBAy|MF@={~YviTrB@< zMws7MvQD<+{JW^O?b8NgNAb*$>w^y09E>O=cSXC$9MhoyA+Vi{a#R1Kjxz)p4Lw(y z;uVMwu)(IPTCG=tAjCGv2q#|(tDfZ6#e5qy1GpKO!pPo`xDSoURNHvOzWFRujRU_sJUpsI&-2(R9GrbMQkE>7tq znGXF3*^fBZ%q!x%>-zK486X?}(zq0hZ*xY?M|rGUy->k3jr}S!d|f_S)8I(Hk` zsFR`2@VjuFD@rF>2iIyypK~)O_v6hY)(s@`R@;PQsUrPb$q@D>$z6M=4oxe7k)g5= z8l?=&N!~SeeOqBZ;0XEK+RWiehIszfVPwii^>@RUf`mWhM3!C4BgI>%$9$G7ab(%F z#%>DNm4d5yOr$*EMoY0PNpx@VzhNDsNRWDUwX@*{sbw7y43=tX&ZnmS#-B!I|KY>$ zd)ayRG`CGF0KlYV5?fP7y%rfs-nLTR_?LTVL*umU9FvNO--6*wNdyxorK_W-owP=r zw~qf=`_6{*51h(9=JXYo-p`)?79M1KCfCf}k6wBycUqJ6>7gx$ZG8Z5Cqqodlmd^^ z9nteSG$a0YHax=lC$z&lo4i9({63v8$a|Z&wCoEYvzefILZslWpnt%sg)--1`hVCC z!rmG8_l6+P!}b@q4Z;VnB5^A`Hg`3OX9Twz}KP6P8mQM_ zC6{6z$Bx}q$Z5*x`NQ=_2Wy|R3UMkJyUmc~=lh|t5VrkZD-+jcb>J2@4HF+6tIlXw zvuM{B>c}h(G@u`Kdc>NPOJt1Mgmz5eJhP=uzKx|`$J7hoiED%l0F1GfM{jLcycgAa z98Bt@fAUd&wcJR9}nc(4Wx z8-I=p6kj$s36u8OFO?W1U<#ES9FsZqIU={?=Lh!N;gmcn=aiRT#Y!bKq#?qG&MyBq z`Ro5K&;9>@_urBO{Fj^DpC(K_aJaap&q5iz3m;kSDWVftf0J9Ql&#Ep=f-MI7CX#* zj`*{~*JI1j9z&k$HnvMR3(!H*XmoZPflESU4rLVT04J5W#v@kRI41U_V9 ztwE5=*0-<&`C#(SolF0b4KULH&o`WUNJ3?=@RwG+C~aHyB)#6DM5Yu;JUsI+I0!jE zMp#4z`u(&J)ahX)12%so#~ig>_yNS#_q|*%13aQ4OjFHV04h^TQnTz;l#Bv%(a*`M zU$dSiNmkQSCgP{uv-qoLtJDqpTYB2!$&#qCh`X*HyG>7UW6GlGRp{SJB+=(glNOHE z6U7!##KQlZ1`WDJ0tY^Jze@LDPwlmwKGp2ERc!_W?wdsyk)|>YI)NgZPp@JzEfb3% zFAlcHo<*BijhK$V8B|B@$D_FaHx2pHUrznTT=@7WX+Yy;0efD~jt0oFvizunkal=E z)2$MrIMt|-1rYwA|Ce>5J1_HuSs#;oPr&wnGB)Abh1x+uBDH?LG;E$YoLeJqX!YP6 zv<3C}Dt40*gG#2HEU2HQ$tMw;lDuGGCQPzNMp4gRQ@~ z3a=&N{r_rvrlj%^3u2cw-$tRX;@^$R{eA_C>#VHGZKMV)aKy$Ja93KIS&|Kbf6he+ zeET$Yt9roW^rW7sO#lEXasas~n2)igbdbt2XvS;zwAiOJ5K*=betMarb5-uY0 z>(AlSXICplDKSk5^~-<;7jEq?a*1nT>#}!wRBWfs6A`kG^DvghNLGAN@xzkD{wE+M zgkct*w6JIO*nsqdz5P^eUz_S+-DHd$R*q)jPKd*e&82x-AoI<;IC$$m*Tvu>@7@Wk znnip#a2CH~SgmnJ1f^}@wtxo3f2esW>5!F5r$i1wY?om{RgMl-a%y9?&jzUj3K|O| z$wvk`Ph~-AIzK_WkDz_2f$wUox`vD7lZUzMVtNmVTh~#tiUebdDHtEfYecd$Hpjx zX-6hK?WUN`e(})wiAcI4rnCKvc%dERdXNk)0~u{vBf0V(S?nYrbb^EQ7vceZp|gdKUDKv2%Uu_x1F1RRJd9nKVg36rNFhRNCmv+o4 zc}p+BDS)v&DAC4>ZGUqSwi~7Ucl2KMJvitvpNk_d~P;ajB$CM(F+8cYQ!lm z4Hpx^T?0lND^2x<5b{Fs`JC@sCW!ywvS|W|ORjsGjgpL3td>S)(#b$fJqCpcmjo+r|<MZAjghNSoV9lx6zkAiD3M5$A$z zkQsJ^{h!FK_CVQZ_Sd;=$)jhB{GIiN|X!%#n z6gv3|i((?P<-ru_pWJ&C44dm_4*T<`sQ>5B!yEOTHih{-+@N^TFe6{EYi%VTtYgM6 z;(vY#e8T2%>sJ0BT`4>5X!LzOdh?2-|7zp(%O3-PFz!2fz8~R2w zCbLK{{tM9P)YInZA+eQ}FZ}e$uw6<3QuSl~>Nhs*wHuTG>m3r(Uh&O;nysxn9Rjl^pCqH&vy;=<(P~c2&xcSL(-!jjv=k+(B;91 z8#bNmZj@EvF50*KE5{a+{X)RDwk~KpvdoNIqyNx_SxCgarlXz}?#qZ&hg8 GM*I(C=F0Z~ literal 5249 zcmeHLX*kqvxPSgLV>gUl)a$2-#-lf4t{>IUmo5^Wl6r_jNtj{kxy*zMkvep69xsJK6Ds4VGVq9{_;0 zv$b*p0NQ~N;6?ASz?ZJ4|CK_VY%D-|uiX3&?sT+2ZLPUqU-^QeKNc%TOnLa=@da;x z-Mda&N%r!mwW^Ga!a5hMug{r>d@=N?7a^QJ>*?)u(%IU|u7p6ymXxfTLGDc;h6aZX z^F0s*VKNxTZ|1Rrg8H6i5fT!8Oho;f#St7%O;tl$TFyE|b!KK}ioqzauOA#7%+1Xe zA=ChozaqaLbjngb;6T+r(&DX)_er(6(xso8^W;u;-kq!hBWLE;u$^0sss0%S3k4|P zyi@D&u=|bdJK0a1ot@chUI=?)?2*`~mlt38h@45)bkM-fbflEm*QRFYg~oq*R!wEw{E$+xKLYe4-XH||5#wLekDb4H#d{x%q^atIptu( zla*ol@`WoO5AWvYCe|PO>H3kWYnNxjgJLSzWz) z6^7wEckbACs_bNQHGO$|VhgEeBdbWE?3oKYTbZFwCr<6;;{O_fe+^O={$34$NQs@5 z`RRz9#hlw-r)DKO@`xAo0~7Zo-}8tQ-N&$V^OHG?#k!5X!6eqXQzF|gUoOR8_8B%f;`TNob6%u-*6T%5{d$_xMc&O-b0`Q?rt(z;e zqg*?>elI}lW67YD4*Fz7{r(>=ARQ>?y~`7L_eNJT*-D?I9o&ot?7Rk&81MTkl6@e0 z`_kl{JN~RgpfZ`&Em_a}ByuG~iv<-uEV@Br3#0*8A{`k<#i#4X-Sns}` zV(figXk%35o!|ENPkP*2Nf6Nt09;FS4VfkiY|~;NS^}@sRFGI;|H2fE9-PY|tN8RaH5Vu>xMP=Maaww%>Bh_vklbBt_7Y0aH{t0Qx>KZ(N`A(dVXa zlBq6O6iG1)ZE1q zF51?btQWPqiCiuK=yYC+y@cLlE47ds$9;nYU{KlT-pZ#gBKgmcr7Q12=C&McfsCk? z$3_jXJhvJX186&CZggn=FfFLWVGx{q9^gkANr#yC>w5!JMCS^zkS56)iVLNzcXG+V~ZC;;8vV%U<#MFsEH+fiu#wVCAG)EKF z5aYDu0N`gBV9g9Hju(YH;pV|mevxOtH-Z=mFT;89uU8Wp??xEVMJrUIIu~2%L zm6dz6(CN%(o|LX&3p!td8#ohhTPy3R3AbmxUSAr|e)2dwy99;jrPb__Kf_y%B=fDB zg@xGTs#iX-8T-aJRpuPF!A5Hi>$fm3QH~i7(K_tTj~@~R_v*PlJ4C?&S}hme4`zE; z86IHMniA&K(-40fo(DmH@28&sLY){W{qydlN0K+cru{zP#^pCVv()4u0fO&fnopX_ zhE?;y2;WO!OPk3=(@gP{x^3$C=86}`od;|+ZnJlr(HO;jtzr~>xUWHf%XJGrpbG}5 zCD0Ke7xGDR@q#dD5)Tr1!M0iX=U@_1t2~+rx)c-IE=$2RUmt(neC(zpEoqFI@;(^) zB(1Fj`7#t}h`MaCD;TO=9p4WeOBJ+@$F^+&<*4J@-dvT*o+J|!IZE(n&3L<)=n0q7>rPtrd>IG5A@4kpBzY+zM_x+;NoSzVp%h)FOJG_Wc(S@b+@%*=V-9+OC2 zJw1a9g@AyQdIBE@Ec(Yh+(KT4xd7mONxdvcTN*EXehe?iv!qWEqm0R)ti$wcZGmFo z%4fxW3)8>W){&xmHt!(GNm~B6<+q}afqDOEIdWmgvQX@_Dv;g;@HIW`D@rcc46>{x zjjEjSo3-Na85K!viBJ#<*ECXIHESCGn=D2&w1mZQ;p;(cUqvvU)umwK9<{Zaq6|o;)?$^)-NgR}v8b}Ye`Pmb9MF7}y#GZ04XoN0i1@hk7P2|4@ zMSE+Sup!7kmOL^|MUjFe`GK7qCWtbeehM9od2m#94^*2gE8iwa>7{grxA6DM(o?6e z)+{eCdkQ@w39d5#aLu_l>i6VPfB+#rkr3jkr#E!6j*lV z=8&%|g*IslHD1$%zrJpBMYZZ@{$ymtP?)MZ0s z&ONzn4rZF0Sz`NQ1q2=wlHJ)b77pU_o~C=CT?n4m{kLhud9om)9ikb2+15PO%Oght zQ~}fha0KvoBmhcEzEGK?!pjTX-y>?IaQ_s({{E zr`l5dj`fk##n1hW^lF_rEr!{O)Ug-3b#KqPCTE-hnqQmVJ!%dz-L(<|@QsQnS}E;N zhG*2fBx2csQ=4lg3k{_O1j*{zA3MqON$Oai5|(*6ja+jE&sXge70xF~%rLKCxN>Pz zUpXIwHhD6sqNC@sBi*7^SEQ;rQD zz--WX@Rt=O0sJESE>3r6lm-svwFp>m_=?67C{R8-WVSaiD5yiD6{Ua*oF*rH^mRRV z<%p%>H>L9X%aaF`&+&l*+?EYW2~Sht(&(NZ8X8jUo`@oC^PtY}+)AL$>N^BBrtfN& zWw?+%sp)G(Q>mE|yUDlB9T*@8i-{78WnjKQvOKwhDa$VkS8OwN@RVm{DG+(>!Tvq4 ztasNBK0|oViG&U`kyniJ1bPeY8#NJWbag`AQV;-y-pT1EUFZd1?h0;MQM$Wz@-g7> z^z*6XUV+fCsGF2;S;?pJYbMQckB$?w89NrGBY2B*N)x++!OJsyr{8}1R95z}^xDXC zE7?J{D02jj%di>2IF?^5yVN)VVI&N|DIc?M>osH@Y}ip$!4DC@=^h=e&@eK}me7i; z9usHQkxNDRy9Az@@PP(~BoDLpRn5FS`uOqXh)k~oKiA2nD(|@tHyxHVuM8r9H!*?T zM%klA64L0=%i!#BKju^N|2%Mz!f%cZQbB z$i%UWHc!zgTfy6cYN81$Ub}TO7GkOHo7DWPnsY(JE-^6~Nc}V!`fa=Yw9b7yAKeUrHj5Zkm$9=12-y1c;+p^*rB_oIhnb9?>( zV@#29&Qp%#h$4trci9;|F&W&I&Lt1Jv$H)s9=gP;-vA^RXLHFETdnG)5PBx2$dkP_ zHFY7THZvUB-SsW_d= zMHP?(6j60qYA*`z_H}1VLxoO!N5OA%ZLyEyU_oU6%>h#DAHb4yJ;d)hienIsq3k8s zbmP0i|&dRQS2YS`O;xk!)=TbTJTphswhh_e;Z;Bk$+{gfxyi-3aCaFKrO(t6oR}eX34+{5sr`*<#PD}WYYjIRT@w6k_`FEu7 zx0$6&h?;a-lN@Y~GnEUuB=RyuK9