mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 02:13:04 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
a1038c0e5b
80 files changed
+4724
-623
No files matched your search
+1
-1
Submodule src/api updated: 2054012fae...b8ba682e9d.
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -55,7 +57,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
|
||||
|
||||
@@ -64,8 +66,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;
|
||||
@@ -632,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
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -662,13 +755,15 @@ 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);
|
||||
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);
|
||||
@@ -707,7 +802,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");
|
||||
@@ -738,6 +833,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 {
|
||||
@@ -868,14 +965,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;
|
||||
}
|
||||
@@ -911,23 +1056,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;
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static kamkeel.npcs.controllers.data.ability.AbilityPhase.*;
|
||||
|
||||
public enum AbilityAnimation {;
|
||||
private final HashMap<AbilityPhase, String> 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 IAnimation 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 IAnimation idle() {
|
||||
return getAnimation(IDLE);
|
||||
}
|
||||
|
||||
public IAnimation windUp() {
|
||||
return getAnimation(WINDUP);
|
||||
}
|
||||
|
||||
public IAnimation active() {
|
||||
return getAnimation(ACTIVE);
|
||||
}
|
||||
|
||||
public IAnimation dazed() {
|
||||
return getAnimation(DAZED);
|
||||
}
|
||||
|
||||
private File getFileFromName(String fileName) {
|
||||
try (InputStream stream = CustomNpcs.class.getResourceAsStream("/internal/data/animations/" + name() + "/" + fileName + ".json")) {
|
||||
|
||||
File file = new File("temp");
|
||||
|
||||
FileUtils.copyInputStreamToFile(stream, file);
|
||||
|
||||
return file;
|
||||
} catch (Exception i) {
|
||||
LogWriter.except(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -18,6 +19,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 +28,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;
|
||||
@@ -45,7 +48,7 @@ public class AbilityCharge extends Ability {
|
||||
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
|
||||
@@ -285,6 +288,69 @@ public class AbilityCharge extends Ability {
|
||||
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);
|
||||
|
||||
@@ -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;
|
||||
@@ -15,6 +16,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 +27,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,
|
||||
@@ -52,7 +55,7 @@ public class AbilityCutter extends Ability {
|
||||
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;
|
||||
@@ -254,14 +257,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -14,13 +15,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.
|
||||
@@ -86,7 +89,7 @@ public class AbilityDash extends Ability {
|
||||
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
|
||||
@@ -221,6 +224,69 @@ public class AbilityDash extends Ability {
|
||||
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
|
||||
@@ -245,14 +311,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -17,13 +18,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;
|
||||
@@ -60,6 +62,7 @@ public class AbilityDisc extends Ability {
|
||||
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;
|
||||
|
||||
@@ -82,6 +85,7 @@ public class AbilityDisc extends Ability {
|
||||
this.minRange = 5.0f;
|
||||
this.cooldownTicks = 0;
|
||||
this.windUpTicks = 20;
|
||||
this.lockMovement = LockMovementType.WINDUP;
|
||||
this.telegraphType = TelegraphType.CIRCLE;
|
||||
this.showTelegraph = true;
|
||||
}
|
||||
@@ -118,10 +122,9 @@ public class AbilityDisc extends Ability {
|
||||
if (discEntity != null && !discEntity.isDead) {
|
||||
discEntity.startMoving(target);
|
||||
}
|
||||
discEntity = null;
|
||||
|
||||
// Disc entity manages itself - ability is done
|
||||
signalCompletion();
|
||||
// Ability stays active until entity dies (prevents firing another while projectile is alive)
|
||||
// Movement locking is handled separately by the base class
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,7 +136,7 @@ public class AbilityDisc extends Ability {
|
||||
// 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,
|
||||
@@ -151,6 +154,11 @@ public class AbilityDisc extends Ability {
|
||||
|
||||
@Override
|
||||
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
|
||||
// Signal completion when entity dies
|
||||
if (discEntity == null || discEntity.isDead) {
|
||||
discEntity = null;
|
||||
signalCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +225,7 @@ public class AbilityDisc extends Ability {
|
||||
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);
|
||||
@@ -249,6 +258,7 @@ public class AbilityDisc extends Ability {
|
||||
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");
|
||||
@@ -302,6 +312,8 @@ public class AbilityDisc extends Ability {
|
||||
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; }
|
||||
@@ -312,6 +324,31 @@ 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); }
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -12,11 +13,11 @@ 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.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.entity.EntityNPCInterface;
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,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;
|
||||
@@ -59,6 +60,7 @@ public class AbilityEnergyBeam extends Ability {
|
||||
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;
|
||||
|
||||
@@ -68,7 +70,7 @@ public class AbilityEnergyBeam extends Ability {
|
||||
private float lightningRadius = 0.5f;
|
||||
|
||||
// Anchor point for charging position
|
||||
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
|
||||
private AnchorPoint anchorPoint = AnchorPoint.RIGHT_HAND;
|
||||
|
||||
// Transient state for beam entity (used during windup charging)
|
||||
private transient EntityAbilityBeam beamEntity = null;
|
||||
@@ -81,8 +83,12 @@ public class AbilityEnergyBeam extends Ability {
|
||||
this.minRange = 5.0f;
|
||||
this.cooldownTicks = 0;
|
||||
this.windUpTicks = 40;
|
||||
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
|
||||
@@ -117,10 +123,9 @@ public class AbilityEnergyBeam extends Ability {
|
||||
if (beamEntity != null && !beamEntity.isDead) {
|
||||
beamEntity.startFiring(target);
|
||||
}
|
||||
beamEntity = null;
|
||||
|
||||
// Beam entity manages itself - ability is done
|
||||
signalCompletion();
|
||||
// Ability stays active until entity dies (prevents firing another while projectile is alive)
|
||||
// Movement locking is handled separately by the base class
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,14 +139,14 @@ public class AbilityEnergyBeam extends Ability {
|
||||
// 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,
|
||||
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
|
||||
@@ -153,6 +158,11 @@ public class AbilityEnergyBeam extends Ability {
|
||||
|
||||
@Override
|
||||
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
|
||||
// Signal completion when entity dies
|
||||
if (beamEntity == null || beamEntity.isDead) {
|
||||
beamEntity = null;
|
||||
signalCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +227,7 @@ public class AbilityEnergyBeam extends Ability {
|
||||
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);
|
||||
@@ -247,6 +258,7 @@ public class AbilityEnergyBeam extends Ability {
|
||||
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");
|
||||
@@ -296,6 +308,8 @@ public class AbilityEnergyBeam extends Ability {
|
||||
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; }
|
||||
@@ -306,6 +320,32 @@ 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; }
|
||||
|
||||
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); }
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -14,13 +15,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();
|
||||
|
||||
@@ -48,7 +51,7 @@ public class AbilityGuard extends Ability {
|
||||
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
|
||||
@@ -228,18 +231,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -18,6 +19,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 +30,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,
|
||||
@@ -81,7 +84,7 @@ public class AbilityHazard extends Ability {
|
||||
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;
|
||||
@@ -443,22 +446,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -15,6 +16,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 +25,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;
|
||||
@@ -47,7 +50,7 @@ public class AbilityHeal extends Ability {
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
@@ -11,13 +12,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;
|
||||
@@ -28,7 +30,7 @@ public class AbilityHeavyHit extends Ability {
|
||||
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;
|
||||
|
||||
@@ -3,9 +3,11 @@ 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;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
@@ -13,13 +15,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;
|
||||
@@ -47,6 +50,7 @@ public class AbilityLaserShot extends Ability {
|
||||
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
|
||||
@@ -54,6 +58,9 @@ public class AbilityLaserShot extends Ability {
|
||||
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";
|
||||
@@ -62,6 +69,7 @@ public class AbilityLaserShot extends Ability {
|
||||
this.minRange = 3.0f;
|
||||
this.cooldownTicks = 0;
|
||||
this.windUpTicks = 15;
|
||||
this.lockMovement = LockMovementType.WINDUP;
|
||||
this.telegraphType = TelegraphType.LINE;
|
||||
this.showTelegraph = true;
|
||||
}
|
||||
@@ -108,10 +116,10 @@ public class AbilityLaserShot extends Ability {
|
||||
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,
|
||||
laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha,
|
||||
damage, knockback, knockbackUp,
|
||||
expansionSpeed, lingerTicks,
|
||||
explosive, explosionRadius, explosionDamageFalloff,
|
||||
@@ -120,15 +128,19 @@ public class AbilityLaserShot extends Ability {
|
||||
lightningEffect, lightningDensity, lightningRadius
|
||||
);
|
||||
|
||||
world.spawnEntityInWorld(laser);
|
||||
world.spawnEntityInWorld(laserEntity);
|
||||
|
||||
// Laser entity manages itself - ability is done
|
||||
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) {
|
||||
// Laser entity manages itself
|
||||
// Signal completion when entity dies
|
||||
if (laserEntity == null || laserEntity.isDead) {
|
||||
laserEntity = null;
|
||||
signalCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,6 +151,15 @@ public class AbilityLaserShot extends Ability {
|
||||
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);
|
||||
@@ -158,6 +179,7 @@ public class AbilityLaserShot extends Ability {
|
||||
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);
|
||||
@@ -183,6 +205,7 @@ public class AbilityLaserShot extends Ability {
|
||||
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;
|
||||
@@ -224,6 +247,8 @@ public class AbilityLaserShot extends Ability {
|
||||
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; }
|
||||
@@ -232,4 +257,28 @@ public class AbilityLaserShot extends Ability {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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.api.ability.type.IAbilityOrb;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
/**
|
||||
@@ -24,7 +26,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;
|
||||
@@ -56,6 +58,7 @@ public class AbilityOrb extends Ability {
|
||||
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
|
||||
|
||||
@@ -66,7 +69,7 @@ public class AbilityOrb extends Ability {
|
||||
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;
|
||||
@@ -79,8 +82,11 @@ public class AbilityOrb extends Ability {
|
||||
this.minRange = 5.0f;
|
||||
this.cooldownTicks = 0;
|
||||
this.windUpTicks = 30;
|
||||
this.lockMovement = LockMovementType.WINDUP;
|
||||
this.telegraphType = TelegraphType.CIRCLE;
|
||||
this.showTelegraph = true;
|
||||
// Default built-in animation
|
||||
this.windUpAnimationName = "Ability_Orb_Windup";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,10 +121,9 @@ public class AbilityOrb extends Ability {
|
||||
if (orbEntity != null && !orbEntity.isDead) {
|
||||
orbEntity.startMoving(target);
|
||||
}
|
||||
orbEntity = null;
|
||||
|
||||
// Orb entity manages itself - ability is done
|
||||
signalCompletion();
|
||||
// Ability stays active until entity dies (prevents firing another while projectile is alive)
|
||||
// Movement locking is handled separately by the base class
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,7 +135,7 @@ public class AbilityOrb extends Ability {
|
||||
// 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,
|
||||
@@ -147,7 +152,11 @@ public class AbilityOrb extends Ability {
|
||||
|
||||
@Override
|
||||
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
|
||||
// Nothing to do - entity manages itself
|
||||
// Signal completion when entity dies
|
||||
if (orbEntity == null || orbEntity.isDead) {
|
||||
orbEntity = null;
|
||||
signalCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,6 +221,7 @@ public class AbilityOrb extends Ability {
|
||||
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);
|
||||
@@ -242,6 +252,7 @@ public class AbilityOrb extends Ability {
|
||||
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");
|
||||
@@ -404,6 +415,14 @@ public class AbilityOrb extends Ability {
|
||||
this.outerColorWidth = outerColorWidth;
|
||||
}
|
||||
|
||||
public float getOuterColorAlpha() {
|
||||
return outerColorAlpha;
|
||||
}
|
||||
|
||||
public void setOuterColorAlpha(float outerColorAlpha) {
|
||||
this.outerColorAlpha = outerColorAlpha;
|
||||
}
|
||||
|
||||
public boolean isOuterColorEnabled() {
|
||||
return outerColorEnabled;
|
||||
}
|
||||
@@ -452,11 +471,39 @@ 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;
|
||||
}
|
||||
|
||||
public int getAnchorPoint() {
|
||||
return anchorPoint.getId();
|
||||
}
|
||||
|
||||
@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 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -14,13 +15,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;
|
||||
@@ -40,6 +43,7 @@ public class AbilityProjectile extends Ability {
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
@@ -15,13 +16,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;
|
||||
@@ -33,7 +36,7 @@ public class AbilityShockwave extends Ability {
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
@@ -17,6 +18,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 +31,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;
|
||||
@@ -50,7 +53,7 @@ public class AbilitySlam extends Ability {
|
||||
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;
|
||||
@@ -358,6 +361,100 @@ public class AbilitySlam extends Ability {
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
@@ -15,6 +16,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 +27,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;
|
||||
@@ -53,7 +55,7 @@ public class AbilitySweeper extends Ability {
|
||||
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
|
||||
@@ -89,8 +91,6 @@ public class AbilitySweeper extends Ability {
|
||||
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,
|
||||
@@ -100,14 +100,15 @@ public class AbilitySweeper extends Ability {
|
||||
lockOnTarget);
|
||||
world.spawnEntityInWorld(activeEntity);
|
||||
|
||||
LogWriter.info("[Sweeper] Spawned sweeper entity");
|
||||
// Entity manages itself - completion signaled from onActiveTick when entity dies
|
||||
// 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) {
|
||||
// Entity handles everything - check if entity finished its rotations
|
||||
// Signal completion when entity dies
|
||||
if (activeEntity == null || activeEntity.isDead) {
|
||||
activeEntity = null;
|
||||
signalCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -18,13 +19,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.
|
||||
@@ -61,6 +64,7 @@ public class AbilityTeleport extends Ability {
|
||||
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;
|
||||
@@ -440,14 +444,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -16,6 +17,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 +29,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,
|
||||
@@ -64,7 +67,7 @@ public class AbilityTrap extends Ability {
|
||||
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;
|
||||
@@ -330,14 +333,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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -14,6 +15,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 +26,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;
|
||||
@@ -51,7 +54,7 @@ public class AbilityVortex extends Ability {
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -104,14 +108,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 +128,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 +136,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 +152,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 +164,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 +225,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 +243,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,
|
||||
@@ -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;
|
||||
|
||||
@@ -560,12 +698,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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -82,7 +86,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 +94,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 +107,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 +119,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 +165,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 +183,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,
|
||||
@@ -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;
|
||||
|
||||
@@ -413,11 +521,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();
|
||||
|
||||
@@ -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,
|
||||
@@ -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
|
||||
@@ -346,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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -71,14 +75,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 +97,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 +108,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 +149,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 +166,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,
|
||||
@@ -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;
|
||||
|
||||
@@ -298,11 +407,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();
|
||||
|
||||
@@ -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 ====================
|
||||
@@ -70,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;
|
||||
@@ -98,13 +101,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 +121,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 +141,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
|
||||
@@ -200,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();
|
||||
@@ -208,32 +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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
// 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;
|
||||
}
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check max distance (subclass can override if needed)
|
||||
if (checkMaxDistance()) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasHit) {
|
||||
if (!worldObj.isRemote) {
|
||||
noppes.npcs.LogWriter.info("[Projectile:" + this.getClass().getSimpleName() + "] DEAD: hasHit=true at tick " + ticksExisted);
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (hasHit) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
|
||||
// Subclass-specific update
|
||||
@@ -314,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;
|
||||
|
||||
@@ -357,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();
|
||||
@@ -388,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);
|
||||
@@ -434,6 +470,10 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
|
||||
return outerColorWidth;
|
||||
}
|
||||
|
||||
public float getOuterColorAlpha() {
|
||||
return outerColorAlpha;
|
||||
}
|
||||
|
||||
public float getRotationSpeed() {
|
||||
return rotationSpeed;
|
||||
}
|
||||
@@ -507,6 +547,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;
|
||||
|
||||
@@ -558,6 +599,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);
|
||||
|
||||
@@ -92,10 +92,15 @@ 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;
|
||||
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 +474,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());
|
||||
@@ -499,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());
|
||||
|
||||
@@ -93,6 +93,7 @@ public enum EnumRequestPacket {
|
||||
AnimationGet,
|
||||
AnimationRemove,
|
||||
AnimationSave,
|
||||
BuiltInAnimationGet,
|
||||
|
||||
RemoteNpcsGet,
|
||||
RemoteTpToNpc,
|
||||
@@ -197,6 +198,10 @@ public enum EnumRequestPacket {
|
||||
NpcAbilitiesGet,
|
||||
NpcAbilitiesSave,
|
||||
AbilitiesGetAll,
|
||||
SavedAbilitiesGet,
|
||||
SavedAbilityGet,
|
||||
SavedAbilityRemove,
|
||||
SavedAbilitySave,
|
||||
Hammer,
|
||||
|
||||
RecipeScript,
|
||||
|
||||
+51
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+69
@@ -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);
|
||||
}
|
||||
}
|
||||
+76
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,5 +44,6 @@ public final class AnimationsGetPacket extends AbstractPacket {
|
||||
return;
|
||||
|
||||
NoppesUtilServer.sendAnimationDataAll((EntityPlayerMP) player);
|
||||
NoppesUtilServer.sendBuiltInAnimationData((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
+72
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class DataAbilities {
|
||||
private transient List<Long> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,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);
|
||||
@@ -604,6 +612,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
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -743,8 +795,8 @@ public class DataAbilities {
|
||||
* Called by AI tasks to determine if they should try to path.
|
||||
* <p>
|
||||
* 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() {
|
||||
@@ -756,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
|
||||
@@ -777,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() {
|
||||
@@ -790,7 +842,7 @@ public class DataAbilities {
|
||||
return false;
|
||||
}
|
||||
|
||||
return currentAbility.isLockMovement();
|
||||
return currentAbility.isMovementLockedDuringActive();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -810,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;
|
||||
|
||||
@@ -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<String, Integer> map = new HashMap<String, Integer>();
|
||||
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) {
|
||||
@@ -776,6 +785,18 @@ public class NoppesUtilServer {
|
||||
sendScrollData(player, map, EnumScrollData.ABILITY_TYPES);
|
||||
}
|
||||
|
||||
public static void sendSavedAbilitiesData(EntityPlayerMP player) {
|
||||
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,13 +59,14 @@ 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
|
||||
protected int cooldownTicks;
|
||||
protected int windUpTicks;
|
||||
protected int dazedTicks;
|
||||
protected boolean syncWindupWithAnimation = true; // Sync windup ticks with animation duration
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// CACHED VALUES - Target Tab
|
||||
@@ -111,7 +113,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
|
||||
@@ -128,8 +130,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();
|
||||
@@ -251,7 +256,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);
|
||||
|
||||
@@ -278,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
|
||||
if (windUpAnimationId >= 0) {
|
||||
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);
|
||||
}
|
||||
@@ -590,12 +606,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");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -644,10 +664,15 @@ 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();
|
||||
// Toggle sync on/off
|
||||
syncWindupWithAnimation = !syncWindupWithAnimation;
|
||||
if (syncWindupWithAnimation) {
|
||||
// Calculate windup ticks from animation when turning sync on
|
||||
calculateWindupFromAnimation();
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
|
||||
// Target tab - Targeting mode
|
||||
@@ -725,19 +750,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();
|
||||
}
|
||||
|
||||
@@ -823,11 +848,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();
|
||||
@@ -874,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);
|
||||
@@ -895,6 +940,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);
|
||||
@@ -920,7 +967,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();
|
||||
@@ -944,14 +991,23 @@ 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() {
|
||||
if (windUpAnimationId < 0 || AnimationController.Instance == null) {
|
||||
private void calculateWindupFromAnimation() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<String> abilityNames = new ArrayList<>();
|
||||
private HashMap<String, Integer> 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<String> 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<String> 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<String> list, HashMap<String, Integer> 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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,12 +231,12 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
|
||||
disc.setOuterColorEnabled(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 205:
|
||||
case 206:
|
||||
disc.setLightningEffect(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 210:
|
||||
disc.setAnchorPoint(AnchorPoint.fromId(value));
|
||||
disc.setAnchorPointEnum(AnchorPoint.fromId(value));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
|
||||
+22
-13
@@ -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);
|
||||
|
||||
@@ -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,12 +220,12 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
|
||||
beam.setOuterColorEnabled(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 205:
|
||||
case 206:
|
||||
beam.setLightningEffect(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 210:
|
||||
beam.setAnchorPoint(AnchorPoint.fromId(value));
|
||||
beam.setAnchorPointEnum(AnchorPoint.fromId(value));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,12 +208,12 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
|
||||
orb.setOuterColorEnabled(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 205:
|
||||
case 206:
|
||||
orb.setLightningEffect(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 210:
|
||||
orb.setAnchorPoint(AnchorPoint.fromId(value));
|
||||
orb.setAnchorPointEnum(AnchorPoint.fromId(value));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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<String, Integer> data = new HashMap<String, Integer>();
|
||||
private HashMap<String, Integer> customData = new HashMap<String, Integer>();
|
||||
private HashMap<String, Integer> builtInData = new HashMap<String, Integer>();
|
||||
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<String, Integer> getCurrentData() {
|
||||
return showingBuiltIn ? builtInData : customData;
|
||||
}
|
||||
|
||||
private List<String> getSearchList() {
|
||||
HashMap<String, Integer> data = getCurrentData();
|
||||
if (search.isEmpty()) {
|
||||
return new ArrayList<String>(this.data.keySet());
|
||||
return new ArrayList<String>(data.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
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<String> list, HashMap<String, Integer> 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<String, Integer> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> abilityNames = new ArrayList<>();
|
||||
private HashMap<String, Integer> 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<String> 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<String> getFilteredList() {
|
||||
private List<String> getSearchList() {
|
||||
if (search.isEmpty()) {
|
||||
return new ArrayList<>(abilityNames);
|
||||
return new ArrayList<>(abilityData.keySet());
|
||||
}
|
||||
List<String> filtered = new ArrayList<>();
|
||||
for (String name : abilityNames) {
|
||||
List<String> 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<String> list, HashMap<String, Integer> 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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String, Integer> animationData = new HashMap<String, Integer>();
|
||||
|
||||
// Built-in animations (name only, no ID)
|
||||
private HashMap<String, Integer> builtInData = new HashMap<>();
|
||||
// Custom/user animations (name -> ID)
|
||||
private HashMap<String, Integer> 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<String> list, HashMap<String, Integer> 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<String> getSearchList() {
|
||||
HashMap<String, Integer> sourceData = showingBuiltIn ? builtInData : customData;
|
||||
|
||||
if (search.isEmpty()) {
|
||||
return new ArrayList<String>(animationData.keySet());
|
||||
return new ArrayList<>(sourceData.keySet());
|
||||
}
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String name : animationData.keySet()) {
|
||||
List<String> 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();
|
||||
}
|
||||
}
|
||||
@@ -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<Entity> 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<Entity> 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<Entity> 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 "";
|
||||
}
|
||||
}
|
||||
@@ -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<Entity> 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<Entity> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<String> lines = TextSplitter.splitText(hoverableText, 30);
|
||||
drawHoveringText(lines, mouseX, mouseY, mc);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawHoveringText(List<String> 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);
|
||||
}
|
||||
}
|
||||
@@ -6,5 +6,8 @@ public enum EnumScrollData {
|
||||
MAGIC_CYCLES,
|
||||
DIALOG_GROUP,
|
||||
QUEST_GROUP,
|
||||
ABILITY_TYPES
|
||||
ABILITY_TYPES,
|
||||
ABILITIES,
|
||||
ANIMATIONS,
|
||||
BUILTIN_ANIMATIONS
|
||||
}
|
||||
@@ -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<Integer, Animation> animations;
|
||||
private HashMap<Integer, String> bootOrder;
|
||||
|
||||
// Built-in animations loaded from assets folder (read-only, keyed by name)
|
||||
public HashMap<String, BuiltInAnimation> 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<Path> 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,27 +314,102 @@ public class AnimationController implements IAnimationHandler {
|
||||
}
|
||||
|
||||
public IAnimation get(String name) {
|
||||
return getAnimationFromName(name);
|
||||
// Check user/custom animations first (allows overriding built-in)
|
||||
for (Map.Entry<Integer, Animation> 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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<IAnimation> 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<IAnimation> 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<Integer, Animation> entryAnimation : AnimationController.getInstance().animations.entrySet()) {
|
||||
// Check user/custom animations first (allows overriding built-in)
|
||||
for (Map.Entry<Integer, Animation> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1457,4 +1457,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
public IMagicData getMagicData() {
|
||||
return npc.stats.magicData;
|
||||
}
|
||||
|
||||
public noppes.npcs.api.ability.IDataAbilities getAbilityData() {
|
||||
return new noppes.npcs.scripted.wrapper.ScriptDataAbilities(npc);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"Loop": 0,
|
||||
"Speed": 1.0f,
|
||||
"Frames": [
|
||||
{
|
||||
"ColorMarker": 16777215,
|
||||
"Comment": "",
|
||||
"Speed": 1.0f,
|
||||
"FrameParts": [
|
||||
{
|
||||
"Pivot2": -5.0f,
|
||||
"Part": "RIGHT_ARM",
|
||||
"Rotation1": -18.0f,
|
||||
"Rotation0": -107.0f,
|
||||
"Pivot0": -1.0f,
|
||||
"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",
|
||||
"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": -5.0f,
|
||||
"Part": "LEFT_ARM",
|
||||
"Rotation1": 12.0f,
|
||||
"Rotation0": -75.0f,
|
||||
"Pivot0": -2.0f,
|
||||
"Pivot1": 3.0f,
|
||||
"Rotation2": 50.0f
|
||||
}
|
||||
],
|
||||
"Smooth": 0b,
|
||||
"Duration": 30
|
||||
}
|
||||
],
|
||||
"CurrentFrameTime": 0,
|
||||
"CurrentFrame": 0,
|
||||
"Smooth": 0b,
|
||||
"ID": 2,
|
||||
"WhileAttacking": 1b,
|
||||
"WhileWalking": 1b,
|
||||
"Name": "Ability_Beam_Active",
|
||||
"WhileStanding": 1b
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
{
|
||||
"Loop": -1,
|
||||
"Speed": 1.0f,
|
||||
"Frames": [
|
||||
{
|
||||
"ColorMarker": 16777215,
|
||||
"Comment": "",
|
||||
"Speed": 0.5f,
|
||||
"FrameParts": [
|
||||
{
|
||||
"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_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
|
||||
},
|
||||
{
|
||||
"Pivot2": 0.0f,
|
||||
"Part": "FULL_MODEL",
|
||||
"Rotation1": 25.0f,
|
||||
"Rotation0": 0.0f,
|
||||
"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,
|
||||
"Duration": 5
|
||||
},
|
||||
{
|
||||
"ColorMarker": 16777215,
|
||||
"Comment": "",
|
||||
"Speed": 0.25f,
|
||||
"FrameParts": [
|
||||
{
|
||||
"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_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
|
||||
},
|
||||
{
|
||||
"Pivot2": 0.0f,
|
||||
"Part": "FULL_MODEL",
|
||||
"Rotation1": 25.0f,
|
||||
"Rotation0": 0.0f,
|
||||
"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": 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": 1,
|
||||
"Smooth": 0b,
|
||||
"ID": 1,
|
||||
"WhileAttacking": 1b,
|
||||
"WhileWalking": 1b,
|
||||
"Name": "Ability_Beam_Windup",
|
||||
"WhileStanding": 1b
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -120,6 +120,10 @@ 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
|
||||
gui.paste=Paste
|
||||
gui.test=Test
|
||||
@@ -685,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
|
||||
@@ -1515,10 +1521,15 @@ 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
|
||||
ability.lockMove=Lock Move
|
||||
ability.lockMove.windup=Windup
|
||||
ability.lockMove.active=Active
|
||||
ability.lockMove.both=Both
|
||||
ability.telegraph=Telegraph
|
||||
ability.telegraphType=Telegraph Type
|
||||
|
||||
@@ -1705,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
|
||||
@@ -1783,6 +1793,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
|
||||
# =========================================
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 12 KiB |
Reference in new issue
Block a user