more pillar changes and fixes

This commit is contained in:
Vidal committed 2026-03-14 22:30:01 -03:00
1 parent a2beef0549
commit 9546500b4b
7 files changed
+270 -169

No files matched your search

+1 -1
Submodule src/api updated: f91e17ab3e...e7f363727e.
@@ -2,7 +2,6 @@ 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.EntityAbilityPillar;
import kamkeel.npcs.entity.EntityAbilityPillar.PillarOrigin;
import kamkeel.npcs.entity.EntityAbilityPillar.PillarShape;
@@ -15,16 +14,17 @@ import org.lwjgl.opengl.GL11;
* Renders EntityAbilityPillar as a vertical energy column.
*
* Shape modes:
* - CIRCLE: cylindrical pillar rendered with triangulated segments.
* - CIRCLE: cylindrical pillar with triangulated segments.
* - SQUARE: rectangular prism pillar.
*
* Both modes render three color layers (outer glow, mid, inner core).
*
* Origin modes:
* - FROM_GROUND: base at posY, pillar grows upward toward posY + height.
* - FROM_ABOVE: pillar falls from above, tip at posY, grows downward.
* The entity posY is always the ground anchor point.
* Visually: base = posY + targetHeight, tip grows down toward posY.
* - FROM_GROUND: posY = ground base. Pillar grows upward (baseY = posY, tipY = posY + height).
* - FROM_ABOVE: posY = top anchor (ceiling). Pillar grows downward
* (baseY = posY, tipY = posY - height).
*
* During charging, a flat disc grows at ground level (FROM_GROUND) or ceiling level (FROM_ABOVE).
*/
@SideOnly(Side.CLIENT)
public class RenderEnergyPillar extends RenderEnergy {
@@ -56,27 +56,19 @@ public class RenderEnergyPillar extends RenderEnergy {
return;
}
// FROM_GROUND: base at y, tip at y+height (grows up).
// FROM_ABOVE: pillar descends from above. The entity's posY is the ground anchor.
// The full column height is targetHeight. The current height is how far
// it has grown. So the visible column spans from:
// tip = posY + targetHeight - height (starts high, descends)
// base = posY + targetHeight (fixed ceiling)
// FROM_GROUND: base at y, tip grows up.
// FROM_ABOVE: posY is the top anchor. Base = y, tip = y - height (grows down).
float baseY, tipY;
float targetHeight = pillar.getPillarData().targetHeight;
if (pillar.getPillarOrigin() == PillarOrigin.FROM_ABOVE) {
baseY = (float) y + targetHeight;
tipY = (float) y + targetHeight - height;
baseY = (float) y;
tipY = (float) y - height;
} else {
baseY = (float) y;
tipY = (float) y + height;
}
float rotationAngle = 0f;
float rotationSpeed = pillar.getRotationSpeed();
if (rotationSpeed != 0f) {
rotationAngle = (pillar.ticksExisted + partialTicks) * rotationSpeed;
}
float rotationAngle = pillar.getRotationSpeed() != 0f
? (pillar.ticksExisted + partialTicks) * pillar.getRotationSpeed() : 0f;
float innerRadius = radius * INNER_SCALE;
int innerColor = pillar.getInnerColor();
@@ -111,23 +103,21 @@ public class RenderEnergyPillar extends RenderEnergy {
private void renderCharging(EntityAbilityPillar pillar, double x, double y, double z,
float partialTicks, float proximityAlpha) {
float radius = pillar.getInterpolatedPillarRadius(partialTicks);
float radius = pillar.getTargetRadius() * 2;
float chargeProgress = pillar.getInterpolatedChargeProgress(partialTicks);
float renderRadius = radius * chargeProgress;
if (renderRadius <= 0.01f) return;
float pulseTime = pillar.ticksExisted + partialTicks;
float pulse = (float) Math.sin(pulseTime * 0.2f) * 0.08f;
renderRadius *= (1.0f + pulse);
renderRadius *= (1.0f + (float) Math.sin(pulseTime * 0.2f) * 0.08f);
// During charging, render a flat disc at ground level
// Flat disc at the anchor point
float baseY = (float) y;
float tipY = baseY + 0.05f;
float rotationAngle = pillar.getRotationSpeed() != 0f
? (pillar.ticksExisted + partialTicks) * pillar.getRotationSpeed()
: 0f;
? (pillar.ticksExisted + partialTicks) * pillar.getRotationSpeed() : 0f;
float innerRadius = renderRadius * INNER_SCALE;
int innerColor = pillar.getInnerColor();
@@ -158,8 +148,7 @@ public class RenderEnergyPillar extends RenderEnergy {
// ==================== SHAPE DISPATCH ====================
private void renderPillarShape(PillarShape shape, double x, float baseY, float tipY,
double z, float radius, int color, float alpha,
float rotationAngle) {
double z, float radius, int color, float alpha, float rotationAngle) {
if (shape == PillarShape.SQUARE) {
renderSquarePillar(x, baseY, tipY, z, radius, color, alpha, rotationAngle);
} else {
@@ -203,6 +192,9 @@ public class RenderEnergyPillar extends RenderEnergy {
}
tess.draw();
float capMinY = Math.min(baseY, tipY);
float capMaxY = Math.max(baseY, tipY);
// Bottom cap
tess.startDrawingQuads();
tess.setColorRGBA_F(r, g, b, alpha);
@@ -212,10 +204,10 @@ public class RenderEnergyPillar extends RenderEnergy {
float z1 = (float) cz + sinTable[i] * radius;
float x2 = (float) cx + cosTable[i + 1] * radius;
float z2 = (float) cz + sinTable[i + 1] * radius;
tess.addVertex((float) cx, baseY, (float) cz);
tess.addVertex(x2, baseY, z2);
tess.addVertex(x1, baseY, z1);
tess.addVertex((float) cx, baseY, (float) cz);
tess.addVertex((float) cx, capMinY, (float) cz);
tess.addVertex(x2, capMinY, z2);
tess.addVertex(x1, capMinY, z1);
tess.addVertex((float) cx, capMinY, (float) cz);
}
tess.draw();
@@ -228,10 +220,10 @@ public class RenderEnergyPillar extends RenderEnergy {
float z1 = (float) cz + sinTable[i] * radius;
float x2 = (float) cx + cosTable[i + 1] * radius;
float z2 = (float) cz + sinTable[i + 1] * radius;
tess.addVertex((float) cx, tipY, (float) cz);
tess.addVertex(x1, tipY, z1);
tess.addVertex(x2, tipY, z2);
tess.addVertex((float) cx, tipY, (float) cz);
tess.addVertex((float) cx, capMaxY, (float) cz);
tess.addVertex(x1, capMaxY, z1);
tess.addVertex(x2, capMaxY, z2);
tess.addVertex((float) cx, capMaxY, (float) cz);
}
tess.draw();
}
@@ -255,6 +247,9 @@ public class RenderEnergyPillar extends RenderEnergy {
corners[i][1] = (float) cz + lx[i] * sinA + lz[i] * cosA;
}
float capMinY = Math.min(baseY, tipY);
float capMaxY = Math.max(baseY, tipY);
Tessellator tess = Tessellator.instance;
tess.startDrawingQuads();
tess.setColorRGBA_F(r, g, b, alpha);
@@ -274,19 +269,17 @@ public class RenderEnergyPillar extends RenderEnergy {
tess.addVertex(x1, tipY, z1);
}
// Bottom cap
tess.setNormal(0, -1, 0);
tess.addVertex(corners[0][0], baseY, corners[0][1]);
tess.addVertex(corners[3][0], baseY, corners[3][1]);
tess.addVertex(corners[2][0], baseY, corners[2][1]);
tess.addVertex(corners[1][0], baseY, corners[1][1]);
tess.addVertex(corners[0][0], capMinY, corners[0][1]);
tess.addVertex(corners[3][0], capMinY, corners[3][1]);
tess.addVertex(corners[2][0], capMinY, corners[2][1]);
tess.addVertex(corners[1][0], capMinY, corners[1][1]);
// Top cap
tess.setNormal(0, 1, 0);
tess.addVertex(corners[0][0], tipY, corners[0][1]);
tess.addVertex(corners[1][0], tipY, corners[1][1]);
tess.addVertex(corners[2][0], tipY, corners[2][1]);
tess.addVertex(corners[3][0], tipY, corners[3][1]);
tess.addVertex(corners[0][0], capMaxY, corners[0][1]);
tess.addVertex(corners[1][0], capMaxY, corners[1][1]);
tess.addVertex(corners[2][0], capMaxY, corners[2][1]);
tess.addVertex(corners[3][0], capMaxY, corners[3][1]);
tess.draw();
}
@@ -38,32 +38,32 @@ public class EnergyPillarData {
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setFloat("TargetRadius", targetRadius);
nbt.setFloat("TargetHeight", targetHeight);
nbt.setFloat("RadiusGrowSpeed", radiusGrowSpeed);
nbt.setFloat("HeightGrowSpeed", heightGrowSpeed);
nbt.setInteger("PillarMode", mode.ordinal());
nbt.setInteger("PillarOrigin", origin.ordinal());
nbt.setInteger("PillarShape", shape.ordinal());
nbt.setInteger("SpawnDelay", spawnDelay);
nbt.setFloat("targetRadius", targetRadius);
nbt.setFloat("targetHeight", targetHeight);
nbt.setFloat("radiusGrowSpeed", radiusGrowSpeed);
nbt.setFloat("heightGrowSpeed", heightGrowSpeed);
nbt.setInteger("pillarMode", mode.ordinal());
nbt.setInteger("pillarOrigin", origin.ordinal());
nbt.setInteger("pillarShape", shape.ordinal());
nbt.setInteger("spawnDelay", spawnDelay);
}
public void readNBT(NBTTagCompound nbt) {
this.targetRadius = nbt.hasKey("TargetRadius") ? nbt.getFloat("TargetRadius") : 1.0f;
this.targetHeight = nbt.hasKey("TargetHeight") ? nbt.getFloat("TargetHeight") : 2.0f;
this.radiusGrowSpeed = nbt.hasKey("RadiusGrowSpeed") ? nbt.getFloat("RadiusGrowSpeed") : 0.1f;
this.heightGrowSpeed = nbt.hasKey("HeightGrowSpeed") ? nbt.getFloat("HeightGrowSpeed") : 0.2f;
this.targetRadius = nbt.hasKey("targetRadius") ? nbt.getFloat("targetRadius") : 1.0f;
this.targetHeight = nbt.hasKey("targetHeight") ? nbt.getFloat("targetHeight") : 2.0f;
this.radiusGrowSpeed = nbt.hasKey("radiusGrowSpeed") ? nbt.getFloat("radiusGrowSpeed") : 0.1f;
this.heightGrowSpeed = nbt.hasKey("heightGrowSpeed") ? nbt.getFloat("heightGrowSpeed") : 0.2f;
int modeOrd = nbt.hasKey("PillarMode") ? nbt.getInteger("PillarMode") : 0;
int modeOrd = nbt.hasKey("pillarMode") ? nbt.getInteger("pillarMode") : 0;
this.mode = (modeOrd >= 0 && modeOrd < PillarMode.values().length) ? PillarMode.values()[modeOrd] : PillarMode.ANCHORED;
int originOrd = nbt.hasKey("PillarOrigin") ? nbt.getInteger("PillarOrigin") : 0;
int originOrd = nbt.hasKey("pillarOrigin") ? nbt.getInteger("pillarOrigin") : 0;
this.origin = (originOrd >= 0 && originOrd < PillarOrigin.values().length) ? PillarOrigin.values()[originOrd] : PillarOrigin.FROM_GROUND;
int shapeOrd = nbt.hasKey("PillarShape") ? nbt.getInteger("PillarShape") : 0;
int shapeOrd = nbt.hasKey("pillarShape") ? nbt.getInteger("pillarShape") : 0;
this.shape = (shapeOrd >= 0 && shapeOrd < PillarShape.values().length) ? PillarShape.values()[shapeOrd] : PillarShape.CIRCLE;
this.spawnDelay = nbt.hasKey("SpawnDelay") ? Math.max(0, nbt.getInteger("SpawnDelay")) : 0;
this.spawnDelay = nbt.hasKey("spawnDelay") ? Math.max(0, nbt.getInteger("spawnDelay")) : 0;
}
public EnergyPillarData copy() {
@@ -184,12 +184,16 @@ public abstract class AbilityEnergyZone<E extends EntityEnergyZone> extends Abil
// ==================== ENTITY CREATION ====================
protected E createZoneEntity(EntityLivingBase caster, EntityLivingBase target, int index) {
double[] pos = getSpawnPosition(caster, target, index);
return createZoneEntityAt(caster, target, index, getSpawnPosition(caster, target, index));
}
protected E createZoneEntityAt(EntityLivingBase caster, EntityLivingBase target, int index, double[] pos) {
EnergyDisplayData resolved = resolveDisplay(index);
E entity = createEntity(caster, target, pos[0], pos[1], pos[2], resolved, index);
entity.setSourceAbility(this);
entity.setIgnoreIFrames(this.isIgnoreIFrames());
entity.setEffects(this.effects);
// Copy ability combat data to entity so hitType, damage, knockback are in sync
noppes.npcs.controllers.data.MagicData resolvedMagic = resolveMagicData(caster);
if (resolvedMagic != null) {
entity.setMagicData(resolvedMagic.copy());
@@ -197,6 +201,15 @@ public abstract class AbilityEnergyZone<E extends EntityEnergyZone> extends Abil
return entity;
}
/**
* Get spawn position for charge visual during windup.
* Default: same as getSpawnPosition. Override for types where windup position
* differs from execute position (e.g. Pillar MOVING uses target pos during windup).
*/
protected double[] getWindupSpawnPosition(EntityLivingBase caster, EntityLivingBase target, int index) {
return getSpawnPosition(caster, target, index);
}
protected void spawnZoneEntity(E entity, int index) {
if (entity == null) return;
spawnAbilityEntity(entity);
@@ -223,7 +236,10 @@ public abstract class AbilityEnergyZone<E extends EntityEnergyZone> extends Abil
if (isPreview() || caster == null || caster.worldObj == null || caster.worldObj.isRemote) return;
if (chargeVisualIds == null || index < 0 || index >= chargeVisualIds.length) return;
E previewEntity = createZoneEntity(caster, target, index);
double[] windupPos = getWindupSpawnPosition(caster, target, index);
E previewEntity = createZoneEntityAt(caster, target, index, windupPos);
previewEntity.setPreviewMode(true);
previewEntity.setPreviewOwner(caster);
setupEntityCharging(previewEntity, index);
@@ -505,16 +521,21 @@ public abstract class AbilityEnergyZone<E extends EntityEnergyZone> extends Abil
.visibleWhen(() -> getHitType() != HitType.SINGLE.ordinal())
.hover("ability.hover.maxHits"));
defs.add(FieldDef.intField("ability.zoneCount", this::getZoneCount, this::setZoneCount)
.range(1, MAX_ZONES));
defs.add(FieldDef.intField("ability.fireDelay", this::getFireDelay, this::setFireDelay)
.range(0, 200)
.visibleWhen(() -> zoneCount > 1));
defs.add(FieldDef.row(
FieldDef.intField("ability.zoneCount", this::getZoneCount, this::setZoneCount)
.range(1, MAX_ZONES),
FieldDef.intField("ability.fireDelay", this::getFireDelay, this::setFireDelay)
.range(0, 200).visibleWhen(() -> zoneCount > 1)
));
addTypeDefinitions(defs);
addEnergyColorDefinitions(defs);
addEnergyEffectDefinitions(defs);
defs.add(FieldDef.section("ability.section.effects").tab("ability.tab.visual"));
defs.add(FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed)
.tab("ability.tab.visual"));
addEnergyLightningDefinitions(defs);
}
// ==================== COMBAT GETTERS & SETTERS ====================
@@ -9,10 +9,14 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyPillarData;
import kamkeel.npcs.controllers.data.ability.enums.HitType;
import kamkeel.npcs.controllers.data.ability.enums.LockMode;
import kamkeel.npcs.controllers.data.ability.enums.TargetingMode;
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityAbilityPillar;
import kamkeel.npcs.entity.EntityAbilityPillar.OffsetAxis;
import kamkeel.npcs.entity.EntityAbilityPillar.PillarMode;
import kamkeel.npcs.entity.EntityAbilityPillar.PillarShape;
import net.minecraft.entity.EntityLivingBase;
@@ -26,18 +30,19 @@ import java.util.List;
* Pillar zone ability — spawns one or more energy pillars that rise from the ground
* or fall from the sky.
*
* ANCHORED: pillar spawns at the target's position and stays there.
* When count > 1, each subsequent pillar recalculates a random position
* near the target at spawn time.
* ANCHORED: pillar spawns at the target's position at execute time and stays there.
* When count > 1, each subsequent pillar gets a random nearby position.
*
* MOVING: pillar spawns in front of the caster and travels forward.
* MOVING: pillar spawns in front of the caster at execute time and travels forward.
* With homing: steers toward target.
* Without homing: straight line along caster look vector or toward target.
* When count > 1, pillarOffset spaces pillars apart along the travel direction.
* When count > 1, pillarOffset spaces pillars along the chosen OffsetAxis.
*
* Telegraph shape matches PillarShape (CIRCLE or SQUARE).
* In MOVING mode, telegraph appears at the spawn point in front of the caster.
* Charge visual appears at the target/spawn position during windup (tick 1),
* growing in radius at ground level — exactly above the telegraph.
*/
// TODO 1. add another mode, static, 2. fix charging radius, rotation, etc
public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
// ==================== PILLAR CONFIG ====================
@@ -45,12 +50,12 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
private EnergyPillarData pillarData = new EnergyPillarData();
private EnergyHomingData homingData = new EnergyHomingData();
/**
* Spacing between pillars in MOVING mode when count > 1.
* 0 = all spawn at the same position.
*/
/** Spacing between pillars when count > 1. 0 = same position. */
private float pillarOffset = 0f;
/** Axis along which pillarOffset is applied in MOVING mode. */
private OffsetAxis offsetAxis = OffsetAxis.Z;
// ==================== CONSTRUCTOR ====================
public AbilityPillar() {
@@ -59,8 +64,16 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
new EnergyCombatData(),
new EnergyLifespanData()
);
combatData.hitType = HitType.MULTI;
combatData.multiHitDelayTicks = 20;
this.typeId = "ability.cnpc.pillar";
this.name = "Pillar";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 25.0f;
this.minRange = 5.0f;
this.cooldownTicks = 0;
this.windUpTicks = 30;
this.lockMovement = LockMode.WINDUP;
this.telegraphType = pillarData.shape.getTelegraphType();
this.showTelegraph = true;
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@@ -69,20 +82,14 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
protected EntityAbilityPillar createEntity(EntityLivingBase caster, EntityLivingBase target,
double x, double y, double z,
EnergyDisplayData resolved, int index) {
return new EntityAbilityPillar(
caster.worldObj, caster,
x, y, z,
pillarData,
resolved,
lightningData,
homingData
);
return new EntityAbilityPillar(caster.worldObj, caster, x, y, z,
pillarData, resolved, combatData, homingData, lightningData, lifespanData);
}
@Override
protected void setupEntityCharging(EntityAbilityPillar entity, int index) {
// The charge visual should appear at ground level at the spawn position,
// not following the caster anchor. Position is already set by createEntity.
// Charge visual: entity is already at the correct ground position.
// Just set it up for charging — it will grow in radius at that position.
entity.setupCharging(windUpTicks);
}
@@ -102,38 +109,39 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
return pillarData.targetRadius;
}
// ==================== SPAWN POSITION ====================
// ==================== SPAWN POSITIONS ====================
/**
* Spawn position at execute time.
* MOVING: in front of caster with offset per index along offsetAxis.
* ANCHORED index 0: pre-calculated telegraph position.
* ANCHORED index > 0: random position near target.
*/
@Override
protected double[] getSpawnPosition(EntityLivingBase caster, EntityLivingBase target, int index) {
if (pillarData.mode == PillarMode.MOVING) {
Vec3 look = caster.getLookVec();
if (look == null) {
return new double[]{caster.posX, caster.posY, caster.posZ};
}
if (look == null) return new double[]{caster.posX, caster.posY, caster.posZ};
float baseDist = Math.max(1.0f, pillarData.targetRadius);
float offsetDist = baseDist + pillarOffset * index;
double ox = offsetAxis == OffsetAxis.X ? pillarOffset * index : 0;
double oz = offsetAxis == OffsetAxis.Z ? pillarOffset * index : 0;
return new double[]{
caster.posX + look.xCoord * offsetDist,
caster.posX + look.xCoord * baseDist + ox,
caster.posY,
caster.posZ + look.zCoord * offsetDist
caster.posZ + look.zCoord * baseDist + oz
};
}
// ANCHORED: index 0 uses pre-calculated telegraph position.
// Subsequent indices recalculate a random nearby position at spawn time.
if (index == 0) {
return super.getSpawnPosition(caster, target, index);
}
// For index > 0, find a new random position near the target
double baseX = target != null ? target.posX : caster.posX;
double baseZ = target != null ? target.posZ : caster.posZ;
double baseY = target != null ? target.posY : caster.posY;
float spawnRadius = Math.max(pillarData.targetRadius * 2.0f, 3.0f);
float spread = Math.max(pillarData.targetRadius * 2.0f, 3.0f);
double angle = Math.random() * Math.PI * 2;
double dist = Math.sqrt(Math.random()) * spawnRadius;
double dist = Math.sqrt(Math.random()) * spread;
return new double[]{
baseX + Math.cos(angle) * dist,
baseY,
@@ -141,6 +149,37 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
};
}
/**
* Windup spawn position for charge visual.
* Always uses the target/telegraph position so the charge visual
* appears at ground level exactly above the telegraph.
*/
@Override
protected double[] getWindupSpawnPosition(EntityLivingBase caster, EntityLivingBase target, int index) {
if (pillarData.mode == PillarMode.MOVING) {
// Charge visual appears at the same spot the pillar will spawn
Vec3 look = caster.getLookVec();
if (look == null) return new double[]{caster.posX, caster.posY, caster.posZ};
float baseDist = Math.max(1.0f, pillarData.targetRadius);
double ox = offsetAxis == OffsetAxis.X ? pillarOffset * index : 0;
double oz = offsetAxis == OffsetAxis.Z ? pillarOffset * index : 0;
return new double[]{
caster.posX + look.xCoord * baseDist + ox,
caster.posY,
caster.posZ + look.zCoord * baseDist + oz
};
}
// ANCHORED: use pre-calculated telegraph position for index 0,
// target position for the rest
if (index == 0 && !preCalculatedPositions.isEmpty()) {
return preCalculatedPositions.get(0);
}
if (target != null) {
return new double[]{target.posX, target.posY, target.posZ};
}
return new double[]{caster.posX, caster.posY, caster.posZ};
}
// ==================== EXECUTE ====================
@Override
@@ -153,7 +192,6 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
entity.setTarget(target);
}
// Set straight-line motion for MOVING mode without homing
if (pillarData.mode == PillarMode.MOVING && !homingData.isHoming()) {
double mx = 0, mz = 0;
if (target != null) {
@@ -201,7 +239,6 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
double telegraphX, telegraphZ, telegraphY;
if (pillarData.mode == PillarMode.MOVING) {
// Telegraph appears at the spawn point in front of the caster
Vec3 look = caster.getLookVec();
if (look != null) {
float dist = Math.max(1.0f, pillarData.targetRadius);
@@ -212,30 +249,20 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
telegraphZ = caster.posZ;
}
telegraphY = findGroundLevel(caster.worldObj, telegraphX, caster.posY, telegraphZ);
preCalculatedPositions.clear();
preCalculatedPositions.add(new double[]{telegraphX, telegraphY, telegraphZ});
} else {
// ANCHORED: telegraph at target position
if (target == null) return null;
telegraphX = target.posX;
telegraphZ = target.posZ;
telegraphY = findGroundLevel(caster.worldObj, telegraphX, target.posY, telegraphZ);
preCalculatedPositions.clear();
preCalculatedPositions.add(new double[]{telegraphX, telegraphY, telegraphZ});
}
preCalculatedPositions.clear();
preCalculatedPositions.add(new double[]{telegraphX, telegraphY, telegraphZ});
TelegraphInstance instance = new TelegraphInstance(
telegraph, telegraphX, telegraphY, telegraphZ, caster.rotationYaw);
instance.setCasterEntityId(caster.getEntityId());
// In ANCHORED+homing, telegraph follows the target
if (pillarData.mode == PillarMode.ANCHORED && homingData.isHoming() && target != null) {
instance.setEntityIdToFollow(target.getEntityId());
} else {
instance.setEntityIdToFollow(-1);
}
instance.setEntityIdToFollow(-1);
return instance;
}
@@ -251,14 +278,18 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
protected void writeTypeSpecificNBT(NBTTagCompound nbt) {
pillarData.writeNBT(nbt);
homingData.writeNBT(nbt);
nbt.setFloat("PillarOffset", pillarOffset);
nbt.setFloat("pillarOffset", pillarOffset);
nbt.setInteger("offsetAxis", offsetAxis.ordinal());
}
@Override
protected void readTypeSpecificNBT(NBTTagCompound nbt) {
pillarData.readNBT(nbt);
homingData.readNBT(nbt);
this.pillarOffset = nbt.hasKey("PillarOffset") ? nbt.getFloat("PillarOffset") : 0f;
this.pillarOffset = nbt.hasKey("pillarOffset") ? nbt.getFloat("pillarOffset") : 0f;
int axisOrd = nbt.hasKey("offsetAxis") ? nbt.getInteger("offsetAxis") : 1;
this.offsetAxis = (axisOrd >= 0 && axisOrd < OffsetAxis.values().length)
? OffsetAxis.values()[axisOrd] : OffsetAxis.Z;
}
// ==================== GUI ====================
@@ -266,6 +297,11 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
@SideOnly(Side.CLIENT)
@Override
protected void addTypeDefinitions(List<FieldDef> defs) {
FieldDef.insertAfter(defs, "ability.fireDelay", FieldDef.row(
FieldDef.floatField("ability.pillar.offset", () -> pillarOffset, v -> pillarOffset = Math.max(0f, v)).range(0f, 20f),
FieldDef.enumField("ability.pillar.offsetAxis", OffsetAxis.class, () -> offsetAxis, v -> offsetAxis = v)
).visibleWhen(() -> zoneCount > 1));
defs.add(FieldDef.section("ability.section.pillar"));
defs.add(FieldDef.enumField("ability.pillarMode", PillarMode.class,
@@ -277,6 +313,11 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
defs.add(FieldDef.enumField("ability.pillarShape", PillarShape.class,
() -> pillarData.shape, v -> pillarData.shape = v));
defs.add(FieldDef.intField("ability.pillar.spawnDelay", () -> pillarData.spawnDelay, v -> pillarData.spawnDelay = Math.max(0, v))
.range(0, 200));
defs.add(FieldDef.section("ability.section.size"));
defs.add(FieldDef.row(
FieldDef.floatField("ability.pillar.targetRadius", () -> pillarData.targetRadius, v -> pillarData.targetRadius = v).range(0.1f, 64f),
FieldDef.floatField("ability.pillar.targetHeight", () -> pillarData.targetHeight, v -> pillarData.targetHeight = v).range(0.1f, 64f)
@@ -287,33 +328,25 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
FieldDef.floatField("ability.pillar.heightGrowSpeed", () -> pillarData.heightGrowSpeed, v -> pillarData.heightGrowSpeed = Math.max(0.01f, v))
));
defs.add(FieldDef.intField("ability.pillar.spawnDelay", () -> pillarData.spawnDelay, v -> pillarData.spawnDelay = Math.max(0, v))
.range(0, 200));
defs.add(FieldDef.floatField("ability.pillar.offset", () -> pillarOffset, v -> pillarOffset = Math.max(0f, v))
.visibleWhen(() -> zoneCount > 1)
.range(0f, 20f));
defs.add(FieldDef.section("ability.section.movement")
.visibleWhen(() -> pillarData.mode == PillarMode.MOVING));
defs.add(FieldDef.section("ability.section.movement"));
defs.add(FieldDef.floatField("ability.speed", () -> homingData.getSpeed(), v -> homingData.setSpeed(v))
.visibleWhen(() -> pillarData.mode == PillarMode.MOVING)
.range(0.01f, 10f));
defs.add(FieldDef.boolField("ability.homing", () -> homingData.isHoming(), v -> homingData.setHoming(v))
.visibleWhen(() -> pillarData.mode == PillarMode.MOVING));
defs.add(FieldDef.boolField("ability.homing", () -> homingData.isHoming(), v -> homingData.setHoming(v)));
defs.add(FieldDef.row(
FieldDef.floatField("ability.homingStrength", () -> homingData.getHomingStrength(), v -> homingData.setHomingStrength(v)).range(0f, 1f),
FieldDef.floatField("ability.homingRange", () -> homingData.getHomingRange(), v -> homingData.setHomingRange(v))
).visibleWhen(() -> pillarData.mode == PillarMode.MOVING && homingData.isHoming()));
).visibleWhen(() -> homingData.isHoming()));
defs.add(FieldDef.section("ability.section.combat"));
defs.add(FieldDef.floatField("ability.damage", this::getDamage, this::setDamage).range(0f, 1000f));
defs.add(FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).range(0f, 10f));
defs.add(FieldDef.intField("ability.maxLifetime", this::getMaxLifetime, this::setMaxLifetime).range(1, 1200));
defs.add(AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects));
}
// ==================== GETTERS & SETTERS ====================
@@ -326,4 +359,7 @@ public class AbilityPillar extends AbilityEnergyZone<EntityAbilityPillar> {
public float getPillarOffset() { return pillarOffset; }
public void setPillarOffset(float offset) { this.pillarOffset = Math.max(0f, offset); }
public OffsetAxis getOffsetAxis() { return offsetAxis; }
public void setOffsetAxis(OffsetAxis axis) { this.offsetAxis = axis != null ? axis : OffsetAxis.Z; }
}
@@ -2,10 +2,7 @@ package kamkeel.npcs.entity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyPillarData;
import kamkeel.npcs.controllers.data.ability.data.energy.*;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -26,12 +23,14 @@ import java.util.List;
* line along the initial direction set by setInitialMotion().
*
* Lifecycle:
* 1. Charging — pillarRadius grows from 0 to targetRadius; pillarHeight stays at MIN_HEIGHT.
* 2. spawnDelay — fully charged, position locks (ANCHORED) or begins moving (MOVING).
* Height growth has not started yet.
* 3. Active — pillarHeight grows toward targetHeight at heightGrowSpeed per tick;
* pillarRadius continues toward targetRadius at radiusGrowSpeed per tick.
* Damage checks run once height exceeds MIN_HEIGHT.
* 1. Charging — charge visual grows in radius at ground level during windup.
* 2. spawnDelay — entity is alive but does not grow and does not deal damage.
* 3. Active — pillarHeight grows toward targetHeight; damage checks begin.
*
* FROM_ABOVE: posY is always the top anchor. The pillar grows downward.
* Hitbox spans from posY - height to posY.
* FROM_GROUND: posY is the ground anchor. The pillar grows upward.
* Hitbox spans from posY to posY + height.
*/
public class EntityAbilityPillar extends EntityEnergyZone {
@@ -39,7 +38,6 @@ public class EntityAbilityPillar extends EntityEnergyZone {
private static final float MIN_HEIGHT = 0.05f;
// DataWatcher slots (base uses 20 for charging)
private static final int DW_PILLAR_RADIUS = 21;
private static final int DW_PILLAR_HEIGHT = 22;
@@ -65,17 +63,20 @@ public class EntityAbilityPillar extends EntityEnergyZone {
}
}
public enum OffsetAxis {
X,
Z
}
// ==================== PILLAR CONFIG ====================
private EnergyPillarData pillarData = new EnergyPillarData();
// ==================== PILLAR DIMENSIONS — LOCAL ====================
// ==================== PILLAR DIMENSIONS ====================
private float pillarRadius = 0.01f;
private float pillarHeight = MIN_HEIGHT;
// ==================== PILLAR DIMENSIONS — RENDER INTERPOLATION ====================
private float renderPillarRadius = 0.01f;
private float renderPillarHeight = MIN_HEIGHT;
@@ -100,19 +101,25 @@ public class EntityAbilityPillar extends EntityEnergyZone {
public EntityAbilityPillar(World world, EntityLivingBase owner,
double x, double y, double z,
EnergyPillarData pillarData,
EnergyDisplayData display,
EnergyLightningData lightning,
EnergyHomingData homing) {
EnergyPillarData pillarData, EnergyDisplayData display,
EnergyCombatData combat, EnergyHomingData homing,
EnergyLightningData lightning, EnergyLifespanData lifespan) {
super(world);
this.ownerEntityId = owner != null ? owner.getEntityId() : -1;
this.pillarData = pillarData != null ? pillarData.copy() : new EnergyPillarData();
this.homingData = homing != null ? homing.copy() : new EnergyHomingData();
this.displayData = display != null ? display.copy() : new EnergyDisplayData();
this.combatData = combat != null ? combat.copy() : new EnergyCombatData();
this.homingData = homing != null ? homing.copy() : new EnergyHomingData();
this.lightningData = lightning != null ? lightning.copy() : new EnergyLightningData();
this.lifespanData = lifespan != null ? lifespan.copy() : new EnergyLifespanData();
snapToGround(x, y, z);
// FROM_ABOVE: posY is the top anchor — position at target height, not ground
if (pillarData != null && pillarData.origin == PillarOrigin.FROM_ABOVE) {
this.setPosition(x, y + pillarData.targetHeight, z);
} else {
snapToGround(x, y, z);
}
setPillarRadiusInternal(0.01f);
setPillarHeightInternal(MIN_HEIGHT);
@@ -152,8 +159,6 @@ public class EntityAbilityPillar extends EntityEnergyZone {
/**
* Set straight-line motion for MOVING mode without homing.
* Called by the ability before spawning, using the caster's look vector or
* direction toward target.
*/
public void setInitialMotion(double mx, double mz) {
this.motionX = mx;
@@ -178,7 +183,7 @@ public class EntityAbilityPillar extends EntityEnergyZone {
/**
* Called by the ability when charging ends.
* Starts the spawnDelay countdown, or immediately begins growing if spawnDelay is 0.
* Starts the spawnDelay countdown. No damage is dealt during spawnDelay.
*/
public void startGrowing() {
setCharging(false);
@@ -217,6 +222,7 @@ public class EntityAbilityPillar extends EntityEnergyZone {
return;
}
// spawnDelay: entity is alive but not growing and not dealing damage
if (!growing) {
spawnDelayTick++;
if (spawnDelayTick >= pillarData.spawnDelay) {
@@ -238,6 +244,7 @@ public class EntityAbilityPillar extends EntityEnergyZone {
updateMovement();
}
// Only deal damage once growing has started and height is meaningful
if (pillarHeight > MIN_HEIGHT) {
checkEntityCollision();
}
@@ -247,10 +254,9 @@ public class EntityAbilityPillar extends EntityEnergyZone {
private void updateMovement() {
if (!homingData.isHoming()) {
// Straight-line: motion was set by setInitialMotion() at spawn time
this.posX += motionX;
this.posZ += motionZ;
snapToGround(posX, posY, posZ);
repositionY();
return;
}
@@ -258,7 +264,7 @@ public class EntityAbilityPillar extends EntityEnergyZone {
if (target == null || !target.isEntityAlive()) {
this.posX += motionX;
this.posZ += motionZ;
snapToGround(posX, posY, posZ);
repositionY();
return;
}
@@ -282,16 +288,28 @@ public class EntityAbilityPillar extends EntityEnergyZone {
this.posX += motionX;
this.posZ += motionZ;
snapToGround(posX, posY, posZ);
repositionY();
}
/**
* Re-anchor Y position after horizontal movement.
* FROM_GROUND: snap to ground.
* FROM_ABOVE: snap to ground + targetHeight (top anchor stays at ceiling height).
*/
private void repositionY() {
if (pillarData.origin == PillarOrigin.FROM_ABOVE) {
double groundY = kamkeel.npcs.controllers.data.ability.Ability.findGroundLevel(worldObj, posX, posY, posZ);
this.setPosition(posX, groundY + pillarData.targetHeight, posZ);
} else {
snapToGround(posX, posY, posZ);
}
}
// ==================== COLLISION ====================
private void checkEntityCollision() {
AxisAlignedBB broadBox = AxisAlignedBB.getBoundingBox(
posX - pillarRadius, posY, posZ - pillarRadius,
posX + pillarRadius, posY + pillarHeight, posZ + pillarRadius
);
AxisAlignedBB broadBox = buildHitBox();
if (broadBox == null) return;
@SuppressWarnings("unchecked")
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, broadBox);
@@ -313,6 +331,26 @@ public class EntityAbilityPillar extends EntityEnergyZone {
}
}
/**
* Build the hit box based on origin.
* FROM_GROUND: posY (base) to posY + height (tip).
* FROM_ABOVE: posY - height (tip) to posY (base/ceiling).
*/
private AxisAlignedBB buildHitBox() {
float minY, maxY;
if (pillarData.origin == PillarOrigin.FROM_ABOVE) {
maxY = (float) posY;
minY = (float) posY - pillarHeight;
} else {
minY = (float) posY;
maxY = (float) posY + pillarHeight;
}
return AxisAlignedBB.getBoundingBox(
posX - pillarRadius, minY, posZ - pillarRadius,
posX + pillarRadius, maxY, posZ + pillarRadius
);
}
private boolean isInPillar(EntityLivingBase entity) {
double dx = entity.posX - posX;
double dz = entity.posZ - posZ;
@@ -443,6 +443,10 @@ public abstract class EntityEnergyZone extends EntityEnergyAbility {
}
protected void writeZoneBaseNBT(NBTTagCompound nbt) {
nbt.setDouble("PosX", posX);
nbt.setDouble("PosY", posY);
nbt.setDouble("PosZ", posZ);
nbt.setFloat("Radius", radius);
nbt.setFloat("Height", height);
nbt.setFloat("TargetRadius", targetRadius);
@@ -466,6 +470,15 @@ public abstract class EntityEnergyZone extends EntityEnergyAbility {
}
protected void readZoneBaseNBT(NBTTagCompound nbt) {
if (nbt.hasKey("PosX")) {
double px = nbt.getDouble("PosX");
double py = nbt.getDouble("PosY");
double pz = nbt.getDouble("PosZ");
this.setPosition(px, py, pz);
this.prevPosX = px; this.prevPosY = py; this.prevPosZ = pz;
this.lastTickPosX = px; this.lastTickPosY = py; this.lastTickPosZ = pz;
}
this.radius = sanitize(nbt.getFloat("Radius"), 1.0f, MAX_ZONE_RADIUS);
this.height = sanitize(nbt.getFloat("Height"), 1.0f, MAX_ZONE_HEIGHT);
this.targetRadius = sanitize(nbt.getFloat("TargetRadius"), 1.0f, MAX_ZONE_RADIUS);