Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vidal committed 2026-01-27 19:17:21 -03:00
commit 3513c92a22
76 files changed
+5106 -1175

No files matched your search

+1
View File
@@ -43,3 +43,4 @@ out
run
src/main/resources/assets/customnpcs/api
df/
tmp/
+1 -1
Submodule src/api updated: ae73e1b885...2054012fae.
@@ -2,6 +2,7 @@ package kamkeel.npcs.client.renderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.client.renderer.lightning.AttachedLightningRenderer;
import kamkeel.npcs.entity.EntityAbilityBeam;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
@@ -31,6 +32,13 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
setupRenderState();
// Handle charging state (windup phase) - render only growing orb
if (beam.isCharging()) {
renderChargingOrb(beam, x, y, z, partialTicks);
restoreRenderState();
return;
}
// Get trail points (these are RELATIVE to origin)
List<Vec3> trail = beam.getTrailPoints();
if (trail.isEmpty()) {
@@ -60,11 +68,21 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
GL11.glPushMatrix();
GL11.glTranslated(renderOriginX, renderOriginY, renderOriginZ);
// Render tail orb at origin (0,0,0) - static, no rotation
renderTailOrb(headSize * 0.8f, innerColor, outerColor, beam.isOuterColorEnabled());
// Calculate head distance from origin (for overlap check)
double headDistFromOrigin = Math.sqrt(headOffsetX * headOffsetX + headOffsetY * headOffsetY + headOffsetZ * headOffsetZ);
// Render trail segments with smooth connections
renderSmoothTrail(trail, beamWidth, innerColor, outerColor, beam.isOuterColorEnabled(), beam.getOuterColorWidth());
// Render tail orb at origin (0,0,0) - only in anchored mode
// Don't render if head is too close to origin (would cause overlap/extra orb appearance)
if (beam.shouldRenderTailOrb() && headDistFromOrigin > headSize * 0.5) {
renderTailOrb(headSize * 0.8f, innerColor, outerColor, beam.isOuterColorEnabled(), beam.getOuterColorWidth());
}
// Render trail segments with smooth connections (with fading for non-anchored)
if (beam.hasFadingTrail()) {
renderFadingTrail(beam, trail, beamWidth, innerColor, outerColor, beam.isOuterColorEnabled(), beam.getOuterColorWidth());
} else {
renderSmoothTrail(trail, beamWidth, innerColor, outerColor, beam.isOuterColorEnabled(), beam.getOuterColorWidth());
}
// Render head at interpolated offset position
renderHead(beam, headOffsetX, headOffsetY, headOffsetZ, headSize, innerColor, outerColor, partialTicks);
@@ -74,27 +92,84 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
restoreRenderState();
}
/**
* Render the charging orb during windup phase.
* Grows from 0 to headSize based on charge progress.
*/
private void renderChargingOrb(EntityAbilityBeam beam, double x, double y, double z, float partialTicks) {
float headSize = beam.getHeadSize();
float chargeProgress = beam.getInterpolatedChargeProgress(partialTicks);
float size = headSize * chargeProgress;
if (size <= 0.01f) return;
int innerColor = beam.getInnerColor();
int outerColor = beam.getOuterColor();
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
// Pulsing effect
float pulseTime = beam.ticksExisted + partialTicks;
float scaleModifier = (float) Math.sin(pulseTime * 0.2f) * 0.08f;
float scale = size * (1.0f + scaleModifier);
// Render lightning during charging if enabled
if (beam.hasLightningEffect()) {
renderAttachedLightning(beam, scale);
}
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
// Inner scale defines the core size
float innerScale = 0.6f;
// Render outer glow only if enabled
if (beam.isOuterColorEnabled()) {
float outerScale = innerScale + beam.getOuterColorWidth();
GL11.glDepthMask(false);
GL11.glPushMatrix();
GL11.glScalef(outerScale, outerScale, outerScale);
renderCube(outerColor, 0.5f, 0.5f);
GL11.glPopMatrix();
GL11.glDepthMask(true);
}
// Render inner core
GL11.glScalef(innerScale, innerScale, innerScale);
renderCube(innerColor, 1.0f, 0.5f);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
/**
* Render the tail orb at the origin (where the beam emanates from).
* This orb does not rotate - it's a stable anchor point.
*/
private void renderTailOrb(float size, int innerColor, int outerColor, boolean outerColorEnabled) {
private void renderTailOrb(float size, int innerColor, int outerColor, boolean outerColorEnabled, float outerColorWidth) {
GL11.glPushMatrix();
// Already at origin (0,0,0)
// Inner scale defines the core size
float innerScale = 0.6f;
// Render outer glow only if enabled
// outerColorWidth is an additive offset from inner size
if (outerColorEnabled) {
float outerScale = innerScale + outerColorWidth;
GL11.glDepthMask(false);
GL11.glPushMatrix();
GL11.glScalef(size, size, size);
GL11.glScalef(size * outerScale, size * outerScale, size * outerScale);
renderCube(outerColor, 0.4f, 0.5f);
GL11.glPopMatrix();
GL11.glDepthMask(true);
}
// Render inner core (smaller, solid)
// Render inner core (solid)
GL11.glPushMatrix();
GL11.glScalef(size * 0.6f, size * 0.6f, size * 0.6f);
GL11.glScalef(size * innerScale, size * innerScale, size * innerScale);
renderCube(innerColor, 1.0f, 0.5f);
GL11.glPopMatrix();
@@ -115,15 +190,153 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
// At connection points, average the perpendiculars for smooth transitions
List<double[]> perpFrames = computePerpendiculars(trail);
// Inner scale defines the core width
float innerScale = 0.6f;
float innerWidth = width * innerScale;
// Render outer glow trail (wider, translucent) - only if enabled
// outerColorWidth is an additive offset from inner width
if (outerColorEnabled) {
float outerWidth = innerWidth + outerColorWidth * width;
GL11.glDepthMask(false);
renderTrailTube(trail, perpFrames, width * outerColorWidth, outerColor, 0.3f, true);
renderTrailTube(trail, perpFrames, outerWidth, outerColor, 0.3f, true);
GL11.glDepthMask(true);
}
// Render inner core trail
renderTrailTube(trail, perpFrames, width * 0.6f, innerColor, 0.9f, false);
renderTrailTube(trail, perpFrames, innerWidth, innerColor, 0.9f, false);
}
/**
* Render trail with fading effect (comet style) for non-anchored beams.
* Older trail points fade out based on their age.
*/
private void renderFadingTrail(EntityAbilityBeam beam, List<Vec3> trail, float width, int innerColor, int outerColor,
boolean outerColorEnabled, float outerColorWidth) {
if (trail.size() < 2) return;
List<Integer> ages = beam.getTrailPointAges();
int fadeTime = beam.getTrailFadeTime();
// Pre-compute perpendicular frames
List<double[]> perpFrames = computePerpendiculars(trail);
// Inner scale defines the core width
float innerScale = 0.6f;
float innerWidth = width * innerScale;
// Render outer glow trail with fading
if (outerColorEnabled) {
float outerWidth = innerWidth + outerColorWidth * width;
GL11.glDepthMask(false);
renderFadingTrailTube(trail, perpFrames, ages, fadeTime, outerWidth, outerColor, 0.3f);
GL11.glDepthMask(true);
}
// Render inner core trail with fading
renderFadingTrailTube(trail, perpFrames, ages, fadeTime, innerWidth, innerColor, 0.9f);
}
/**
* Render trail tube with age-based fading.
*/
private void renderFadingTrailTube(List<Vec3> trail, List<double[]> perpFrames, List<Integer> ages,
int fadeTime, float width, int color, float baseAlpha) {
float[] rgb = extractRGB(color);
float r = rgb[0], g = rgb[1], b = rgb[2];
float halfWidth = width * 0.5f;
int size = trail.size();
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
for (int i = 0; i < size - 1; i++) {
Vec3 p1 = trail.get(i);
Vec3 p2 = trail.get(i + 1);
double[] frame1 = perpFrames.get(i);
double[] frame2 = perpFrames.get(i + 1);
// Calculate alpha based on age (older = more faded)
float age1 = i < ages.size() ? ages.get(i) : 0;
float age2 = (i + 1) < ages.size() ? ages.get(i + 1) : 0;
float fade1 = 1.0f - Math.min(1.0f, age1 / fadeTime);
float fade2 = 1.0f - Math.min(1.0f, age2 / fadeTime);
float alpha1 = baseAlpha * fade1;
float alpha2 = baseAlpha * fade2;
// Skip fully faded segments
if (alpha1 <= 0.01f && alpha2 <= 0.01f) continue;
// Calculate 4 corners at start
double s1x = p1.xCoord - frame1[0] * halfWidth - frame1[3] * halfWidth;
double s1y = p1.yCoord - frame1[1] * halfWidth - frame1[4] * halfWidth;
double s1z = p1.zCoord - frame1[2] * halfWidth - frame1[5] * halfWidth;
double s2x = p1.xCoord + frame1[0] * halfWidth - frame1[3] * halfWidth;
double s2y = p1.yCoord + frame1[1] * halfWidth - frame1[4] * halfWidth;
double s2z = p1.zCoord + frame1[2] * halfWidth - frame1[5] * halfWidth;
double s3x = p1.xCoord + frame1[0] * halfWidth + frame1[3] * halfWidth;
double s3y = p1.yCoord + frame1[1] * halfWidth + frame1[4] * halfWidth;
double s3z = p1.zCoord + frame1[2] * halfWidth + frame1[5] * halfWidth;
double s4x = p1.xCoord - frame1[0] * halfWidth + frame1[3] * halfWidth;
double s4y = p1.yCoord - frame1[1] * halfWidth + frame1[4] * halfWidth;
double s4z = p1.zCoord - frame1[2] * halfWidth + frame1[5] * halfWidth;
// Calculate 4 corners at end
double e1x = p2.xCoord - frame2[0] * halfWidth - frame2[3] * halfWidth;
double e1y = p2.yCoord - frame2[1] * halfWidth - frame2[4] * halfWidth;
double e1z = p2.zCoord - frame2[2] * halfWidth - frame2[5] * halfWidth;
double e2x = p2.xCoord + frame2[0] * halfWidth - frame2[3] * halfWidth;
double e2y = p2.yCoord + frame2[1] * halfWidth - frame2[4] * halfWidth;
double e2z = p2.zCoord + frame2[2] * halfWidth - frame2[5] * halfWidth;
double e3x = p2.xCoord + frame2[0] * halfWidth + frame2[3] * halfWidth;
double e3y = p2.yCoord + frame2[1] * halfWidth + frame2[4] * halfWidth;
double e3z = p2.zCoord + frame2[2] * halfWidth + frame2[5] * halfWidth;
double e4x = p2.xCoord - frame2[0] * halfWidth + frame2[3] * halfWidth;
double e4y = p2.yCoord - frame2[1] * halfWidth + frame2[4] * halfWidth;
double e4z = p2.zCoord - frame2[2] * halfWidth + frame2[5] * halfWidth;
// Bottom face
tess.setColorRGBA_F(r, g, b, alpha1);
tess.addVertex(s1x, s1y, s1z);
tess.addVertex(s2x, s2y, s2z);
tess.setColorRGBA_F(r, g, b, alpha2);
tess.addVertex(e2x, e2y, e2z);
tess.addVertex(e1x, e1y, e1z);
// Top face
tess.setColorRGBA_F(r, g, b, alpha1);
tess.addVertex(s4x, s4y, s4z);
tess.setColorRGBA_F(r, g, b, alpha2);
tess.addVertex(e4x, e4y, e4z);
tess.addVertex(e3x, e3y, e3z);
tess.setColorRGBA_F(r, g, b, alpha1);
tess.addVertex(s3x, s3y, s3z);
// Left face
tess.setColorRGBA_F(r, g, b, alpha1);
tess.addVertex(s1x, s1y, s1z);
tess.setColorRGBA_F(r, g, b, alpha2);
tess.addVertex(e1x, e1y, e1z);
tess.addVertex(e4x, e4y, e4z);
tess.setColorRGBA_F(r, g, b, alpha1);
tess.addVertex(s4x, s4y, s4z);
// Right face
tess.setColorRGBA_F(r, g, b, alpha1);
tess.addVertex(s2x, s2y, s2z);
tess.addVertex(s3x, s3y, s3z);
tess.setColorRGBA_F(r, g, b, alpha2);
tess.addVertex(e3x, e3y, e3z);
tess.addVertex(e2x, e2y, e2z);
}
tess.draw();
}
/**
@@ -328,6 +541,11 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
float scaleModifier = (float) Math.sin(pulseTime * 0.2f) * 0.1f;
float scale = size * (1.0f + scaleModifier);
// Render lightning BEFORE rotation so it crackles in all directions (only on head)
if (beam.hasLightningEffect()) {
renderAttachedLightning(beam, scale);
}
// Rotation
GL11.glRotatef(beam.getInterpolatedRotationX(partialTicks), 1.0f, 0.0f, 0.0f);
GL11.glRotatef(beam.getInterpolatedRotationY(partialTicks), 0.0f, 1.0f, 0.0f);
@@ -336,19 +554,54 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
// Inner scale defines the core size
float innerScale = 0.6f;
// Render outer glow only if enabled
// outerColorWidth is an additive offset from inner size
if (beam.isOuterColorEnabled()) {
float outerScale = innerScale + beam.getOuterColorWidth();
GL11.glDepthMask(false);
GL11.glPushMatrix();
GL11.glScalef(outerScale, outerScale, outerScale);
renderCube(outerColor, 0.5f, 0.5f);
GL11.glPopMatrix();
GL11.glDepthMask(true);
}
// Render inner core
float innerScale = 0.6f;
GL11.glScalef(innerScale, innerScale, innerScale);
renderCube(innerColor, 1.0f, 0.5f);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
/**
* Render fading lightning arcs attached to the beam head (in local space).
*/
private void renderAttachedLightning(EntityAbilityBeam beam, float headScale) {
AttachedLightningRenderer.LightningState state = getLightningState(beam);
float density = beam.getLightningDensity();
// Lightning radius extends outward from inner surface (innerScale = 0.6)
float innerRadius = 0.6f * headScale * 0.5f;
float radius = innerRadius + beam.getLightningRadius() * headScale;
int outerColor = beam.getOuterColor();
int innerColor = beam.getInnerColor();
int fadeTime = beam.getLightningFadeTime();
state.update(density, radius, outerColor, innerColor, fadeTime);
state.render();
}
/**
* Get or create the lightning state for an entity.
*/
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityBeam beam) {
if (beam.lightningState == null) {
beam.lightningState = new AttachedLightningRenderer.LightningState();
}
return (AttachedLightningRenderer.LightningState) beam.lightningState;
}
}
@@ -2,6 +2,7 @@ package kamkeel.npcs.client.renderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.client.renderer.lightning.AttachedLightningRenderer;
import kamkeel.npcs.entity.EntityAbilityDisc;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
@@ -21,6 +22,7 @@ public class RenderAbilityDisc extends RenderAbilityProjectile {
setupRenderState();
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
// Get interpolated values
@@ -33,29 +35,66 @@ public class RenderAbilityDisc extends RenderAbilityProjectile {
float scaleModifier = (float) Math.sin(pulseTime * 0.1f) * 0.03f;
float scale = 1.0f + scaleModifier;
// Render lightning BEFORE rotation so it crackles in all directions
if (disc.hasLightningEffect()) {
renderAttachedLightning(disc, radius * scale);
}
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
// Apply ONLY Y-axis rotation for flat spin
GL11.glRotatef(disc.getInterpolatedRotationY(partialTicks), 0.0f, 1.0f, 0.0f);
// Inner scale defines the core size
float innerScale = 0.6f;
// Render outer square (translucent) - only if enabled
// outerColorWidth is an additive offset from inner size
if (disc.isOuterColorEnabled()) {
float outerScale = disc.getOuterColorWidth() / 1.8f; // Normalize to default width
float outerScale = innerScale + disc.getOuterColorWidth();
GL11.glDepthMask(false);
renderFlatSquare(disc.getOuterColor(), 0.5f, radius * outerScale, thickness);
GL11.glDepthMask(true);
}
// Render inner square (solid, smaller)
float innerScale = 0.6f;
// Render inner square (solid)
renderFlatSquare(disc.getInnerColor(), 1.0f, radius * innerScale, thickness * 1.2f);
GL11.glPopMatrix();
GL11.glPopMatrix();
restoreRenderState();
}
/**
* Render fading lightning arcs attached to the disc (in local space).
*/
private void renderAttachedLightning(EntityAbilityDisc disc, float discSize) {
AttachedLightningRenderer.LightningState state = getLightningState(disc);
float density = disc.getLightningDensity();
// Lightning radius extends outward from inner surface (innerScale = 0.6)
float innerRadius = 0.6f * discSize * 0.5f;
float radius = innerRadius + disc.getLightningRadius() * discSize;
int outerColor = disc.getOuterColor();
int innerColor = disc.getInnerColor();
int fadeTime = disc.getLightningFadeTime();
state.update(density, radius, outerColor, innerColor, fadeTime);
state.render();
}
/**
* Get or create the lightning state for an entity.
*/
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityDisc disc) {
if (disc.lightningState == null) {
disc.lightningState = new AttachedLightningRenderer.LightningState();
}
return (AttachedLightningRenderer.LightningState) disc.lightningState;
}
/**
* Render a flat square (thin cube) centered at origin.
* The square lies flat on the XZ plane with thin Y height.
@@ -2,6 +2,7 @@ package kamkeel.npcs.client.renderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.client.renderer.lightning.AttachedLightningRenderer;
import kamkeel.npcs.entity.EntityAbilityLaser;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
@@ -84,32 +85,103 @@ public class RenderAbilityLaser extends RenderAbilityProjectile {
double vertY = dz * horzX - dx * horzZ;
double vertZ = dx * horzY - dy * horzX;
// Inner scale defines the core width
float innerScale = 0.6f;
float innerWidth = width * innerScale;
// Render outer rectangle (larger, outer color, translucent) - only if enabled
// outerColorWidth is an additive offset from inner width
if (laser.isOuterColorEnabled()) {
float outerScale = laser.getOuterColorWidth();
float outerWidth = innerWidth + laser.getOuterColorWidth() * width;
GL11.glDepthMask(false);
renderBeamRectangle(renderStartX, renderStartY, renderStartZ,
renderEndX, renderEndY, renderEndZ,
horzX, horzY, horzZ, vertX, vertY, vertZ,
width * outerScale, laser.getOuterColor(), alpha * 0.4f);
outerWidth, laser.getOuterColor(), alpha * 0.4f);
// Render middle layer
// Render middle layer (halfway between inner and outer)
float midWidth = innerWidth + (outerWidth - innerWidth) * 0.5f;
renderBeamRectangle(renderStartX, renderStartY, renderStartZ,
renderEndX, renderEndY, renderEndZ,
horzX, horzY, horzZ, vertX, vertY, vertZ,
width * 1.3f, laser.getOuterColor(), alpha * 0.7f);
midWidth, laser.getOuterColor(), alpha * 0.7f);
GL11.glDepthMask(true);
}
// Render inner core (smaller, inner color, solid)
// Render inner core (solid)
renderBeamRectangle(renderStartX, renderStartY, renderStartZ,
renderEndX, renderEndY, renderEndZ,
horzX, horzY, horzZ, vertX, vertY, vertZ,
width * 0.6f, laser.getInnerColor(), alpha);
innerWidth, laser.getInnerColor(), alpha);
// Render lightning along the laser beam
if (laser.hasLightningEffect() && laser.getCurrentLength() > 0.1f) {
renderLaserLightning(laser, renderStartX, renderStartY, renderStartZ,
renderEndX, renderEndY, renderEndZ, width);
}
restoreRenderState();
}
/**
* Render lightning effects along the laser beam at multiple points.
*/
private void renderLaserLightning(EntityAbilityLaser laser,
double startX, double startY, double startZ,
double endX, double endY, double endZ, float width) {
AttachedLightningRenderer.LightningState state = getLightningState(laser);
float density = laser.getLightningDensity();
// Lightning radius extends outward from inner width
float innerRadius = width * 0.6f * 0.5f;
float radius = innerRadius + laser.getLightningRadius() * width;
int outerColor = laser.getOuterColor();
int innerColor = laser.getInnerColor();
int fadeTime = laser.getLightningFadeTime();
// Render lightning at multiple points along the laser
// Start, middle, and end points
double midX = (startX + endX) * 0.5;
double midY = (startY + endY) * 0.5;
double midZ = (startZ + endZ) * 0.5;
GL11.glPushMatrix();
GL11.glTranslated(midX, midY, midZ);
state.update(density, radius, outerColor, innerColor, fadeTime);
state.render();
GL11.glPopMatrix();
// Also render at the tip
GL11.glPushMatrix();
GL11.glTranslated(endX, endY, endZ);
// Use a secondary state for the tip
AttachedLightningRenderer.LightningState tipState = getTipLightningState(laser);
tipState.update(density * 0.7f, radius * 0.8f, outerColor, innerColor, fadeTime);
tipState.render();
GL11.glPopMatrix();
}
/**
* Get or create the main lightning state for the laser.
*/
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityLaser laser) {
if (laser.lightningState == null) {
laser.lightningState = new AttachedLightningRenderer.LightningState();
}
return (AttachedLightningRenderer.LightningState) laser.lightningState;
}
/**
* Get or create the tip lightning state for the laser.
* Stored as a secondary object in lightningState2.
*/
private AttachedLightningRenderer.LightningState getTipLightningState(EntityAbilityLaser laser) {
// Use a simple approach - store in a transient field
// Since lightningState is already used, we'll create a new state each time
// This works because we're updating and rendering immediately
return new AttachedLightningRenderer.LightningState();
}
/**
* Render a beam as a 3D rectangular prism (box along a line).
*/
@@ -2,57 +2,29 @@ package kamkeel.npcs.client.renderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.client.renderer.quadric.SphereRenderer;
import kamkeel.npcs.client.renderer.lightning.AttachedLightningRenderer;
import kamkeel.npcs.entity.EntityAbilityOrb;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
/**
* Renders the AbilityOrb entity as a glowing sphere with inner and outer layers.
*
* Design inspired by LouisXIV's energy rendering system.
* Renders the AbilityOrb entity as a cube with inner and outer layers.
* Minecraft-style blocky appearance using Tessellator.
*/
@SideOnly(Side.CLIENT)
public class RenderAbilityOrb extends Render {
public class RenderAbilityOrb extends RenderAbilityProjectile {
// White texture for solid color rendering
private static final ResourceLocation WHITE_TEXTURE = new ResourceLocation("customnpcs", "textures/entity/white.png");
// Static sphere renderer - shared across all orb renders
private static final SphereRenderer sphere = new SphereRenderer(0.5f, 16);
public RenderAbilityOrb() {
this.shadowSize = 0.0f;
}
private static final int LIGHTNING_FADE_TICKS = 6;
@Override
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
EntityAbilityOrb orb = (EntityAbilityOrb) entity;
setupRenderState();
GL11.glPushMatrix();
// Disable culling, enable rescale normal
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_ALPHA_TEST);
// Enable blending for transparency
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
// Disable lighting for self-illumination
GL11.glDisable(GL11.GL_LIGHTING);
// Translate to render position
GL11.glTranslated(x, y, z);
// Bind texture
this.bindTexture(WHITE_TEXTURE);
// Get interpolated size for smooth rendering
float size = orb.getInterpolatedSize(partialTicks);
@@ -61,51 +33,74 @@ public class RenderAbilityOrb extends Render {
float scaleModifier = (float) Math.sin(pulseTime * 0.15f) * 0.05f;
float scale = size * (1.0f + scaleModifier);
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
// Render lightning BEFORE rotation so it crackles in all directions
if (orb.hasLightningEffect()) {
renderAttachedLightning(orb, scale);
}
// Use entity's interpolated rotation for smooth spinning
GL11.glRotatef(orb.getInterpolatedRotationX(partialTicks), 1.0f, 0.0f, 0.0f);
GL11.glRotatef(orb.getInterpolatedRotationY(partialTicks), 0.0f, 1.0f, 0.0f);
GL11.glRotatef(orb.getInterpolatedRotationZ(partialTicks), 0.0f, 0.0f, 1.0f);
// Render outer sphere (translucent) - only if enabled
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
// Inner scale defines the core size
float innerScale = 0.6f;
// Render outer cube (translucent) - only if enabled
// outerColorWidth is an additive offset from inner size
if (orb.isOuterColorEnabled()) {
float outerScale = innerScale + orb.getOuterColorWidth();
GL11.glDepthMask(false);
this.bindTexture(WHITE_TEXTURE);
float outerScale = orb.getOuterColorWidth() / 1.8f; // Normalize to default width
GL11.glPushMatrix();
GL11.glScalef(outerScale, outerScale, outerScale);
renderSphere(orb.getOuterColor(), 0.6f);
renderCube(orb.getOuterColor(), 0.5f, 0.5f);
GL11.glPopMatrix();
GL11.glDepthMask(true);
}
// Render inner sphere (more opaque)
float innerScale = 0.75f;
GL11.glPushMatrix();
// Render inner cube (solid)
GL11.glScalef(innerScale, innerScale, innerScale);
this.bindTexture(WHITE_TEXTURE);
renderSphere(orb.getInnerColor(), 1.0f);
GL11.glPopMatrix();
renderCube(orb.getInnerColor(), 1.0f, 0.5f);
GL11.glPopMatrix();
// Restore GL state
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
restoreRenderState();
}
private void renderSphere(int color, float alpha) {
// Set sphere properties and render (rotation already applied to matrix)
sphere.setScale(1.0f);
sphere.setAlpha(alpha);
sphere.setColor(color);
sphere.render(0);
/**
* Render fading lightning arcs attached to the orb (in local space).
* Arcs persist for a few ticks and fade out, while staying attached to the orb.
*/
private void renderAttachedLightning(EntityAbilityOrb orb, float orbScale) {
// Get or create the lightning state for this entity
AttachedLightningRenderer.LightningState state = getLightningState(orb);
float density = orb.getLightningDensity();
// Lightning radius extends outward from inner surface (innerScale = 0.6)
float innerRadius = 0.6f * orbScale * 0.5f; // Half size of inner cube
float radius = innerRadius + orb.getLightningRadius() * orbScale;
int outerColor = orb.getOuterColor();
int innerColor = orb.getInnerColor();
int fadeTime = orb.getLightningFadeTime();
// Update: age existing arcs, spawn new ones based on density
state.update(density, radius, outerColor, innerColor, fadeTime);
// Render all active arcs in local space (they move with the orb)
state.render();
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return WHITE_TEXTURE;
/**
* Get or create the lightning state for an entity.
*/
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityOrb orb) {
if (orb.lightningState == null) {
orb.lightningState = new AttachedLightningRenderer.LightningState();
}
return (AttachedLightningRenderer.LightningState) orb.lightningState;
}
}
@@ -1,56 +0,0 @@
package kamkeel.npcs.client.renderer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.entity.EntityAbilityOrb;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11;
/**
* Renders the AbilityOrb entity as a cube with inner and outer layers.
* Minecraft-style blocky appearance using Tessellator.
*
* Design inspired by LouisXIV's energy rendering system.
*/
@SideOnly(Side.CLIENT)
public class RenderAbilityOrbCube extends RenderAbilityProjectile {
@Override
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
EntityAbilityOrb orb = (EntityAbilityOrb) entity;
setupRenderState();
GL11.glTranslated(x, y, z);
// Get interpolated size for smooth rendering
float size = orb.getInterpolatedSize(partialTicks);
// Pulsing scale effect
float pulseTime = entity.ticksExisted + partialTicks;
float scaleModifier = (float) Math.sin(pulseTime * 0.15f) * 0.05f;
float scale = size * (1.0f + scaleModifier);
// Use entity's interpolated rotation for smooth spinning
GL11.glRotatef(orb.getInterpolatedRotationX(partialTicks), 1.0f, 0.0f, 0.0f);
GL11.glRotatef(orb.getInterpolatedRotationY(partialTicks), 0.0f, 1.0f, 0.0f);
GL11.glRotatef(orb.getInterpolatedRotationZ(partialTicks), 0.0f, 0.0f, 1.0f);
GL11.glPushMatrix();
GL11.glScalef(scale, scale, scale);
// Render outer cube (translucent)
GL11.glDepthMask(false);
renderCube(orb.getOuterColor(), 0.5f, 0.5f);
GL11.glDepthMask(true);
// Render inner cube (solid, smaller)
float innerScale = 0.6f;
GL11.glScalef(innerScale, innerScale, innerScale);
renderCube(orb.getInnerColor(), 1.0f, 0.5f);
GL11.glPopMatrix();
restoreRenderState();
}
}
@@ -76,10 +76,10 @@ public class TelegraphRenderer {
return;
}
// Calculate render position relative to camera
double renderX = instance.getX() - playerX;
double renderY = instance.getY() - playerY + telegraph.getHeightOffset();
double renderZ = instance.getZ() - playerZ;
// Calculate render position relative to camera using interpolated positions for smooth movement
double renderX = instance.getInterpolatedX(partialTicks) - playerX;
double renderY = instance.getInterpolatedY(partialTicks) - playerY + telegraph.getHeightOffset();
double renderZ = instance.getInterpolatedZ(partialTicks) - playerZ;
// Get animated color
int color = instance.getAnimatedColor(partialTicks);
@@ -91,8 +91,8 @@ public class TelegraphRenderer {
GL11.glPushMatrix();
GL11.glTranslated(renderX, renderY, renderZ);
// Rotate for directional shapes
GL11.glRotatef(-instance.getYaw(), 0, 1, 0);
// Rotate for directional shapes using interpolated yaw for smooth rotation
GL11.glRotatef(-instance.getInterpolatedYaw(partialTicks), 0, 1, 0);
switch (telegraph.getType()) {
case CIRCLE:
@@ -0,0 +1,281 @@
package kamkeel.npcs.client.renderer.lightning;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
/**
* Renders lightning arcs attached to an entity (in local space).
* Supports both instant arcs and fading persistent bolts that move with the entity.
*/
public class AttachedLightningRenderer {
private static final Random rand = new Random();
/**
* Data for a single lightning bolt with fading support.
*/
public static class LightningArc {
public List<double[]> points;
public int age;
public int maxAge;
public int outerColor;
public int innerColor;
public LightningArc(List<double[]> points, int maxAge, int outerColor, int innerColor) {
this.points = points;
this.age = 0;
this.maxAge = maxAge;
this.outerColor = outerColor;
this.innerColor = innerColor;
}
public float getAlphaMultiplier() {
// Fade out over lifetime
return 1.0f - ((float) age / (float) maxAge);
}
public boolean isDead() {
return age >= maxAge;
}
public void tick() {
age++;
}
}
/**
* Storage for persistent lightning arcs per entity.
* Call updateAndRender() each frame from the entity's renderer.
*/
public static class LightningState {
private final List<LightningArc> arcs = new ArrayList<>();
private float spawnAccumulator = 0;
/**
* Update arc ages, remove dead arcs, spawn new ones based on density.
*
* @param density Arcs per tick (can be fractional)
* @param radius Max arc distance from center
* @param outerColor Outer glow color
* @param innerColor Inner core color
* @param maxAge How many ticks arcs live (for fading)
*/
public void update(float density, float radius, int outerColor, int innerColor, int maxAge) {
// Age existing arcs and remove dead ones
Iterator<LightningArc> iter = arcs.iterator();
while (iter.hasNext()) {
LightningArc arc = iter.next();
arc.tick();
if (arc.isDead()) {
iter.remove();
}
}
// Spawn new arcs based on density
spawnAccumulator += density;
while (spawnAccumulator >= 1.0f) {
spawnAccumulator -= 1.0f;
arcs.add(createArc(radius, outerColor, innerColor, maxAge));
}
}
/**
* Render all active arcs in local space.
* Call this after glTranslated to entity position.
*/
public void render() {
if (arcs.isEmpty()) return;
// Setup GL state
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
Tessellator tess = Tessellator.instance;
for (LightningArc arc : arcs) {
float alphaMult = arc.getAlphaMultiplier();
// Render outer glow
renderBoltPath(tess, arc.points, arc.outerColor, 0.025f, 0.35f * alphaMult);
// Render inner core
renderBoltPath(tess, arc.points, arc.innerColor, 0.012f, 0.7f * alphaMult);
}
GL11.glDepthMask(true);
GL11.glPopAttrib();
}
public int getArcCount() {
return arcs.size();
}
}
/**
* Create a new lightning arc from center to a random point.
*/
private static LightningArc createArc(float radius, int outerColor, int innerColor, int maxAge) {
// Random end point on sphere
double theta = rand.nextDouble() * Math.PI * 2;
double phi = Math.acos(2 * rand.nextDouble() - 1);
double r = radius * (0.5 + rand.nextDouble() * 0.5);
double endX = r * Math.sin(phi) * Math.cos(theta);
double endY = r * Math.sin(phi) * Math.sin(theta);
double endZ = r * Math.cos(phi);
int segments = 4 + rand.nextInt(3);
float displacement = radius * 0.25f;
List<double[]> points = generateLightningPath(0, 0, 0, endX, endY, endZ, segments, displacement);
return new LightningArc(points, maxAge, outerColor, innerColor);
}
/**
* Generate a jagged lightning path between two points.
*/
private static List<double[]> generateLightningPath(double x1, double y1, double z1,
double x2, double y2, double z2,
int segments, float displacement) {
List<double[]> points = new ArrayList<>();
points.add(new double[]{x1, y1, z1});
double dx = x2 - x1;
double dy = y2 - y1;
double dz = z2 - z1;
// Create perpendicular vectors for displacement
Vec3d dir = new Vec3d(dx, dy, dz);
Vec3d perp1 = dir.copy().perpendicular().normalize();
Vec3d perp2 = dir.copy().crossProduct(perp1).normalize();
for (int i = 1; i < segments; i++) {
double t = (double) i / segments;
double px = x1 + dx * t;
double py = y1 + dy * t;
double pz = z1 + dz * t;
// Displacement strongest in middle
float strength = (float) (1.0 - Math.abs(t - 0.5) * 2.0) * displacement;
double offset1 = (rand.nextDouble() - 0.5) * 2 * strength;
double offset2 = (rand.nextDouble() - 0.5) * 2 * strength;
px += perp1.x * offset1 + perp2.x * offset2;
py += perp1.y * offset1 + perp2.y * offset2;
pz += perp1.z * offset1 + perp2.z * offset2;
points.add(new double[]{px, py, pz});
}
points.add(new double[]{x2, y2, z2});
return points;
}
/**
* Render the lightning path as quads.
*/
private static void renderBoltPath(Tessellator tess, List<double[]> points, int color, float width, float alpha) {
if (alpha <= 0.01f) return;
Color c = new Color(color);
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
int a = Math.min(255, Math.max(0, (int) (alpha * 255)));
for (int i = 0; i < points.size() - 1; i++) {
double[] p1 = points.get(i);
double[] p2 = points.get(i + 1);
double segDx = p2[0] - p1[0];
double segDy = p2[1] - p1[1];
double segDz = p2[2] - p1[2];
Vec3d segDir = new Vec3d(segDx, segDy, segDz);
Vec3d perp = segDir.copy().perpendicular().normalize().multiply(width);
// First quad
tess.startDrawingQuads();
tess.setBrightness(0xF000F0);
tess.setColorRGBA(r, g, b, a);
tess.addVertex(p1[0] - perp.x, p1[1] - perp.y, p1[2] - perp.z);
tess.addVertex(p1[0] + perp.x, p1[1] + perp.y, p1[2] + perp.z);
tess.addVertex(p2[0] + perp.x, p2[1] + perp.y, p2[2] + perp.z);
tess.addVertex(p2[0] - perp.x, p2[1] - perp.y, p2[2] - perp.z);
tess.draw();
// Second quad (perpendicular for 3D look)
Vec3d perp2 = segDir.copy().crossProduct(perp).normalize().multiply(width);
tess.startDrawingQuads();
tess.setBrightness(0xF000F0);
tess.setColorRGBA(r, g, b, a);
tess.addVertex(p1[0] - perp2.x, p1[1] - perp2.y, p1[2] - perp2.z);
tess.addVertex(p1[0] + perp2.x, p1[1] + perp2.y, p1[2] + perp2.z);
tess.addVertex(p2[0] + perp2.x, p2[1] + perp2.y, p2[2] + perp2.z);
tess.addVertex(p2[0] - perp2.x, p2[1] - perp2.y, p2[2] - perp2.z);
tess.draw();
}
}
// ==================== INSTANT RENDERING (no persistence) ====================
/**
* Render a single instant lightning arc (no fading, drawn this frame only).
*/
public static void renderInstantArc(float radius, int outerColor, int innerColor) {
double theta = rand.nextDouble() * Math.PI * 2;
double phi = Math.acos(2 * rand.nextDouble() - 1);
double r = radius * (0.5 + rand.nextDouble() * 0.5);
double endX = r * Math.sin(phi) * Math.cos(theta);
double endY = r * Math.sin(phi) * Math.sin(theta);
double endZ = r * Math.cos(phi);
int segments = 4 + rand.nextInt(3);
float displacement = radius * 0.25f;
List<double[]> points = generateLightningPath(0, 0, 0, endX, endY, endZ, segments, displacement);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDepthMask(false);
Tessellator tess = Tessellator.instance;
renderBoltPath(tess, points, outerColor, 0.025f, 0.35f);
renderBoltPath(tess, points, innerColor, 0.012f, 0.7f);
GL11.glDepthMask(true);
GL11.glPopAttrib();
}
/**
* Render multiple instant arcs.
*/
public static void renderCracklingLightning(int count, float radius, int outerColor, int innerColor) {
for (int i = 0; i < count; i++) {
renderInstantArc(radius, outerColor, innerColor);
}
}
}
@@ -0,0 +1,295 @@
package kamkeel.npcs.client.renderer.lightning;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* Lightning bolt data model with fractal segment generation.
* Adapted from Botania's LightningBolt by Vazkii/ChickenBones.
*/
public class LightningBolt {
public static ConcurrentLinkedQueue<LightningBolt> boltList = new ConcurrentLinkedQueue<>();
public ArrayList<Segment> segments = new ArrayList<>();
public Vec3d start;
public Vec3d end;
public double length;
public int numSegments0;
private int numSplits;
private boolean finalized;
private Random rand;
public long seed;
public int particleAge;
public int particleMaxAge;
public boolean isDead;
private World world;
private HashMap<Integer, Integer> splitParents = new HashMap<>();
public float speed = 1.5F;
public static final int FADE_TIME = 4; // Short lifespan for projectile-attached lightning
public int colorOuter;
public int colorInner;
public LightningBolt(World world, Vec3d start, Vec3d end, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
this.world = world;
this.seed = seed;
this.rand = new Random(seed);
this.start = start;
this.end = end;
this.speed = ticksPerMeter;
this.colorOuter = colorOuter;
this.colorInner = colorInner;
this.numSegments0 = 1;
this.length = end.copy().subtract(start).mag();
this.particleMaxAge = FADE_TIME + rand.nextInt(FADE_TIME) - FADE_TIME / 2;
this.particleAge = -(int) (length * speed);
segments.add(new Segment(start, end));
}
/**
* Apply default fractal splitting for natural-looking lightning.
*/
public void defaultFractal() {
fractal(2, length / 1.5, 0.7F, 0.7F, 45);
fractal(2, length / 4, 0.5F, 0.8F, 50);
fractal(2, length / 15, 0.5F, 0.9F, 55);
fractal(2, length / 30, 0.5F, 1.0F, 60);
fractal(2, length / 60, 0, 0, 0);
fractal(2, length / 100, 0, 0, 0);
fractal(2, length / 400, 0, 0, 0);
}
/**
* Simplified fractal for short-lived projectile lightning.
* Less detail but faster and more appropriate for fast-moving objects.
*/
public void simpleFractal() {
fractal(2, length / 2.0, 0.4F, 0.6F, 35);
fractal(2, length / 6, 0.3F, 0.7F, 40);
fractal(2, length / 20, 0, 0, 0);
}
/**
* Apply fractal splitting to create branching lightning.
*
* @param splits Number of splits per segment
* @param amount Displacement amount
* @param splitChance Probability of branching (0-1)
* @param splitLength Length multiplier for branches
* @param splitAngle Angle for branch splits in degrees
*/
public void fractal(int splits, double amount, double splitChance, double splitLength, double splitAngle) {
if (finalized) return;
ArrayList<Segment> oldSegments = segments;
segments = new ArrayList<>();
Segment prev = null;
for (Segment segment : oldSegments) {
prev = segment.prev;
Vec3d subSegment = segment.diff.copy().multiply(1.0 / splits);
BoltPoint[] newPoints = new BoltPoint[splits + 1];
Vec3d startPoint = segment.startPoint.point;
newPoints[0] = segment.startPoint;
newPoints[splits] = segment.endPoint;
for (int i = 1; i < splits; i++) {
Vec3d randOff = segment.diff.copy().perpendicular().normalize()
.rotate(rand.nextFloat() * 360, segment.diff);
randOff.multiply((rand.nextFloat() - 0.5F) * amount * 2);
Vec3d basePoint = startPoint.copy().add(subSegment.copy().multiply(i));
newPoints[i] = new BoltPoint(basePoint, randOff);
}
for (int i = 0; i < splits; i++) {
Segment next = new Segment(newPoints[i], newPoints[i + 1], segment.light,
segment.segmentNo * splits + i, segment.splitNo);
next.prev = prev;
if (prev != null) {
prev.next = next;
}
if (i != 0 && rand.nextFloat() < splitChance) {
Vec3d splitRot = next.diff.copy().xCrossProduct()
.rotate(rand.nextFloat() * 360, next.diff);
Vec3d diff = next.diff.copy()
.rotate((rand.nextFloat() * 0.66F + 0.33F) * splitAngle, splitRot)
.multiply(splitLength);
numSplits++;
splitParents.put(numSplits, next.splitNo);
Segment split = new Segment(newPoints[i],
new BoltPoint(newPoints[i + 1].basePoint, newPoints[i + 1].offsetVec.copy().add(diff)),
segment.light / 2F, next.segmentNo, numSplits);
split.prev = prev;
segments.add(split);
}
prev = next;
segments.add(next);
}
if (segment.next != null) {
segment.next.prev = prev;
}
}
numSegments0 *= splits;
}
/**
* Finalize the bolt after all fractal passes.
*/
public void finalizeBolt() {
if (finalized) return;
finalized = true;
calculateEndDiffs();
Collections.sort(segments, new SegmentLightSorter());
}
private void calculateEndDiffs() {
Collections.sort(segments, new SegmentSorter());
for (Segment segment : segments) {
segment.calcEndDiffs();
}
}
public void onUpdate() {
particleAge++;
if (particleAge >= particleMaxAge) {
isDead = true;
}
}
/**
* Update all active lightning bolts. Called from client tick handler.
*/
public static void updateAll() {
for (Iterator<LightningBolt> iterator = boltList.iterator(); iterator.hasNext(); ) {
LightningBolt bolt = iterator.next();
bolt.onUpdate();
if (bolt.isDead) {
iterator.remove();
}
}
}
// ==================== INNER CLASSES ====================
public class BoltPoint {
public Vec3d point;
public Vec3d basePoint;
public Vec3d offsetVec;
public BoltPoint(Vec3d basePoint, Vec3d offsetVec) {
this.point = basePoint.copy().add(offsetVec);
this.basePoint = basePoint;
this.offsetVec = offsetVec;
}
}
public class Segment {
public BoltPoint startPoint;
public BoltPoint endPoint;
public Vec3d diff;
public Segment prev;
public Segment next;
public Vec3d nextDiff;
public Vec3d prevDiff;
public float sinPrev;
public float sinNext;
public float light;
public int segmentNo;
public int splitNo;
public Segment(BoltPoint start, BoltPoint end, float light, int segmentNo, int splitNo) {
this.startPoint = start;
this.endPoint = end;
this.light = light;
this.segmentNo = segmentNo;
this.splitNo = splitNo;
calcDiff();
}
public Segment(Vec3d start, Vec3d end) {
this(new BoltPoint(start, new Vec3d(0, 0, 0)),
new BoltPoint(end, new Vec3d(0, 0, 0)), 1, 0, 0);
}
public void calcDiff() {
diff = endPoint.point.copy().subtract(startPoint.point);
}
public void calcEndDiffs() {
if (prev != null) {
Vec3d prevDiffNorm = prev.diff.copy().normalize();
Vec3d thisDiffNorm = diff.copy().normalize();
prevDiff = thisDiffNorm.copy().add(prevDiffNorm).normalize();
sinPrev = (float) Math.sin(thisDiffNorm.angle(prevDiffNorm.multiply(-1)) / 2);
} else {
prevDiff = diff.copy().normalize();
sinPrev = 1;
}
if (next != null) {
Vec3d nextDiffNorm = next.diff.copy().normalize();
Vec3d thisDiffNorm = diff.copy().normalize();
nextDiff = thisDiffNorm.add(nextDiffNorm).normalize();
sinNext = (float) Math.sin(thisDiffNorm.angle(nextDiffNorm.multiply(-1)) / 2);
} else {
nextDiff = diff.copy().normalize();
sinNext = 1;
}
}
}
public class SegmentSorter implements Comparator<Segment> {
@Override
public int compare(Segment o1, Segment o2) {
int comp = Integer.compare(o1.splitNo, o2.splitNo);
if (comp == 0) {
return Integer.compare(o1.segmentNo, o2.segmentNo);
}
return comp;
}
}
public class SegmentLightSorter implements Comparator<Segment> {
@Override
public int compare(Segment o1, Segment o2) {
return Float.compare(o2.light, o1.light);
}
}
}
@@ -0,0 +1,202 @@
package kamkeel.npcs.client.renderer.lightning;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.client.renderer.lightning.LightningBolt.Segment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
import java.awt.Color;
/**
* Handles rendering of lightning bolts in the world.
* Adapted from Botania's LightningHandler by Vazkii/ChickenBones.
*
* Register this handler with: MinecraftForge.EVENT_BUS.register(new LightningHandler());
*/
@SideOnly(Side.CLIENT)
public class LightningHandler {
private static final ResourceLocation TEXTURE_OUTER = new ResourceLocation("customnpcs", "textures/effects/lightning_outer.png");
private static final ResourceLocation TEXTURE_INNER = new ResourceLocation("customnpcs", "textures/effects/lightning_inner.png");
public static int lightningCount = 0;
private static Vec3d getRelativeViewVector(Vec3d pos) {
Entity renderEntity = Minecraft.getMinecraft().renderViewEntity;
return new Vec3d(
(float) renderEntity.posX - pos.x,
(float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y,
(float) renderEntity.posZ - pos.z
);
}
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
float partialTicks = event.partialTicks;
Entity entity = Minecraft.getMinecraft().thePlayer;
TextureManager textureManager = Minecraft.getMinecraft().renderEngine;
double interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
double interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
double interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
if (LightningBolt.boltList.isEmpty()) {
return;
}
GL11.glPushMatrix();
GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ);
Tessellator tessellator = Tessellator.instance;
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_CULL_FACE);
lightningCount = 0;
// Render outer layer (translucent glow)
for (LightningBolt bolt : LightningBolt.boltList) {
renderBolt(bolt, tessellator, partialTicks, false);
}
// Render inner layer (bright core)
for (LightningBolt bolt : LightningBolt.boltList) {
renderBolt(bolt, tessellator, partialTicks, true);
}
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
private void renderBolt(LightningBolt bolt, Tessellator tessellator, float partialTicks, boolean inner) {
lightningCount++;
float boltAge = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge;
float mainAlpha;
if (!inner) {
mainAlpha = (1 - boltAge) * 0.4F;
} else {
mainAlpha = 1 - boltAge * 0.5F;
}
int expandTime = (int) (bolt.length * bolt.speed);
int renderStart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) / (float) (expandTime / 2) * bolt.numSegments0);
int renderEnd = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numSegments0);
for (Segment segment : bolt.segments) {
if (segment.segmentNo < renderStart || segment.segmentNo > renderEnd) {
continue;
}
Vec3d playerVec = getRelativeViewVector(segment.startPoint.point).multiply(-1);
double width = 0.008F * (playerVec.mag() / 8 + 1) * (1 + segment.light) * 0.4F;
Vec3d diff1 = playerVec.copy().crossProduct(segment.prevDiff).normalize().multiply(width / segment.sinPrev);
Vec3d diff2 = playerVec.copy().crossProduct(segment.nextDiff).normalize().multiply(width / segment.sinNext);
Vec3d startVec = segment.startPoint.point;
Vec3d endVec = segment.endPoint.point;
int color = inner ? bolt.colorInner : bolt.colorOuter;
Color c = new Color(color);
int alpha = (int) (mainAlpha * segment.light * c.getAlpha());
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
tessellator.setColorRGBA(c.getRed(), c.getGreen(), c.getBlue(), alpha);
tessellator.addVertex(endVec.x - diff2.x, endVec.y - diff2.y, endVec.z - diff2.z);
tessellator.addVertex(startVec.x - diff1.x, startVec.y - diff1.y, startVec.z - diff1.z);
tessellator.addVertex(startVec.x + diff1.x, startVec.y + diff1.y, startVec.z + diff1.z);
tessellator.addVertex(endVec.x + diff2.x, endVec.y + diff2.y, endVec.z + diff2.z);
tessellator.draw();
// Rounded end caps
if (segment.next == null) {
Vec3d roundEnd = segment.endPoint.point.copy().add(segment.diff.copy().normalize().multiply(width));
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
tessellator.setColorRGBA(c.getRed(), c.getGreen(), c.getBlue(), alpha);
tessellator.addVertex(roundEnd.x - diff2.x, roundEnd.y - diff2.y, roundEnd.z - diff2.z);
tessellator.addVertex(endVec.x - diff2.x, endVec.y - diff2.y, endVec.z - diff2.z);
tessellator.addVertex(endVec.x + diff2.x, endVec.y + diff2.y, endVec.z + diff2.z);
tessellator.addVertex(roundEnd.x + diff2.x, roundEnd.y + diff2.y, roundEnd.z + diff2.z);
tessellator.draw();
}
if (segment.prev == null) {
Vec3d roundEnd = segment.startPoint.point.copy().subtract(segment.diff.copy().normalize().multiply(width));
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
tessellator.setColorRGBA(c.getRed(), c.getGreen(), c.getBlue(), alpha);
tessellator.addVertex(startVec.x - diff1.x, startVec.y - diff1.y, startVec.z - diff1.z);
tessellator.addVertex(roundEnd.x - diff1.x, roundEnd.y - diff1.y, roundEnd.z - diff1.z);
tessellator.addVertex(roundEnd.x + diff1.x, roundEnd.y + diff1.y, roundEnd.z + diff1.z);
tessellator.addVertex(startVec.x + diff1.x, startVec.y + diff1.y, startVec.z + diff1.z);
tessellator.draw();
}
}
}
/**
* Spawn a lightning bolt between two points.
*
* @param world The world
* @param start Start position
* @param end End position
* @param ticksPerMeter Speed of bolt expansion
* @param seed Random seed for consistent appearance
* @param colorOuter Outer glow color (ARGB)
* @param colorInner Inner core color (ARGB)
*/
public static void spawnLightningBolt(World world, Vec3d start, Vec3d end, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
LightningBolt bolt = new LightningBolt(world, start, end, ticksPerMeter, seed, colorOuter, colorInner);
bolt.defaultFractal();
bolt.finalizeBolt();
LightningBolt.boltList.add(bolt);
}
/**
* Spawn a lightning bolt with automatic seed.
*/
public static void spawnLightningBolt(World world, Vec3d start, Vec3d end, float ticksPerMeter, int colorOuter, int colorInner) {
spawnLightningBolt(world, start, end, ticksPerMeter, System.nanoTime(), colorOuter, colorInner);
}
/**
* Spawn a simple lightning bolt for projectiles - less detail, faster.
*/
public static void spawnSimpleLightningBolt(World world, Vec3d start, Vec3d end, float ticksPerMeter, int colorOuter, int colorInner) {
LightningBolt bolt = new LightningBolt(world, start, end, ticksPerMeter, System.nanoTime(), colorOuter, colorInner);
bolt.simpleFractal();
bolt.finalizeBolt();
LightningBolt.boltList.add(bolt);
}
}
@@ -0,0 +1,85 @@
package kamkeel.npcs.client.renderer.lightning;
/**
* Quaternion class for axis-angle rotations in lightning calculations.
* Adapted from Botania's Quat by ChickenBones.
*/
public class Quaternion {
public double x;
public double y;
public double z;
public double s;
public Quaternion() {
s = 1.0;
x = 0.0;
y = 0.0;
z = 0.0;
}
public Quaternion(Quaternion quat) {
x = quat.x;
y = quat.y;
z = quat.z;
s = quat.s;
}
public Quaternion(double s, double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
this.s = s;
}
public static Quaternion aroundAxis(double ax, double ay, double az, double angle) {
angle *= 0.5;
double sinAngle = Math.sin(angle);
return new Quaternion(Math.cos(angle), ax * sinAngle, ay * sinAngle, az * sinAngle);
}
public static Quaternion aroundAxis(Vec3d axis, double angle) {
return aroundAxis(axis.x, axis.y, axis.z, angle);
}
public void multiply(Quaternion quat) {
double d = s * quat.s - x * quat.x - y * quat.y - z * quat.z;
double d1 = s * quat.x + x * quat.s - y * quat.z + z * quat.y;
double d2 = s * quat.y + x * quat.z + y * quat.s - z * quat.x;
double d3 = s * quat.z - x * quat.y + y * quat.x + z * quat.s;
s = d;
x = d1;
y = d2;
z = d3;
}
public double mag() {
return Math.sqrt(x * x + y * y + z * z + s * s);
}
public void normalize() {
double d = mag();
if (d == 0.0) {
return;
}
d = 1.0 / d;
x *= d;
y *= d;
z *= d;
s *= d;
}
public void rotate(Vec3d vec) {
double d = -x * vec.x - y * vec.y - z * vec.z;
double d1 = s * vec.x + y * vec.z - z * vec.y;
double d2 = s * vec.y - x * vec.z + z * vec.x;
double d3 = s * vec.z + x * vec.y - y * vec.x;
vec.x = d1 * s - d * x - d2 * z + d3 * y;
vec.y = d2 * s - d * y + d1 * z - d3 * x;
vec.z = d3 * s - d * z - d1 * y + d2 * x;
}
@Override
public String toString() {
return "Quaternion(" + s + ", " + x + ", " + y + ", " + z + ")";
}
}
@@ -0,0 +1,184 @@
package kamkeel.npcs.client.renderer.lightning;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
/**
* 3D Vector helper class for lightning calculations.
* Adapted from Botania's Vector3 by ChickenBones.
*/
public class Vec3d {
public double x;
public double y;
public double z;
public Vec3d() {
}
public Vec3d(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vec3d(Vec3d vec) {
this.x = vec.x;
this.y = vec.y;
this.z = vec.z;
}
public Vec3d(Vec3 vec) {
this.x = vec.xCoord;
this.y = vec.yCoord;
this.z = vec.zCoord;
}
public Vec3d copy() {
return new Vec3d(this);
}
public static Vec3d fromEntity(Entity e) {
return new Vec3d(e.posX, e.posY, e.posZ);
}
public static Vec3d fromEntityCenter(Entity e) {
return new Vec3d(e.posX, e.posY - e.yOffset + e.height / 2, e.posZ);
}
public Vec3d set(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
public Vec3d set(Vec3d vec) {
this.x = vec.x;
this.y = vec.y;
this.z = vec.z;
return this;
}
public double dotProduct(Vec3d vec) {
double d = vec.x * x + vec.y * y + vec.z * z;
if (d > 1 && d < 1.00001) d = 1;
else if (d < -1 && d > -1.00001) d = -1;
return d;
}
public Vec3d crossProduct(Vec3d vec) {
double d = y * vec.z - z * vec.y;
double d1 = z * vec.x - x * vec.z;
double d2 = x * vec.y - y * vec.x;
x = d;
y = d1;
z = d2;
return this;
}
public Vec3d add(double x, double y, double z) {
this.x += x;
this.y += y;
this.z += z;
return this;
}
public Vec3d add(Vec3d vec) {
this.x += vec.x;
this.y += vec.y;
this.z += vec.z;
return this;
}
public Vec3d subtract(Vec3d vec) {
this.x -= vec.x;
this.y -= vec.y;
this.z -= vec.z;
return this;
}
public Vec3d multiply(double d) {
this.x *= d;
this.y *= d;
this.z *= d;
return this;
}
public double mag() {
return Math.sqrt(x * x + y * y + z * z);
}
public double magSquared() {
return x * x + y * y + z * z;
}
public Vec3d normalize() {
double d = mag();
if (d != 0) {
multiply(1 / d);
}
return this;
}
public Vec3d perpendicular() {
if (z == 0) {
return zCrossProduct();
}
return xCrossProduct();
}
public Vec3d xCrossProduct() {
double d = z;
double d1 = -y;
x = 0;
y = d;
z = d1;
return this;
}
public Vec3d zCrossProduct() {
double d = y;
double d1 = -x;
x = d;
y = d1;
z = 0;
return this;
}
public Vec3 toVec3() {
return Vec3.createVectorHelper(x, y, z);
}
public double angle(Vec3d vec) {
return Math.acos(copy().normalize().dotProduct(vec.copy().normalize()));
}
public Vec3d negate() {
x = -x;
y = -y;
z = -z;
return this;
}
public Vec3d rotate(double angle, Vec3d axis) {
Quaternion.aroundAxis(axis.copy().normalize(), angle).rotate(this);
return this;
}
public void glVertex() {
GL11.glVertex3d(x, y, z);
}
@Override
public String toString() {
return "Vec3d(" + x + ", " + y + ", " + z + ")";
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Vec3d)) return false;
Vec3d v = (Vec3d) o;
return x == v.x && y == v.y && z == v.z;
}
}
@@ -1,138 +0,0 @@
package kamkeel.npcs.client.renderer.quadric;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.GLAllocation;
import org.lwjgl.opengl.GL11;
/**
* Base class for rendering GLU quadric shapes (spheres, cylinders, etc.)
* Uses display lists for efficient rendering.
*
* Design inspired by LouisXIV's quadric rendering system.
*/
@SideOnly(Side.CLIENT)
public abstract class QuadricRenderer {
protected int displayList;
private boolean compiled;
public final float radius;
public final int slices;
public final int stacks;
// Current render state
protected float scaleX = 1.0f;
protected float scaleY = 1.0f;
protected float scaleZ = 1.0f;
protected float rotationX = 0.0f;
protected float rotationY = 0.0f;
protected float rotationZ = 0.0f;
protected int color = 0xFFFFFF;
protected float alpha = 1.0f;
public QuadricRenderer(float radius, int slices, int stacks) {
this.radius = radius;
this.slices = slices;
this.stacks = stacks;
}
public QuadricRenderer(float radius, int resolution) {
this(radius, resolution, resolution);
}
public QuadricRenderer() {
this(0.5f, 16);
}
/**
* Render the quadric shape with current transform and color settings.
*/
public void render(float partialTicks) {
if (!compiled) {
displayList = GLAllocation.generateDisplayLists(1);
GL11.glNewList(displayList, GL11.GL_COMPILE);
compile();
GL11.glEndList();
compiled = true;
}
GL11.glPushMatrix();
// Apply scale
GL11.glScalef(scaleX, scaleY, scaleZ);
// Apply rotation
GL11.glRotatef(rotationX, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(rotationY, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(rotationZ, 0.0f, 0.0f, 1.0f);
// Apply color
float r = ((color >> 16) & 0xFF) / 255.0f;
float g = ((color >> 8) & 0xFF) / 255.0f;
float b = (color & 0xFF) / 255.0f;
GL11.glColor4f(r, g, b, alpha);
GL11.glCallList(displayList);
GL11.glPopMatrix();
}
/**
* Compile the quadric geometry into the display list.
* Called once, then cached.
*/
protected abstract void compile();
// Setters for render state
public void setScale(float scale) {
this.scaleX = this.scaleY = this.scaleZ = scale;
}
public void setScale(float x, float y, float z) {
this.scaleX = x;
this.scaleY = y;
this.scaleZ = z;
}
public void setRotation(float x, float y, float z) {
this.rotationX = x;
this.rotationY = y;
this.rotationZ = z;
}
public void setColor(int color) {
this.color = color;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
/**
* Linear interpolation helper.
*/
public static float lerp(float current, float target, float factor) {
return current + (target - current) * factor;
}
/**
* Color interpolation helper.
*/
public static int lerpColor(int from, int to, float factor) {
int r1 = (from >> 16) & 0xFF;
int g1 = (from >> 8) & 0xFF;
int b1 = from & 0xFF;
int r2 = (to >> 16) & 0xFF;
int g2 = (to >> 8) & 0xFF;
int b2 = to & 0xFF;
int r = (int) (r1 + (r2 - r1) * factor);
int g = (int) (g1 + (g2 - g1) * factor);
int b = (int) (b1 + (b2 - b1) * factor);
return (r << 16) | (g << 8) | b;
}
}
@@ -1,37 +0,0 @@
package kamkeel.npcs.client.renderer.quadric;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.util.glu.GLU;
import org.lwjgl.util.glu.Sphere;
/**
* Renders a sphere using GLU quadrics.
*
* Design inspired by LouisXIV's quadric rendering system.
*/
@SideOnly(Side.CLIENT)
public class SphereRenderer extends QuadricRenderer {
public SphereRenderer(float radius, int slices, int stacks) {
super(radius, slices, stacks);
}
public SphereRenderer(float radius, int resolution) {
super(radius, resolution);
}
public SphereRenderer() {
super();
}
@Override
protected void compile() {
Sphere sphere = new Sphere();
sphere.setTextureFlag(true); // Enable texture coordinates
sphere.setDrawStyle(GLU.GLU_FILL);
sphere.setNormals(GLU.GLU_NONE); // No normals for self-illuminated rendering
sphere.setOrientation(GLU.GLU_OUTSIDE);
sphere.draw(radius, slices, stacks);
}
}
@@ -119,8 +119,9 @@ public class AbilityCommand extends CommandKamkeelBase {
sendResult(sender, " Type: \u00A7d" + ability.getTypeId());
sendResult(sender, " Cooldown: \u00A7e" + ability.getCooldownTicks() + " ticks");
sendResult(sender, " Wind Up: \u00A7e" + ability.getWindUpTicks() + " ticks");
sendResult(sender, " Active: \u00A7e" + ability.getActiveTicks() + " ticks");
sendResult(sender, " Recovery: \u00A7e" + ability.getRecoveryTicks() + " ticks");
if (ability.isInterruptible()) {
sendResult(sender, " Dazed: \u00A7e" + ability.getDazedTicks() + " ticks");
}
sendResult(sender, " Range: \u00A7e" + ability.getMinRange() + " - " + ability.getMaxRange());
sendResult(sender, " Telegraph: \u00A7e" + (ability.isShowTelegraph() ? "Yes" : "No"));
}
@@ -17,6 +17,8 @@ import noppes.npcs.api.INbt;
import noppes.npcs.api.ability.IAbility;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.AbilityEvent;
@@ -45,18 +47,13 @@ public abstract class Ability implements IAbility {
protected float maxRange = 20;
// Timing (ticks)
protected int cooldownTicks = 100;
protected int cooldownTicks = 0; // Added to global cooldown after ability completes
protected int windUpTicks = 20;
protected int activeTicks = 10;
protected int recoveryTicks = 20;
protected int dazedTicks = 80; // Only used when interrupted during WINDUP (if interruptible)
// Interruption
protected boolean interruptible = true;
// Wait for completion - if true, ability controls when active phase ends (ignores activeTicks)
// Used for abilities like Slam that need to wait for landing, or Beam that runs until entity dies
protected boolean waitForCompletion = false;
// Feedback
protected boolean lockMovement = true;
protected int windUpColor = 0x80FF4400; // Telegraph color during wind up
@@ -78,6 +75,9 @@ public abstract class Ability implements IAbility {
// Custom data for external mods
protected NBTTagCompound customData = new NBTTagCompound();
// Configurable potion effects
protected List<AbilityEffect> effects = new ArrayList<>();
// ═══════════════════════════════════════════════════════════════════
// EXECUTION STATE (not saved, reset each combat)
// ═══════════════════════════════════════════════════════════════════
@@ -224,6 +224,21 @@ public abstract class Ability implements IAbility {
hitEntity.velocityChanged = true;
}
/**
* Applies all configured effects to the given entity.
* Call this after damage is applied to the target.
*
* @param entity The entity to apply effects to
*/
protected void applyEffects(EntityLivingBase entity) {
if (entity == null || effects.isEmpty()) {
return;
}
for (AbilityEffect effect : effects) {
effect.apply(entity);
}
}
public float getTelegraphRadius() {
return 5.0f;
}
@@ -487,11 +502,8 @@ public abstract class Ability implements IAbility {
/**
* Tick the ability forward. Called every game tick while executing.
* <p>
* Normal flow: WINDUP -> ACTIVE -> IDLE (no recovery in normal completion)
* Interrupted flow: WINDUP -> RECOVERY -> IDLE (recovery only on interrupt)
* <p>
* If waitForCompletion is true, the ability controls when active ends
* by calling signalCompletion() instead of using activeTicks.
* Normal flow: WINDUP -> ACTIVE -> IDLE
* Interrupted flow: WINDUP -> DAZED -> IDLE (dazed only on interrupt during WINDUP)
*
* @return true if phase changed this tick
*/
@@ -509,18 +521,13 @@ public abstract class Ability implements IAbility {
}
break;
case ACTIVE:
// If waitForCompletion is true, ability must call signalCompletion()
// Otherwise, auto-complete when activeTicks is reached
if (!waitForCompletion && currentTick >= activeTicks) {
phase = AbilityPhase.IDLE;
currentTick = 0;
return true;
}
// Abilities control their own completion by calling signalCompletion()
// No auto-complete - each ability determines when it's done
break;
case RECOVERY:
// Recovery phase is only entered on interrupt
// Count down recoveryTicks then go to IDLE
if (currentTick >= recoveryTicks) {
case DAZED:
// Dazed phase is only entered on interrupt during WINDUP
// NPC cannot attack during this time
if (currentTick >= dazedTicks) {
phase = AbilityPhase.IDLE;
currentTick = 0;
return true;
@@ -532,13 +539,14 @@ public abstract class Ability implements IAbility {
/**
* Signal that the ability has completed its active phase.
* Called by abilities with waitForCompletion=true when they are done.
* Called by abilities when they are done.
* For example, AbilitySlam calls this when the NPC lands.
*
* @return true if phase changed to IDLE
*/
public boolean signalCompletion() {
if (phase == AbilityPhase.ACTIVE) {
cleanup();
phase = AbilityPhase.IDLE;
currentTick = 0;
return true;
@@ -547,13 +555,14 @@ public abstract class Ability implements IAbility {
}
/**
* Interrupt this ability. Transitions to RECOVERY phase if interruptible.
* Interrupt this ability. Transitions to DAZED phase if interruptible during WINDUP.
* Called when NPC takes direct damage during WINDUP.
*/
public void interrupt() {
cleanup();
if (interruptible && phase == AbilityPhase.WINDUP) {
// Interrupted during windup - go to recovery (dazed state)
phase = AbilityPhase.RECOVERY;
// Interrupted during windup - go to dazed state
phase = AbilityPhase.DAZED;
currentTick = 0;
} else {
// Force stop - go directly to IDLE
@@ -604,15 +613,25 @@ public abstract class Ability implements IAbility {
}
/**
* Reset all execution state (called on combat end)
* Reset all execution state (called on combat end, NPC death, target lost, etc.)
*/
public void reset() {
cleanup();
phase = AbilityPhase.IDLE;
currentTick = 0;
currentTarget = null;
telegraphInstance = null;
}
/**
* Cleanup any resources created by this ability.
* Override this to kill spawned entities, cancel telegraphs, etc.
* Called when ability ends for any reason (completion, interrupt, reset, NPC death).
*/
public void cleanup() {
// Override in subclasses to clean up spawned entities, etc.
}
// ═══════════════════════════════════════════════════════════════════
// CONDITION CHECKING
// ═══════════════════════════════════════════════════════════════════
@@ -641,10 +660,8 @@ public abstract class Ability implements IAbility {
nbt.setFloat("maxRange", maxRange);
nbt.setInteger("cooldown", cooldownTicks);
nbt.setInteger("windUp", windUpTicks);
nbt.setInteger("active", activeTicks);
nbt.setInteger("recovery", recoveryTicks);
nbt.setInteger("recovery", dazedTicks);
nbt.setBoolean("interruptible", interruptible);
nbt.setBoolean("waitForCompletion", waitForCompletion);
nbt.setBoolean("lockMovement", lockMovement);
nbt.setInteger("windUpColor", windUpColor);
nbt.setInteger("activeColor", activeColor);
@@ -662,6 +679,13 @@ public abstract class Ability implements IAbility {
for (Condition c : conditions) condList.appendTag(c.writeNBT());
nbt.setTag("conditions", condList);
// Effects
NBTTagList effectList = new NBTTagList();
for (AbilityEffect effect : effects) {
effectList.appendTag(effect.writeNBT());
}
nbt.setTag("effects", effectList);
// Type-specific
NBTTagCompound typeNBT = new NBTTagCompound();
writeTypeNBT(typeNBT);
@@ -681,10 +705,8 @@ public abstract class Ability implements IAbility {
maxRange = nbt.getFloat("maxRange");
cooldownTicks = nbt.getInteger("cooldown");
windUpTicks = nbt.getInteger("windUp");
activeTicks = nbt.getInteger("active");
recoveryTicks = nbt.getInteger("recovery");
dazedTicks = nbt.getInteger("recovery");
interruptible = nbt.getBoolean("interruptible");
waitForCompletion = nbt.getBoolean("waitForCompletion");
lockMovement = nbt.getBoolean("lockMovement");
// Support old telegraphColor key for backwards compatibility
if (nbt.hasKey("windUpColor")) {
@@ -735,6 +757,18 @@ public abstract class Ability implements IAbility {
if (c != null) conditions.add(c);
}
// Effects
effects.clear();
if (nbt.hasKey("effects")) {
NBTTagList effectList = nbt.getTagList("effects", 10);
for (int i = 0; i < effectList.tagCount(); i++) {
AbilityEffect effect = AbilityEffect.fromNBT(effectList.getCompoundTagAt(i));
if (effect != null && effect.isValid()) {
effects.add(effect);
}
}
}
readTypeNBT(nbt.getCompoundTag("typeData"));
}
@@ -807,7 +841,7 @@ public abstract class Ability implements IAbility {
}
public void setCooldownTicks(int cooldownTicks) {
this.cooldownTicks = cooldownTicks;
this.cooldownTicks = Math.max(0, cooldownTicks);
}
public int getWindUpTicks() {
@@ -815,23 +849,15 @@ public abstract class Ability implements IAbility {
}
public void setWindUpTicks(int windUpTicks) {
this.windUpTicks = windUpTicks;
this.windUpTicks = Math.max(0, windUpTicks);
}
public int getActiveTicks() {
return activeTicks;
public int getDazedTicks() {
return dazedTicks;
}
public void setActiveTicks(int activeTicks) {
this.activeTicks = activeTicks;
}
public int getRecoveryTicks() {
return recoveryTicks;
}
public void setRecoveryTicks(int recoveryTicks) {
this.recoveryTicks = recoveryTicks;
public void setDazedTicks(int dazedTicks) {
this.dazedTicks = Math.max(0, dazedTicks);
}
public boolean isInterruptible() {
@@ -842,14 +868,6 @@ public abstract class Ability implements IAbility {
this.interruptible = interruptible;
}
public boolean isWaitForCompletion() {
return waitForCompletion;
}
public void setWaitForCompletion(boolean waitForCompletion) {
this.waitForCompletion = waitForCompletion;
}
public boolean isLockMovement() {
return lockMovement;
}
@@ -890,16 +908,20 @@ public abstract class Ability implements IAbility {
this.activeSound = activeSound;
}
public int getWindUpAnimationId() {
return windUpAnimationId;
public Animation getWindUpAnimation() {
if (AnimationController.Instance == null) return null;
return (Animation) AnimationController.Instance.get(windUpAnimationId);
}
public void setWindUpAnimationId(int windUpAnimationId) {
this.windUpAnimationId = windUpAnimationId;
}
public int getActiveAnimationId() {
return activeAnimationId;
public Animation getActiveAnimation() {
if (AnimationController.Instance == null) return null;
return (Animation) AnimationController.Instance.get(activeAnimationId);
}
public void setActiveAnimationId(int activeAnimationId) {
@@ -935,7 +957,7 @@ public abstract class Ability implements IAbility {
}
/**
* Get the current execution phase as int (0=IDLE, 1=WINDUP, 2=ACTIVE, 3=RECOVERY).
* Get the current execution phase as int (0=IDLE, 1=WINDUP, 2=ACTIVE, 3=DAZED).
* Required for IAbility interface.
*/
@Override
@@ -963,6 +985,24 @@ public abstract class Ability implements IAbility {
conditions.add(c);
}
public List<AbilityEffect> getEffects() {
return effects;
}
public void setEffects(List<AbilityEffect> effects) {
this.effects = effects != null ? effects : new ArrayList<>();
}
public void addEffect(AbilityEffect effect) {
if (effect != null && effect.isValid()) {
effects.add(effect);
}
}
public void clearEffects() {
effects.clear();
}
// ═══════════════════════════════════════════════════════════════════
// IAbility API METHODS
// ═══════════════════════════════════════════════════════════════════
@@ -0,0 +1,100 @@
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;
}
}
@@ -25,11 +25,7 @@ import noppes.npcs.api.handler.IAbilityHandler;
import noppes.npcs.util.NBTJsonUtil;
import java.io.File;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.Supplier;
/**
@@ -0,0 +1,146 @@
package kamkeel.npcs.controllers.data.ability;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
/**
* Represents a configurable potion effect that can be applied by abilities.
* Provides a unified system for managing debuffs like slowness, weakness, poison, etc.
*/
public class AbilityEffect {
public enum EffectType {
NONE("gui.none", -1),
SLOWNESS("potion.moveSlowdown", Potion.moveSlowdown.id),
WEAKNESS("potion.weakness", Potion.weakness.id),
POISON("potion.poison", Potion.poison.id),
WITHER("potion.wither", Potion.wither.id),
BLINDNESS("potion.blindness", Potion.blindness.id),
NAUSEA("potion.confusion", Potion.confusion.id),
HUNGER("potion.hunger", Potion.hunger.id),
MINING_FATIGUE("potion.digSlowDown", Potion.digSlowdown.id);
private final String langKey;
private final int potionId;
EffectType(String langKey, int potionId) {
this.langKey = langKey;
this.potionId = potionId;
}
public String getLangKey() {
return langKey;
}
public int getPotionId() {
return potionId;
}
public static EffectType fromOrdinal(int ordinal) {
EffectType[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return NONE;
}
}
private EffectType type = EffectType.NONE;
private int durationTicks = 60;
private int amplifier = 0; // 0-10
public AbilityEffect() {
}
public AbilityEffect(EffectType type, int durationTicks, int amplifier) {
this.type = type;
this.durationTicks = Math.max(1, durationTicks);
this.amplifier = Math.max(0, Math.min(10, amplifier));
}
/**
* Creates a copy of this effect.
*/
public AbilityEffect copy() {
return new AbilityEffect(type, durationTicks, amplifier);
}
/**
* Applies this effect to the given entity.
* Does nothing if type is NONE.
*/
public void apply(EntityLivingBase entity) {
if (entity == null || type == EffectType.NONE) {
return;
}
int potionId = type.getPotionId();
if (potionId >= 0) {
entity.addPotionEffect(new PotionEffect(potionId, durationTicks, amplifier));
}
}
/**
* Writes this effect to NBT.
*/
public NBTTagCompound writeNBT() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("type", type.ordinal());
nbt.setInteger("duration", durationTicks);
nbt.setInteger("amplifier", amplifier);
return nbt;
}
/**
* Reads this effect from NBT.
*/
public void readNBT(NBTTagCompound nbt) {
this.type = EffectType.fromOrdinal(nbt.getInteger("type"));
this.durationTicks = nbt.hasKey("duration") ? nbt.getInteger("duration") : 60;
this.amplifier = nbt.hasKey("amplifier") ? nbt.getInteger("amplifier") : 0;
}
/**
* Creates an AbilityEffect from NBT.
*/
public static AbilityEffect fromNBT(NBTTagCompound nbt) {
AbilityEffect effect = new AbilityEffect();
effect.readNBT(nbt);
return effect;
}
// Getters & Setters
public EffectType getType() {
return type;
}
public void setType(EffectType type) {
this.type = type != null ? type : EffectType.NONE;
}
public int getDurationTicks() {
return durationTicks;
}
public void setDurationTicks(int durationTicks) {
this.durationTicks = Math.max(1, durationTicks);
}
public int getAmplifier() {
return amplifier;
}
public void setAmplifier(int amplifier) {
this.amplifier = Math.max(0, Math.min(10, amplifier));
}
/**
* Returns true if this effect is configured (not NONE).
*/
public boolean isValid() {
return type != EffectType.NONE;
}
}
@@ -4,5 +4,5 @@ public enum AbilityPhase {
IDLE, // Not executing
WINDUP, // Charging up (telegraph visible)
ACTIVE, // Executing (damage happens)
RECOVERY // Finishing animation
DAZED // Stunned after interrupt during WINDUP (cannot attack)
}
@@ -0,0 +1,55 @@
package kamkeel.npcs.controllers.data.ability;
/**
* Defines anchor points for ability charging effects.
* Determines where the charging visual (orb, disc, etc.) appears relative to the entity.
*/
public enum AnchorPoint {
FRONT(0, "Front"), // In front of entity face (default)
CENTER(1, "Center"), // Entity center
RIGHT_HAND(2, "Right Hand"), // Right arm/hand position
LEFT_HAND(3, "Left Hand"), // Left arm/hand position
ABOVE_HEAD(4, "Above Head"), // Above the entity
CHEST(5, "Chest"); // Chest level, centered
private final int id;
private final String displayName;
AnchorPoint(int id, String displayName) {
this.id = id;
this.displayName = displayName;
}
public int getId() {
return id;
}
public String getDisplayName() {
return displayName;
}
/**
* Get AnchorPoint from NBT id value.
* Returns FRONT if id is invalid.
*/
public static AnchorPoint fromId(int id) {
for (AnchorPoint anchor : values()) {
if (anchor.id == id) {
return anchor;
}
}
return FRONT;
}
/**
* Get all display names for GUI dropdowns.
*/
public static String[] getDisplayNames() {
AnchorPoint[] values = values();
String[] names = new String[values.length];
for (int i = 0; i < values.length; i++) {
names[i] = values[i].displayName;
}
return names;
}
}
@@ -46,10 +46,8 @@ public class AbilityCharge extends Ability {
this.maxRange = 20.0f;
this.minRange = 4.0f;
this.lockMovement = false; // Movement IS the ability
this.cooldownTicks = 80;
this.cooldownTicks = 0;
this.windUpTicks = 20;
this.activeTicks = 40;
this.recoveryTicks = 10;
// LINE telegraph showing charge path
this.telegraphType = TelegraphType.LINE;
this.showTelegraph = true;
@@ -161,11 +159,13 @@ public class AbilityCharge extends Ability {
npc.motionX = 0;
npc.motionZ = 0;
npc.velocityChanged = true;
signalCompletion();
return;
}
if (isChargeBlocked(npc)) {
stopMomentum(npc);
signalCompletion();
return;
}
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@@ -40,10 +38,8 @@ public class AbilityCutter extends Ability {
private SweepMode sweepMode = SweepMode.SWIPE;
private float sweepSpeed = 6.0f;
private int spinDurationTicks = 60; // Duration for SPIN mode
private int stunDuration = 0;
private int poisonDurationSeconds = 0;
private int poisonLevel = 0;
private boolean piercing = true;
private float innerRadius = 0.0f;
@@ -57,10 +53,8 @@ public class AbilityCutter extends Ability {
this.targetingMode = TargetingMode.AOE_SELF;
this.maxRange = 8.0f;
this.lockMovement = true;
this.cooldownTicks = 80;
this.cooldownTicks = 0;
this.windUpTicks = 20;
this.activeTicks = 15;
this.recoveryTicks = 15;
this.telegraphType = TelegraphType.CONE;
this.windUpSound = "random.bow";
this.activeSound = "random.break";
@@ -115,6 +109,7 @@ public class AbilityCutter extends Ability {
switch (sweepMode) {
case SWIPE:
if (currentRotation > arcAngle / 2.0f) {
signalCompletion(); // Swipe arc complete
return;
}
performSweepDamage(npc, world, innerRadius, range, currentRotation);
@@ -122,6 +117,10 @@ public class AbilityCutter extends Ability {
break;
case SPIN:
if (tick >= spinDurationTicks) {
signalCompletion(); // Spin duration complete
return;
}
currentRotation = (currentRotation + sweepSpeed) % 360.0f;
hitEntities.clear();
performSweepDamage(npc, world, innerRadius, range, currentRotation);
@@ -161,15 +160,9 @@ public class AbilityCutter extends Ability {
// Apply damage with scripted event support
boolean wasHit = applyAbilityDamage(npc, entity, actualDamage, knockback);
// Only apply effects if hit wasn't cancelled
// Apply effects if hit wasn't cancelled
if (wasHit) {
if (stunDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
}
if (poisonDurationSeconds > 0) {
entity.addPotionEffect(new PotionEffect(Potion.poison.id, poisonDurationSeconds * 20, poisonLevel));
}
applyEffects(entity);
}
}
}
@@ -206,9 +199,7 @@ public class AbilityCutter extends Ability {
nbt.setFloat("knockback", knockback);
nbt.setString("sweepMode", sweepMode.name());
nbt.setFloat("sweepSpeed", sweepSpeed);
nbt.setInteger("stunDuration", stunDuration);
nbt.setInteger("poisonDurationSeconds", poisonDurationSeconds);
nbt.setInteger("poisonLevel", poisonLevel);
nbt.setInteger("spinDurationTicks", spinDurationTicks);
nbt.setBoolean("piercing", piercing);
nbt.setFloat("innerRadius", innerRadius);
}
@@ -225,9 +216,7 @@ public class AbilityCutter extends Ability {
this.sweepMode = SweepMode.SWIPE;
}
this.sweepSpeed = nbt.hasKey("sweepSpeed") ? nbt.getFloat("sweepSpeed") : 6.0f;
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
this.poisonDurationSeconds = nbt.hasKey("poisonDurationSeconds") ? nbt.getInteger("poisonDurationSeconds") : 0;
this.poisonLevel = nbt.hasKey("poisonLevel") ? nbt.getInteger("poisonLevel") : 0;
this.spinDurationTicks = nbt.hasKey("spinDurationTicks") ? nbt.getInteger("spinDurationTicks") : 60;
this.piercing = !nbt.hasKey("piercing") || nbt.getBoolean("piercing");
this.innerRadius = nbt.hasKey("innerRadius") ? nbt.getFloat("innerRadius") : 0.0f;
}
@@ -281,28 +270,12 @@ public class AbilityCutter extends Ability {
this.sweepSpeed = sweepSpeed;
}
public int getStunDuration() {
return stunDuration;
public int getSpinDurationTicks() {
return spinDurationTicks;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getPoisonDurationSeconds() {
return poisonDurationSeconds;
}
public void setPoisonDurationSeconds(int poisonDurationSeconds) {
this.poisonDurationSeconds = poisonDurationSeconds;
}
public int getPoisonLevel() {
return poisonLevel;
}
public void setPoisonLevel(int poisonLevel) {
this.poisonLevel = poisonLevel;
public void setSpinDurationTicks(int spinDurationTicks) {
this.spinDurationTicks = Math.max(1, spinDurationTicks);
}
public boolean isPiercing() {
@@ -87,10 +87,8 @@ public class AbilityDash extends Ability {
this.maxRange = 20.0f;
this.minRange = 0.0f;
this.lockMovement = false;
this.cooldownTicks = 40;
this.cooldownTicks = 0;
this.windUpTicks = 5;
this.activeTicks = 8;
this.recoveryTicks = 10;
// No telegraph for dash - it's a quick evasive move
this.telegraphType = TelegraphType.NONE;
this.showTelegraph = false;
@@ -174,6 +172,7 @@ public class AbilityDash extends Ability {
npc.motionX = 0;
npc.motionZ = 0;
npc.velocityChanged = true;
signalCompletion();
return;
}
@@ -181,6 +180,7 @@ public class AbilityDash extends Ability {
npc.motionX = 0;
npc.motionZ = 0;
npc.velocityChanged = true;
signalCompletion();
return;
}
@@ -199,8 +199,6 @@ public class AbilityDash extends Ability {
npc.motionX = 0;
npc.motionZ = 0;
npc.velocityChanged = true;
dashDirection = null;
chosenDirection = null;
}
@Override
@@ -208,23 +206,21 @@ public class AbilityDash extends Ability {
npc.motionX = 0;
npc.motionZ = 0;
npc.velocityChanged = true;
}
@Override
public void cleanup() {
dashDirection = null;
chosenDirection = null;
}
private boolean isDashBlocked(EntityNPCInterface npc) {
if (dashDirection == null) return true;
double nextX = dashDirection.xCoord * dashSpeed;
double nextZ = dashDirection.zCoord * dashSpeed;
return !npc.worldObj.getCollidingBoundingBoxes(npc, npc.boundingBox.copy().offset(nextX, 0, nextZ)).isEmpty();
}
@Override
public void reset() {
super.reset();
dashDirection = null;
chosenDirection = null;
}
@Override
public float getTelegraphRadius() {
return 0; // No telegraph for dash
@@ -3,11 +3,13 @@ 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.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityAbilityDisc;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
@@ -28,7 +30,7 @@ public class AbilityDisc extends Ability {
private float discRadius = 1.0f;
private float discThickness = 0.2f;
private float maxDistance = 35.0f;
private int maxLifetime = 250;
private int maxLifetime = 200;
// Combat properties
private float damage = 8.0f;
@@ -57,20 +59,29 @@ public class AbilityDisc extends Ability {
// Visual properties
private int innerColor = 0xFFFFFF;
private int outerColor = 0xFF8800;
private float outerColorWidth = 1.8f;
private float outerColorWidth = 0.4f; // Additive offset from inner size
private boolean outerColorEnabled = true;
private float rotationSpeed = 5.0f;
// Lightning effect properties
private boolean lightningEffect = false;
private float lightningDensity = 0.15f;
private float lightningRadius = 0.5f;
// Anchor point for charging position
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
// Transient state for disc entity (used during windup charging)
private transient EntityAbilityDisc discEntity = null;
public AbilityDisc() {
this.typeId = "ability.cnpc.disc";
this.name = "Disc";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 30.0f;
this.minRange = 5.0f;
this.cooldownTicks = 80;
this.cooldownTicks = 0;
this.windUpTicks = 20;
this.activeTicks = 1;
this.recoveryTicks = 10;
this.telegraphType = TelegraphType.CIRCLE;
this.showTelegraph = true;
}
@@ -98,25 +109,44 @@ public class AbilityDisc extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (world.isRemote) {
signalCompletion();
return;
}
// Start moving the disc that was spawned during windup
if (discEntity != null && !discEntity.isDead) {
discEntity.startMoving(target);
}
discEntity = null;
// Disc entity manages itself - ability is done
signalCompletion();
}
@Override
public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (world.isRemote) return;
double spawnX = npc.posX;
double spawnY = npc.posY + npc.getEyeHeight() * 0.8;
double spawnZ = npc.posZ;
// Spawn disc in charging mode on first tick of windup
if (tick == 1) {
// 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,
damage, knockback, knockbackUp,
speed, homing, homingStrength, homingRange,
boomerang, boomerangDelay,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius,
anchorPoint, // Anchor point for charging position
windUpTicks // Charge duration = windup duration
);
EntityAbilityDisc disc = new EntityAbilityDisc(
world, npc, target,
spawnX, spawnY, spawnZ,
discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp,
speed, homing, homingStrength, homingRange,
boomerang, boomerangDelay,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime
);
world.spawnEntityInWorld(disc);
world.spawnEntityInWorld(discEntity);
}
}
@Override
@@ -128,7 +158,12 @@ public class AbilityDisc extends Ability {
}
@Override
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
public void cleanup() {
// Despawn disc entity if still alive
if (discEntity != null && !discEntity.isDead) {
discEntity.setDead();
}
discEntity = null;
}
@Override
@@ -184,6 +219,10 @@ public class AbilityDisc extends Ability {
nbt.setFloat("outerColorWidth", outerColorWidth);
nbt.setBoolean("outerColorEnabled", outerColorEnabled);
nbt.setFloat("rotationSpeed", rotationSpeed);
nbt.setBoolean("lightningEffect", lightningEffect);
nbt.setFloat("lightningDensity", lightningDensity);
nbt.setFloat("lightningRadius", lightningRadius);
nbt.setInteger("anchorPoint", anchorPoint.getId());
}
@Override
@@ -192,7 +231,7 @@ public class AbilityDisc extends Ability {
this.discRadius = nbt.hasKey("discRadius") ? nbt.getFloat("discRadius") : 1.0f;
this.discThickness = nbt.hasKey("discThickness") ? nbt.getFloat("discThickness") : 0.2f;
this.maxDistance = nbt.hasKey("maxDistance") ? nbt.getFloat("maxDistance") : 35.0f;
this.maxLifetime = nbt.hasKey("maxLifetime") ? nbt.getInteger("maxLifetime") : 250;
this.maxLifetime = nbt.hasKey("maxLifetime") ? nbt.getInteger("maxLifetime") : 200;
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 1.2f;
this.knockbackUp = nbt.hasKey("knockbackUp") ? nbt.getFloat("knockbackUp") : 0.15f;
@@ -209,9 +248,13 @@ public class AbilityDisc extends Ability {
this.slowLevel = nbt.hasKey("slowLevel") ? nbt.getInteger("slowLevel") : 0;
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") : 1.8f;
this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f;
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");
this.lightningDensity = nbt.hasKey("lightningDensity") ? nbt.getFloat("lightningDensity") : 0.15f;
this.lightningRadius = nbt.hasKey("lightningRadius") ? nbt.getFloat("lightningRadius") : 0.5f;
this.anchorPoint = nbt.hasKey("anchorPoint") ? AnchorPoint.fromId(nbt.getInteger("anchorPoint")) : AnchorPoint.FRONT;
}
// Getters & Setters
@@ -263,4 +306,12 @@ public class AbilityDisc extends Ability {
public void setOuterColorEnabled(boolean outerColorEnabled) { this.outerColorEnabled = outerColorEnabled; }
public float getRotationSpeed() { return rotationSpeed; }
public void setRotationSpeed(float rotationSpeed) { this.rotationSpeed = rotationSpeed; }
public boolean hasLightningEffect() { return lightningEffect; }
public void setLightningEffect(boolean lightningEffect) { this.lightningEffect = lightningEffect; }
public float getLightningDensity() { return lightningDensity; }
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; }
}
@@ -3,11 +3,13 @@ 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.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityAbilityBeam;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
@@ -56,20 +58,29 @@ public class AbilityEnergyBeam extends Ability {
// Visual properties
private int innerColor = 0xFFFFFF;
private int outerColor = 0x00AAFF;
private float outerColorWidth = 1.8f;
private float outerColorWidth = 0.4f; // Additive offset from inner size
private boolean outerColorEnabled = true;
private float rotationSpeed = 6.0f;
// Lightning effect properties (only on head)
private boolean lightningEffect = false;
private float lightningDensity = 0.15f;
private float lightningRadius = 0.5f;
// Anchor point for charging position
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
// Transient state for beam entity (used during windup charging)
private transient EntityAbilityBeam beamEntity = null;
public AbilityEnergyBeam() {
this.typeId = "ability.cnpc.beam";
this.name = "Beam";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 20.0f;
this.minRange = 5.0f;
this.cooldownTicks = 150;
this.cooldownTicks = 0;
this.windUpTicks = 40;
this.activeTicks = 200; // Match maxLifetime to keep NPC locked while beam is active
this.recoveryTicks = 5;
this.telegraphType = TelegraphType.CIRCLE;
this.showTelegraph = true;
}
@@ -97,24 +108,47 @@ public class AbilityEnergyBeam extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (world.isRemote) {
signalCompletion();
return;
}
// Start firing the beam that was spawned during windup
if (beamEntity != null && !beamEntity.isDead) {
beamEntity.startFiring(target);
}
beamEntity = null;
// Beam entity manages itself - ability is done
signalCompletion();
}
@Override
public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (world.isRemote) return;
double spawnX = npc.posX;
double spawnY = npc.posY + npc.getEyeHeight() * 0.7;
double spawnZ = npc.posZ;
// Spawn beam in charging mode on first tick of windup
if (tick == 1) {
float offsetDist = 1.0f;
EntityAbilityBeam beam = new EntityAbilityBeam(
world, npc, target,
spawnX, spawnY, spawnZ,
beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp,
speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime
);
// 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,
damage, knockback, knockbackUp,
speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius,
lockMovement, // Anchored mode
windUpTicks, // Charge duration = windup duration
offsetDist, // Offset distance (used by FRONT anchor)
anchorPoint // Anchor point for charging position
);
world.spawnEntityInWorld(beam);
world.spawnEntityInWorld(beamEntity);
}
}
@Override
@@ -126,7 +160,12 @@ public class AbilityEnergyBeam extends Ability {
}
@Override
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
public void cleanup() {
// Despawn beam entity if still alive
if (beamEntity != null && !beamEntity.isDead) {
beamEntity.setDead();
}
beamEntity = null;
}
@Override
@@ -180,6 +219,10 @@ public class AbilityEnergyBeam extends Ability {
nbt.setFloat("outerColorWidth", outerColorWidth);
nbt.setBoolean("outerColorEnabled", outerColorEnabled);
nbt.setFloat("rotationSpeed", rotationSpeed);
nbt.setBoolean("lightningEffect", lightningEffect);
nbt.setFloat("lightningDensity", lightningDensity);
nbt.setFloat("lightningRadius", lightningRadius);
nbt.setInteger("anchorPoint", anchorPoint.getId());
}
@Override
@@ -203,9 +246,13 @@ public class AbilityEnergyBeam extends Ability {
this.slowLevel = nbt.hasKey("slowLevel") ? nbt.getInteger("slowLevel") : 0;
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") : 1.8f;
this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f;
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");
this.lightningDensity = nbt.hasKey("lightningDensity") ? nbt.getFloat("lightningDensity") : 0.15f;
this.lightningRadius = nbt.hasKey("lightningRadius") ? nbt.getFloat("lightningRadius") : 0.5f;
this.anchorPoint = nbt.hasKey("anchorPoint") ? AnchorPoint.fromId(nbt.getInteger("anchorPoint")) : AnchorPoint.FRONT;
}
// Getters & Setters
@@ -253,4 +300,12 @@ public class AbilityEnergyBeam extends Ability {
public void setOuterColorEnabled(boolean outerColorEnabled) { this.outerColorEnabled = outerColorEnabled; }
public float getRotationSpeed() { return rotationSpeed; }
public void setRotationSpeed(float rotationSpeed) { this.rotationSpeed = rotationSpeed; }
public boolean hasLightningEffect() { return lightningEffect; }
public void setLightningEffect(boolean lightningEffect) { this.lightningEffect = lightningEffect; }
public float getLightningDensity() { return lightningDensity; }
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; }
}
@@ -25,6 +25,7 @@ public class AbilityGuard extends Ability {
private static final Random RANDOM = new Random();
// Type-specific parameters
private int durationTicks = 60;
private float damageReduction = 0.5f;
private boolean canCounter = false;
private CounterType counterType = CounterType.FLAT;
@@ -48,10 +49,8 @@ public class AbilityGuard extends Ability {
this.name = "Guard";
this.targetingMode = TargetingMode.SELF;
this.lockMovement = true;
this.cooldownTicks = 120;
this.cooldownTicks = 0;
this.windUpTicks = 10;
this.activeTicks = 60;
this.recoveryTicks = 10;
this.interruptible = false; // Hard to interrupt while guarding
// No telegraph for guard - it's a defensive stance
this.telegraphType = TelegraphType.NONE;
@@ -95,6 +94,11 @@ public class AbilityGuard extends Ability {
if (canCounter && counterTriggered && lastAttacker != null && !world.isRemote) {
performCounter(npc, world);
}
// Check if guard duration has ended
if (tick >= durationTicks) {
signalCompletion();
}
}
/**
@@ -112,11 +116,7 @@ public class AbilityGuard extends Ability {
lastAttacker = attacker;
lastDamageTaken = damage;
counterTriggered = true;
if (interruptible) {
performCounter(npc, npc.worldObj);
npc.abilities.interruptCurrentAbility(source, damage);
}
// Counter will be performed in onActiveTick - don't self-interrupt
}
private void performCounter(EntityNPCInterface npc, World world) {
@@ -175,6 +175,7 @@ public class AbilityGuard extends Ability {
@Override
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setInteger("durationTicks", durationTicks);
nbt.setFloat("damageReduction", damageReduction);
nbt.setBoolean("canCounter", canCounter);
nbt.setString("counterType", counterType.name());
@@ -186,6 +187,7 @@ public class AbilityGuard extends Ability {
@Override
public void readTypeNBT(NBTTagCompound nbt) {
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 60;
this.damageReduction = nbt.hasKey("damageReduction") ? nbt.getFloat("damageReduction") : 0.5f;
this.canCounter = nbt.hasKey("canCounter") && nbt.getBoolean("canCounter");
try {
@@ -206,6 +208,14 @@ public class AbilityGuard extends Ability {
}
// Getters & Setters
public int getDurationTicks() {
return durationTicks;
}
public void setDurationTicks(int durationTicks) {
this.durationTicks = Math.max(1, durationTicks);
}
public float getDamageReduction() {
return damageReduction;
}
@@ -42,6 +42,7 @@ public class AbilityHazard extends Ability {
FOLLOW_TARGET
}
private int durationTicks = 100;
private float radius = 4.0f;
private float innerRadius = 0.0f;
private float coneAngle = 45.0f;
@@ -81,10 +82,8 @@ public class AbilityHazard extends Ability {
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 15.0f;
this.lockMovement = true;
this.cooldownTicks = 200;
this.cooldownTicks = 0;
this.windUpTicks = 30;
this.activeTicks = 100;
this.recoveryTicks = 10;
this.telegraphType = TelegraphType.CIRCLE;
}
@@ -232,6 +231,12 @@ public class AbilityHazard extends Ability {
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (world.isRemote) return;
// Check if hazard duration has ended
if (tick >= durationTicks) {
signalCompletion();
return;
}
damagedThisTick.clear();
ticksSinceDamage++;
@@ -342,6 +347,7 @@ public class AbilityHazard extends Ability {
@Override
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setInteger("durationTicks", durationTicks);
nbt.setFloat("radius", radius);
nbt.setFloat("innerRadius", innerRadius);
nbt.setFloat("coneAngle", coneAngle);
@@ -366,6 +372,7 @@ public class AbilityHazard extends Ability {
@Override
public void readTypeNBT(NBTTagCompound nbt) {
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 100;
this.radius = nbt.hasKey("radius") ? nbt.getFloat("radius") : 4.0f;
this.innerRadius = nbt.hasKey("innerRadius") ? nbt.getFloat("innerRadius") : 0.0f;
this.coneAngle = nbt.hasKey("coneAngle") ? nbt.getFloat("coneAngle") : 45.0f;
@@ -404,6 +411,14 @@ public class AbilityHazard extends Ability {
}
// Getters & Setters
public int getDurationTicks() {
return durationTicks;
}
public void setDurationTicks(int durationTicks) {
this.durationTicks = Math.max(1, durationTicks);
}
public float getRadius() {
return radius;
}
@@ -25,6 +25,7 @@ import java.util.List;
public class AbilityHeal extends Ability {
// Type-specific parameters
private int durationTicks = 60;
private float healAmount = 10.0f;
private float healPercent = 0.0f;
private boolean healSelf = true;
@@ -33,17 +34,22 @@ public class AbilityHeal extends Ability {
private boolean instantHeal = true;
// Runtime state
private transient List<EntityLivingBase> healedAllies = new ArrayList<>();
private transient List<EntityLivingBase> healedAllies;
private List<EntityLivingBase> getHealedAllies() {
if (healedAllies == null) {
healedAllies = new ArrayList<>();
}
return healedAllies;
}
public AbilityHeal() {
this.typeId = "ability.cnpc.heal";
this.name = "Heal";
this.targetingMode = TargetingMode.SELF;
this.lockMovement = true;
this.cooldownTicks = 200;
this.cooldownTicks = 0;
this.windUpTicks = 30;
this.activeTicks = 10;
this.recoveryTicks = 10;
// No telegraph for heal - it's a self/ally buff
this.telegraphType = TelegraphType.NONE;
this.showTelegraph = false;
@@ -74,7 +80,7 @@ public class AbilityHeal extends Ability {
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (world.isRemote) return;
healedAllies.clear();
getHealedAllies().clear();
// Always find allies if we're healing them (needed for both instant and HoT)
if (healAllies && healRadius > 0) {
@@ -88,10 +94,13 @@ public class AbilityHeal extends Ability {
spawnHealParticles(world, npc);
}
for (EntityLivingBase ally : healedAllies) {
for (EntityLivingBase ally : getHealedAllies()) {
healEntity(ally);
spawnHealParticles(world, ally);
}
// Instant heal completes immediately
signalCompletion();
}
// If not instant, HoT healing is applied in onActiveTick
}
@@ -100,16 +109,16 @@ public class AbilityHeal extends Ability {
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (world.isRemote || instantHeal) return;
// Heal over time - distribute heal across active ticks
// Heal over time - distribute heal across duration ticks
if (tick % 10 == 0) {
// Calculate tick-based heal for fixed amount
float tickHeal = (healAmount / (float) activeTicks) * 10;
float tickHeal = (healAmount / (float) durationTicks) * 10;
if (healSelf) {
float selfTickHeal = tickHeal;
// Add percentage-based heal portion
if (healPercent > 0) {
selfTickHeal += (npc.getMaxHealth() * healPercent / (float) activeTicks) * 10;
selfTickHeal += (npc.getMaxHealth() * healPercent / (float) durationTicks) * 10;
}
npc.heal(selfTickHeal);
if (tick % 20 == 0) {
@@ -118,12 +127,12 @@ public class AbilityHeal extends Ability {
}
if (healAllies && healRadius > 0) {
for (EntityLivingBase ally : healedAllies) {
for (EntityLivingBase ally : getHealedAllies()) {
if (!ally.isDead) {
float allyTickHeal = tickHeal;
// Add percentage-based heal portion for each ally
if (healPercent > 0) {
allyTickHeal += (ally.getMaxHealth() * healPercent / (float) activeTicks) * 10;
allyTickHeal += (ally.getMaxHealth() * healPercent / (float) durationTicks) * 10;
}
ally.heal(allyTickHeal);
if (tick % 20 == 0) {
@@ -133,6 +142,11 @@ public class AbilityHeal extends Ability {
}
}
}
// Check if heal duration has ended
if (tick >= durationTicks) {
signalCompletion();
}
}
/**
@@ -157,7 +171,7 @@ public class AbilityHeal extends Ability {
if (living instanceof EntityNPCInterface) {
float dist = npc.getDistanceToEntity(living);
if (dist <= healRadius) {
healedAllies.add(living);
getHealedAllies().add(living);
}
}
}
@@ -185,14 +199,8 @@ public class AbilityHeal extends Ability {
}
@Override
public void onInterrupt(EntityNPCInterface npc, net.minecraft.util.DamageSource source, float damage) {
healedAllies.clear();
}
@Override
public void reset() {
super.reset();
healedAllies.clear();
public void cleanup() {
getHealedAllies().clear();
}
@Override
@@ -202,6 +210,7 @@ public class AbilityHeal extends Ability {
@Override
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setInteger("durationTicks", durationTicks);
nbt.setFloat("healAmount", healAmount);
nbt.setFloat("healPercent", healPercent);
nbt.setBoolean("healSelf", healSelf);
@@ -212,6 +221,7 @@ public class AbilityHeal extends Ability {
@Override
public void readTypeNBT(NBTTagCompound nbt) {
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 60;
this.healAmount = nbt.hasKey("healAmount") ? nbt.getFloat("healAmount") : 10.0f;
this.healPercent = nbt.hasKey("healPercent") ? nbt.getFloat("healPercent") : 0.0f;
this.healSelf = !nbt.hasKey("healSelf") || nbt.getBoolean("healSelf");
@@ -221,6 +231,14 @@ public class AbilityHeal extends Ability {
}
// Getters & Setters
public int getDurationTicks() {
return durationTicks;
}
public void setDurationTicks(int durationTicks) {
this.durationTicks = Math.max(1, durationTicks);
}
public float getHealAmount() {
return healAmount;
}
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit;
@@ -23,9 +21,6 @@ public class AbilityHeavyHit extends Ability {
private float damage = 8.0f;
private float knockback = 2.0f;
private int slownessLevel = 1;
private int weaknessLevel = 0;
private int potionDurationSeconds = 2;
public AbilityHeavyHit() {
this.typeId = "ability.cnpc.heavy_hit";
@@ -34,10 +29,8 @@ public class AbilityHeavyHit extends Ability {
this.maxRange = 3.0f;
this.minRange = 0.0f;
this.lockMovement = true;
this.cooldownTicks = 80;
this.cooldownTicks = 0;
this.windUpTicks = 30;
this.activeTicks = 5;
this.recoveryTicks = 10;
this.telegraphType = TelegraphType.POINT;
this.showTelegraph = false;
this.windUpSound = "random.anvil_use";
@@ -68,20 +61,21 @@ public class AbilityHeavyHit extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (world.isRemote || target == null) return;
if (world.isRemote || target == null) {
signalCompletion();
return;
}
// Apply damage with scripted event support
boolean wasHit = applyAbilityDamage(npc, target, damage, knockback);
if (wasHit && potionDurationSeconds > 0) {
int durationTicks = potionDurationSeconds * 20;
if (slownessLevel >= 0) {
target.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, durationTicks, slownessLevel));
}
if (weaknessLevel >= 0) {
target.addPotionEffect(new PotionEffect(Potion.weakness.id, durationTicks, weaknessLevel));
}
// Apply effects if hit wasn't cancelled
if (wasHit) {
applyEffects(target);
}
// Heavy Hit is instant
signalCompletion();
}
@Override
@@ -93,18 +87,12 @@ public class AbilityHeavyHit extends Ability {
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setFloat("damage", damage);
nbt.setFloat("knockback", knockback);
nbt.setInteger("slownessLevel", slownessLevel);
nbt.setInteger("weaknessLevel", weaknessLevel);
nbt.setInteger("potionDurationSeconds", potionDurationSeconds);
}
@Override
public void readTypeNBT(NBTTagCompound nbt) {
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 2.0f;
this.slownessLevel = nbt.hasKey("slownessLevel") ? nbt.getInteger("slownessLevel") : 1;
this.weaknessLevel = nbt.hasKey("weaknessLevel") ? nbt.getInteger("weaknessLevel") : 0;
this.potionDurationSeconds = nbt.hasKey("potionDurationSeconds") ? nbt.getInteger("potionDurationSeconds") : 2;
}
// Getters & Setters
@@ -123,28 +111,4 @@ public class AbilityHeavyHit extends Ability {
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public int getSlownessLevel() {
return slownessLevel;
}
public void setSlownessLevel(int slownessLevel) {
this.slownessLevel = slownessLevel;
}
public int getWeaknessLevel() {
return weaknessLevel;
}
public void setWeaknessLevel(int weaknessLevel) {
this.weaknessLevel = weaknessLevel;
}
public int getPotionDurationSeconds() {
return potionDurationSeconds;
}
public void setPotionDurationSeconds(int potionDurationSeconds) {
this.potionDurationSeconds = potionDurationSeconds;
}
}
@@ -46,19 +46,22 @@ public class AbilityLaserShot extends Ability {
// Visual properties
private int innerColor = 0xFFFFFF;
private int outerColor = 0xFF0000;
private float outerColorWidth = 1.8f;
private float outerColorWidth = 0.4f; // Additive offset from inner width
private boolean outerColorEnabled = true;
// Lightning effect properties
private boolean lightningEffect = false;
private float lightningDensity = 0.15f;
private float lightningRadius = 0.5f;
public AbilityLaserShot() {
this.typeId = "ability.cnpc.laser_shot";
this.name = "Laser Shot";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 35.0f;
this.minRange = 3.0f;
this.cooldownTicks = 60;
this.cooldownTicks = 0;
this.windUpTicks = 15;
this.activeTicks = 1;
this.recoveryTicks = 5;
this.telegraphType = TelegraphType.LINE;
this.showTelegraph = true;
}
@@ -96,7 +99,10 @@ public class AbilityLaserShot extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (world.isRemote) return;
if (world.isRemote) {
signalCompletion();
return;
}
double spawnX = npc.posX;
double spawnY = npc.posY + npc.getEyeHeight() * 0.8;
@@ -110,14 +116,19 @@ public class AbilityLaserShot extends Ability {
expansionSpeed, lingerTicks,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius
);
world.spawnEntityInWorld(laser);
// Laser entity manages itself - ability is done
signalCompletion();
}
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// Laser entity manages itself
}
@Override
@@ -148,6 +159,9 @@ public class AbilityLaserShot extends Ability {
nbt.setInteger("outerColor", outerColor);
nbt.setFloat("outerColorWidth", outerColorWidth);
nbt.setBoolean("outerColorEnabled", outerColorEnabled);
nbt.setBoolean("lightningEffect", lightningEffect);
nbt.setFloat("lightningDensity", lightningDensity);
nbt.setFloat("lightningRadius", lightningRadius);
}
@Override
@@ -168,8 +182,11 @@ public class AbilityLaserShot extends Ability {
this.slowLevel = nbt.hasKey("slowLevel") ? nbt.getInteger("slowLevel") : 0;
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") : 1.8f;
this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f;
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;
this.lightningRadius = nbt.hasKey("lightningRadius") ? nbt.getFloat("lightningRadius") : 0.5f;
}
// Getters & Setters
@@ -209,4 +226,10 @@ public class AbilityLaserShot extends Ability {
public void setOuterColorWidth(float outerColorWidth) { this.outerColorWidth = outerColorWidth; }
public boolean isOuterColorEnabled() { return outerColorEnabled; }
public void setOuterColorEnabled(boolean outerColorEnabled) { this.outerColorEnabled = outerColorEnabled; }
public boolean hasLightningEffect() { return lightningEffect; }
public void setLightningEffect(boolean lightningEffect) { this.lightningEffect = lightningEffect; }
public float getLightningDensity() { return lightningDensity; }
public void setLightningDensity(float lightningDensity) { this.lightningDensity = lightningDensity; }
public float getLightningRadius() { return lightningRadius; }
public void setLightningRadius(float lightningRadius) { this.lightningRadius = lightningRadius; }
}
@@ -3,11 +3,13 @@ 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.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityAbilityOrb;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
@@ -53,20 +55,30 @@ public class AbilityOrb extends Ability {
// Visual properties
private int innerColor = 0xFFFFFF; // White core
private int outerColor = 0x8888FF; // Light blue glow
private float outerColorWidth = 1.8f; // Multiplier for outer glow size
private float outerColorWidth = 0.4f; // Additive offset from inner size
private boolean outerColorEnabled = true; // Whether to render outer glow
private float rotationSpeed = 4.0f; // Degrees per tick
// Lightning effect properties
private boolean lightningEffect = false;
private float lightningDensity = 0.15f; // Bolts spawned per tick (0.15 = ~15% chance per frame)
private float lightningRadius = 0.5f; // Max distance lightning arcs - scales with orbSize
private int lightningFadeTime = 6; // Ticks before lightning fades out
// Anchor point for charging position
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
// Transient state for orb entity (used during windup charging)
private transient EntityAbilityOrb orbEntity = null;
public AbilityOrb() {
this.typeId = "ability.cnpc.orb";
this.name = "Orb";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 25.0f;
this.minRange = 5.0f;
this.cooldownTicks = 100;
this.cooldownTicks = 0;
this.windUpTicks = 30;
this.activeTicks = 1; // Minimal - just spawn and done
this.recoveryTicks = 10;
this.telegraphType = TelegraphType.CIRCLE;
this.showTelegraph = true;
}
@@ -94,26 +106,43 @@ public class AbilityOrb extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (world.isRemote) {
signalCompletion();
return;
}
// Start moving the orb that was spawned during windup
if (orbEntity != null && !orbEntity.isDead) {
orbEntity.startMoving(target);
}
orbEntity = null;
// Orb entity manages itself - ability is done
signalCompletion();
}
@Override
public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (world.isRemote) return;
// Spawn position at NPC's eye level
double spawnX = npc.posX;
double spawnY = npc.posY + npc.getEyeHeight() * 0.8;
double spawnZ = npc.posZ;
// Spawn orb in charging mode on first tick of windup
if (tick == 1) {
// 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,
damage, knockback, knockbackUp,
orbSpeed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius, lightningFadeTime,
anchorPoint, // Anchor point for charging position
windUpTicks // Charge duration = windup duration
);
// Create and spawn the self-managing orb entity
EntityAbilityOrb orb = new EntityAbilityOrb(
world, npc, target,
spawnX, spawnY, spawnZ,
orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp,
orbSpeed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime
);
world.spawnEntityInWorld(orb);
world.spawnEntityInWorld(orbEntity);
}
}
@Override
@@ -127,8 +156,12 @@ public class AbilityOrb extends Ability {
}
@Override
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
// Nothing to clean up - entity manages itself
public void cleanup() {
// Despawn orb entity if still alive
if (orbEntity != null && !orbEntity.isDead) {
orbEntity.setDead();
}
orbEntity = null;
}
@Override
@@ -181,6 +214,11 @@ public class AbilityOrb extends Ability {
nbt.setFloat("outerColorWidth", outerColorWidth);
nbt.setBoolean("outerColorEnabled", outerColorEnabled);
nbt.setFloat("rotationSpeed", rotationSpeed);
nbt.setBoolean("lightningEffect", lightningEffect);
nbt.setFloat("lightningDensity", lightningDensity);
nbt.setFloat("lightningRadius", lightningRadius);
nbt.setInteger("lightningFadeTime", lightningFadeTime);
nbt.setInteger("anchorPoint", anchorPoint.getId());
}
@Override
@@ -203,9 +241,14 @@ public class AbilityOrb extends Ability {
this.slowLevel = nbt.hasKey("slowLevel") ? nbt.getInteger("slowLevel") : 0;
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") : 1.8f;
this.outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f;
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");
this.lightningDensity = nbt.hasKey("lightningDensity") ? nbt.getFloat("lightningDensity") : 0.15f;
this.lightningRadius = nbt.hasKey("lightningRadius") ? nbt.getFloat("lightningRadius") : 0.5f;
this.lightningFadeTime = nbt.hasKey("lightningFadeTime") ? nbt.getInteger("lightningFadeTime") : 6;
this.anchorPoint = nbt.hasKey("anchorPoint") ? AnchorPoint.fromId(nbt.getInteger("anchorPoint")) : AnchorPoint.FRONT;
}
// Getters & Setters
@@ -376,4 +419,44 @@ public class AbilityOrb extends Ability {
public void setRotationSpeed(float rotationSpeed) {
this.rotationSpeed = rotationSpeed;
}
public boolean hasLightningEffect() {
return lightningEffect;
}
public void setLightningEffect(boolean lightningEffect) {
this.lightningEffect = lightningEffect;
}
public float getLightningDensity() {
return lightningDensity;
}
public void setLightningDensity(float lightningDensity) {
this.lightningDensity = lightningDensity;
}
public float getLightningRadius() {
return lightningRadius;
}
public void setLightningRadius(float lightningRadius) {
this.lightningRadius = lightningRadius;
}
public int getLightningFadeTime() {
return lightningFadeTime;
}
public void setLightningFadeTime(int lightningFadeTime) {
this.lightningFadeTime = lightningFadeTime;
}
public AnchorPoint getAnchorPoint() {
return anchorPoint;
}
public void setAnchorPoint(AnchorPoint anchorPoint) {
this.anchorPoint = anchorPoint;
}
}
@@ -38,10 +38,8 @@ public class AbilityProjectile extends Ability {
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.minRange = 5.0f;
this.maxRange = 20.0f;
this.cooldownTicks = 60;
this.cooldownTicks = 0;
this.windUpTicks = 15;
this.activeTicks = 5;
this.recoveryTicks = 10;
// No telegraph for projectile - it's a ranged attack
this.telegraphType = TelegraphType.NONE;
this.showTelegraph = false;
@@ -122,6 +120,9 @@ public class AbilityProjectile extends Ability {
// Spawn projectile particles (visual trail)
spawnProjectileParticles(world, npc, target);
// Projectile is instant
signalCompletion();
}
private void spawnProjectileParticles(World world, EntityNPCInterface npc, EntityLivingBase target) {
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@@ -28,22 +26,16 @@ public class AbilityShockwave extends Ability {
private float pushRadius = 8.0f;
private float pushStrength = 1.5f;
private float damage = 8.0f;
private int stunDuration = 0;
private int maxTargets = 10;
// Runtime state
private transient boolean executed = false;
public AbilityShockwave() {
this.typeId = "ability.cnpc.shockwave";
this.name = "Shockwave";
this.targetingMode = TargetingMode.AOE_SELF;
this.maxRange = 15.0f;
this.lockMovement = true;
this.cooldownTicks = 100;
this.cooldownTicks = 0;
this.windUpTicks = 25;
this.activeTicks = 5;
this.recoveryTicks = 10;
this.telegraphType = TelegraphType.CIRCLE;
this.windUpSound = "random.explode";
this.activeSound = "random.explode";
@@ -77,13 +69,7 @@ public class AbilityShockwave extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
executed = false;
}
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (executed) return;
executed = true;
// Shockwave is instant - apply effect immediately after windup
// Get all entities in radius
AxisAlignedBB box = npc.boundingBox.expand(pushRadius, pushRadius / 2, pushRadius);
@@ -122,22 +108,19 @@ public class AbilityShockwave extends Ability {
// Apply damage with custom knockback direction
boolean wasHit = applyAbilityDamageWithDirection(npc, entity, damage * distFactor, finalPush, dx, dz);
// Apply stun if hit connected
if (wasHit && stunDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
// Apply effects if hit connected
if (wasHit) {
applyEffects(entity);
}
}
// Shockwave completes instantly
signalCompletion();
}
@Override
public void onComplete(EntityNPCInterface npc, EntityLivingBase target) {
executed = false;
}
@Override
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
executed = false;
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// Shockwave is instant - nothing to do per-tick
}
@Override
@@ -145,7 +128,6 @@ public class AbilityShockwave extends Ability {
nbt.setFloat("pushRadius", pushRadius);
nbt.setFloat("pushStrength", pushStrength);
nbt.setFloat("damage", damage);
nbt.setInteger("stunDuration", stunDuration);
nbt.setInteger("maxTargets", maxTargets);
}
@@ -154,7 +136,6 @@ public class AbilityShockwave extends Ability {
this.pushRadius = nbt.hasKey("pushRadius") ? nbt.getFloat("pushRadius") : 8.0f;
this.pushStrength = nbt.hasKey("pushStrength") ? nbt.getFloat("pushStrength") : 1.5f;
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
this.maxTargets = nbt.hasKey("maxTargets") ? nbt.getInteger("maxTargets") : 10;
}
@@ -183,14 +164,6 @@ public class AbilityShockwave extends Ability {
this.damage = damage;
}
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getMaxTargets() {
return maxTargets;
}
@@ -49,11 +49,8 @@ public class AbilitySlam extends Ability {
this.name = "Slam";
this.targetingMode = TargetingMode.AOE_SELF; // Can also be AOE_TARGET to leap to target
this.windUpTicks = 30;
this.activeTicks = 60; // Max time in air (used as timeout if waitForCompletion fails)
this.recoveryTicks = 10;
this.cooldownTicks = 100;
this.cooldownTicks = 0;
this.lockMovement = true;
this.waitForCompletion = true; // Ability completes when NPC lands, not by activeTicks
this.minRange = 2.0f;
this.maxRange = 15.0f;
this.telegraphType = TelegraphType.CIRCLE;
@@ -30,7 +30,7 @@ public class AbilitySweeper extends Ability {
// Type-specific parameters
private float beamLength = 10.0f;
private float beamWidth = 0.3f; // Thin like beam trail
private float beamHeight = 0.8f; // Height above ground (low enough to jump over)
private float beamHeight = 0.5f; // Height above ground (low enough to jump over)
private float damage = 5.0f;
private int damageInterval = 5;
private boolean piercing = true;
@@ -54,10 +54,8 @@ public class AbilitySweeper extends Ability {
this.maxRange = 15.0f;
this.minRange = 0.0f;
this.lockMovement = true;
this.cooldownTicks = 200;
this.cooldownTicks = 0;
this.windUpTicks = 60;
this.activeTicks = 400; // Long duration - entity controls actual end
this.recoveryTicks = 5; // Short recovery
// Circle telegraph to show range
this.telegraphType = TelegraphType.CIRCLE;
this.showTelegraph = true;
@@ -86,36 +84,36 @@ public class AbilitySweeper extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
if (!world.isRemote) {
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,
innerColor, outerColor, outerColorEnabled, outerColorWidth,
sweepSpeed, numberOfRotations,
damage, damageInterval, piercing,
lockOnTarget);
world.spawnEntityInWorld(activeEntity);
LogWriter.info("[Sweeper] Spawned sweeper entity");
if (world.isRemote) {
signalCompletion();
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,
innerColor, outerColor, outerColorEnabled, outerColorWidth,
sweepSpeed, numberOfRotations,
damage, damageInterval, piercing,
lockOnTarget);
world.spawnEntityInWorld(activeEntity);
LogWriter.info("[Sweeper] Spawned sweeper entity");
// Entity manages itself - completion signaled from onActiveTick when entity dies
}
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// Entity handles everything - nothing to do here
// Check if entity died early (entity manages its own death based on rotations)
if (activeEntity != null && activeEntity.isDead) {
// Entity finished, ability can end early
// The ability system will handle the recovery phase
// Entity handles everything - check if entity finished its rotations
if (activeEntity == null || activeEntity.isDead) {
signalCompletion();
}
}
@Override
public void reset() {
super.reset();
public void cleanup() {
// Clean up entity if still alive
if (activeEntity != null && !activeEntity.isDead) {
activeEntity.setDead();
@@ -174,7 +172,7 @@ public class AbilitySweeper extends Ability {
public void readTypeNBT(NBTTagCompound nbt) {
this.beamLength = nbt.hasKey("beamLength") ? nbt.getFloat("beamLength") : 10.0f;
this.beamWidth = nbt.hasKey("beamWidth") ? nbt.getFloat("beamWidth") : 0.3f;
this.beamHeight = nbt.hasKey("beamHeight") ? nbt.getFloat("beamHeight") : 0.8f;
this.beamHeight = nbt.hasKey("beamHeight") ? nbt.getFloat("beamHeight") : 0.5f;
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 5.0f;
this.damageInterval = nbt.hasKey("damageInterval") ? nbt.getInteger("damageInterval") : 5;
this.piercing = !nbt.hasKey("piercing") || nbt.getBoolean("piercing");
@@ -59,10 +59,8 @@ public class AbilityTeleport extends Ability {
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 30.0f;
this.minRange = 5.0f;
this.cooldownTicks = 100;
this.cooldownTicks = 0;
this.windUpTicks = 10;
this.activeTicks = 40;
this.recoveryTicks = 10;
// No telegraph for teleport - it's instant repositioning
this.telegraphType = TelegraphType.NONE;
this.showTelegraph = false;
@@ -101,7 +99,10 @@ public class AbilityTeleport extends Ability {
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
int blinkLimit = mode == TeleportMode.BLINK ? blinkCount : 1;
if (currentBlink >= blinkLimit) return;
if (currentBlink >= blinkLimit) {
signalCompletion();
return;
}
ticksSinceLastBlink++;
@@ -109,6 +110,11 @@ public class AbilityTeleport extends Ability {
performBlink(npc, target, world);
currentBlink++;
ticksSinceLastBlink = 0;
// Check if this was the last blink
if (currentBlink >= blinkLimit) {
signalCompletion();
}
}
}
@@ -261,8 +267,13 @@ public class AbilityTeleport extends Ability {
int blockY = MathHelper.floor_double(checkY);
int blockZ = MathHelper.floor_double(checkZ);
// Skip out-of-world coordinates
if (blockY < 0 || blockY >= 256) {
continue;
}
Block block = world.getBlock(blockX, blockY, blockZ);
if (block.getMaterial().isSolid() && block.isOpaqueCube()) {
if (block != null && block.getMaterial().isSolid() && block.isOpaqueCube()) {
return false;
}
}
@@ -327,10 +338,20 @@ public class AbilityTeleport extends Ability {
}
private boolean isSafeLocation(World world, int x, int y, int z) {
// Bounds check - ensure we're within valid world coordinates
if (y < 1 || y >= 255) {
return false;
}
Block groundBlock = world.getBlock(x, y - 1, z);
Block feetBlock = world.getBlock(x, y, z);
Block headBlock = world.getBlock(x, y + 1, z);
// Defensive null checks (shouldn't happen in MC 1.7.10, but safe)
if (groundBlock == null || feetBlock == null || headBlock == null) {
return false;
}
return groundBlock.getMaterial().isSolid() &&
!feetBlock.getMaterial().isSolid() &&
!headBlock.getMaterial().isSolid();
@@ -353,7 +374,10 @@ public class AbilityTeleport extends Ability {
double dist = Math.sqrt(Math.pow(living.posX - x, 2) + Math.pow(living.posZ - z, 2));
if (dist <= damageRadius) {
// Apply damage with scripted event support (no knockback for teleport damage)
applyAbilityDamage(npc, living, damage, 0);
boolean wasHit = applyAbilityDamage(npc, living, damage, 0);
if (wasHit) {
applyEffects(living);
}
}
}
}
@@ -8,8 +8,6 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
@@ -36,6 +34,7 @@ public class AbilityTrap extends Ability {
AHEAD_OF_CASTER
}
private int durationTicks = 200;
private TrapPlacement placement = TrapPlacement.AT_TARGET;
private float placementDistance = 5.0f;
private float triggerRadius = 2.0f;
@@ -45,12 +44,6 @@ public class AbilityTrap extends Ability {
private float damage = 6.0f;
private float damageRadius = 0.0f;
private float knockback = 0.5f;
private int stunDuration = 0;
private int rootDuration = 40;
private int slowDuration = 0;
private int slowLevel = 1;
private int poisonDuration = 0;
private int poisonLevel = 0;
private boolean visible = true;
// Offset parameters - trap spawns near target, not exactly on them
@@ -72,10 +65,8 @@ public class AbilityTrap extends Ability {
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 15.0f;
this.lockMovement = true;
this.cooldownTicks = 150;
this.cooldownTicks = 0;
this.windUpTicks = 20;
this.activeTicks = 200;
this.recoveryTicks = 10;
this.telegraphType = TelegraphType.CIRCLE;
}
@@ -188,6 +179,12 @@ public class AbilityTrap extends Ability {
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// Check if trap duration has ended
if (tick >= durationTicks) {
signalCompletion();
return;
}
if (!armed) {
if (tick >= armTime) {
armed = true;
@@ -198,6 +195,7 @@ public class AbilityTrap extends Ability {
ticksSinceLastTrigger++;
if (maxTriggers > 0 && triggerCount >= maxTriggers) {
signalCompletion(); // All triggers used, trap is done
return;
}
@@ -262,24 +260,9 @@ public class AbilityTrap extends Ability {
// Apply damage with scripted event support
boolean wasHit = applyAbilityDamage(npc, entity, damage, knockback);
// Only apply effects if the hit wasn't cancelled
// Apply effects if the hit wasn't cancelled
if (wasHit) {
if (stunDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
}
if (rootDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, rootDuration, 127));
}
if (slowDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, slowDuration, slowLevel));
}
if (poisonDuration > 0 && poisonLevel >= 0) {
entity.addPotionEffect(new PotionEffect(Potion.poison.id, poisonDuration, poisonLevel));
}
applyEffects(entity);
}
}
}
@@ -300,6 +283,7 @@ public class AbilityTrap extends Ability {
@Override
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setInteger("durationTicks", durationTicks);
nbt.setString("placement", placement.name());
nbt.setFloat("placementDistance", placementDistance);
nbt.setFloat("triggerRadius", triggerRadius);
@@ -309,12 +293,6 @@ public class AbilityTrap extends Ability {
nbt.setFloat("damage", damage);
nbt.setFloat("damageRadius", damageRadius);
nbt.setFloat("knockback", knockback);
nbt.setInteger("stunDuration", stunDuration);
nbt.setInteger("rootDuration", rootDuration);
nbt.setInteger("slowDuration", slowDuration);
nbt.setInteger("slowLevel", slowLevel);
nbt.setInteger("poisonDuration", poisonDuration);
nbt.setInteger("poisonLevel", poisonLevel);
nbt.setBoolean("visible", visible);
nbt.setFloat("minOffset", minOffset);
nbt.setFloat("maxOffset", maxOffset);
@@ -323,6 +301,7 @@ public class AbilityTrap extends Ability {
@Override
public void readTypeNBT(NBTTagCompound nbt) {
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 200;
try {
this.placement = TrapPlacement.valueOf(nbt.getString("placement"));
} catch (Exception e) {
@@ -336,12 +315,6 @@ public class AbilityTrap extends Ability {
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 6.0f;
this.damageRadius = nbt.hasKey("damageRadius") ? nbt.getFloat("damageRadius") : 0.0f;
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 0.5f;
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
this.rootDuration = nbt.hasKey("rootDuration") ? nbt.getInteger("rootDuration") : 40;
this.slowDuration = nbt.hasKey("slowDuration") ? nbt.getInteger("slowDuration") : 0;
this.slowLevel = nbt.hasKey("slowLevel") ? nbt.getInteger("slowLevel") : 1;
this.poisonDuration = nbt.hasKey("poisonDuration") ? nbt.getInteger("poisonDuration") : 0;
this.poisonLevel = nbt.hasKey("poisonLevel") ? nbt.getInteger("poisonLevel") : 0;
this.visible = !nbt.hasKey("visible") || nbt.getBoolean("visible");
this.minOffset = nbt.hasKey("minOffset") ? nbt.getFloat("minOffset") : 0.0f;
this.maxOffset = nbt.hasKey("maxOffset") ? nbt.getFloat("maxOffset") : 1.5f;
@@ -349,6 +322,14 @@ public class AbilityTrap extends Ability {
}
// Getters & Setters
public int getDurationTicks() {
return durationTicks;
}
public void setDurationTicks(int durationTicks) {
this.durationTicks = Math.max(1, durationTicks);
}
public TrapPlacement getPlacement() {
return placement;
}
@@ -421,54 +402,6 @@ public class AbilityTrap extends Ability {
this.knockback = knockback;
}
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getRootDuration() {
return rootDuration;
}
public void setRootDuration(int rootDuration) {
this.rootDuration = rootDuration;
}
public int getSlowDuration() {
return slowDuration;
}
public void setSlowDuration(int slowDuration) {
this.slowDuration = slowDuration;
}
public int getSlowLevel() {
return slowLevel;
}
public void setSlowLevel(int slowLevel) {
this.slowLevel = slowLevel;
}
public int getPoisonDuration() {
return poisonDuration;
}
public void setPoisonDuration(int poisonDuration) {
this.poisonDuration = poisonDuration;
}
public int getPoisonLevel() {
return poisonLevel;
}
public void setPoisonLevel(int poisonLevel) {
this.poisonLevel = poisonLevel;
}
public boolean isVisible() {
return visible;
}
@@ -7,10 +7,7 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex;
@@ -32,28 +29,31 @@ public class AbilityVortex extends Ability {
private float pullStrength = 0.8f;
private float damage = 0.0f;
private float knockback = 0.0f;
private int stunDuration = 0;
private int rootDuration = 0;
private boolean aoe = false;
private int maxTargets = 5;
private boolean damageOnPull = false;
private float pullDamage = 0.0f;
// Runtime state
private transient Set<UUID> pulledEntities = new HashSet<>();
private transient Set<UUID> pulledEntities;
private transient boolean pullComplete = false;
private transient int ticksSincePullDamage = 0;
private Set<UUID> getPulledEntities() {
if (pulledEntities == null) {
pulledEntities = new HashSet<>();
}
return pulledEntities;
}
public AbilityVortex() {
this.typeId = "ability.cnpc.vortex";
this.name = "Vortex";
this.targetingMode = TargetingMode.AOE_SELF;
this.maxRange = 15.0f;
this.lockMovement = true;
this.cooldownTicks = 120;
this.cooldownTicks = 0;
this.windUpTicks = 30;
this.activeTicks = 40;
this.recoveryTicks = 5;
this.telegraphType = TelegraphType.CIRCLE;
this.windUpSound = "mob.ghast.charge";
this.activeSound = "mob.ghast.fireball";
@@ -88,7 +88,7 @@ public class AbilityVortex extends Ability {
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
pulledEntities.clear();
getPulledEntities().clear();
pullComplete = false;
ticksSincePullDamage = 0;
@@ -104,7 +104,7 @@ public class AbilityVortex extends Ability {
double dist = npc.getDistanceToEntity(entity);
if (dist <= pullRadius) {
pulledEntities.add(entity.getUniqueID());
getPulledEntities().add(entity.getUniqueID());
count++;
if (count >= maxTargets) break;
}
@@ -114,7 +114,7 @@ public class AbilityVortex extends Ability {
if (target != null && !target.isDead) {
double dist = npc.getDistanceToEntity(target);
if (dist <= pullRadius) {
pulledEntities.add(target.getUniqueID());
getPulledEntities().add(target.getUniqueID());
}
}
}
@@ -122,7 +122,8 @@ public class AbilityVortex extends Ability {
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
if (pullComplete || pulledEntities.isEmpty()) {
if (pullComplete || getPulledEntities().isEmpty()) {
signalCompletion();
return;
}
@@ -133,10 +134,10 @@ public class AbilityVortex extends Ability {
boolean anyStillPulling = false;
ticksSincePullDamage++;
for (UUID uuid : new HashSet<>(pulledEntities)) {
EntityLivingBase entity = findEntity(world, uuid);
for (UUID uuid : new HashSet<>(getPulledEntities())) {
EntityLivingBase entity = findEntity(npc, world, uuid);
if (entity == null || entity.isDead) {
pulledEntities.remove(uuid);
getPulledEntities().remove(uuid);
continue;
}
@@ -146,7 +147,7 @@ public class AbilityVortex extends Ability {
double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist <= 1.0f) {
pulledEntities.remove(uuid);
getPulledEntities().remove(uuid);
onTargetArrived(npc, entity, world);
continue;
}
@@ -160,7 +161,7 @@ public class AbilityVortex extends Ability {
AxisAlignedBB nextBox = entity.boundingBox.copy().offset(nextX, nextY, nextZ);
if (!world.getCollidingBoundingBoxes(entity, nextBox).isEmpty()) {
pulledEntities.remove(uuid);
getPulledEntities().remove(uuid);
continue;
}
@@ -176,8 +177,9 @@ public class AbilityVortex extends Ability {
}
}
if (!anyStillPulling && pulledEntities.isEmpty()) {
if (!anyStillPulling && getPulledEntities().isEmpty()) {
pullComplete = true;
signalCompletion();
}
}
@@ -187,40 +189,31 @@ public class AbilityVortex extends Ability {
// Only apply effects if hit wasn't cancelled
if (wasHit) {
if (stunDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
}
if (rootDuration > 0) {
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, rootDuration, 127));
}
applyEffects(entity);
}
}
/**
* Find an entity by UUID within the vortex pull area.
* Uses AABB search instead of iterating all loaded entities.
*/
@SuppressWarnings("unchecked")
private EntityLivingBase findEntity(World world, UUID uuid) {
for (Object obj : world.loadedEntityList) {
if (obj instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) obj;
if (entity.getUniqueID().equals(uuid)) {
return entity;
}
private EntityLivingBase findEntity(EntityNPCInterface npc, World world, UUID uuid) {
// Search within pull radius (entities being pulled should be within this area)
AxisAlignedBB searchBox = npc.boundingBox.expand(pullRadius, pullRadius / 2, pullRadius);
List<EntityLivingBase> nearbyEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, searchBox);
for (EntityLivingBase entity : nearbyEntities) {
if (entity.getUniqueID().equals(uuid)) {
return entity;
}
}
return null;
}
@Override
public void onComplete(EntityNPCInterface npc, EntityLivingBase target) {
pulledEntities.clear();
pullComplete = false;
ticksSincePullDamage = 0;
}
@Override
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
pulledEntities.clear();
public void cleanup() {
getPulledEntities().clear();
pullComplete = false;
ticksSincePullDamage = 0;
}
@@ -231,8 +224,6 @@ public class AbilityVortex extends Ability {
nbt.setFloat("pullStrength", pullStrength);
nbt.setFloat("damage", damage);
nbt.setFloat("knockback", knockback);
nbt.setInteger("stunDuration", stunDuration);
nbt.setInteger("rootDuration", rootDuration);
nbt.setBoolean("aoe", aoe);
nbt.setInteger("maxTargets", maxTargets);
nbt.setBoolean("damageOnPull", damageOnPull);
@@ -245,8 +236,6 @@ public class AbilityVortex extends Ability {
this.pullStrength = nbt.hasKey("pullStrength") ? nbt.getFloat("pullStrength") : 0.8f;
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 0.0f;
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 0.0f;
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
this.rootDuration = nbt.hasKey("rootDuration") ? nbt.getInteger("rootDuration") : 0;
this.aoe = nbt.hasKey("aoe") && nbt.getBoolean("aoe");
this.maxTargets = nbt.hasKey("maxTargets") ? nbt.getInteger("maxTargets") : 5;
this.damageOnPull = nbt.hasKey("damageOnPull") && nbt.getBoolean("damageOnPull");
@@ -286,22 +275,6 @@ public class AbilityVortex extends Ability {
this.knockback = knockback;
}
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getRootDuration() {
return rootDuration;
}
public void setRootDuration(int rootDuration) {
this.rootDuration = rootDuration;
}
public boolean isAoe() {
return aoe;
}
@@ -17,12 +17,18 @@ public class TelegraphInstance {
private String instanceId;
private Telegraph telegraph;
// Position
// Position (current)
private double x;
private double y;
private double z;
private float yaw;
// Position (previous tick - for interpolation)
private double prevX;
private double prevY;
private double prevZ;
private float prevYaw;
// Entity tracking
private int entityIdToFollow = -1;
private int casterEntityId = -1;
@@ -50,6 +56,11 @@ public class TelegraphInstance {
this.y = y;
this.z = z;
this.yaw = yaw;
// Initialize prev positions to current for first frame
this.prevX = x;
this.prevY = y;
this.prevZ = z;
this.prevYaw = yaw;
this.remainingTicks = telegraph.getDurationTicks();
this.totalTicks = telegraph.getDurationTicks();
}
@@ -69,6 +80,12 @@ public class TelegraphInstance {
return false;
}
// Save previous position for interpolation
this.prevX = this.x;
this.prevY = this.y;
this.prevZ = this.z;
this.prevYaw = this.yaw;
remainingTicks--;
// Update position if following an entity
@@ -144,6 +161,43 @@ public class TelegraphInstance {
return (alpha << 24) | (r << 16) | (g << 8) | b;
}
// ═══════════════════════════════════════════════════════════════════
// INTERPOLATED POSITION (for smooth rendering)
// ═══════════════════════════════════════════════════════════════════
/**
* Get interpolated X position for smooth rendering.
*/
public double getInterpolatedX(float partialTicks) {
return prevX + (x - prevX) * partialTicks;
}
/**
* Get interpolated Y position for smooth rendering.
*/
public double getInterpolatedY(float partialTicks) {
return prevY + (y - prevY) * partialTicks;
}
/**
* Get interpolated Z position for smooth rendering.
*/
public double getInterpolatedZ(float partialTicks) {
return prevZ + (z - prevZ) * partialTicks;
}
/**
* Get interpolated yaw for smooth rendering.
* Handles angle wrapping for smooth rotation.
*/
public float getInterpolatedYaw(float partialTicks) {
// Handle angle wrapping to prevent spinning the wrong way
float diff = yaw - prevYaw;
while (diff > 180.0f) diff -= 360.0f;
while (diff < -180.0f) diff += 360.0f;
return prevYaw + diff * partialTicks;
}
// ═══════════════════════════════════════════════════════════════════
// NBT SERIALIZATION
// ═══════════════════════════════════════════════════════════════════
@@ -1,5 +1,7 @@
package kamkeel.npcs.entity;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -47,6 +49,24 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
// Origin stays fixed (or follows owner)
private boolean attachedToOwner = true;
// Whether to render tail orb (only when anchored)
private boolean renderTailOrb = true;
// Charging state (during windup)
private boolean charging = false;
private int chargeDuration = 40;
private int chargeTick = 0;
private float chargeOffsetDistance = 1.0f;
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
// Trail fading for non-anchored beams (comet effect)
private boolean fadeTrail = false;
private int trailFadeTime = 20; // Ticks for trail to fully fade
private List<Integer> trailPointAges = new ArrayList<>();
// Data watcher index for charging state (synced to clients)
private static final int DW_CHARGING = 20;
// Debug logging
private static final boolean DEBUG_LOGGING = true;
@@ -54,8 +74,32 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
super(world);
}
@Override
protected void entityInit() {
super.entityInit();
// Register data watcher for charging state
this.dataWatcher.addObject(DW_CHARGING, (byte) 0);
}
/**
* Full constructor with all parameters.
* Check if beam is in charging state (synced via data watcher).
*/
public boolean isCharging() {
return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1;
}
/**
* Set charging state (server only, synced to clients via data watcher).
*/
private void setCharging(boolean value) {
this.charging = value;
if (!worldObj.isRemote) {
this.dataWatcher.updateObject(DW_CHARGING, (byte) (value ? 1 : 0));
}
}
/**
* Full constructor with all parameters (no lightning).
*/
public EntityAbilityBeam(World world, EntityNPCInterface owner, EntityLivingBase target,
double x, double y, double z,
@@ -66,15 +110,62 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
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,
damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
false, 0.15f, 0.5f);
}
/**
* Full constructor with all parameters including lightning.
*/
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,
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,
boolean lightningEffect, float lightningDensity, float lightningRadius) {
this(world, owner, target, x, y, z,
beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius,
true); // Default to anchored mode
}
/**
* Full constructor with all parameters including lightning and anchored mode.
* @param anchoredMode If true, origin follows owner and tail orb is rendered.
* If false, beam is free-moving with trailing length (no tail orb).
*/
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,
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,
boolean lightningEffect, float lightningDensity, float lightningRadius,
boolean anchoredMode) {
super(world);
// Initialize base properties
// Initialize base properties with lightning
initProjectile(owner, target, x, y, z,
headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime);
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius, 6);
// Beam-specific properties
this.speed = speed;
@@ -84,6 +175,10 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
this.beamWidth = beamWidth;
this.headSize = headSize;
// Anchored mode controls whether origin follows owner and tail orb is rendered
this.attachedToOwner = anchoredMode;
this.renderTailOrb = anchoredMode;
// Initialize head offset at origin (0,0,0 relative)
this.headOffsetX = 0;
this.headOffsetY = 0;
@@ -119,6 +214,120 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
}
}
/**
* Create a beam in charging mode (for windup phase).
* The beam will grow from 0 to headSize over chargeDuration ticks.
* Position follows the owner based on anchor point.
*/
public static EntityAbilityBeam createCharging(World world, EntityNPCInterface owner, EntityLivingBase target,
float beamWidth, float headSize, int innerColor, int outerColor,
boolean outerColorEnabled, float outerColorWidth, 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,
boolean lightningEffect, float lightningDensity, float lightningRadius,
boolean anchoredMode, int chargeDuration, float chargeOffsetDistance,
AnchorPoint anchorPoint) {
// Calculate initial position based on anchor point
Vec3 spawnPos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint, chargeOffsetDistance);
double spawnX = spawnPos.xCoord;
double spawnY = spawnPos.yCoord;
double spawnZ = spawnPos.zCoord;
EntityAbilityBeam beam = new EntityAbilityBeam(
world, owner, target,
spawnX, spawnY, spawnZ,
beamWidth, headSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius,
anchoredMode);
// Set charging state (uses data watcher for client sync)
beam.setCharging(true);
beam.chargeDuration = chargeDuration;
beam.chargeTick = 0;
beam.chargeOffsetDistance = chargeOffsetDistance;
beam.anchorPoint = anchorPoint;
// Non-anchored beams have fading trail (comet effect)
beam.fadeTrail = !anchoredMode;
// Clear motion while charging
beam.motionX = 0;
beam.motionY = 0;
beam.motionZ = 0;
return beam;
}
/**
* Start the beam firing (exit charging mode).
* Called by ability when windup ends.
*
* For anchored beams: origin follows owner, head starts at charged position
* For non-anchored beams: origin fixed at charged position, head starts there
*/
public void startFiring(EntityLivingBase target) {
if (!isCharging()) return;
setCharging(false);
// Origin (tail) stays at the charged position - where the orb was
// This is the same for both anchored and non-anchored modes
startX = posX;
startY = posY;
startZ = posZ;
// Head starts at the origin (tail position)
headOffsetX = 0;
headOffsetY = 0;
headOffsetZ = 0;
prevHeadOffsetX = 0;
prevHeadOffsetY = 0;
prevHeadOffsetZ = 0;
// Origin no longer follows owner after firing starts
// (for anchored mode, tail is fixed in space; for non-anchored, there's no tail)
attachedToOwner = false;
// Initialize trail with just the origin point
trailPoints.clear();
trailPointAges.clear();
trailPoints.add(Vec3.createVectorHelper(0, 0, 0));
if (fadeTrail) trailPointAges.add(0);
// Calculate velocity toward target (head starts at origin = startX/Y/Z)
Entity owner = getOwner();
if (target != null) {
double dx = target.posX - startX;
double dy = (target.posY + target.height * 0.5) - startY;
double dz = target.posZ - startZ;
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (len > 0) {
motionX = (dx / len) * speed;
motionY = (dy / len) * speed;
motionZ = (dz / len) * speed;
}
} else if (owner != null) {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = (float) Math.toRadians(owner.rotationPitch);
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
motionY = -Math.sin(pitch) * speed;
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
}
if (DEBUG_LOGGING && !worldObj.isRemote) {
LogWriter.info("[Beam] startFiring: origin=(" + startX + "," + startY + "," + startZ +
") headOffset=(" + headOffsetX + "," + headOffsetY + "," + headOffsetZ +
") motion=(" + motionX + "," + motionY + "," + motionZ + ")");
}
}
@Override
protected boolean checkMaxDistance() {
// Check distance using head offset (distance from origin)
@@ -136,19 +345,33 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
@Override
protected void updateProjectile() {
// Handle charging state (windup phase) - use isCharging() for synced value
if (isCharging()) {
updateCharging();
return;
}
// Store previous head offset for interpolation
prevHeadOffsetX = headOffsetX;
prevHeadOffsetY = headOffsetY;
prevHeadOffsetZ = headOffsetZ;
// Age trail points for fading effect
if (fadeTrail) {
ageTrailPoints();
}
if (worldObj.isRemote) {
// Client: interpolate entity position, derive head from offset
// Client: interpolate entity position
handleClientInterpolation();
// Client also updates head offset to match motion for smooth movement
headOffsetX += motionX;
headOffsetY += motionY;
headOffsetZ += motionZ;
// Client: derive head offset from entity position and origin
// Entity position = head world position, so headOffset = pos - origin
// Note: During charging, updateCharging() handles origin positioning
// After firing, origin is fixed at the charged position
headOffsetX = posX - startX;
headOffsetY = posY - startY;
headOffsetZ = posZ - startZ;
// Add trail point on client
addTrailPoint();
@@ -166,7 +389,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
Entity owner = getOwner();
if (owner != null) {
startX = owner.posX;
startY = owner.posY + owner.height * 0.7;
startY = owner.posY + owner.getEyeHeight() * 0.7;
startZ = owner.posZ;
}
}
@@ -201,10 +424,67 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
}
}
/**
* Update during charging state - follow owner based on anchor point.
*/
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
if (owner == null || owner.isDead) {
setDead();
return;
}
// Calculate position based on anchor point
Vec3 pos;
if (owner instanceof EntityLivingBase) {
pos = AnchorPointHelper.calculateAnchorPosition((EntityLivingBase) owner, anchorPoint, chargeOffsetDistance);
} else {
// Fallback for non-living entities (shouldn't happen normally)
float yaw = (float) Math.toRadians(owner.rotationYaw);
double offsetX = -Math.sin(yaw) * chargeOffsetDistance;
double offsetZ = Math.cos(yaw) * chargeOffsetDistance;
pos = Vec3.createVectorHelper(
owner.posX + offsetX,
owner.posY + owner.getEyeHeight() * 0.7,
owner.posZ + offsetZ
);
}
setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
// Also update origin for when firing starts
startX = pos.xCoord;
startY = pos.yCoord;
startZ = pos.zCoord;
}
/**
* Age trail points and remove old ones (for comet effect).
*/
private void ageTrailPoints() {
// Age all trail points
for (int i = 0; i < trailPointAges.size(); i++) {
trailPointAges.set(i, trailPointAges.get(i) + 1);
}
// Remove trail points that have fully faded
while (!trailPointAges.isEmpty() && trailPointAges.get(0) >= trailFadeTime) {
trailPointAges.remove(0);
if (!trailPoints.isEmpty()) {
trailPoints.remove(0);
}
}
}
private void addTrailPoint() {
// Trail points are RELATIVE to origin
if (trailPoints.isEmpty()) {
trailPoints.add(Vec3.createVectorHelper(headOffsetX, headOffsetY, headOffsetZ));
if (fadeTrail) {
trailPointAges.add(0);
}
return;
}
@@ -217,10 +497,15 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
if (dist >= MIN_POINT_DISTANCE) {
trailPoints.add(Vec3.createVectorHelper(headOffsetX, headOffsetY, headOffsetZ));
if (fadeTrail) {
trailPointAges.add(0);
}
// Limit trail length
while (trailPoints.size() > MAX_TRAIL_POINTS) {
trailPoints.remove(0);
// Limit trail length (only if not using fading - fading handles its own cleanup)
if (!fadeTrail) {
while (trailPoints.size() > MAX_TRAIL_POINTS) {
trailPoints.remove(0);
}
}
}
}
@@ -369,6 +654,59 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
return startZ;
}
/**
* Whether the tail orb should be rendered (only true in anchored mode).
*/
public boolean shouldRenderTailOrb() {
return renderTailOrb;
}
/**
* Whether the beam is attached to its owner (anchored mode).
*/
public boolean isAttachedToOwner() {
return attachedToOwner;
}
/**
* Get the charge progress (0-1).
*/
public float getChargeProgress() {
if (chargeDuration <= 0) return 1.0f;
return Math.min(1.0f, (float) chargeTick / chargeDuration);
}
/**
* Get interpolated charge progress for smooth rendering.
*/
public float getInterpolatedChargeProgress(float partialTicks) {
if (chargeDuration <= 0) return 1.0f;
float prevProgress = Math.max(0, (float) (chargeTick - 1) / chargeDuration);
float currProgress = Math.min(1.0f, (float) chargeTick / chargeDuration);
return prevProgress + (currProgress - prevProgress) * partialTicks;
}
/**
* Whether trail should fade (comet effect for non-anchored beams).
*/
public boolean hasFadingTrail() {
return fadeTrail;
}
/**
* Get trail point ages for fading calculation.
*/
public List<Integer> getTrailPointAges() {
return trailPointAges;
}
/**
* Get trail fade time in ticks.
*/
public int getTrailFadeTime() {
return trailFadeTime;
}
// ==================== NBT ====================
@Override
@@ -386,6 +724,17 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
this.prevHeadOffsetY = this.headOffsetY;
this.prevHeadOffsetZ = this.headOffsetZ;
this.attachedToOwner = !nbt.hasKey("AttachedToOwner") || nbt.getBoolean("AttachedToOwner");
this.renderTailOrb = !nbt.hasKey("RenderTailOrb") || nbt.getBoolean("RenderTailOrb");
// Read charging state and sync to data watcher
boolean isCharging = nbt.hasKey("Charging") && nbt.getBoolean("Charging");
this.charging = isCharging;
this.dataWatcher.updateObject(DW_CHARGING, (byte) (isCharging ? 1 : 0));
this.chargeDuration = nbt.hasKey("ChargeDuration") ? nbt.getInteger("ChargeDuration") : 40;
this.chargeTick = nbt.hasKey("ChargeTick") ? nbt.getInteger("ChargeTick") : 0;
this.chargeOffsetDistance = nbt.hasKey("ChargeOffsetDistance") ? nbt.getFloat("ChargeOffsetDistance") : 1.0f;
this.anchorPoint = nbt.hasKey("AnchorPoint") ? AnchorPoint.fromId(nbt.getInteger("AnchorPoint")) : AnchorPoint.FRONT;
this.fadeTrail = nbt.hasKey("FadeTrail") && nbt.getBoolean("FadeTrail");
this.trailFadeTime = nbt.hasKey("TrailFadeTime") ? nbt.getInteger("TrailFadeTime") : 20;
// Read trail points (relative to origin)
trailPoints.clear();
@@ -414,6 +763,14 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
nbt.setDouble("HeadOffsetY", headOffsetY);
nbt.setDouble("HeadOffsetZ", headOffsetZ);
nbt.setBoolean("AttachedToOwner", attachedToOwner);
nbt.setBoolean("RenderTailOrb", renderTailOrb);
nbt.setBoolean("Charging", isCharging());
nbt.setInteger("ChargeDuration", chargeDuration);
nbt.setInteger("ChargeTick", chargeTick);
nbt.setFloat("ChargeOffsetDistance", chargeOffsetDistance);
nbt.setInteger("AnchorPoint", anchorPoint.getId());
nbt.setBoolean("FadeTrail", fadeTrail);
nbt.setInteger("TrailFadeTime", trailFadeTime);
// Write trail points
NBTTagList trailList = new NBTTagList();
@@ -1,5 +1,7 @@
package kamkeel.npcs.entity;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -35,12 +37,47 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
private float discRadius = 1.0f; // Width of disc
private float discThickness = 0.2f; // Height of disc
// Charging state (during windup)
private boolean charging = false;
private int chargeDuration = 40;
private int chargeTick = 0;
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
private float targetDiscRadius = 1.0f; // Full radius to grow to during charging
private float targetDiscThickness = 0.2f; // Full thickness to grow to during charging
// Data watcher index for charging state (synced to clients)
private static final int DW_CHARGING = 20;
public EntityAbilityDisc(World world) {
super(world);
}
@Override
protected void entityInit() {
super.entityInit();
// Register data watcher for charging state
this.dataWatcher.addObject(DW_CHARGING, (byte) 0);
}
/**
* Full constructor with all parameters.
* Check if disc is in charging state (synced via data watcher).
*/
public boolean isCharging() {
return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1;
}
/**
* Set charging state (server only, synced to clients via data watcher).
*/
private void setCharging(boolean value) {
this.charging = value;
if (!worldObj.isRemote) {
this.dataWatcher.updateObject(DW_CHARGING, (byte) (value ? 1 : 0));
}
}
/**
* Full constructor with all parameters (no lightning).
*/
public EntityAbilityDisc(World world, EntityNPCInterface owner, EntityLivingBase target,
double x, double y, double z,
@@ -52,15 +89,38 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
boolean explosive, float explosionRadius, float explosionDamageFalloff,
int stunDuration, int slowDuration, int slowLevel,
float maxDistance, int maxLifetime) {
this(world, owner, target, x, y, z,
discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange,
boomerang, boomerangDelay, explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
false, 0.15f, 0.5f);
}
/**
* Full constructor with all parameters including lightning.
*/
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,
float damage, float knockback, float knockbackUp,
float speed, boolean homing, float homingStrength, float homingRange,
boolean boomerang, int boomerangDelay,
boolean explosive, float explosionRadius, float explosionDamageFalloff,
int stunDuration, int slowDuration, int slowLevel,
float maxDistance, int maxLifetime,
boolean lightningEffect, float lightningDensity, float lightningRadius) {
super(world);
// Initialize base properties (use discRadius as size for base)
// Initialize base properties with lightning (use discRadius as size for base)
initProjectile(owner, target, x, y, z,
discRadius, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime);
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius, 6);
// Disc-specific properties
this.speed = speed;
@@ -94,6 +154,97 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
}
}
/**
* Create a disc in charging mode (for windup phase).
* The disc will grow from 0 to discRadius over chargeDuration ticks.
* Position follows the owner based on anchor point.
*/
public static EntityAbilityDisc createCharging(World world, EntityNPCInterface owner, EntityLivingBase target,
float discRadius, float discThickness, int innerColor, int outerColor,
boolean outerColorEnabled, float outerColorWidth, float rotationSpeed,
float damage, float knockback, float knockbackUp,
float speed, boolean homing, float homingStrength, float homingRange,
boolean boomerang, int boomerangDelay,
boolean explosive, float explosionRadius, float explosionDamageFalloff,
int stunDuration, int slowDuration, int slowLevel,
float maxDistance, int maxLifetime,
boolean lightningEffect, float lightningDensity, float lightningRadius,
AnchorPoint anchorPoint, int chargeDuration) {
// Calculate initial position based on anchor point
Vec3 spawnPos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint);
double spawnX = spawnPos.xCoord;
double spawnY = spawnPos.yCoord;
double spawnZ = spawnPos.zCoord;
EntityAbilityDisc disc = new EntityAbilityDisc(
world, owner, target,
spawnX, spawnY, spawnZ,
discRadius, discThickness, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange,
boomerang, boomerangDelay,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius);
// Set charging state (uses data watcher for client sync)
disc.setCharging(true);
disc.chargeDuration = chargeDuration;
disc.chargeTick = 0;
disc.anchorPoint = anchorPoint;
// Store target size and start at 0 for grow effect
disc.targetDiscRadius = disc.discRadius;
disc.targetDiscThickness = disc.discThickness;
disc.discRadius = 0.01f; // Start very small
disc.discThickness = 0.01f;
disc.size = 0.01f; // Base size used for rendering
disc.renderCurrentSize = 0.01f;
disc.prevRenderSize = 0.01f;
// Clear motion while charging
disc.motionX = 0;
disc.motionY = 0;
disc.motionZ = 0;
return disc;
}
/**
* Start the disc moving (exit charging mode).
* Called by ability when windup ends.
*/
public void startMoving(EntityLivingBase target) {
if (!isCharging()) return;
setCharging(false);
// Update start position to current position
startX = posX;
startY = posY;
startZ = posZ;
// Calculate velocity toward target
Entity owner = getOwner();
if (target != null) {
double dx = target.posX - posX;
double dy = (target.posY + target.height * 0.5) - posY;
double dz = target.posZ - posZ;
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (len > 0) {
motionX = (dx / len) * speed;
motionY = (dy / len) * speed;
motionZ = (dz / len) * speed;
}
} else if (owner != null) {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = (float) Math.toRadians(owner.rotationPitch);
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
motionY = -Math.sin(pitch) * speed;
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
}
}
@Override
protected void updateRotation() {
// Disc spins ONLY on Y axis (flat spin like a saw blade)
@@ -104,6 +255,12 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
@Override
protected void updateProjectile() {
// Handle charging state (windup phase)
if (isCharging()) {
updateCharging();
return;
}
if (worldObj.isRemote) {
handleClientInterpolation();
} else {
@@ -118,17 +275,8 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
checkEntityCollision();
this.moveEntity(motionX, motionY, motionZ);
// Boomerang: if we've traveled far without hitting, start returning
// Track ticks for boomerang delay (checkMaxDistance handles the actual return trigger)
if (boomerang && !returning && !hasHit) {
double distTraveled = Math.sqrt(
(posX - startX) * (posX - startX) +
(posY - startY) * (posY - startY) +
(posZ - startZ) * (posZ - startZ)
);
// Start returning at 80% of max distance or after delay
if (distTraveled >= maxDistance * 0.8 || ticksSinceMiss >= boomerangDelay) {
returning = true;
}
ticksSinceMiss++;
}
}
@@ -147,20 +295,41 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
@Override
protected boolean checkMaxDistance() {
// If boomerang and returning, don't die from max distance
if (boomerang && returning) {
// Die if we get close to owner
Entity owner = getOwner();
if (owner != null) {
double distToOwner = Math.sqrt(
(posX - owner.posX) * (posX - owner.posX) +
(posY - owner.posY) * (posY - owner.posY) +
(posZ - owner.posZ) * (posZ - owner.posZ)
);
return distToOwner < 1.0;
double distTraveled = Math.sqrt(
(posX - startX) * (posX - startX) +
(posY - startY) * (posY - startY) +
(posZ - startZ) * (posZ - startZ)
);
if (boomerang) {
// If not returning yet, check if we should start returning
if (!returning && !hasHit) {
if (distTraveled >= maxDistance * 0.8 || ticksSinceMiss >= boomerangDelay) {
returning = true;
}
}
// If returning, only die when close to owner
if (returning) {
Entity owner = getOwner();
if (owner != null) {
double distToOwner = Math.sqrt(
(posX - owner.posX) * (posX - owner.posX) +
(posY - owner.posY) * (posY - owner.posY) +
(posZ - owner.posZ) * (posZ - owner.posZ)
);
return distToOwner < 1.5;
}
// Owner gone but returning - keep going toward last known position
return false;
}
// Not returning yet - don't die from distance (we'll trigger return above)
return false;
}
return super.checkMaxDistance();
// Non-boomerang: standard max distance check
return distTraveled >= maxDistance;
}
private void updateHoming() {
@@ -202,19 +371,28 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
private void updateReturnToOwner() {
Entity owner = getOwner();
if (owner == null) {
this.setDead();
return;
// If owner is gone (unloaded/dead), head back toward start position
double targetX, targetY, targetZ;
if (owner != null) {
targetX = owner.posX;
targetY = owner.posY + owner.height * 0.5;
targetZ = owner.posZ;
} else {
// Return to start position if owner not available
targetX = startX;
targetY = startY;
targetZ = startZ;
}
double dx = owner.posX - posX;
double dy = (owner.posY + owner.height * 0.5) - posY;
double dz = owner.posZ - posZ;
double dx = targetX - posX;
double dy = targetY - posY;
double dz = targetZ - posZ;
double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist > 0) {
// Stronger homing when returning
double returnStrength = homingStrength * 2.0;
double returnStrength = Math.min(1.0, homingStrength * 2.5);
double desiredVX = (dx / dist) * speed;
double desiredVY = (dy / dist) * speed;
double desiredVZ = (dz / dist) * speed;
@@ -274,6 +452,52 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
}
}
/**
* Update during charging state - follow owner based on anchor point.
*/
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
if (owner == null || owner.isDead) {
setDead();
return;
}
// Grow size based on charge progress
float progress = getChargeProgress();
this.discRadius = targetDiscRadius * progress;
this.discThickness = targetDiscThickness * progress;
this.size = this.discRadius; // Base size for interpolation
// Calculate position based on anchor point
if (owner instanceof EntityLivingBase) {
Vec3 pos = AnchorPointHelper.calculateAnchorPosition((EntityLivingBase) owner, anchorPoint);
setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
}
// Update rotation during charging (disc still spins)
updateRotation();
}
/**
* Get the charge progress (0-1).
*/
public float getChargeProgress() {
if (chargeDuration <= 0) return 1.0f;
return Math.min(1.0f, (float) chargeTick / chargeDuration);
}
/**
* Get interpolated charge progress for smooth rendering.
*/
public float getInterpolatedChargeProgress(float partialTicks) {
if (chargeDuration <= 0) return 1.0f;
float prevProgress = Math.max(0, (float) (chargeTick - 1) / chargeDuration);
float currProgress = Math.min(1.0f, (float) chargeTick / chargeDuration);
return prevProgress + (currProgress - prevProgress) * partialTicks;
}
// ==================== GETTERS ====================
public float getSpeed() {
@@ -313,6 +537,15 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
this.discRadius = nbt.hasKey("DiscRadius") ? nbt.getFloat("DiscRadius") : 1.0f;
this.discThickness = nbt.hasKey("DiscThickness") ? nbt.getFloat("DiscThickness") : 0.2f;
this.returning = nbt.hasKey("Returning") && nbt.getBoolean("Returning");
// Charging state
boolean isCharging = nbt.hasKey("Charging") && nbt.getBoolean("Charging");
this.charging = isCharging;
this.dataWatcher.updateObject(DW_CHARGING, (byte) (isCharging ? 1 : 0));
this.chargeDuration = nbt.hasKey("ChargeDuration") ? nbt.getInteger("ChargeDuration") : 40;
this.chargeTick = nbt.hasKey("ChargeTick") ? nbt.getInteger("ChargeTick") : 0;
this.anchorPoint = nbt.hasKey("AnchorPoint") ? AnchorPoint.fromId(nbt.getInteger("AnchorPoint")) : AnchorPoint.FRONT;
this.targetDiscRadius = nbt.hasKey("TargetDiscRadius") ? nbt.getFloat("TargetDiscRadius") : this.discRadius;
this.targetDiscThickness = nbt.hasKey("TargetDiscThickness") ? nbt.getFloat("TargetDiscThickness") : this.discThickness;
}
@Override
@@ -326,5 +559,12 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
nbt.setFloat("DiscRadius", discRadius);
nbt.setFloat("DiscThickness", discThickness);
nbt.setBoolean("Returning", returning);
// Charging state
nbt.setBoolean("Charging", isCharging());
nbt.setInteger("ChargeDuration", chargeDuration);
nbt.setInteger("ChargeTick", chargeTick);
nbt.setInteger("AnchorPoint", anchorPoint.getId());
nbt.setFloat("TargetDiscRadius", targetDiscRadius);
nbt.setFloat("TargetDiscThickness", targetDiscThickness);
}
}
@@ -45,7 +45,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
}
/**
* Full constructor with all parameters.
* Full constructor with all parameters (no lightning).
*/
public EntityAbilityLaser(World world, EntityNPCInterface owner, EntityLivingBase target,
double x, double y, double z,
@@ -56,15 +56,37 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
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,
damage, knockback, knockbackUp, expansionSpeed, lingerTicks,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
false, 0.15f, 0.5f);
}
/**
* Full constructor with all parameters including lightning.
*/
public EntityAbilityLaser(World world, EntityNPCInterface owner, EntityLivingBase target,
double x, double y, double z,
float laserWidth, int innerColor, int outerColor,
boolean outerColorEnabled, float outerColorWidth,
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,
boolean lightningEffect, float lightningDensity, float lightningRadius) {
super(world);
// Initialize base properties
// Initialize base properties with lightning
initProjectile(owner, target, x, y, z,
laserWidth, innerColor, outerColor, outerColorEnabled, outerColorWidth, 0.0f, // No rotation for laser
damage, knockback, knockbackUp,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime);
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius, 6);
// Laser-specific properties
this.laserWidth = laserWidth;
@@ -1,5 +1,7 @@
package kamkeel.npcs.entity;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -25,10 +27,44 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
private float homingStrength = 0.35f; // Increased from 0.15 for better tracking
private float homingRange = 20.0f;
// Charging state (during windup)
private boolean charging = false;
private int chargeDuration = 40;
private int chargeTick = 0;
private AnchorPoint anchorPoint = AnchorPoint.FRONT;
private float targetSize = 1.0f; // Full size to grow to during charging
// Data watcher index for charging state (synced to clients)
private static final int DW_CHARGING = 20;
public EntityAbilityOrb(World world) {
super(world);
}
@Override
protected void entityInit() {
super.entityInit();
// Register data watcher for charging state
this.dataWatcher.addObject(DW_CHARGING, (byte) 0);
}
/**
* Check if orb is in charging state (synced via data watcher).
*/
public boolean isCharging() {
return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1;
}
/**
* Set charging state (server only, synced to clients via data watcher).
*/
private void setCharging(boolean value) {
this.charging = value;
if (!worldObj.isRemote) {
this.dataWatcher.updateObject(DW_CHARGING, (byte) (value ? 1 : 0));
}
}
/**
* Full constructor with all parameters.
*/
@@ -41,15 +77,39 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
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,
damage, knockback, knockbackUp,
speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime,
false, 0.15f, 0.5f, 6); // Default: no lightning, low density, small radius, 6 tick fade
}
/**
* Full constructor with lightning effect support.
*/
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,
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,
boolean lightningEffect, float lightningDensity, float lightningRadius, int lightningFadeTime) {
super(world);
// Initialize base properties
// Initialize base properties with lightning
initProjectile(owner, target, x, y, z,
orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime);
maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius, lightningFadeTime);
// Orb-specific properties
this.speed = speed;
@@ -78,8 +138,100 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
}
}
/**
* Create an orb in charging mode (for windup phase).
* The orb will grow from 0 to orbSize over chargeDuration ticks.
* Position follows the owner based on anchor point.
*/
public static EntityAbilityOrb createCharging(World world, EntityNPCInterface owner, EntityLivingBase target,
float orbSize, int innerColor, int outerColor,
boolean outerColorEnabled, float outerColorWidth, 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,
boolean lightningEffect, float lightningDensity, float lightningRadius, int lightningFadeTime,
AnchorPoint anchorPoint, int chargeDuration) {
// Calculate initial position based on anchor point
Vec3 spawnPos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint);
double spawnX = spawnPos.xCoord;
double spawnY = spawnPos.yCoord;
double spawnZ = spawnPos.zCoord;
EntityAbilityOrb orb = new EntityAbilityOrb(
world, owner, target,
spawnX, spawnY, spawnZ,
orbSize, innerColor, outerColor, outerColorEnabled, outerColorWidth, rotationSpeed,
damage, knockback, knockbackUp, speed, homing, homingStrength, homingRange,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel, maxDistance, maxLifetime,
lightningEffect, lightningDensity, lightningRadius, lightningFadeTime);
// Set charging state (uses data watcher for client sync)
orb.setCharging(true);
orb.chargeDuration = chargeDuration;
orb.chargeTick = 0;
orb.anchorPoint = anchorPoint;
// Store target size and start at 0 for grow effect
orb.targetSize = orb.size;
orb.size = 0.01f; // Start very small
orb.renderCurrentSize = 0.01f;
orb.prevRenderSize = 0.01f;
// Clear motion while charging
orb.motionX = 0;
orb.motionY = 0;
orb.motionZ = 0;
return orb;
}
/**
* Start the orb moving (exit charging mode).
* Called by ability when windup ends.
*/
public void startMoving(EntityLivingBase target) {
if (!isCharging()) return;
setCharging(false);
// Update start position to current position
startX = posX;
startY = posY;
startZ = posZ;
// Calculate velocity toward target
Entity owner = getOwner();
if (target != null) {
double dx = target.posX - posX;
double dy = (target.posY + target.height * 0.5) - posY;
double dz = target.posZ - posZ;
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (len > 0) {
motionX = (dx / len) * speed;
motionY = (dy / len) * speed;
motionZ = (dz / len) * speed;
}
} else if (owner != null) {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = (float) Math.toRadians(owner.rotationPitch);
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
motionY = -Math.sin(pitch) * speed;
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
}
}
@Override
protected void updateProjectile() {
// Handle charging state (windup phase)
if (isCharging()) {
updateCharging();
return;
}
if (worldObj.isRemote) {
handleClientInterpolation();
} else {
@@ -183,6 +335,47 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
}
}
/**
* Update during charging state - follow owner based on anchor point.
*/
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
if (owner == null || owner.isDead) {
setDead();
return;
}
// Grow size based on charge progress
float progress = getChargeProgress();
this.size = targetSize * progress;
// Calculate position based on anchor point
if (owner instanceof EntityLivingBase) {
Vec3 pos = AnchorPointHelper.calculateAnchorPosition((EntityLivingBase) owner, anchorPoint);
setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
}
}
/**
* Get the charge progress (0-1).
*/
public float getChargeProgress() {
if (chargeDuration <= 0) return 1.0f;
return Math.min(1.0f, (float) chargeTick / chargeDuration);
}
/**
* Get interpolated charge progress for smooth rendering.
*/
public float getInterpolatedChargeProgress(float partialTicks) {
if (chargeDuration <= 0) return 1.0f;
float prevProgress = Math.max(0, (float) (chargeTick - 1) / chargeDuration);
float currProgress = Math.min(1.0f, (float) chargeTick / chargeDuration);
return prevProgress + (currProgress - prevProgress) * partialTicks;
}
// ==================== GETTERS ====================
public float getSpeed() {
@@ -214,6 +407,14 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
this.homing = !nbt.hasKey("Homing") || nbt.getBoolean("Homing");
this.homingStrength = nbt.hasKey("HomingStrength") ? nbt.getFloat("HomingStrength") : 0.15f;
this.homingRange = nbt.hasKey("HomingRange") ? nbt.getFloat("HomingRange") : 20.0f;
// Charging state
boolean isCharging = nbt.hasKey("Charging") && nbt.getBoolean("Charging");
this.charging = isCharging;
this.dataWatcher.updateObject(DW_CHARGING, (byte) (isCharging ? 1 : 0));
this.chargeDuration = nbt.hasKey("ChargeDuration") ? nbt.getInteger("ChargeDuration") : 40;
this.chargeTick = nbt.hasKey("ChargeTick") ? nbt.getInteger("ChargeTick") : 0;
this.anchorPoint = nbt.hasKey("AnchorPoint") ? AnchorPoint.fromId(nbt.getInteger("AnchorPoint")) : AnchorPoint.FRONT;
this.targetSize = nbt.hasKey("TargetSize") ? nbt.getFloat("TargetSize") : this.size;
}
@Override
@@ -222,5 +423,11 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
nbt.setBoolean("Homing", homing);
nbt.setFloat("HomingStrength", homingStrength);
nbt.setFloat("HomingRange", homingRange);
// Charging state
nbt.setBoolean("Charging", isCharging());
nbt.setInteger("ChargeDuration", chargeDuration);
nbt.setInteger("ChargeTick", chargeTick);
nbt.setInteger("AnchorPoint", anchorPoint.getId());
nbt.setFloat("TargetSize", targetSize);
}
}
@@ -30,7 +30,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
protected int innerColor = 0xFFFFFF;
protected int outerColor = 0x8888FF;
protected boolean outerColorEnabled = true;
protected float outerColorWidth = 1.8f;
protected float outerColorWidth = 0.4f; // Additive offset from inner size
protected float rotationSpeed = 4.0f;
// ==================== COMBAT PROPERTIES ====================
@@ -48,6 +48,16 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
protected float explosionRadius = 3.0f;
protected float explosionDamageFalloff = 0.5f;
// ==================== LIGHTNING EFFECT PROPERTIES ====================
protected boolean lightningEffect = false;
protected float lightningDensity = 0.15f; // Bolts spawned per tick (0.15 = ~15% chance per frame)
protected float lightningRadius = 0.5f; // Max distance lightning can arc from center
protected int lightningFadeTime = 6; // Ticks before lightning fades out
// Client-side lightning state (not saved to NBT)
@cpw.mods.fml.relauncher.SideOnly(cpw.mods.fml.relauncher.Side.CLIENT)
public transient Object lightningState; // Actually AttachedLightningRenderer.LightningState
// ==================== LIFESPAN ====================
protected float maxDistance = 30.0f;
protected int maxLifetime = 200;
@@ -93,6 +103,27 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
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,
damage, knockback, knockbackUp,
explosive, explosionRadius, explosionDamageFalloff,
stunDuration, slowDuration, slowLevel,
maxDistance, maxLifetime,
false, 0.15f, 0.5f, 6); // Default: no lightning, low density, small radius, 6 tick fade
}
/**
* Initialize common properties with lightning effect support.
*/
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,
float damage, float knockback, float knockbackUp,
boolean explosive, float explosionRadius, float explosionDamageFalloff,
int stunDuration, int slowDuration, int slowLevel,
float maxDistance, int maxLifetime,
boolean lightningEffect, float lightningDensity, float lightningRadius, int lightningFadeTime) {
this.setPosition(x, y, z);
this.startX = x;
this.startY = y;
@@ -129,6 +160,12 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
this.maxLifetime = maxLifetime;
// deathWorldTime will be set on first tick when world is available
// Lightning
this.lightningEffect = lightningEffect;
this.lightningDensity = lightningDensity;
this.lightningRadius = lightningRadius;
this.lightningFadeTime = lightningFadeTime;
// Initialize render size
this.renderCurrentSize = size;
this.prevRenderSize = size;
@@ -417,6 +454,24 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
return this.prevRenderSize + (this.renderCurrentSize - this.prevRenderSize) * partialTicks;
}
// ==================== LIGHTNING GETTERS ====================
public boolean hasLightningEffect() {
return lightningEffect;
}
public float getLightningDensity() {
return lightningDensity;
}
public float getLightningRadius() {
return lightningRadius;
}
public int getLightningFadeTime() {
return lightningFadeTime;
}
// ==================== BRIGHTNESS ====================
@Override
@@ -452,7 +507,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
this.innerColor = nbt.getInteger("InnerColor");
this.outerColor = nbt.getInteger("OuterColor");
this.outerColorEnabled = !nbt.hasKey("OuterColorEnabled") || nbt.getBoolean("OuterColorEnabled");
this.outerColorWidth = nbt.hasKey("OuterColorWidth") ? nbt.getFloat("OuterColorWidth") : 1.8f;
this.outerColorWidth = nbt.hasKey("OuterColorWidth") ? nbt.getFloat("OuterColorWidth") : 0.4f;
this.rotationSpeed = nbt.hasKey("RotationSpeed") ? nbt.getFloat("RotationSpeed") : 4.0f;
this.damage = nbt.getFloat("Damage");
@@ -482,6 +537,12 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
this.motionY = nbt.getDouble("MotionY");
this.motionZ = nbt.getDouble("MotionZ");
// Lightning
this.lightningEffect = nbt.getBoolean("LightningEffect");
this.lightningDensity = nbt.hasKey("LightningDensity") ? nbt.getFloat("LightningDensity") : 0.15f;
this.lightningRadius = nbt.hasKey("LightningRadius") ? nbt.getFloat("LightningRadius") : 0.5f;
this.lightningFadeTime = nbt.hasKey("LightningFadeTime") ? nbt.getInteger("LightningFadeTime") : 6;
if (this.worldObj != null && this.worldObj.isRemote) {
this.renderCurrentSize = this.size;
this.prevRenderSize = this.size;
@@ -525,6 +586,12 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
nbt.setDouble("MotionX", motionX);
nbt.setDouble("MotionY", motionY);
nbt.setDouble("MotionZ", motionZ);
// Lightning
nbt.setBoolean("LightningEffect", lightningEffect);
nbt.setFloat("LightningDensity", lightningDensity);
nbt.setFloat("LightningRadius", lightningRadius);
nbt.setInteger("LightningFadeTime", lightningFadeTime);
}
/**
@@ -0,0 +1,328 @@
package kamkeel.npcs.util;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.Vec3;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Frame;
import noppes.npcs.controllers.data.FramePart;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.entity.data.ModelScalePart;
/**
* Utility class for calculating world positions based on anchor points.
* Supports both EntityNPCInterface and EntityPlayer with animation and model size awareness.
*/
public class AnchorPointHelper {
// Default biped model constants (in model units, 1 unit = 1/16 block)
private static final float MODEL_SCALE = 1f / 16f;
// Shoulder position relative to model origin
private static final float SHOULDER_Y = 2f;
private static final float SHOULDER_X_OFFSET = 5f; // Distance from center to shoulder
// Palm position (in arm's local space, relative to shoulder)
// Arm is 12 units long; palm is near the end
private static final float PALM_DOWN = 11f; // Distance down the arm to palm center
private static final float PALM_FORWARD = 2f; // Forward offset to palm surface (not center of hand)
private static final float PALM_INWARD = 0f; // Lateral offset (0 = centered on arm)
// Default height offsets as fraction of entity height
private static final float FRONT_HEIGHT = 0.7f;
private static final float CENTER_HEIGHT = 0.5f;
private static final float ARM_HEIGHT = 0.75f;
private static final float ABOVE_HEAD_HEIGHT = 1.2f;
private static final float CHEST_HEIGHT = 0.65f;
// Distance in front for FRONT anchor
private static final float DEFAULT_FRONT_DISTANCE = 1.0f;
// Fallback arm positioning (when no animation, arms hang at sides)
private static final float FALLBACK_LATERAL = 0.35f; // Distance from body center to arm
private static final float FALLBACK_FORWARD = 0.1f; // Slight forward offset
private static final float FALLBACK_ARM_HEIGHT = 0.45f; // Hand height when arms hang down (near hip)
/**
* Calculate world position for an anchor point on an entity.
*/
public static Vec3 calculateAnchorPosition(EntityLivingBase entity, AnchorPoint anchor) {
return calculateAnchorPosition(entity, anchor, DEFAULT_FRONT_DISTANCE);
}
/**
* Calculate world position for an anchor point with custom front offset.
*/
public static Vec3 calculateAnchorPosition(EntityLivingBase entity, AnchorPoint anchor, float frontOffset) {
float scale = getModelScale(entity);
float height = entity.height;
double x = entity.posX;
double y = entity.posY;
double z = entity.posZ;
float headYaw = (float) Math.toRadians(entity.rotationYawHead);
float bodyYaw = (float) Math.toRadians(entity.renderYawOffset);
switch (anchor) {
case FRONT:
x -= Math.sin(headYaw) * frontOffset * scale;
y += height * FRONT_HEIGHT;
z += Math.cos(headYaw) * frontOffset * scale;
break;
case CENTER:
y += height * CENTER_HEIGHT;
break;
case RIGHT_HAND:
return calculateHandPosition(entity, true, scale);
case LEFT_HAND:
return calculateHandPosition(entity, false, scale);
case ABOVE_HEAD:
y += height * ABOVE_HEAD_HEIGHT;
break;
case CHEST:
y += height * CHEST_HEIGHT;
break;
}
return Vec3.createVectorHelper(x, y, z);
}
/**
* Get model scale factor for an entity.
* NPCs have configurable model size, players use default scale.
*/
private static float getModelScale(EntityLivingBase entity) {
if (entity instanceof EntityNPCInterface) {
int modelSize = ((EntityNPCInterface) entity).display.modelSize;
return modelSize / 5f; // modelSize 5 = 100% scale
}
return 1f;
}
// Default arm scale (no scaling)
private static final ModelScalePart DEFAULT_ARM_SCALE = new ModelScalePart();
/**
* Get arm scale for an entity.
* EntityCustomNpc has per-part scaling, others use default (1,1,1).
*/
private static ModelScalePart getArmScale(EntityLivingBase entity) {
if (entity instanceof EntityCustomNpc) {
return ((EntityCustomNpc) entity).modelData.modelScale.arms;
}
return DEFAULT_ARM_SCALE;
}
/**
* Calculate hand position using animation data if available.
*/
private static Vec3 calculateHandPosition(EntityLivingBase entity, boolean rightHand, float scale) {
// Try to get animated position first
Vec3 animatedPos = getAnimatedHandPosition(entity, rightHand, scale);
if (animatedPos != null) {
return animatedPos;
}
// Fallback to static position
return calculateFallbackHandPosition(entity, rightHand, scale);
}
/**
* Calculate hand position from animation data.
* Works for both NPCs and Players.
*/
private static Vec3 getAnimatedHandPosition(EntityLivingBase entity, boolean rightHand, float scale) {
AnimationData animData = AnimationData.getData(entity);
if (animData == null || !animData.isActive() || animData.animation == null) {
return null;
}
Frame frame = (Frame) animData.animation.currentFrame();
if (frame == null) {
return null;
}
EnumAnimationPart armPart = rightHand ? EnumAnimationPart.RIGHT_ARM : EnumAnimationPart.LEFT_ARM;
FramePart part = frame.frameParts.get(armPart);
if (part == null) {
return null;
}
// Get arm scale for EntityCustomNpc
ModelScalePart armScale = getArmScale(entity);
// Get rotation and pivot values
float[] rotations = getRotations(part, entity);
float[] pivots = getPivots(part, entity);
// Shoulder position in model space
float shoulderX = rightHand ? -SHOULDER_X_OFFSET : SHOULDER_X_OFFSET;
float shoulderY = SHOULDER_Y;
float shoulderZ = 0f;
// Add pivot offsets
shoulderX += pivots[0];
shoulderY += pivots[1];
shoulderZ += pivots[2];
// Palm offset in arm's local space (before rotation)
// Apply arm scaling to the palm position
float palmX = (rightHand ? -PALM_INWARD : PALM_INWARD) * armScale.scaleX;
float palmY = PALM_DOWN * armScale.scaleY;
float palmZ = PALM_FORWARD * armScale.scaleZ;
// Apply arm rotations (order: X -> Y -> Z, matching GL's reverse application)
double hx = palmX, hy = palmY, hz = palmZ;
// X rotation first
double cosX = Math.cos(rotations[0]);
double sinX = Math.sin(rotations[0]);
double newY = hy * cosX - hz * sinX;
double newZ = hy * sinX + hz * cosX;
hy = newY;
hz = newZ;
// Y rotation second
double cosY = Math.cos(rotations[1]);
double sinY = Math.sin(rotations[1]);
double newX = hx * cosY + hz * sinY;
newZ = -hx * sinY + hz * cosY;
hx = newX;
hz = newZ;
// Z rotation last
double cosZ = Math.cos(rotations[2]);
double sinZ = Math.sin(rotations[2]);
newX = hx * cosZ - hy * sinZ;
newY = hx * sinZ + hy * cosZ;
hx = newX;
hy = newY;
// Combine shoulder + rotated hand offset
double modelX = shoulderX + hx;
double modelY = shoulderY + hy;
double modelZ = shoulderZ + hz;
// Convert to blocks and apply model scale
double blockX = modelX * MODEL_SCALE * scale;
double blockY = modelY * MODEL_SCALE * scale;
double blockZ = modelZ * MODEL_SCALE * scale;
// Apply body yaw rotation
// Renderer uses glRotate(180 - yaw), so: cos(180-yaw) = -cos(yaw), sin(180-yaw) = sin(yaw)
// Y-axis rotation: x' = x*cos + z*sin, z' = -x*sin + z*cos
// Substituting: x' = -x*cos(yaw) + z*sin(yaw), z' = -x*sin(yaw) - z*cos(yaw)
float bodyYaw = (float) Math.toRadians(entity.renderYawOffset);
double cosYaw = Math.cos(bodyYaw);
double sinYaw = Math.sin(bodyYaw);
double worldOffsetX = blockX * cosYaw + blockZ * sinYaw;
double worldOffsetZ = blockX * sinYaw - blockZ * cosYaw;
// Calculate shoulder height based on entity and scale
float shoulderHeight = entity.height * ARM_HEIGHT;
// Final world position
double worldX = entity.posX + worldOffsetX;
double worldY = entity.posY + shoulderHeight - blockY;
double worldZ = entity.posZ + worldOffsetZ;
return Vec3.createVectorHelper(worldX, worldY, worldZ);
}
/**
* Get rotation values from FramePart.
* Uses interpolated values on client, raw values on server.
*/
private static float[] getRotations(FramePart part, EntityLivingBase entity) {
if (entity.worldObj.isRemote) {
// Client side - use interpolated values (already in radians)
part.interpolateAngles();
return part.prevRotations;
} else {
// Server side - convert raw degrees to radians
float pi = (float) Math.PI / 180f;
return new float[]{
part.rotation[0] * pi,
part.rotation[1] * pi,
part.rotation[2] * pi
};
}
}
/**
* Get pivot values from FramePart.
* Uses interpolated values on client, raw values on server.
*/
private static float[] getPivots(FramePart part, EntityLivingBase entity) {
if (entity.worldObj.isRemote) {
// Client side - use interpolated values
part.interpolateOffset();
return part.prevPivots;
} else {
// Server side - use raw values
return part.pivot;
}
}
/**
* Calculate fallback hand position when no animation is active.
* Represents arms hanging at sides in default idle pose.
*/
private static Vec3 calculateFallbackHandPosition(EntityLivingBase entity, boolean rightHand, float scale) {
float bodyYaw = (float) Math.toRadians(entity.renderYawOffset);
// Get arm scale for EntityCustomNpc
ModelScalePart armScale = getArmScale(entity);
// Perpendicular direction for lateral offset (right = +90°, left = -90° from body facing)
float perpYaw = bodyYaw + (rightHand ? (float) (Math.PI / 2) : (float) (-Math.PI / 2));
// Calculate lateral offset - arms hang at sides
// Scale by model size, but not by arm scale (lateral distance is fixed by skeleton)
double lateralX = -Math.sin(perpYaw) * FALLBACK_LATERAL * scale;
double lateralZ = Math.cos(perpYaw) * FALLBACK_LATERAL * scale;
// Small forward offset
double forwardX = -Math.sin(bodyYaw) * FALLBACK_FORWARD * scale;
double forwardZ = Math.cos(bodyYaw) * FALLBACK_FORWARD * scale;
// Arm length affects vertical position - longer arms = lower hands
double armLengthOffset = armScale.scaleY * 0.3 * scale;
double x = entity.posX + lateralX + forwardX;
double y = entity.posY + entity.height * FALLBACK_ARM_HEIGHT + armLengthOffset;
double z = entity.posZ + lateralZ + forwardZ;
return Vec3.createVectorHelper(x, y, z);
}
/**
* Get default height multiplier for an anchor point.
*/
public static float getHeightMultiplier(AnchorPoint anchor) {
switch (anchor) {
case FRONT:
return FRONT_HEIGHT;
case CENTER:
return CENTER_HEIGHT;
case RIGHT_HAND:
case LEFT_HAND:
return ARM_HEIGHT;
case ABOVE_HEAD:
return ABOVE_HEAD_HEIGHT;
case CHEST:
return CHEST_HEIGHT;
default:
return FRONT_HEIGHT;
}
}
}
+163 -42
View File
@@ -78,6 +78,16 @@ public class DataAbilities {
*/
private transient List<Long> recentHitTimes = new ArrayList<>();
/**
* Locked rotation values for ACTIVE phase with lockMovement.
* Stored when entering ACTIVE phase, applied every tick to prevent rotation changes.
*/
private transient boolean rotationLocked = false;
private transient float lockedYaw = 0;
private transient float lockedYawHead = 0;
private transient float lockedRenderYawOffset = 0;
private transient float lockedPitch = 0;
// ═══════════════════════════════════════════════════════════════════
// CONSTRUCTOR
// ═══════════════════════════════════════════════════════════════════
@@ -136,9 +146,15 @@ public class DataAbilities {
// Remove telegraph - it has served its purpose
removeTelegraph(currentAbility);
// Lock rotation if lockMovement is true
// Capture current rotation values to force them every tick
if (currentAbility.isLockMovement()) {
captureLockedRotation();
}
// Play active sound and animation
playAbilitySound(currentAbility.getActiveSound());
playAbilityAnimation(currentAbility.getActiveAnimationId());
playAbilityAnimation(currentAbility.getActiveAnimation());
// Fire execute event (cancelable)
AbilityEvent.ExecuteEvent executeEvent = new AbilityEvent.ExecuteEvent(
@@ -150,26 +166,52 @@ public class DataAbilities {
// Call onExecute
currentAbility.onExecute(npc, target, npc.worldObj);
// Check if ability completed during onExecute (signalCompletion was called)
if (currentAbility.getPhase() == AbilityPhase.IDLE) {
handleAbilityCompletion(target);
return;
}
}
currentAbility.onActiveTick(npc, target, npc.worldObj, currentAbility.getCurrentTick());
// Check if ability completed during onActiveTick (signalCompletion was called)
if (currentAbility.getPhase() == AbilityPhase.IDLE) {
handleAbilityCompletion(target);
return;
}
break;
case RECOVERY:
// Recovery phase - just wait
case DAZED:
// Dazed phase - NPC cannot attack, just wait for daze to end
break;
case IDLE:
// Ability completed
currentAbility.onComplete(npc, target);
// Fire complete event
AbilityEvent.CompleteEvent completeEvent = new AbilityEvent.CompleteEvent(
npc.wrappedNPC, currentAbility, target);
NpcAPI.EVENT_BUS.post(completeEvent);
onAbilityComplete();
// Ability completed (reached via tick() phase transition from DAZED)
handleAbilityCompletion(target);
break;
}
}
/**
* Handle ability completion - called when ability phase becomes IDLE.
* This can happen from:
* - signalCompletion() called in onExecute() or onActiveTick()
* - tick() transitioning from DAZED to IDLE
*/
private void handleAbilityCompletion(EntityLivingBase target) {
if (currentAbility == null) return;
// Call onComplete callback
currentAbility.onComplete(npc, target);
// Fire complete event
AbilityEvent.CompleteEvent completeEvent = new AbilityEvent.CompleteEvent(
npc.wrappedNPC, currentAbility, target);
NpcAPI.EVENT_BUS.post(completeEvent);
// Clean up and roll cooldown
onAbilityComplete();
// Clear AI pathfinding if ability is controlling movement
// But DON'T zero motion - let the ability set it if needed
@@ -186,9 +228,9 @@ public class DataAbilities {
}
}
// Lock look direction at target during ACTIVE phase only
if (shouldLockLookDirection() && target != null && target.isEntityAlive()) {
npc.getLookHelper().setLookPositionWithEntity(target, 30.0F, 30.0F);
// Unlock rotation when leaving ACTIVE phase
if (rotationLocked && currentAbility.getPhase() != AbilityPhase.ACTIVE) {
releaseLockedRotation();
}
}
}
@@ -202,13 +244,14 @@ public class DataAbilities {
// Stop any ability animation
stopAbilityAnimation();
// Release rotation lock
releaseLockedRotation();
// Calculate cooldown: random(min, max) + ability offset
int baseCooldown = minCooldown;
if (maxCooldown > minCooldown) {
baseCooldown = minCooldown + random.nextInt(maxCooldown - minCooldown + 1);
}
int totalCooldown = baseCooldown + currentAbility.getCooldownTicks();
cooldownEndTime = npc.worldObj.getTotalWorldTime() + totalCooldown;
int abilityCooldownOffset = currentAbility.getCooldownTicks();
rollCooldown();
// Add ability-specific cooldown offset
cooldownEndTime += abilityCooldownOffset;
currentAbility = null;
lastTarget = null;
@@ -340,7 +383,7 @@ public class DataAbilities {
playAbilitySound(ability.getWindUpSound());
// Play wind up animation if configured
playAbilityAnimation(ability.getWindUpAnimationId());
playAbilityAnimation(ability.getWindUpAnimation());
return true;
}
@@ -358,18 +401,23 @@ public class DataAbilities {
* Play an animation on the NPC by ID.
* Public so abilities can trigger animations directly if needed.
*
* @param animationId The global animation ID to play, or -1 for none
* @param animation The animation to play, or null if none
*/
public void playAbilityAnimation(int animationId) {
if (animationId < 0) return;
public void playAbilityAnimation(Animation animation) {
if (animation == null || animation.id < 0) return;
if (AnimationController.Instance == null) return;
Animation animation = AnimationController.Instance.animations.get(animationId);
if (animation != null) {
npc.display.animationData.setEnabled(true);
npc.display.animationData.setAnimation(animation);
npc.display.animationData.updateClient();
}
npc.display.animationData.setEnabled(true);
npc.display.animationData.setAnimation(animation);
npc.display.animationData.updateClient();
}
public void playAbilityAnimation(int animation) {
if (animation < 0) return;
if (AnimationController.Instance == null) return;
if (AnimationController.Instance.get(animation) == null) return;
playAbilityAnimation((Animation) AnimationController.Instance.get(animation));
}
/**
@@ -515,8 +563,8 @@ public class DataAbilities {
/**
* Interrupt the currently executing ability.
* The ability will transition to RECOVERY phase (dazed state) and continue ticking.
* When RECOVERY completes, the ability will move to IDLE and onAbilityComplete() is called.
* If interrupted during WINDUP, the ability will transition to DAZED phase.
* When DAZED completes, the ability will move to IDLE and onAbilityComplete() is called.
*/
public void interruptCurrentAbility(DamageSource source, float damage) {
if (currentAbility != null) {
@@ -526,16 +574,19 @@ public class DataAbilities {
// Stop any ability animation
stopAbilityAnimation();
// Release rotation lock
releaseLockedRotation();
// Fire interrupt event
AbilityEvent.InterruptEvent interruptEvent = new AbilityEvent.InterruptEvent(
npc.wrappedNPC, currentAbility, lastTarget, source, damage);
NpcAPI.EVENT_BUS.post(interruptEvent);
currentAbility.onInterrupt(npc, source, damage);
currentAbility.interrupt(); // This now transitions to RECOVERY, not IDLE
currentAbility.interrupt(); // Transitions to DAZED if interrupted during WINDUP
// Don't clear currentAbility - let it tick through RECOVERY phase
// When RECOVERY ends and phase becomes IDLE, onAbilityComplete() will be called
// Don't clear currentAbility - let it tick through DAZED phase
// When DAZED ends and phase becomes IDLE, onAbilityComplete() will be called
}
}
@@ -546,6 +597,7 @@ public class DataAbilities {
if (currentAbility != null) {
removeTelegraph(currentAbility);
stopAbilityAnimation();
releaseLockedRotation();
currentAbility.interrupt();
currentAbility = null;
lastTarget = null;
@@ -603,10 +655,13 @@ public class DataAbilities {
/**
* Reset all runtime state (cooldowns, current ability).
* Called when NPC respawns or combat ends.
* Rolls cooldown so NPC doesn't immediately use an ability.
*/
public void reset() {
stopCurrentAbility();
resetCooldown();
// Roll cooldown so NPC doesn't immediately attack after reset
rollCooldown();
// Reset execution state on all abilities
for (Ability ability : abilities) {
@@ -614,6 +669,18 @@ public class DataAbilities {
}
}
/**
* Roll a new cooldown using the min/max range.
* Called after ability completes and on reset.
*/
private void rollCooldown() {
int baseCooldown = minCooldown;
if (maxCooldown > minCooldown) {
baseCooldown = minCooldown + random.nextInt(maxCooldown - minCooldown + 1);
}
cooldownEndTime = npc.worldObj.getTotalWorldTime() + baseCooldown;
}
// ═══════════════════════════════════════════════════════════════════
// ABILITY LIST MANAGEMENT
// ═══════════════════════════════════════════════════════════════════
@@ -678,7 +745,7 @@ public class DataAbilities {
* Rules:
* - WINDUP phase: Block AI if lockMovement is true
* - ACTIVE phase: Block AI if lockMovement OR hasAbilityMovement is true
* - RECOVERY phase: Block AI if lockMovement is true
* - DAZED phase: Always block AI (NPC is stunned)
*/
public boolean isAbilityControllingMovement() {
if (currentAbility == null || !currentAbility.isExecuting()) {
@@ -699,9 +766,9 @@ public class DataAbilities {
// - hasAbilityMovement is true (ability is moving the NPC itself)
return currentAbility.isLockMovement() || currentAbility.hasAbilityMovement();
case RECOVERY:
// During recovery, block if lockMovement is set
return currentAbility.isLockMovement();
case DAZED:
// During dazed phase, always block - NPC is stunned from interrupt
return true;
default:
return false;
@@ -711,7 +778,7 @@ public class DataAbilities {
/**
* Check if NPC's look direction should be locked to target.
* Only locks during ACTIVE phase when lockMovement is true.
* This allows the NPC to freely track target during WINDUP and RECOVERY.
* This allows the NPC to freely track target during WINDUP and DAZED.
*/
public boolean shouldLockLookDirection() {
if (currentAbility == null || !currentAbility.isExecuting()) {
@@ -737,6 +804,60 @@ public class DataAbilities {
return phase == AbilityPhase.WINDUP || phase == AbilityPhase.ACTIVE;
}
// ═══════════════════════════════════════════════════════════════════
// ROTATION LOCKING
// ═══════════════════════════════════════════════════════════════════
/**
* Capture current rotation values to lock NPC's look direction.
* Called when entering ACTIVE phase with lockMovement enabled.
*/
private void captureLockedRotation() {
lockedYaw = npc.rotationYaw;
lockedYawHead = npc.rotationYawHead;
lockedRenderYawOffset = npc.renderYawOffset;
lockedPitch = npc.rotationPitch;
rotationLocked = true;
}
/**
* Release the rotation lock.
* Called when leaving ACTIVE phase or ability completes.
*/
private void releaseLockedRotation() {
rotationLocked = false;
}
/**
* Apply locked rotation values to the NPC.
* Called AFTER super.onLivingUpdate() in EntityNPCInterface to override
* any rotation changes made by the look helper or AI tasks.
*/
public void applyLockedRotation() {
if (!rotationLocked) {
return;
}
// Force rotation back to locked values
npc.rotationYaw = lockedYaw;
npc.rotationYawHead = lockedYawHead;
npc.renderYawOffset = lockedRenderYawOffset;
npc.rotationPitch = lockedPitch;
// Also set prev values to prevent interpolation jitter
npc.prevRotationYaw = lockedYaw;
npc.prevRotationYawHead = lockedYawHead;
npc.prevRenderYawOffset = lockedRenderYawOffset;
npc.prevRotationPitch = lockedPitch;
}
/**
* Check if rotation is currently locked.
*/
public boolean isRotationLocked() {
return rotationLocked;
}
// ═══════════════════════════════════════════════════════════════════
// NBT SERIALIZATION
// ═══════════════════════════════════════════════════════════════════
@@ -144,11 +144,12 @@ import noppes.npcs.client.renderer.RenderNpcCrystal;
import noppes.npcs.client.renderer.RenderNpcDragon;
import noppes.npcs.client.renderer.RenderNpcSlime;
import noppes.npcs.client.renderer.RenderProjectile;
import kamkeel.npcs.client.renderer.RenderAbilityOrbCube;
import kamkeel.npcs.client.renderer.RenderAbilityOrb;
import kamkeel.npcs.client.renderer.RenderAbilityDisc;
import kamkeel.npcs.client.renderer.RenderAbilityLaser;
import kamkeel.npcs.client.renderer.RenderAbilityBeam;
import kamkeel.npcs.client.renderer.RenderAbilitySweeper;
import kamkeel.npcs.client.renderer.lightning.LightningHandler;
import kamkeel.npcs.entity.EntityAbilityOrb;
import kamkeel.npcs.entity.EntityAbilityDisc;
import kamkeel.npcs.entity.EntityAbilityLaser;
@@ -261,8 +262,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityNpcDragon.class, new RenderNpcDragon(new ModelNpcDragon(0.0F), 0.5F));
RenderingRegistry.registerEntityRenderingHandler(EntityNpcSlime.class, new RenderNpcSlime(new ModelNpcSlime(16), new ModelNpcSlime(0), 0.25F));
RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, new RenderProjectile());
// RenderingRegistry.registerEntityRenderingHandler(EntityAbilityOrb.class, new RenderAbilityOrb());
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityOrb.class, new RenderAbilityOrbCube());
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityOrb.class, new RenderAbilityOrb());
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityDisc.class, new RenderAbilityDisc());
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityLaser.class, new RenderAbilityLaser());
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityBeam.class, new RenderAbilityBeam());
@@ -340,6 +340,9 @@ public class ClientProxy extends CommonProxy {
TelegraphManager.initClient();
MinecraftForge.EVENT_BUS.register(new TelegraphRenderer());
// Lightning effect rendering system
MinecraftForge.EVENT_BUS.register(new LightningHandler());
if (ConfigClient.InventoryGuiEnabled) {
MinecraftForge.EVENT_BUS.register(new TabRegistry());
if (TabRegistry.getTabList().isEmpty()) {
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import kamkeel.npcs.client.renderer.lightning.LightningBolt;
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
@@ -115,6 +116,9 @@ public class ClientTickHandler {
if (TelegraphManager.ClientInstance != null) {
TelegraphManager.ClientInstance.tick(mc.theWorld);
}
// Update lightning bolts for ability effects
LightningBolt.updateAll();
if (Minecraft.getMinecraft().thePlayer != null && (prevWidth != mc.displayWidth || prevHeight != mc.displayHeight)) {
prevWidth = mc.displayWidth;
prevHeight = mc.displayHeight;
@@ -25,10 +25,10 @@ public class SubGuiColorSelector extends SubGuiInterface implements ITextfieldLi
public int color;
public SubGuiColorSelector(int color) {
xSize = 176;
xSize = 182;
ySize = 222;
this.color = color;
setBackground("smallbg.png");
setBackground("menubg.png");
}
@Override
@@ -40,7 +40,7 @@ public class SubGuiColorSelector extends SubGuiInterface implements ITextfieldLi
this.addTextField(textfield = new GuiNpcTextField(0, this, guiLeft + 53, guiTop + 20, 70, 20, getColor()));
textfield.setTextColor(color);
addButton(new GuiNpcButton(66, guiLeft + 112, guiTop + 198, 60, 20, "gui.done"));
addButton(new GuiNpcButton(66, guiLeft + 112, guiTop + 175, 60, 20, "gui.done"));
}
public String getColor() {
@@ -73,15 +73,15 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
addLabel(new GuiNpcLabel(100, "gui.enabled", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(100, guiLeft + 55, y, 50, 20, new String[]{"gui.no", "gui.yes"}, abilitiesEnabled ? 1 : 0));
// Cooldown range: Min Cooldown and Max Cooldown
// Cooldown range: Min Cooldown and Max Cooldown (spaced apart more)
addLabel(new GuiNpcLabel(101, "ability.minCooldown", guiLeft + 115, y + 5));
GuiNpcTextField minField = new GuiNpcTextField(101, this, fontRendererObj, guiLeft + 185, y, 40, 20, String.valueOf(minCooldown));
GuiNpcTextField minField = new GuiNpcTextField(101, this, fontRendererObj, guiLeft + 165, y, 40, 20, String.valueOf(minCooldown));
minField.setIntegersOnly();
minField.setMinMaxDefault(0, 10000, 20);
addTextField(minField);
addLabel(new GuiNpcLabel(102, "ability.maxCooldown", guiLeft + 235, y + 5));
GuiNpcTextField maxField = new GuiNpcTextField(102, this, fontRendererObj, guiLeft + 305, y, 40, 20, String.valueOf(maxCooldown));
addLabel(new GuiNpcLabel(102, "ability.maxCooldown", guiLeft + 260, y + 5));
GuiNpcTextField maxField = new GuiNpcTextField(102, this, fontRendererObj, guiLeft + 310, y, 40, 20, String.valueOf(maxCooldown));
maxField.setIntegersOnly();
maxField.setMinMaxDefault(0, 10000, 60);
addTextField(maxField);
@@ -123,6 +123,14 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
// Load button (under the add/remove arrows)
addButton(new GuiNpcButton(75, centerX, y + 90, 40, 20, "gui.load"));
// On/Off toggle for selected ability (under Load button)
if (selectedAbilityIndex >= 0 && selectedAbilityIndex < npcAbilities.size()) {
Ability selectedAbility = npcAbilities.get(selectedAbilityIndex);
GuiNpcButton toggleBtn = new GuiNpcButton(77, centerX, y + 112, 40, 20,
new String[]{"gui.off", "gui.on"}, selectedAbility.isEnabled() ? 1 : 0);
addButton(toggleBtn);
}
// Right side buttons: Edit and Up/Down carrots with Save button
addButton(new GuiNpcButton(72, guiLeft + 210, y + 145, 55, 20, "gui.edit"));
getButton(72).setEnabled(selectedAbilityIndex >= 0);
@@ -243,6 +251,19 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
return;
}
// Toggle selected ability on/off
if (id == 77) {
if (selectedAbilityIndex >= 0 && selectedAbilityIndex < npcAbilities.size()) {
Ability ability = npcAbilities.get(selectedAbilityIndex);
ability.setEnabled(((GuiNpcButton) guibutton).getValue() == 1);
updateNpcAbilitiesList();
selectAbilityByIndex(selectedAbilityIndex);
initGui();
save();
}
return;
}
initGui();
}
@@ -4,6 +4,9 @@ import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.Condition;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.Frame;
import noppes.npcs.controllers.AnimationController;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
@@ -61,8 +64,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Timing
protected int cooldownTicks;
protected int windUpTicks;
protected int activeTicks;
protected int recoveryTicks;
protected int dazedTicks;
// ═══════════════════════════════════════════════════════════════════════════
// CACHED VALUES - Target Tab
@@ -115,8 +117,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Timing
this.cooldownTicks = ability.getCooldownTicks();
this.windUpTicks = ability.getWindUpTicks();
this.activeTicks = ability.getActiveTicks();
this.recoveryTicks = ability.getRecoveryTicks();
this.dazedTicks = ability.getDazedTicks();
// Target
this.minRange = ability.getMinRange();
@@ -127,8 +128,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Effects
this.windUpSound = ability.getWindUpSound();
this.activeSound = ability.getActiveSound();
this.windUpAnimationId = ability.getWindUpAnimationId();
this.activeAnimationId = ability.getActiveAnimationId();
this.windUpAnimationId = ability.getWindUpAnimation() != null ? ability.getWindUpAnimation().getID() : -1;
this.activeAnimationId = ability.getActiveAnimation() != null ? ability.getActiveAnimation().getID() : -1;
// Telegraph
this.showTelegraph = ability.isShowTelegraph();
@@ -142,7 +143,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
this.hasTypeSettings = ability.hasTypeSettings();
this.hasVisualSettings = hasVisualSettings();
setBackground("menubg.png");
setBackground("menubg.png", 217);
xSize = 356;
ySize = 200;
}
@@ -250,13 +251,26 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
addTextField(weightField);
addLabel(new GuiNpcLabel(5, "ability.lockMove", col2LabelX, y + 5));
addButton(new GuiNpcButton(16, col2FieldX, y, 40, 20, new String[]{"gui.no", "gui.yes"}, lockMovement ? 1 : 0));
GuiNpcButton lockMoveBtn = new GuiNpcButton(16, col2FieldX, y, 40, 20, new String[]{"gui.no", "gui.yes"}, lockMovement ? 1 : 0);
lockMoveBtn.setHoverText("ability.hover.lockMove");
addButton(lockMoveBtn);
y += 24;
// Row 3: Interruptible
// Row 3: Interruptible + Dazed Ticks (only if interruptible)
addLabel(new GuiNpcLabel(6, "ability.interruptible", col1LabelX, y + 5));
addButton(new GuiNpcButton(14, guiLeft + 85, y, 40, 20, new String[]{"gui.no", "gui.yes"}, interruptible ? 1 : 0));
GuiNpcButton interruptBtn = new GuiNpcButton(14, guiLeft + 85, y, 40, 20, new String[]{"gui.no", "gui.yes"}, interruptible ? 1 : 0);
interruptBtn.setHoverText("ability.hover.interruptible");
addButton(interruptBtn);
// Only show dazed ticks if interruptible is enabled
if (interruptible) {
addLabel(new GuiNpcLabel(12, "ability.dazed", col2LabelX, y + 5));
GuiNpcTextField dazedField = new GuiNpcTextField(13, this, fontRendererObj, col2FieldX, y, 40, 20, String.valueOf(dazedTicks));
dazedField.setIntegersOnly();
dazedField.setMinMaxDefault(0, 1000, 80);
addTextField(dazedField);
}
y += 28;
@@ -264,32 +278,24 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
addLabel(new GuiNpcLabel(7, "ability.timing", col1LabelX, y));
y += 14;
// Row 4: Windup Ticks + Active Ticks
// 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);
addLabel(new GuiNpcLabel(11, "ability.active", col2LabelX, y + 5));
GuiNpcTextField activeField = new GuiNpcTextField(12, this, fontRendererObj, col2FieldX, y, 40, 20, String.valueOf(activeTicks));
activeField.setIntegersOnly();
activeField.setMinMaxDefault(1, 1000, 10);
addTextField(activeField);
y += 24;
// Row 5: Recovery Ticks + Cooldown Ticks
addLabel(new GuiNpcLabel(12, "ability.recovery", col1LabelX, y + 5));
GuiNpcTextField recoveryField = new GuiNpcTextField(13, this, fontRendererObj, col1FieldX, y, 40, 20, String.valueOf(recoveryTicks));
recoveryField.setIntegersOnly();
recoveryField.setMinMaxDefault(0, 1000, 20);
addTextField(recoveryField);
// Sync button - only show if windup animation is selected
if (windUpAnimationId >= 0) {
GuiNpcButton syncBtn = new GuiNpcButton(17, guiLeft + 115, y, 40, 20, "gui.sync");
syncBtn.setHoverText("ability.hover.sync");
addButton(syncBtn);
}
addLabel(new GuiNpcLabel(13, "ability.cooldown", col2LabelX, y + 5));
GuiNpcTextField cooldownField = new GuiNpcTextField(10, this, fontRendererObj, col2FieldX, y, 40, 20, String.valueOf(cooldownTicks));
cooldownField.setIntegersOnly();
cooldownField.setMinMaxDefault(0, 10000, 100);
cooldownField.setMinMaxDefault(0, 10000, 0);
addTextField(cooldownField);
}
@@ -395,7 +401,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
if (!targetingModeLocked) {
String[] targetingModes = getAvailableTargetingModes();
int selectedIndex = getTargetingModeIndex(targetingMode);
addButton(new GuiNpcButton(4, col1FieldX, y, 90, 20, targetingModes, selectedIndex));
GuiNpcButton targetBtn = new GuiNpcButton(4, col1FieldX, y, 90, 20, targetingModes, selectedIndex);
targetBtn.setHoverText("ability.hover.targeting");
addButton(targetBtn);
} else {
String modeName = "ability.target." + targetingMode.name().toLowerCase();
addLabel(new GuiNpcLabel(23, modeName, col1FieldX, y + 5));
@@ -542,7 +550,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Show Telegraph
addLabel(new GuiNpcLabel(41, "ability.showTelegraph", col1LabelX, y + 5));
addButton(new GuiNpcButton(20, guiLeft + 95, y, 40, 20, new String[]{"gui.no", "gui.yes"}, showTelegraph ? 1 : 0));
GuiNpcButton telegraphBtn = new GuiNpcButton(20, guiLeft + 95, y, 40, 20, new String[]{"gui.no", "gui.yes"}, showTelegraph ? 1 : 0);
telegraphBtn.setHoverText("ability.hover.showTelegraph");
addButton(telegraphBtn);
// Telegraph Type (separate column)
String typeKey = ability.getTelegraphType().name().toLowerCase();
@@ -552,20 +562,20 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
y += 24;
// Colors
addLabel(new GuiNpcLabel(44, "ability.windUpColor", col1LabelX, y + 5));
String windUpHex = String.format("%06X", windUpColor & 0xFFFFFF);
GuiNpcButton windUpColorBtn = new GuiNpcButton(22, guiLeft + 95, y, 55, 20, windUpHex);
windUpColorBtn.setEnabled(showTelegraph);
windUpColorBtn.setTextColor(windUpColor & 0xFFFFFF);
addButton(windUpColorBtn);
// Colors - only show when telegraph is enabled
if (showTelegraph) {
addLabel(new GuiNpcLabel(44, "ability.windUpColor", col1LabelX, y + 5));
String windUpHex = String.format("%06X", windUpColor & 0xFFFFFF);
GuiNpcButton windUpColorBtn = new GuiNpcButton(22, guiLeft + 95, y, 55, 20, windUpHex);
windUpColorBtn.setTextColor(windUpColor & 0xFFFFFF);
addButton(windUpColorBtn);
addLabel(new GuiNpcLabel(45, "ability.activeColor", guiLeft + 200, y + 5));
String activeHex = String.format("%06X", activeColor & 0xFFFFFF);
GuiNpcButton activeColorBtn = new GuiNpcButton(24, guiLeft + 280, y, 55, 20, activeHex);
activeColorBtn.setEnabled(showTelegraph);
activeColorBtn.setTextColor(activeColor & 0xFFFFFF);
addButton(activeColorBtn);
addLabel(new GuiNpcLabel(45, "ability.activeColor", guiLeft + 200, y + 5));
String activeHex = String.format("%06X", activeColor & 0xFFFFFF);
GuiNpcButton activeColorBtn = new GuiNpcButton(24, guiLeft + 280, y, 55, 20, activeHex);
activeColorBtn.setTextColor(activeColor & 0xFFFFFF);
addButton(activeColorBtn);
}
}
}
@@ -632,8 +642,12 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// General tab buttons
else if (id == 14) {
interruptible = ((GuiNpcButton) guibutton).getValue() == 1;
initGui(); // Refresh to show/hide dazed ticks field
} else if (id == 16) {
lockMovement = ((GuiNpcButton) guibutton).getValue() == 1;
} else if (id == 17) {
// Sync windup ticks with animation duration
syncWindupWithAnimation();
}
// Target tab - Targeting mode
@@ -764,10 +778,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
cooldownTicks = textField.getInteger();
} else if (id == 11) {
windUpTicks = textField.getInteger();
} else if (id == 12) {
activeTicks = textField.getInteger();
} else if (id == 13) {
recoveryTicks = textField.getInteger();
dazedTicks = textField.getInteger();
}
// Visual-specific fields (200+) - delegate to subclass
@@ -865,8 +877,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Timing
ability.setCooldownTicks(cooldownTicks);
ability.setWindUpTicks(windUpTicks);
ability.setActiveTicks(activeTicks);
ability.setRecoveryTicks(recoveryTicks);
ability.setDazedTicks(dazedTicks);
// Target
ability.setMinRange(minRange);
@@ -914,8 +925,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
this.cooldownTicks = ability.getCooldownTicks();
this.windUpTicks = ability.getWindUpTicks();
this.activeTicks = ability.getActiveTicks();
this.recoveryTicks = ability.getRecoveryTicks();
this.dazedTicks = ability.getDazedTicks();
this.minRange = ability.getMinRange();
this.maxRange = ability.getMaxRange();
@@ -929,6 +939,34 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
initGui();
}
// ═══════════════════════════════════════════════════════════════════════════
// SYNC ANIMATION
// ═══════════════════════════════════════════════════════════════════════════
/**
* Syncs windup ticks with the selected windup animation's total duration.
*/
private void syncWindupWithAnimation() {
if (windUpAnimationId < 0 || AnimationController.Instance == null) {
return;
}
Animation animation = (Animation) AnimationController.Instance.get(windUpAnimationId);
if (animation == null || animation.frames.isEmpty()) {
return;
}
// Calculate total duration by summing all frame durations
int totalDuration = 0;
for (Frame frame : animation.frames) {
totalDuration += frame.getDuration();
}
// Update the cached value and refresh GUI
windUpTicks = totalDuration;
initGui();
}
// ═══════════════════════════════════════════════════════════════════════════
// HELPER METHODS FOR SUBCLASSES
// ═══════════════════════════════════════════════════════════════════════════
@@ -1,10 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityCharge;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Charge ability type-specific settings.
@@ -41,10 +46,30 @@ public class SubGuiAbilityCharge extends SubGuiAbilityConfig {
y += 24;
// Row 3: Hit Width
// Row 3: Hit Width + Effects
addLabel(new GuiNpcLabel(104, "ability.hitWidth", labelX, y + 5));
addTextField(createFloatField(104, fieldX, y, 50, charge.getHitWidth()));
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
}
@Override
protected void handleTypeButton(int id, GuiNpcButton button) {
if (id == 150) {
setSubGui(new SubGuiAbilityEffects(charge.getEffects()));
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
charge.setEffects(result);
}
}
}
@Override
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityCutter;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Cutter ability type-specific settings.
@@ -57,25 +61,26 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
// Row 4: Sweep Mode + Piercing
addLabel(new GuiNpcLabel(106, "ability.sweepMode", labelX, y + 5));
String[] sweepModes = {"Swipe", "Spin"};
addButton(new GuiNpcButton(106, fieldX, y, 70, 20, sweepModes, cutter.getSweepMode().ordinal()));
GuiNpcButton sweepModeBtn = new GuiNpcButton(106, fieldX, y, 70, 20, sweepModes, cutter.getSweepMode().ordinal());
sweepModeBtn.setHoverText("ability.hover.sweepMode");
addButton(sweepModeBtn);
addLabel(new GuiNpcLabel(107, "ability.piercing", col2LabelX, y + 5));
addButton(new GuiNpcButton(107, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, cutter.isPiercing() ? 1 : 0));
GuiNpcButton piercingBtn = new GuiNpcButton(107, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, cutter.isPiercing() ? 1 : 0);
piercingBtn.setHoverText("ability.hover.piercing");
addButton(piercingBtn);
y += 24;
// Row 5: Stun Duration + Poison Time
addLabel(new GuiNpcLabel(108, "ability.stunDuration", labelX, y + 5));
addTextField(createIntField(108, fieldX, y, 50, cutter.getStunDuration()));
// Row 5: Spin Duration (only for SPIN mode) + Effects button
if (cutter.getSweepMode() == AbilityCutter.SweepMode.SPIN) {
addLabel(new GuiNpcLabel(108, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(108, fieldX, y, 50, cutter.getSpinDurationTicks());
durationField.setMinMaxDefault(1, 1000, 60);
addTextField(durationField);
}
addLabel(new GuiNpcLabel(109, "ability.poisonTime", col2LabelX, y + 5));
addTextField(createIntField(109, col2FieldX, y, 50, cutter.getPoisonDurationSeconds()));
y += 24;
// Row 6: Poison Level
addLabel(new GuiNpcLabel(110, "ability.poisonLvl", labelX, y + 5));
addTextField(createIntField(110, fieldX, y, 50, cutter.getPoisonLevel()));
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -84,10 +89,26 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
switch (id) {
case 106:
cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]);
initGui(); // Refresh to show/hide duration field
break;
case 107:
cutter.setPiercing(value == 1);
break;
case 150:
setSubGui(new SubGuiAbilityEffects(cutter.getEffects()));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
cutter.setEffects(result);
}
}
}
@@ -113,13 +134,7 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed()));
break;
case 108:
cutter.setStunDuration(field.getInteger());
break;
case 109:
cutter.setPoisonDurationSeconds(field.getInteger());
break;
case 110:
cutter.setPoisonLevel(field.getInteger());
cutter.setSpinDurationTicks(field.getInteger());
break;
}
}
@@ -30,7 +30,9 @@ public class SubGuiAbilityDash extends SubGuiAbilityConfig {
// Row 1: Dash Mode
addLabel(new GuiNpcLabel(100, "ability.mode", labelX, y + 5));
String[] dashModes = {"Aggressive", "Defensive"};
addButton(new GuiNpcButton(100, fieldX, y, 80, 20, dashModes, dash.getDashMode().ordinal()));
GuiNpcButton modeBtn = new GuiNpcButton(100, fieldX, y, 80, 20, dashModes, dash.getDashMode().ordinal());
modeBtn.setHoverText("ability.hover.dashMode");
addButton(modeBtn);
y += 24;
@@ -1,5 +1,7 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.type.AbilityDisc;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
@@ -9,6 +11,8 @@ import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Disc ability type-specific settings.
*/
@@ -53,30 +57,42 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
y += 24;
// Row 3: Homing + Homing Strength
// Row 3: Homing + Homing Strength (only show strength if homing)
addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isHoming() ? 1 : 0));
GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isHoming() ? 1 : 0);
homingBtn.setHoverText("ability.hover.homing");
addButton(homingBtn);
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, disc.getHomingStrength()));
if (disc.isHoming()) {
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, disc.getHomingStrength()));
}
y += 24;
// Row 4: Boomerang + Boomerang Delay
// Row 4: Boomerang + Boomerang Delay (only show delay if boomerang)
addLabel(new GuiNpcLabel(106, "ability.boomerang", labelX, y + 5));
addButton(new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isBoomerang() ? 1 : 0));
GuiNpcButton boomerangBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isBoomerang() ? 1 : 0);
boomerangBtn.setHoverText("ability.hover.boomerang");
addButton(boomerangBtn);
addLabel(new GuiNpcLabel(107, "ability.boomerangDelay", col2LabelX, y + 5));
addTextField(createIntField(107, col2FieldX, y, 50, disc.getBoomerangDelay()));
if (disc.isBoomerang()) {
addLabel(new GuiNpcLabel(107, "ability.boomerangDelay", col2LabelX, y + 5));
addTextField(createIntField(107, col2FieldX, y, 50, disc.getBoomerangDelay()));
}
y += 24;
// Row 5: Explosive + Explosion Radius
// Row 5: Explosive + Explosion Radius (only show radius if explosive)
addLabel(new GuiNpcLabel(108, "ability.explosive", labelX, y + 5));
addButton(new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isExplosive() ? 1 : 0));
GuiNpcButton explosiveBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, disc.isExplosive() ? 1 : 0);
explosiveBtn.setHoverText("ability.hover.explosive");
addButton(explosiveBtn);
addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(109, col2FieldX, y, 50, disc.getExplosionRadius()));
if (disc.isExplosive()) {
addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(109, col2FieldX, y, 50, disc.getExplosionRadius()));
}
y += 24;
@@ -86,6 +102,14 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
addLabel(new GuiNpcLabel(111, "ability.maxDist", col2LabelX, y + 5));
addTextField(createFloatField(111, col2FieldX, y, 50, disc.getMaxDistance()));
y += 24;
// Row 7: Max Lifetime + Effects button
addLabel(new GuiNpcLabel(112, "ability.lifetime", labelX, y + 5));
addTextField(createIntField(112, fieldX, y, 50, disc.getMaxLifetime()));
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -96,7 +120,15 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 180;
int col2FieldX = guiLeft + 260;
// Row 1: Inner Color + Outer Color
// 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());
anchorBtn.setHoverText("ability.hover.anchorPoint");
addButton(anchorBtn);
y += 24;
// Row 2: Inner Color + Outer Color
addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5));
String innerHex = String.format("%06X", disc.getInnerColor() & 0xFFFFFF);
GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex);
@@ -126,6 +158,30 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
// Row 3: Rotation Speed
addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", labelX, y + 5));
addTextField(createFloatField(204, fieldX, y, 50, disc.getRotationSpeed()));
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);
lightningBtn.setHoverText("ability.hover.lightning");
addButton(lightningBtn);
// Only show Lightning settings if Lightning is enabled
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()));
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()));
radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f);
addTextField(radiusField);
}
}
@Override
@@ -134,12 +190,18 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
switch (id) {
case 104:
disc.setHoming(value == 1);
initGui();
break;
case 106:
disc.setBoomerang(value == 1);
initGui();
break;
case 108:
disc.setExplosive(value == 1);
initGui();
break;
case 150:
setSubGui(new SubGuiAbilityEffects(disc.getEffects()));
break;
}
}
@@ -160,6 +222,13 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
disc.setOuterColorEnabled(value == 1);
initGui();
break;
case 205:
disc.setLightningEffect(value == 1);
initGui();
break;
case 210:
disc.setAnchorPoint(AnchorPoint.fromId(value));
break;
}
}
@@ -175,6 +244,12 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
}
editingVisualColorId = 0;
initGui();
} else if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
disc.setEffects(result);
}
} else {
super.subGuiClosed(subgui);
}
@@ -210,6 +285,9 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
case 111:
disc.setMaxDistance(parseFloat(field, disc.getMaxDistance()));
break;
case 112:
disc.setMaxLifetime(field.getInteger());
break;
}
}
@@ -222,6 +300,12 @@ public class SubGuiAbilityDisc extends SubGuiAbilityConfig {
case 204:
disc.setRotationSpeed(parseFloat(field, disc.getRotationSpeed()));
break;
case 206:
disc.setLightningDensity(parseFloat(field, disc.getLightningDensity()));
break;
case 207:
disc.setLightningRadius(parseFloat(field, disc.getLightningRadius()));
break;
}
}
}
@@ -0,0 +1,197 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.List;
/**
* SubGui for editing ability effects (potion effects that apply to targets).
* Allows adding/removing effects and configuring type, duration, and amplifier.
*/
public class SubGuiAbilityEffects extends SubGuiInterface implements ITextfieldListener {
private static final int MAX_EFFECTS = 5;
// Effect type names for display
private static final String[] EFFECT_TYPE_NAMES = {
"gui.none",
"potion.moveSlowdown",
"potion.weakness",
"potion.poison",
"potion.wither",
"potion.blindness",
"potion.confusion",
"potion.hunger",
"potion.digSlowDown"
};
// Working copy of effects
private List<AbilityEffect> effects;
private boolean cancelled = false;
public SubGuiAbilityEffects(List<AbilityEffect> existingEffects) {
// Create working copies of effects
this.effects = new ArrayList<>();
if (existingEffects != null) {
for (AbilityEffect effect : existingEffects) {
this.effects.add(effect.copy());
}
}
setBackground("menubg.png");
xSize = 280;
ySize = 180;
}
@Override
public void initGui() {
super.initGui();
int y = guiTop + 8;
int labelX = guiLeft + 8;
// Title
addLabel(new GuiNpcLabel(0, "ability.effects", labelX, y));
y += 16;
// Column headers
addLabel(new GuiNpcLabel(1, "gui.type", guiLeft + 10, y));
addLabel(new GuiNpcLabel(2, "gui.duration", guiLeft + 115, y));
addLabel(new GuiNpcLabel(3, "gui.amp", guiLeft + 175, y));
y += 14;
// Effect rows
for (int i = 0; i < effects.size() && i < MAX_EFFECTS; i++) {
AbilityEffect effect = effects.get(i);
int baseId = 1 + i * 10;
// Type selector button
int typeIndex = effect.getType().ordinal();
addButton(new GuiNpcButton(baseId, guiLeft + 8, y, 100, 20, EFFECT_TYPE_NAMES, typeIndex));
// 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);
addTextField(durField);
// Amplifier selector (0-10)
String[] ampValues = new String[11];
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()));
// Delete button
addButton(new GuiNpcButton(baseId + 3, guiLeft + 215, y, 20, 20, "X"));
y += 24;
}
// Add button (if space available)
if (effects.size() < MAX_EFFECTS) {
addButton(new GuiNpcButton(100, guiLeft + 8, y, 50, 20, "gui.add"));
}
// Bottom buttons
addButton(new GuiNpcButton(65, guiLeft + 8, guiTop + ySize - 28, 60, 20, "gui.cancel"));
addButton(new GuiNpcButton(66, guiLeft + xSize - 68, guiTop + ySize - 28, 60, 20, "gui.done"));
}
@Override
public void buttonEvent(GuiButton guibutton) {
int id = guibutton.id;
// Add button
if (id == 100) {
if (effects.size() < MAX_EFFECTS) {
// Add new effect with default values (Slowness, 60 ticks, amp 0)
effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0));
initGui();
}
return;
}
// Cancel button
if (id == 65) {
cancelled = true;
close();
return;
}
// Done button
if (id == 66) {
// Remove any NONE effects before saving
effects.removeIf(e -> !e.isValid());
cancelled = false;
close();
return;
}
// Effect row buttons (id >= 1 and < 100)
if (id >= 1 && id < 100) {
int effectIndex = (id - 1) / 10;
int action = (id - 1) % 10;
if (effectIndex >= 0 && effectIndex < effects.size()) {
AbilityEffect effect = effects.get(effectIndex);
switch (action) {
case 0: // Type selector
int typeIndex = ((GuiNpcButton) guibutton).getValue();
effect.setType(AbilityEffect.EffectType.fromOrdinal(typeIndex));
break;
case 2: // Amplifier selector
int amp = ((GuiNpcButton) guibutton).getValue();
effect.setAmplifier(amp);
break;
case 3: // Delete button
effects.remove(effectIndex);
initGui();
break;
}
}
}
}
@Override
public void unFocused(GuiNpcTextField textField) {
int id = textField.id;
// Duration text fields (baseId + 1)
if (id >= 2 && id < 100) {
int effectIndex = (id - 1) / 10;
int action = (id - 1) % 10;
if (action == 1 && effectIndex >= 0 && effectIndex < effects.size()) {
effects.get(effectIndex).setDurationTicks(textField.getInteger());
}
}
}
/**
* Returns the resulting effects list after the dialog closes.
* Returns null if cancelled.
*/
public List<AbilityEffect> getResult() {
if (cancelled) {
return null;
}
return effects;
}
/**
* Returns true if the dialog was cancelled.
*/
public boolean wasCancelled() {
return cancelled;
}
}
@@ -1,5 +1,7 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.type.AbilityEnergyBeam;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
@@ -9,6 +11,8 @@ import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Energy Beam ability type-specific settings.
* Energy Beam is a homing head with trailing path (DBZ-style).
@@ -54,30 +58,40 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
y += 24;
// Row 3: Homing + Homing Strength
// Row 3: Homing + Homing Strength (only show strength if homing)
addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isHoming() ? 1 : 0));
GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isHoming() ? 1 : 0);
homingBtn.setHoverText("ability.hover.homing");
addButton(homingBtn);
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, beam.getHomingStrength()));
if (beam.isHoming()) {
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, beam.getHomingStrength()));
}
y += 24;
// Row 4: Homing Range + Max Distance
addLabel(new GuiNpcLabel(106, "ability.homingRange", labelX, y + 5));
addTextField(createFloatField(106, fieldX, y, 50, beam.getHomingRange()));
// Row 4: Max Distance (+ Homing Range only if homing)
if (beam.isHoming()) {
addLabel(new GuiNpcLabel(106, "ability.homingRange", labelX, y + 5));
addTextField(createFloatField(106, fieldX, y, 50, beam.getHomingRange()));
}
addLabel(new GuiNpcLabel(107, "ability.maxDist", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, beam.getMaxDistance()));
addLabel(new GuiNpcLabel(107, "ability.maxDist", beam.isHoming() ? col2LabelX : labelX, y + 5));
addTextField(createFloatField(107, beam.isHoming() ? col2FieldX : fieldX, y, 50, beam.getMaxDistance()));
y += 24;
// Row 5: Explosive + Explosion Radius
// Row 5: Explosive + Explosion Radius (only show radius if explosive)
addLabel(new GuiNpcLabel(108, "ability.explosive", labelX, y + 5));
addButton(new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isExplosive() ? 1 : 0));
GuiNpcButton explosiveBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, beam.isExplosive() ? 1 : 0);
explosiveBtn.setHoverText("ability.hover.explosive");
addButton(explosiveBtn);
addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(109, col2FieldX, y, 50, beam.getExplosionRadius()));
if (beam.isExplosive()) {
addLabel(new GuiNpcLabel(109, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(109, col2FieldX, y, 50, beam.getExplosionRadius()));
}
y += 24;
@@ -87,6 +101,11 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
addLabel(new GuiNpcLabel(111, "ability.lifetime", col2LabelX, y + 5));
addTextField(createIntField(111, col2FieldX, y, 50, beam.getMaxLifetime()));
y += 24;
// Row 7: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -97,7 +116,15 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 180;
int col2FieldX = guiLeft + 260;
// Row 1: Inner Color + Outer Color
// 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());
anchorBtn.setHoverText("ability.hover.anchorPoint");
addButton(anchorBtn);
y += 24;
// Row 2: Inner Color + Outer Color
addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5));
String innerHex = String.format("%06X", beam.getInnerColor() & 0xFFFFFF);
GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex);
@@ -127,6 +154,30 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
// Row 3: Rotation Speed
addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", labelX, y + 5));
addTextField(createFloatField(204, fieldX, 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);
lightningBtn.setHoverText("ability.hover.lightning");
addButton(lightningBtn);
// Only show Lightning settings if Lightning is enabled
if (beam.hasLightningEffect()) {
y += 24;
// Row 5: Density + Radius
addLabel(new GuiNpcLabel(206, "ability.lightningDensity", labelX, y + 5));
GuiNpcTextField densityField = new GuiNpcTextField(206, 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()));
radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f);
addTextField(radiusField);
}
}
@Override
@@ -135,9 +186,14 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
switch (id) {
case 104:
beam.setHoming(value == 1);
initGui();
break;
case 108:
beam.setExplosive(value == 1);
initGui();
break;
case 150:
setSubGui(new SubGuiAbilityEffects(beam.getEffects()));
break;
}
}
@@ -158,6 +214,13 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
beam.setOuterColorEnabled(value == 1);
initGui();
break;
case 205:
beam.setLightningEffect(value == 1);
initGui();
break;
case 210:
beam.setAnchorPoint(AnchorPoint.fromId(value));
break;
}
}
@@ -173,6 +236,12 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
}
editingVisualColorId = 0;
initGui();
} else if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
beam.setEffects(result);
}
} else {
super.subGuiClosed(subgui);
}
@@ -223,6 +292,12 @@ public class SubGuiAbilityEnergyBeam extends SubGuiAbilityConfig {
case 204:
beam.setRotationSpeed(parseFloat(field, beam.getRotationSpeed()));
break;
case 206:
beam.setLightningDensity(parseFloat(field, beam.getLightningDensity()));
break;
case 207:
beam.setLightningRadius(parseFloat(field, beam.getLightningRadius()));
break;
}
}
}
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Guard ability type-specific settings.
@@ -27,19 +31,27 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 165;
int col2FieldX = guiLeft + 225;
// Row 1: Damage Reduction
addLabel(new GuiNpcLabel(100, "ability.dmgReduce", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, guard.getDamageReduction()));
// Row 1: Duration + Damage Reduction
addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, guard.getDurationTicks());
durationField.setMinMaxDefault(1, 1000, 60);
addTextField(durationField);
addLabel(new GuiNpcLabel(100, "ability.dmgReduce", col2LabelX, y + 5));
addTextField(createFloatField(100, col2FieldX, y, 50, guard.getDamageReduction()));
y += 24;
// Row 2: Can Counter + Counter Type
addLabel(new GuiNpcLabel(101, "ability.canCounter", labelX, y + 5));
addButton(new GuiNpcButton(101, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, guard.isCanCounter() ? 1 : 0));
GuiNpcButton canCounterBtn = new GuiNpcButton(101, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, guard.isCanCounter() ? 1 : 0);
canCounterBtn.setHoverText("ability.hover.canCounter");
addButton(canCounterBtn);
addLabel(new GuiNpcLabel(102, "ability.counterType", col2LabelX, y + 5));
String[] types = {"Flat", "Percent"};
GuiNpcButton counterTypeButton = new GuiNpcButton(102, col2FieldX, y, 60, 20, types, guard.getCounterType().ordinal());
counterTypeButton.setHoverText("ability.hover.counterType");
counterTypeButton.setEnabled(guard.isCanCounter());
addButton(counterTypeButton);
@@ -68,6 +80,13 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
GuiNpcTextField counterAnimField = createIntField(106, col2FieldX, y, 50, guard.getCounterAnimationId());
counterAnimField.setEnabled(guard.isCanCounter());
addTextField(counterAnimField);
y += 24;
// Row 5: Effects button (applies on counter)
GuiNpcButton effectsBtn = new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects");
effectsBtn.setEnabled(guard.isCanCounter());
addButton(effectsBtn);
}
@Override
@@ -80,12 +99,30 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
case 102:
guard.setCounterType(AbilityGuard.CounterType.values()[button.getValue()]);
break;
case 150:
setSubGui(new SubGuiAbilityEffects(guard.getEffects()));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
guard.setEffects(result);
}
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
guard.setDurationTicks(field.getInteger());
break;
case 100:
guard.setDamageReduction(parseFloat(field, guard.getDamageReduction()));
break;
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityHazard;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Hazard ability type-specific settings.
@@ -27,14 +31,26 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Shape + Placement
addLabel(new GuiNpcLabel(100, "ability.shape", labelX, y + 5));
String[] shapes = {"Circle", "Ring", "Cone"};
addButton(new GuiNpcButton(100, fieldX, y, 55, 20, shapes, hazard.getShape().ordinal()));
// Row 1: Duration + Shape
addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, hazard.getDurationTicks());
durationField.setMinMaxDefault(1, 2000, 100);
addTextField(durationField);
addLabel(new GuiNpcLabel(101, "ability.placement", col2LabelX, y + 5));
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());
shapeBtn.setHoverText("ability.hover.shape");
addButton(shapeBtn);
y += 24;
// Row 2: Placement
addLabel(new GuiNpcLabel(101, "ability.placement", labelX, y + 5));
String[] placements = {"Caster", "Target", "FollowCast", "FollowTgt"};
addButton(new GuiNpcButton(101, col2FieldX, y, 60, 20, placements, hazard.getPlacement().ordinal()));
GuiNpcButton placementBtn = new GuiNpcButton(101, fieldX, y, 70, 20, placements, hazard.getPlacement().ordinal());
placementBtn.setHoverText("ability.hover.placement");
addButton(placementBtn);
y += 24;
@@ -70,7 +86,14 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
addTextField(createIntField(108, fieldX, y, 50, hazard.getPoisonLevel()));
addLabel(new GuiNpcLabel(109, "ability.affectsCaster", col2LabelX, y + 5));
addButton(new GuiNpcButton(109, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, hazard.isAffectsCaster() ? 1 : 0));
GuiNpcButton affectsCasterBtn = new GuiNpcButton(109, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, hazard.isAffectsCaster() ? 1 : 0);
affectsCasterBtn.setHoverText("ability.hover.affectsCaster");
addButton(affectsCasterBtn);
y += 24;
// Row 6: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -86,12 +109,30 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
case 109:
hazard.setAffectsCaster(value == 1);
break;
case 150:
setSubGui(new SubGuiAbilityEffects(hazard.getEffects()));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
hazard.setEffects(result);
}
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
hazard.setDurationTicks(field.getInteger());
break;
case 102:
hazard.setRadius(parseFloat(field, hazard.getRadius()));
break;
@@ -27,7 +27,22 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Heal Amount + Heal Percent
// Row 1: Instant Heal + Duration (only shown if not instant)
addLabel(new GuiNpcLabel(103, "dialog.instant", labelX, y + 5));
GuiNpcButton instantBtn = new GuiNpcButton(103, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isInstantHeal() ? 1 : 0);
instantBtn.setHoverText("ability.hover.instant");
addButton(instantBtn);
if (!heal.isInstantHeal()) {
addLabel(new GuiNpcLabel(99, "ability.duration", col2LabelX, y + 5));
GuiNpcTextField durationField = createIntField(99, col2FieldX, y, 50, heal.getDurationTicks());
durationField.setMinMaxDefault(1, 1000, 60);
addTextField(durationField);
}
y += 24;
// Row 2: Heal Amount + Heal Percent
addLabel(new GuiNpcLabel(100, "ability.healAmount", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, heal.getHealAmount()));
@@ -36,21 +51,22 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
y += 24;
// Row 2: Heal Radius + Instant Heal
// Row 3: Heal Radius
addLabel(new GuiNpcLabel(102, "ability.healRadius", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, heal.getHealRadius()));
addLabel(new GuiNpcLabel(103, "dialog.instant", col2LabelX, y + 5));
addButton(new GuiNpcButton(103, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isInstantHeal() ? 1 : 0));
y += 24;
// Row 3: Heal Self + Heal Allies
// Row 4: Heal Self + Heal Allies
addLabel(new GuiNpcLabel(104, "ability.healSelf", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealSelf() ? 1 : 0));
GuiNpcButton healSelfBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealSelf() ? 1 : 0);
healSelfBtn.setHoverText("ability.hover.healSelf");
addButton(healSelfBtn);
addLabel(new GuiNpcLabel(105, "ability.healAllies", col2LabelX, y + 5));
addButton(new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealAllies() ? 1 : 0));
GuiNpcButton healAlliesBtn = new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isHealAllies() ? 1 : 0);
healAlliesBtn.setHoverText("ability.hover.healAllies");
addButton(healAlliesBtn);
}
@Override
@@ -59,6 +75,7 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
switch (id) {
case 103:
heal.setInstantHeal(value == 1);
initGui(); // Refresh to show/hide duration field
break;
case 104:
heal.setHealSelf(value == 1);
@@ -72,6 +89,9 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
heal.setDurationTicks(field.getInteger());
break;
case 100:
heal.setHealAmount(parseFloat(field, heal.getHealAmount()));
break;
@@ -1,10 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeavyHit;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Heavy Hit ability type-specific settings.
@@ -24,29 +29,37 @@ public class SubGuiAbilityHeavyHit extends SubGuiAbilityConfig {
int labelX = guiLeft + 8;
int fieldX = guiLeft + 85;
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Potion Time
// Row 1: Damage + Knockback
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, heavyHit.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.potionTime", col2LabelX, y + 5));
addTextField(createIntField(101, col2FieldX, y, 50, heavyHit.getPotionDurationSeconds()));
addLabel(new GuiNpcLabel(102, "ability.knockback", col2LabelX, y + 5));
addTextField(createFloatField(102, guiLeft + 205, y, 50, heavyHit.getKnockback()));
y += 24;
// Row 2: Knockback + Slowness Level
addLabel(new GuiNpcLabel(102, "ability.knockback", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, heavyHit.getKnockback()));
// Row 2: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
addLabel(new GuiNpcLabel(103, "ability.slownessLvl", col2LabelX, y + 5));
addTextField(createIntField(103, col2FieldX, y, 50, heavyHit.getSlownessLevel()));
@Override
protected void handleTypeButton(int id, GuiNpcButton button) {
if (id == 150) {
setSubGui(new SubGuiAbilityEffects(heavyHit.getEffects()));
}
}
y += 24;
// Row 3: Weakness Level
addLabel(new GuiNpcLabel(104, "ability.weaknessLvl", labelX, y + 5));
addTextField(createIntField(104, fieldX, y, 50, heavyHit.getWeaknessLevel()));
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
heavyHit.setEffects(result);
}
}
}
@Override
@@ -55,18 +68,9 @@ public class SubGuiAbilityHeavyHit extends SubGuiAbilityConfig {
case 100:
heavyHit.setDamage(parseFloat(field, heavyHit.getDamage()));
break;
case 101:
heavyHit.setPotionDurationSeconds(field.getInteger());
break;
case 102:
heavyHit.setKnockback(parseFloat(field, heavyHit.getKnockback()));
break;
case 103:
heavyHit.setSlownessLevel(field.getInteger());
break;
case 104:
heavyHit.setWeaknessLevel(field.getInteger());
break;
}
}
}
@@ -1,5 +1,6 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityLaserShot;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
@@ -9,6 +10,8 @@ import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Laser Shot ability type-specific settings.
*/
@@ -62,12 +65,16 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
y += 24;
// Row 4: Explosive + Explosion Radius
// Row 4: Explosive + Explosion Radius (only show radius if explosive)
addLabel(new GuiNpcLabel(106, "ability.explosive", labelX, y + 5));
addButton(new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, laser.isExplosive() ? 1 : 0));
GuiNpcButton explosiveBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, laser.isExplosive() ? 1 : 0);
explosiveBtn.setHoverText("ability.hover.explosive");
addButton(explosiveBtn);
addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, laser.getExplosionRadius()));
if (laser.isExplosive()) {
addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, laser.getExplosionRadius()));
}
y += 24;
@@ -77,6 +84,11 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
addLabel(new GuiNpcLabel(109, "ability.knockbackUp", col2LabelX, y + 5));
addTextField(createFloatField(109, col2FieldX, y, 50, laser.getKnockbackUp()));
y += 24;
// Row 6: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -111,6 +123,30 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, laser.getOuterColorWidth());
widthField.setEnabled(laser.isOuterColorEnabled());
addTextField(widthField);
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);
lightningBtn.setHoverText("ability.hover.lightning");
addButton(lightningBtn);
// Only show Lightning settings if Lightning is enabled
if (laser.hasLightningEffect()) {
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()));
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()));
radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f);
addTextField(radiusField);
}
}
@Override
@@ -119,6 +155,10 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
switch (id) {
case 106:
laser.setExplosive(value == 1);
initGui();
break;
case 150:
setSubGui(new SubGuiAbilityEffects(laser.getEffects()));
break;
}
}
@@ -139,6 +179,10 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
laser.setOuterColorEnabled(value == 1);
initGui();
break;
case 204:
laser.setLightningEffect(value == 1);
initGui();
break;
}
}
@@ -154,6 +198,12 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
}
editingVisualColorId = 0;
initGui();
} else if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
laser.setEffects(result);
}
} else {
super.subGuiClosed(subgui);
}
@@ -165,6 +215,12 @@ public class SubGuiAbilityLaserShot extends SubGuiAbilityConfig {
case 203:
laser.setOuterColorWidth(parseFloat(field, laser.getOuterColorWidth()));
break;
case 205:
laser.setLightningDensity(parseFloat(field, laser.getLightningDensity()));
break;
case 206:
laser.setLightningRadius(parseFloat(field, laser.getLightningRadius()));
break;
}
}
@@ -1,5 +1,7 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.type.AbilityOrb;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
@@ -9,6 +11,8 @@ import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Orb ability type-specific settings.
*/
@@ -53,21 +57,29 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
y += 24;
// Row 3: Homing + Homing Strength
// Row 3: Homing + Homing Strength (only show strength if homing)
addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isHoming() ? 1 : 0));
GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isHoming() ? 1 : 0);
homingBtn.setHoverText("ability.hover.homing");
addButton(homingBtn);
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, orb.getHomingStrength()));
if (orb.isHoming()) {
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, orb.getHomingStrength()));
}
y += 24;
// Row 4: Explosive + Explosion Radius
// Row 4: Explosive + Explosion Radius (only show radius if explosive)
addLabel(new GuiNpcLabel(106, "ability.explosive", labelX, y + 5));
addButton(new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isExplosive() ? 1 : 0));
GuiNpcButton explosiveBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isExplosive() ? 1 : 0);
explosiveBtn.setHoverText("ability.hover.explosive");
addButton(explosiveBtn);
addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, orb.getExplosionRadius()));
if (orb.isExplosive()) {
addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, orb.getExplosionRadius()));
}
y += 24;
@@ -77,6 +89,11 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
addLabel(new GuiNpcLabel(109, "ability.lifetime", col2LabelX, y + 5));
addTextField(createIntField(109, col2FieldX, y, 50, orb.getMaxLifetime()));
y += 24;
// Row 6: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -87,36 +104,68 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 180;
int col2FieldX = guiLeft + 260;
// Row 1: Inner Color + Outer Color
// 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());
anchorBtn.setHoverText("ability.hover.anchorPoint");
addButton(anchorBtn);
y += 24;
// Row 2: Inner Color + Rotation Speed
addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5));
String innerHex = String.format("%06X", orb.getInnerColor() & 0xFFFFFF);
GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex);
innerColorBtn.setTextColor(orb.getInnerColor() & 0xFFFFFF);
addButton(innerColorBtn);
addLabel(new GuiNpcLabel(201, "ability.outerColor", col2LabelX, y + 5));
String outerHex = String.format("%06X", orb.getOuterColor() & 0xFFFFFF);
GuiNpcButton outerColorBtn = new GuiNpcButton(201, col2FieldX, y, 55, 20, outerHex);
outerColorBtn.setTextColor(orb.getOuterColor() & 0xFFFFFF);
outerColorBtn.setEnabled(orb.isOuterColorEnabled());
addButton(outerColorBtn);
addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", col2LabelX, y + 5));
addTextField(createFloatField(204, col2FieldX, y, 55, orb.getRotationSpeed()));
y += 24;
// Row 2: Outer Color Enabled + Outer Color Width
// Row 2: 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));
addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5));
GuiNpcTextField widthField = createFloatField(203, col2FieldX, y, 55, orb.getOuterColorWidth());
widthField.setEnabled(orb.isOuterColorEnabled());
addTextField(widthField);
// Only show Outer Color and Width if Outer Glow is enabled
if (orb.isOuterColorEnabled()) {
y += 24;
// Row 3: Outer Color + Outer Width
addLabel(new GuiNpcLabel(201, "ability.outerColor", labelX, y + 5));
String outerHex = String.format("%06X", orb.getOuterColor() & 0xFFFFFF);
GuiNpcButton outerColorBtn = new GuiNpcButton(201, fieldX, y, 55, 20, outerHex);
outerColorBtn.setTextColor(orb.getOuterColor() & 0xFFFFFF);
addButton(outerColorBtn);
addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5));
addTextField(createFloatField(203, col2FieldX, y, 55, orb.getOuterColorWidth()));
}
y += 24;
// Row 3: Rotation Speed
addLabel(new GuiNpcLabel(204, "ability.rotationSpeed", labelX, y + 5));
addTextField(createFloatField(204, fieldX, y, 50, orb.getRotationSpeed()));
// 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);
lightningBtn.setHoverText("ability.hover.lightning");
addButton(lightningBtn);
// Only show Lightning settings if Lightning is enabled
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()));
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()));
radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f);
addTextField(radiusField);
}
}
@Override
@@ -125,9 +174,14 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
switch (id) {
case 104:
orb.setHoming(value == 1);
initGui();
break;
case 106:
orb.setExplosive(value == 1);
initGui();
break;
case 150:
setSubGui(new SubGuiAbilityEffects(orb.getEffects()));
break;
}
}
@@ -148,6 +202,13 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
orb.setOuterColorEnabled(value == 1);
initGui();
break;
case 205:
orb.setLightningEffect(value == 1);
initGui();
break;
case 210:
orb.setAnchorPoint(AnchorPoint.fromId(value));
break;
}
}
@@ -163,6 +224,12 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
}
editingVisualColorId = 0;
initGui();
} else if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
orb.setEffects(result);
}
} else {
super.subGuiClosed(subgui);
}
@@ -207,6 +274,12 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
case 204:
orb.setRotationSpeed(parseFloat(field, orb.getRotationSpeed()));
break;
case 206:
orb.setLightningDensity(parseFloat(field, orb.getLightningDensity()));
break;
case 207:
orb.setLightningRadius(parseFloat(field, orb.getLightningRadius()));
break;
}
}
}
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityProjectile;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Projectile ability type-specific settings.
@@ -54,21 +58,34 @@ public class SubGuiAbilityProjectile extends SubGuiAbilityConfig {
y += 24;
// Row 3: Explosive + Explosion Radius
// Row 3: Explosive + Explosion Radius (only show radius if explosive)
addLabel(new GuiNpcLabel(104, "ability.explosive", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, projectile.isExplosive() ? 1 : 0));
GuiNpcButton explosiveBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, projectile.isExplosive() ? 1 : 0);
explosiveBtn.setHoverText("ability.hover.explosive");
addButton(explosiveBtn);
addLabel(new GuiNpcLabel(105, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, projectile.getExplosionRadius()));
if (projectile.isExplosive()) {
addLabel(new GuiNpcLabel(105, "ability.explosionRad", col2LabelX, y + 5));
addTextField(createFloatField(105, col2FieldX, y, 50, projectile.getExplosionRadius()));
}
y += 24;
// Row 4: Homing + Homing Strength
// Row 4: Homing + Homing Strength (only show strength if homing)
addLabel(new GuiNpcLabel(106, "ability.homing", labelX, y + 5));
addButton(new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, projectile.isHoming() ? 1 : 0));
GuiNpcButton homingBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, projectile.isHoming() ? 1 : 0);
homingBtn.setHoverText("ability.hover.homing");
addButton(homingBtn);
addLabel(new GuiNpcLabel(107, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, projectile.getHomingStrength()));
if (projectile.isHoming()) {
addLabel(new GuiNpcLabel(107, "ability.homingStr", col2LabelX, y + 5));
addTextField(createFloatField(107, col2FieldX, y, 50, projectile.getHomingStrength()));
}
y += 24;
// Row 5: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -81,10 +98,27 @@ public class SubGuiAbilityProjectile extends SubGuiAbilityConfig {
break;
case 104:
projectile.setExplosive(value == 1);
initGui();
break;
case 106:
projectile.setHoming(value == 1);
initGui();
break;
case 150:
setSubGui(new SubGuiAbilityEffects(projectile.getEffects()));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
projectile.setEffects(result);
}
}
}
@@ -1,10 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityShockwave;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Shockwave ability type-specific settings.
@@ -41,17 +46,35 @@ public class SubGuiAbilityShockwave extends SubGuiAbilityConfig {
y += 24;
// Row 3: Stun Duration + Max Targets
addLabel(new GuiNpcLabel(103, "ability.stunDuration", labelX, y + 5));
addTextField(createIntField(103, fieldX, y, 50, shockwave.getStunDuration()));
// Row 3: Max Targets + Effects button
addLabel(new GuiNpcLabel(104, "ability.maxTargets", labelX, y + 5));
addTextField(createIntField(104, fieldX, y, 50, shockwave.getMaxTargets()));
addLabel(new GuiNpcLabel(104, "ability.maxTargets", col2LabelX, y + 5));
addTextField(createIntField(104, col2FieldX, y, 50, shockwave.getMaxTargets()));
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
y += 24;
addLabel(new GuiNpcLabel(105, "ability.shockwaveFalloff", labelX, y + 5));
}
@Override
protected void handleTypeButton(int id, GuiNpcButton button) {
if (id == 150) {
setSubGui(new SubGuiAbilityEffects(shockwave.getEffects()));
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
shockwave.setEffects(result);
}
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
@@ -64,9 +87,6 @@ public class SubGuiAbilityShockwave extends SubGuiAbilityConfig {
case 102:
shockwave.setPushStrength(parseFloat(field, shockwave.getPushStrength()));
break;
case 103:
shockwave.setStunDuration(field.getInteger());
break;
case 104:
shockwave.setMaxTargets(field.getInteger());
break;
@@ -1,10 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilitySlam;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Slam ability type-specific settings.
@@ -44,9 +49,30 @@ public class SubGuiAbilitySlam extends SubGuiAbilityConfig {
y += 24;
// Row 3: Leap Height
// Row 3: Leap Height + Effects
addLabel(new GuiNpcLabel(104, "ability.leapHeight", labelX, y + 5));
addTextField(createFloatField(104, fieldX, y, 50, slam.getLeapHeight()));
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
}
@Override
protected void handleTypeButton(int id, GuiNpcButton button) {
if (id == 150) {
setSubGui(new SubGuiAbilityEffects(slam.getEffects()));
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
slam.setEffects(result);
}
}
}
@Override
@@ -1,5 +1,6 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilitySweeper;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
@@ -9,6 +10,8 @@ import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Sweeper ability type-specific settings.
* Sweeper is a low rotating beam that players can jump over.
@@ -68,13 +71,22 @@ public class SubGuiAbilitySweeper extends SubGuiAbilityConfig {
addTextField(createIntField(106, fieldX, y, 50, sweeper.getNumberOfRotations()));
addLabel(new GuiNpcLabel(107, "ability.piercing", col2LabelX, y + 5));
addButton(new GuiNpcButton(107, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isPiercing() ? 1 : 0));
GuiNpcButton piercingBtn = new GuiNpcButton(107, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isPiercing() ? 1 : 0);
piercingBtn.setHoverText("ability.hover.piercing");
addButton(piercingBtn);
y += 24;
// Row 5: Lock On Target
addLabel(new GuiNpcLabel(108, "ability.lockTarget", labelX, y + 5));
addButton(new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isLockOnTarget() ? 1 : 0));
GuiNpcButton lockTargetBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, sweeper.isLockOnTarget() ? 1 : 0);
lockTargetBtn.setHoverText("ability.hover.lockTarget");
addButton(lockTargetBtn);
y += 24;
// Row 6: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -121,6 +133,9 @@ public class SubGuiAbilitySweeper extends SubGuiAbilityConfig {
case 108:
sweeper.setLockOnTarget(value == 1);
break;
case 150:
setSubGui(new SubGuiAbilityEffects(sweeper.getEffects()));
break;
}
}
@@ -155,6 +170,12 @@ public class SubGuiAbilitySweeper extends SubGuiAbilityConfig {
}
editingVisualColorId = 0;
initGui();
} else if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
sweeper.setEffects(result);
}
} else {
super.subGuiClosed(subgui);
}
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityTeleport;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Teleport ability type-specific settings.
@@ -50,7 +54,9 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
addTextField(createIntField(103, fieldX, y, 50, teleport.getBlinkDelayTicks()));
addLabel(new GuiNpcLabel(105, "ability.lineOfSight", col2LabelX, y + 5));
addButton(new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isRequireLineOfSight() ? 1 : 0));
GuiNpcButton losBtn1 = new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isRequireLineOfSight() ? 1 : 0);
losBtn1.setHoverText("ability.hover.lineOfSight");
addButton(losBtn1);
y += 24;
break;
case SINGLE:
@@ -59,7 +65,9 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
addTextField(createFloatField(101, fieldX, y, 50, teleport.getBlinkRadius()));
addLabel(new GuiNpcLabel(105, "ability.lineOfSight", col2LabelX, y + 5));
addButton(new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isRequireLineOfSight() ? 1 : 0));
GuiNpcButton losBtn2 = new GuiNpcButton(105, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isRequireLineOfSight() ? 1 : 0);
losBtn2.setHoverText("ability.hover.lineOfSight");
addButton(losBtn2);
y += 24;
break;
case BEHIND:
@@ -81,10 +89,19 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
// Damage at Start/End
addLabel(new GuiNpcLabel(108, "ability.dmgAtStart", labelX, y + 5));
addButton(new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isDamageAtStart() ? 1 : 0));
GuiNpcButton dmgStartBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isDamageAtStart() ? 1 : 0);
dmgStartBtn.setHoverText("ability.hover.dmgAtStart");
addButton(dmgStartBtn);
addLabel(new GuiNpcLabel(109, "ability.dmgAtEnd", col2LabelX, y + 5));
addButton(new GuiNpcButton(109, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isDamageAtEnd() ? 1 : 0));
GuiNpcButton dmgEndBtn = new GuiNpcButton(109, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, teleport.isDamageAtEnd() ? 1 : 0);
dmgEndBtn.setHoverText("ability.hover.dmgAtEnd");
addButton(dmgEndBtn);
y += 24;
// Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
}
@Override
@@ -104,6 +121,21 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
case 109:
teleport.setDamageAtEnd(value == 1);
break;
case 150:
setSubGui(new SubGuiAbilityEffects(teleport.getEffects()));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
teleport.setEffects(result);
}
}
}
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityTrap;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Trap ability type-specific settings.
@@ -27,13 +31,23 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
int col2LabelX = guiLeft + 145;
int col2FieldX = guiLeft + 205;
// Row 1: Placement + Trigger Radius
addLabel(new GuiNpcLabel(100, "ability.placement", labelX, y + 5));
String[] placements = {"Caster", "Target", "Ahead"};
addButton(new GuiNpcButton(100, fieldX, y, 55, 20, placements, trap.getPlacement().ordinal()));
// Row 1: Duration + Placement
addLabel(new GuiNpcLabel(99, "ability.duration", labelX, y + 5));
GuiNpcTextField durationField = createIntField(99, fieldX, y, 50, trap.getDurationTicks());
durationField.setMinMaxDefault(1, 2000, 200);
addTextField(durationField);
addLabel(new GuiNpcLabel(101, "ability.triggerRad", col2LabelX, y + 5));
addTextField(createFloatField(101, col2FieldX, y, 50, trap.getTriggerRadius()));
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());
placementBtn.setHoverText("ability.hover.placement");
addButton(placementBtn);
y += 24;
// Row 2: Trigger Radius
addLabel(new GuiNpcLabel(101, "ability.triggerRad", labelX, y + 5));
addTextField(createFloatField(101, fieldX, y, 50, trap.getTriggerRadius()));
y += 24;
@@ -55,30 +69,40 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
y += 24;
// Row 4: Root Duration + Stun Duration
addLabel(new GuiNpcLabel(106, "ability.rootDuration", labelX, y + 5));
addTextField(createIntField(106, fieldX, y, 50, trap.getRootDuration()));
addLabel(new GuiNpcLabel(107, "ability.stunDuration", col2LabelX, y + 5));
addTextField(createIntField(107, col2FieldX, y, 50, trap.getStunDuration()));
y += 24;
// Row 5: Knockback
// Row 4: Knockback + Effects button
addLabel(new GuiNpcLabel(108, "ability.knockback", labelX, y + 5));
addTextField(createFloatField(108, fieldX, y, 50, trap.getKnockback()));
addButton(new GuiNpcButton(150, col2LabelX, y, 80, 20, "ability.effects"));
}
@Override
protected void handleTypeButton(int id, GuiNpcButton button) {
if (id == 100) {
trap.setPlacement(AbilityTrap.TrapPlacement.values()[button.getValue()]);
} else if (id == 150) {
setSubGui(new SubGuiAbilityEffects(trap.getEffects()));
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
trap.setEffects(result);
}
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 99:
trap.setDurationTicks(field.getInteger());
break;
case 101:
trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius()));
break;
@@ -94,12 +118,6 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
case 105:
trap.setMaxTriggers(field.getInteger());
break;
case 106:
trap.setRootDuration(field.getInteger());
break;
case 107:
trap.setStunDuration(field.getInteger());
break;
case 108:
trap.setKnockback(parseFloat(field, trap.getKnockback()));
break;
@@ -1,11 +1,15 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.type.AbilityVortex;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.List;
/**
* GUI for configuring Vortex ability type-specific settings.
@@ -47,25 +51,25 @@ public class SubGuiAbilityVortex extends SubGuiAbilityConfig {
// Row 3: AOE + Max Targets
addLabel(new GuiNpcLabel(104, "ability.aoe", labelX, y + 5));
addButton(new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, vortex.isAoe() ? 1 : 0));
GuiNpcButton aoeBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, vortex.isAoe() ? 1 : 0);
aoeBtn.setHoverText("ability.hover.aoe");
addButton(aoeBtn);
addLabel(new GuiNpcLabel(105, "ability.maxTargets", col2LabelX, y + 5));
addTextField(createIntField(105, col2FieldX, y, 50, vortex.getMaxTargets()));
y += 24;
// Row 4: Stun Duration + Root Duration
addLabel(new GuiNpcLabel(106, "ability.stunDuration", labelX, y + 5));
addTextField(createIntField(106, fieldX, y, 50, vortex.getStunDuration()));
addLabel(new GuiNpcLabel(107, "ability.rootDuration", col2LabelX, y + 5));
addTextField(createIntField(107, col2FieldX, y, 50, vortex.getRootDuration()));
// Row 4: Effects button
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
y += 24;
// Row 5: Damage on Pull + Pull Damage
addLabel(new GuiNpcLabel(108, "ability.dmgOnPull", labelX, y + 5));
addButton(new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, vortex.isDamageOnPull() ? 1 : 0));
GuiNpcButton dmgOnPullBtn = new GuiNpcButton(108, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, vortex.isDamageOnPull() ? 1 : 0);
dmgOnPullBtn.setHoverText("ability.hover.dmgOnPull");
addButton(dmgOnPullBtn);
addLabel(new GuiNpcLabel(109, "ability.pullDamage", col2LabelX, y + 5));
addTextField(createFloatField(109, col2FieldX, y, 50, vortex.getPullDamage()));
@@ -81,6 +85,21 @@ public class SubGuiAbilityVortex extends SubGuiAbilityConfig {
case 108:
vortex.setDamageOnPull(value == 1);
break;
case 150:
setSubGui(new SubGuiAbilityEffects(vortex.getEffects()));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
super.subGuiClosed(subgui);
if (subgui instanceof SubGuiAbilityEffects) {
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
List<AbilityEffect> result = effectsGui.getResult();
if (result != null) {
vortex.setEffects(result);
}
}
}
@@ -102,12 +121,6 @@ public class SubGuiAbilityVortex extends SubGuiAbilityConfig {
case 105:
vortex.setMaxTargets(field.getInteger());
break;
case 106:
vortex.setStunDuration(field.getInteger());
break;
case 107:
vortex.setRootDuration(field.getInteger());
break;
case 109:
vortex.setPullDamage(parseFloat(field, vortex.getPullDamage()));
break;
@@ -58,7 +58,7 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr
if (scrollAnimations == null) {
scrollAnimations = new GuiCustomScroll(this, 0, 0);
scrollAnimations.setSize(212, 163);
scrollAnimations.setSize(212, 150);
}
scrollAnimations.setList(getSearchList());
if (selectedName != null) {
@@ -68,7 +68,8 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr
scrollAnimations.guiTop = guiTop + 14;
this.addScroll(scrollAnimations);
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 4, guiTop + 179, 212, 20, search));
// Search textbox - moved up to avoid overlapping with buttons
addTextField(new GuiNpcTextField(55, this, fontRendererObj, guiLeft + 4, guiTop + 166, 212, 20, search));
}
@Override
@@ -57,6 +57,7 @@ public abstract class GuiNPCInterface extends GuiScreen {
public float bgScaleX = 1;
public float bgScaleY = 1;
public float bgScaleZ = 1;
public int bgTextureHeight = 256; // Actual content height in texture (for bottom border stitching)
public GuiNPCInterface(EntityNPCInterface npc) {
this.player = Minecraft.getMinecraft().thePlayer;
@@ -74,6 +75,11 @@ public abstract class GuiNPCInterface extends GuiScreen {
background = new ResourceLocation("customnpcs", "textures/gui/" + texture);
}
public void setBackground(String texture, int textureHeight) {
background = new ResourceLocation("customnpcs", "textures/gui/" + texture);
bgTextureHeight = textureHeight;
}
public ResourceLocation getResource(String texture) {
return new ResourceLocation("customnpcs", "textures/gui/" + texture);
}
@@ -421,23 +427,44 @@ public abstract class GuiNPCInterface extends GuiScreen {
GL11.glTranslatef(guiLeft, guiTop, 0);
GL11.glScalef(bgScale * bgScaleX, bgScale * bgScaleY, bgScale * bgScaleZ);
mc.renderEngine.bindTexture(background);
// Handle Y dimension: if ySize < texture content height, stitch bottom border
int topHeight = ySize;
int bottomHeight = 0;
int bottomTextureV = 0;
if (ySize < bgTextureHeight) {
// Keep bottom border from texture bottom (last 6 pixels of actual content)
bottomHeight = 6;
topHeight = ySize - bottomHeight;
bottomTextureV = bgTextureHeight - bottomHeight;
}
if (xSize > 256) {
// GUI wider than texture: draw left portion, then right portion from texture edge
drawTexturedModalRect(0, 0, 0, 0, 250, ySize);
drawTexturedModalRect(250, 0, 256 - (xSize - 250), 0, xSize - 250, ySize);
drawTexturedModalRect(0, 0, 0, 0, 250, topHeight);
drawTexturedModalRect(250, 0, 256 - (xSize - 250), 0, xSize - 250, topHeight);
if (bottomHeight > 0) {
drawTexturedModalRect(0, topHeight, 0, bottomTextureV, 250, bottomHeight);
drawTexturedModalRect(250, topHeight, 256 - (xSize - 250), bottomTextureV, xSize - 250, bottomHeight);
}
} else if (xSize < 256) {
// GUI narrower than texture: stitch left and right edges together
// Left portion (first half of GUI)
int leftWidth = xSize / 2;
// Right portion width (remaining)
int rightWidth = xSize - leftWidth;
// Draw left side from texture start
drawTexturedModalRect(0, 0, 0, 0, leftWidth, ySize);
// Draw right side from texture end (256 - rightWidth)
drawTexturedModalRect(leftWidth, 0, 256 - rightWidth, 0, rightWidth, ySize);
// Draw top portion
drawTexturedModalRect(0, 0, 0, 0, leftWidth, topHeight);
drawTexturedModalRect(leftWidth, 0, 256 - rightWidth, 0, rightWidth, topHeight);
// Draw bottom border strip
if (bottomHeight > 0) {
drawTexturedModalRect(0, topHeight, 0, bottomTextureV, leftWidth, bottomHeight);
drawTexturedModalRect(leftWidth, topHeight, 256 - rightWidth, bottomTextureV, rightWidth, bottomHeight);
}
} else {
// GUI exactly 256px: draw full texture
drawTexturedModalRect(0, 0, 0, 0, xSize, ySize);
// GUI exactly 256px wide
drawTexturedModalRect(0, 0, 0, 0, xSize, topHeight);
if (bottomHeight > 0) {
drawTexturedModalRect(0, topHeight, 0, bottomTextureV, xSize, bottomHeight);
}
}
GL11.glPopMatrix();
}
@@ -481,6 +481,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
super.onLivingUpdate();
// Apply locked rotation after super.onLivingUpdate() to override look helper changes
abilities.applyLockedRotation();
handleMountRiderState();
if (worldObj.isRemote) {
@@ -115,6 +115,7 @@ gui.play=Play
gui.selectSound=Select Sound
gui.selectnpc=Select NPC
gui.select=Select
gui.sync=Sync
gui.range=Range
gui.partly=Partially
gui.copy=Copy
@@ -1504,6 +1505,8 @@ menu.abilities=Abilities
ability.availableTypes=Available Types
ability.npcAbilities=NPC Abilities
ability.globalCooldown=Global Cooldown
ability.minCooldown=Min CD
ability.maxCooldown=Max CD
ability.edit=Edit Ability
ability.weight=Weight
ability.targeting=Targeting
@@ -1512,8 +1515,7 @@ ability.maxRange=Max Range
ability.timing=Timing (ticks)
ability.cooldown=Cooldown
ability.windup=Wind Up
ability.active=Active
ability.recovery=Recovery
ability.dazed=Dazed Ticks
ability.interruptible=Interruptible
ability.threshold=Threshold
ability.lockMove=Lock Move
@@ -1575,17 +1577,11 @@ ability.minDist=Min Dist
ability.distance=Distance
ability.lifetime=Lifetime
ability.stunTicks=Stun
ability.stunDur=Stun Dur
ability.rootDur=Root Dur
ability.rootDuration=Root Duration
ability.stunDuration=Stun Duration
ability.leapHeight=Leap Height
ability.hitWidth=Hit Width
ability.potionTime=Potion Time (s)
ability.weaknessLvl=Weakness Lvl
ability.poisonTime=Poison Time (s)
ability.slownessLvl=Slowness Lvl
ability.poisonLvl=Poison Lvl
ability.effects=Effects
gui.duration=Duration
gui.amp=Amp
# Slam Settings
ability.leapSpeed=Leap Speed
@@ -1686,6 +1682,10 @@ ability.innerColor=Inner Color
ability.outerColor=Outer Color
ability.outerEnabled=Outer Glow
ability.outerWidth=Outer Width
ability.lightning=Lightning
ability.lightningDensity=Density
ability.lightningRadius=Radius
ability.anchorPoint=Anchor Point
ability.noVisualSettings=No visual settings for this ability type
# Laser Shot Settings
@@ -1728,6 +1728,50 @@ ability.typeId=Type ID
ability.conditions=Conditions
ability.noTypeSettings=No type-specific settings
ability.hover.weight=Higher weight = more likely to be chosen when multiple abilities available
ability.hover.lockMove=Prevents NPC from moving while ability is charging or active
ability.hover.interruptible=If enabled, ability can be interrupted by taking damage
ability.hover.dazed=Stun duration in ticks if ability is interrupted (20 ticks = 1 second)
ability.hover.windup=Charge-up time before ability activates (20 ticks = 1 second)
ability.hover.cooldown=Time before ability can be used again (20 ticks = 1 second)
ability.hover.sync=Set windup ticks to match animation duration
ability.hover.minRange=Target must be at least this far away
ability.hover.maxRange=Target must be within this distance
ability.hover.targeting=How the ability selects its target
ability.hover.conditions=Requirements that must be met for ability to activate
ability.hover.showTelegraph=Show visual warning indicator during windup
ability.hover.windUpColor=Color of telegraph during charge-up phase
ability.hover.activeColor=Color of telegraph when ability is active
ability.hover.homing=Projectile tracks toward target
ability.hover.homingStr=How aggressively the projectile tracks (higher = tighter turns)
ability.hover.explosive=Creates explosion on impact
ability.hover.explosionRad=Size of explosion radius
ability.hover.piercing=Hits multiple targets instead of stopping on first hit
ability.hover.lightning=Add electrical effect to visuals
ability.hover.outerGlow=Enable outer glow layer around projectile
ability.hover.anchorPoint=Where on the NPC the ability spawns from
ability.hover.damage=Base damage dealt to targets
ability.hover.speed=Movement speed of projectile
ability.hover.lifetime=Maximum ticks before despawning
ability.hover.knockback=Push force applied to targets
ability.hover.boomerang=Projectile returns to caster after reaching max distance
ability.hover.dashMode=Aggressive dashes toward target, Defensive dashes away
ability.hover.aoe=Affects all valid targets in range instead of just one
ability.hover.dmgOnPull=Deal damage continuously while pulling targets
ability.hover.lineOfSight=Requires clear line of sight to the target
ability.hover.dmgAtStart=Deal damage at the teleport origin location
ability.hover.dmgAtEnd=Deal damage at the teleport destination
ability.hover.instant=Heals instantly instead of over time
ability.hover.healSelf=Ability can heal the casting NPC
ability.hover.healAllies=Ability can heal nearby allied NPCs
ability.hover.placement=Where the ability effect is placed (Caster, Target, etc.)
ability.hover.lockTarget=Sweeper beam tracks the target's position
ability.hover.canCounter=Enable counterattack when blocking damage
ability.hover.counterType=Flat = fixed damage, Percent = % of blocked damage
ability.hover.shape=Shape of the hazard zone (Circle, Ring, Cone)
ability.hover.affectsCaster=Hazard can damage the NPC that created it
ability.hover.sweepMode=Swipe = single arc attack, Spin = continuous rotation
# Conditions
condition.edit=Edit Condition
condition.hp_above=NPC HP Above