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

This commit is contained in:
Vidal committed 2026-02-04 05:09:58 -03:00
commit 69ee5eae48
48 files changed
+2085 -699

No files matched your search

+15
View File
@@ -31,6 +31,21 @@ tasks.create('buildNoMixin', Exec) {
commandLine gradleWrapper, 'build', '-Pnomixin'
}
// No Nashorn Run Tasks
tasks.create('runClientNoNashorn', Exec) {
description 'Runs the client without Nashorn'
group 'CustomNPC+'
workingDir project.rootDir
commandLine gradleWrapper, 'runClient', '-PnoNashorn'
}
tasks.create('runServerNoNashorn', Exec) {
description 'Runs the server without Nashorn'
group 'CustomNPC+'
workingDir project.rootDir
commandLine gradleWrapper, 'runServer', '-PnoNashorn'
}
sourceSets.main.java {
def apiDir = file('src/api/java')
+3 -1
View File
@@ -36,7 +36,9 @@
def embedMixin = !project.hasProperty("nomixin");
dependencies {
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.5.4-GTNH:dev")
runtimeOnlyNonPublishable("curse.maven:Nashorn-374413:2924946")
if (!project.hasProperty("noNashorn")) {
runtimeOnlyNonPublishable("curse.maven:Nashorn-374413:2924946")
}
// compileOnly(files("./tools/bukkit-api/spigot-api-ONLY.jar"))
// compileOnly(files("./tools/bukkit-api/Vault-1.4.1.jar"))
+1 -1
Submodule src/api updated: 03be7a5cac...29ad8637d6.
@@ -662,13 +662,19 @@ public abstract class Ability implements IAbility {
// ═══════════════════════════════════════════════════════════════════
/**
* Start executing this ability
* Start executing this ability.
* If windUpTicks is 0, skips WINDUP and goes directly to ACTIVE.
*/
public void start(EntityLivingBase target) {
this.phase = AbilityPhase.WINDUP;
this.currentTick = 0;
this.currentTarget = target;
this.executionStartTime = System.currentTimeMillis();
if (windUpTicks <= 0) {
this.phase = AbilityPhase.ACTIVE;
} else {
this.phase = AbilityPhase.WINDUP;
}
}
/**
@@ -2,8 +2,9 @@ package kamkeel.npcs.controllers.data.ability.data;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.data.IEnergyAnchorData;
public class EnergyAnchorData {
public class EnergyAnchorData implements IEnergyAnchorData {
public AnchorPoint anchorPoint = AnchorPoint.FRONT;
public float anchorOffsetX = 0;
public float anchorOffsetY = 0;
@@ -34,6 +35,54 @@ public class EnergyAnchorData {
this.anchorOffsetZ = anchorOffsetZ;
}
public AnchorPoint getAnchorPoint() {
return anchorPoint;
}
public void setAnchorPoint(AnchorPoint anchorPoint) {
this.anchorPoint = anchorPoint;
}
@Override
public int getAnchor() {
return anchorPoint.ordinal();
}
@Override
public void setAnchor(int anchor) {
this.anchorPoint = AnchorPoint.fromOrdinal(anchor);
}
@Override
public float getAnchorOffsetX() {
return anchorOffsetX;
}
@Override
public void setAnchorOffsetX(float anchorOffsetX) {
this.anchorOffsetX = anchorOffsetX;
}
@Override
public float getAnchorOffsetY() {
return anchorOffsetY;
}
@Override
public void setAnchorOffsetY(float anchorOffsetY) {
this.anchorOffsetY = anchorOffsetY;
}
@Override
public float getAnchorOffsetZ() {
return anchorOffsetZ;
}
@Override
public void setAnchorOffsetZ(float anchorOffsetZ) {
this.anchorOffsetZ = anchorOffsetZ;
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setInteger("anchorPoint", anchorPoint.ordinal());
nbt.setFloat("anchorOffsetX", anchorOffsetX);
@@ -1,12 +1,13 @@
package kamkeel.npcs.controllers.data.ability.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.data.IEnergyCombatData;
/**
* Groups combat properties shared by energy projectile abilities.
* Used as a parameter object for entity constructors and ability configuration.
*/
public class EnergyCombatData {
public class EnergyCombatData implements IEnergyCombatData {
public float damage = 7.0f;
public float knockback = 1.0f;
public float knockbackUp = 0.1f;
@@ -26,6 +27,66 @@ public class EnergyCombatData {
this.explosionDamageFalloff = explosionDamageFalloff;
}
@Override
public float getDamage() {
return damage;
}
@Override
public void setDamage(float damage) {
this.damage = damage;
}
@Override
public float getKnockback() {
return knockback;
}
@Override
public void setKnockback(float knockback) {
this.knockback = knockback;
}
@Override
public float getKnockbackUp() {
return knockbackUp;
}
@Override
public void setKnockbackUp(float knockbackUp) {
this.knockbackUp = knockbackUp;
}
@Override
public boolean isExplosive() {
return explosive;
}
@Override
public void setExplosive(boolean explosive) {
this.explosive = explosive;
}
@Override
public float getExplosionRadius() {
return explosionRadius;
}
@Override
public void setExplosionRadius(float explosionRadius) {
this.explosionRadius = explosionRadius;
}
@Override
public float getExplosionDamageFalloff() {
return explosionDamageFalloff;
}
@Override
public void setExplosionDamageFalloff(float explosionDamageFalloff) {
this.explosionDamageFalloff = explosionDamageFalloff;
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setFloat("damage", damage);
nbt.setFloat("knockback", knockback);
@@ -1,12 +1,13 @@
package kamkeel.npcs.controllers.data.ability.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.data.IEnergyDisplayData;
/**
* Groups visual color properties shared by all energy abilities.
* Used as a parameter object for entity constructors and ability configuration.
*/
public class EnergyColorData {
public class EnergyDisplayData implements IEnergyDisplayData {
public int innerColor = 0xFFFFFF;
public int outerColor = 0x8888FF;
public boolean outerColorEnabled = true;
@@ -14,15 +15,15 @@ public class EnergyColorData {
public float outerColorAlpha = 0.5f;
public float rotationSpeed = 4.0f;
public EnergyColorData() {}
public EnergyDisplayData() {}
public EnergyColorData(int innerColor, int outerColor) {
public EnergyDisplayData(int innerColor, int outerColor) {
this.innerColor = innerColor;
this.outerColor = outerColor;
}
public EnergyColorData(int innerColor, int outerColor, boolean outerColorEnabled,
float outerColorWidth, float outerColorAlpha, float rotationSpeed) {
public EnergyDisplayData(int innerColor, int outerColor, boolean outerColorEnabled,
float outerColorWidth, float outerColorAlpha, float rotationSpeed) {
this.innerColor = innerColor;
this.outerColor = outerColor;
this.outerColorEnabled = outerColorEnabled;
@@ -31,6 +32,66 @@ public class EnergyColorData {
this.rotationSpeed = rotationSpeed;
}
@Override
public int getInnerColor() {
return innerColor;
}
@Override
public void setInnerColor(int innerColor) {
this.innerColor = innerColor;
}
@Override
public int getOuterColor() {
return outerColor;
}
@Override
public void setOuterColor(int outerColor) {
this.outerColor = outerColor;
}
@Override
public boolean isOuterColorEnabled() {
return outerColorEnabled;
}
@Override
public void setOuterColorEnabled(boolean outerColorEnabled) {
this.outerColorEnabled = outerColorEnabled;
}
@Override
public float getOuterColorWidth() {
return outerColorWidth;
}
@Override
public void setOuterColorWidth(float outerColorWidth) {
this.outerColorWidth = outerColorWidth;
}
@Override
public float getOuterColorAlpha() {
return outerColorAlpha;
}
@Override
public void setOuterColorAlpha(float outerColorAlpha) {
this.outerColorAlpha = outerColorAlpha;
}
@Override
public float getRotationSpeed() {
return rotationSpeed;
}
@Override
public void setRotationSpeed(float rotationSpeed) {
this.rotationSpeed = rotationSpeed;
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setInteger("innerColor", innerColor);
nbt.setInteger("outerColor", outerColor);
@@ -49,7 +110,7 @@ public class EnergyColorData {
rotationSpeed = nbt.hasKey("rotationSpeed") ? nbt.getFloat("rotationSpeed") : 4.0f;
}
public EnergyColorData copy() {
return new EnergyColorData(innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed);
public EnergyDisplayData copy() {
return new EnergyDisplayData(innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed);
}
}
@@ -1,12 +1,14 @@
package kamkeel.npcs.controllers.data.ability.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.data.IEnergyHomingData;
/**
* Groups homing/movement properties for energy projectile abilities.
* Used by Orb, Disc, and Beam (not Laser or Sweeper).
*/
public class EnergyHomingData {
public class EnergyHomingData implements IEnergyHomingData {
public float speed = 0.5f;
public boolean homing = true;
public float homingStrength = 0.15f;
@@ -21,6 +23,46 @@ public class EnergyHomingData {
this.homingRange = homingRange;
}
@Override
public float getSpeed() {
return speed;
}
@Override
public void setSpeed(float speed) {
this.speed = speed;
}
@Override
public boolean isHoming() {
return homing;
}
@Override
public void setHoming(boolean homing) {
this.homing = homing;
}
@Override
public float getHomingStrength() {
return homingStrength;
}
@Override
public void setHomingStrength(float homingStrength) {
this.homingStrength = homingStrength;
}
@Override
public float getHomingRange() {
return homingRange;
}
@Override
public void setHomingRange(float homingRange) {
this.homingRange = homingRange;
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setFloat("speed", speed);
nbt.setBoolean("homing", homing);
@@ -1,12 +1,13 @@
package kamkeel.npcs.controllers.data.ability.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.data.IEnergyLifespanData;
/**
* Groups lifespan/range properties for energy projectile abilities.
* Used as a parameter object for entity constructors and ability configuration.
*/
public class EnergyLifespanData {
public class EnergyLifespanData implements IEnergyLifespanData {
public float maxDistance = 30.0f;
public int maxLifetime = 200;
@@ -17,6 +18,26 @@ public class EnergyLifespanData {
this.maxLifetime = maxLifetime;
}
@Override
public float getMaxDistance() {
return maxDistance;
}
@Override
public void setMaxDistance(float maxDistance) {
this.maxDistance = maxDistance;
}
@Override
public int getMaxLifetime() {
return maxLifetime;
}
@Override
public void setMaxLifetime(int maxLifetime) {
this.maxLifetime = maxLifetime;
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setFloat("maxDistance", maxDistance);
nbt.setInteger("maxLifetime", maxLifetime);
@@ -1,12 +1,13 @@
package kamkeel.npcs.controllers.data.ability.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.data.IEnergyLightningData;
/**
* Groups lightning visual effect properties for energy abilities.
* Used as a parameter object for entity constructors and ability configuration.
*/
public class EnergyLightningData {
public class EnergyLightningData implements IEnergyLightningData {
public boolean lightningEffect = false;
public float lightningDensity = 0.15f;
public float lightningRadius = 0.5f;
@@ -22,6 +23,46 @@ public class EnergyLightningData {
this.lightningFadeTime = lightningFadeTime;
}
@Override
public boolean isLightningEffect() {
return lightningEffect;
}
@Override
public void setLightningEffect(boolean lightningEffect) {
this.lightningEffect = lightningEffect;
}
@Override
public float getLightningDensity() {
return lightningDensity;
}
@Override
public void setLightningDensity(float lightningDensity) {
this.lightningDensity = lightningDensity;
}
@Override
public float getLightningRadius() {
return lightningRadius;
}
@Override
public void setLightningRadius(float lightningRadius) {
this.lightningRadius = lightningRadius;
}
@Override
public int getLightningFadeTime() {
return lightningFadeTime;
}
@Override
public void setLightningFadeTime(int lightningFadeTime) {
this.lightningFadeTime = lightningFadeTime;
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setBoolean("lightningEffect", lightningEffect);
nbt.setFloat("lightningDensity", lightningDensity);
@@ -0,0 +1,288 @@
package kamkeel.npcs.controllers.data.ability.data;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.Constants;
import noppes.npcs.api.IPos;
import noppes.npcs.api.ability.data.IEnergyTrajectoryData;
import noppes.npcs.scripted.NpcAPI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
public class EnergyTrajectoryData implements IEnergyTrajectoryData {
public int currentPath = 0;
private final List<Path> trajectory = new ArrayList<>();
public EnergyTrajectoryData() {}
public EnergyTrajectoryData(int startingPath, Path... paths) {
trajectory.addAll(Arrays.asList(paths));
this.currentPath = startingPath < trajectory.size() && startingPath >= 0 ? startingPath : 0;
}
@Override
public int getCurrentPath() {
return currentPath;
}
@Override
public void setCurrentPath(int currentPath) {
this.currentPath = currentPath;
}
@Override
public int getDelay(int path) {
if (getPath(path) == null) return -1;
return getPath(path).getDelay();
}
@Override
public void setDelay(int path, int ticks) {
if (getPath(path) == null) return;
getPath(path).setDelay(ticks);
}
@Override
public IPos getPos(int path) {
IPath p = getPath(path);
return p == null ? null : p.getPos();
}
@Override
public void setPos(int path, IPos pos) {
IPath p = getPath(path);
if (p != null) p.setPos(pos);
}
@Override
public boolean isConcluded(int path) {
IPath p = getPath(path);
return p != null && p.isConcluded();
}
@Override
public void setConcluded(int path, boolean concluded) {
IPath p = getPath(path);
if (p != null) p.setConcluded(concluded);
}
@Override
public double getX(int path) {
IPath p = getPath(path);
return p == null ? 0 : p.getX();
}
@Override
public double getY(int path) {
IPath p = getPath(path);
return p == null ? 0 : p.getY();
}
@Override
public double getZ(int path) {
IPath p = getPath(path);
return p == null ? 0 : p.getZ();
}
@Override
public void setX(int path, double x) {
IPath p = getPath(path);
if (p != null) p.setX(x);
}
@Override
public void setY(int path, double y) {
IPath p = getPath(path);
if (p != null) p.setY(y);
}
@Override
public void setZ(int path, double z) {
IPath p = getPath(path);
if (p != null) p.setZ(z);
}
public IPath getPath(int path) {
if (path < 0 || path >= trajectory.size()) return null;
return trajectory.get(path);
}
@Override
public void setPath(int path, IPos pos) {
setPath(path, pos, 0);
}
@Override
public void setPath(int path, IPos pos, int delay) {
setPath(path, pos.getX(), pos.getY(), pos.getZ(), delay);
}
@Override
public void setPath(int path, double x, double y, double z) {
setPath(path, x, y, z, 0);
}
@Override
public void setPath(int path, double x, double y, double z, int delay) {
Path newPath = new Path(
NpcAPI.Instance().getIPos(x, y, z),
delay
);
while (trajectory.size() <= path) {
trajectory.add(null);
}
trajectory.set(path, newPath);
}
@Override
public IPath createPath(IPos pos) {
return new Path(pos, 0);
}
@Override
public IPath createPath(IPos pos, int delay) {
return new Path(pos, delay);
}
@Override
public IPath createPath(double x, double y, double z) {
return createPath(x, y, z, 0);
}
@Override
public IPath createPath(double x, double y, double z, int delay) {
return new Path(NpcAPI.Instance().getIPos(x, y, z), delay);
}
@Override
public void forEach(BiConsumer<Integer, IPath> lambda) {
for (int i = 0; i < trajectory.size(); i++) {
lambda.accept(i, trajectory.get(i));
}
}
public int size() {
return trajectory.size();
}
public boolean isEmpty() {
return trajectory.isEmpty();
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setInteger("currentPath", currentPath);
for (int i = 0; i < trajectory.size(); i++) {
Path path = trajectory.get(i);
NBTTagCompound pathNbt = new NBTTagCompound();
path.writeNBT(pathNbt);
nbt.setTag("Path_" + i, pathNbt);
}
}
public void readNBT(NBTTagCompound nbt) {
this.currentPath = nbt.hasKey("currentPath") ? nbt.getInteger("currentPath") : 0;
int i = 0;
while (nbt.hasKey("Path_" + i, Constants.NBT.TAG_COMPOUND)) {
NBTTagCompound pathNbt = nbt.getCompoundTag("Path_" + i);
Path path = (Path) createPath(0, 0, 0);
path.readNBT(pathNbt);
trajectory.add(path);
i++;
}
}
public static class Path implements IEnergyTrajectoryData.IPath{
public IPos pos;
public int delayTicks;
public boolean concluded;
public Path(IPos pos, int delayTicks) {
this.pos = pos;
this.delayTicks = delayTicks;
}
@Override
public IPos getPos() {
return pos;
}
@Override
public void setPos(IPos pos) {
this.pos = pos;
}
@Override
public int getDelay() {
return delayTicks;
}
@Override
public void setDelay(int delayTicks) {
this.delayTicks = delayTicks;
}
@Override
public boolean isConcluded() {
return concluded;
}
@Override
public void setConcluded(boolean concluded) {
this.concluded = concluded;
}
@Override
public double getX() {
return pos.getX();
}
@Override
public void setX(double x) {
this.pos = NpcAPI.Instance().getIPos(x, getY(), getZ());
}
@Override
public double getY() {
return pos.getY();
}
@Override
public void setY(double y) {
this.pos = NpcAPI.Instance().getIPos(getX(), y, getZ());
}
@Override
public double getZ() {
return pos.getZ();
}
@Override
public void setZ(double z) {
this.pos = NpcAPI.Instance().getIPos(pos.getX(), pos.getY(), z);
}
public void writeNBT(NBTTagCompound nbt) {
nbt.setInteger("delay", delayTicks);
nbt.setBoolean("concluded", concluded);
nbt.setDouble("X", getX());
nbt.setDouble("Y", getY());
nbt.setDouble("Z", getZ());
}
public void readNBT(NBTTagCompound nbt) {
this.delayTicks = nbt.hasKey("delay") ? nbt.getInteger("delay") : 0;
this.concluded = nbt.hasKey("concluded") && nbt.getBoolean("concluded");
double x = nbt.getDouble("X");
double y = nbt.getDouble("Y");
double z = nbt.getDouble("Z");
this.pos = NpcAPI.Instance().getIPos(x, y, z);
}
}
}
@@ -37,12 +37,13 @@ public class AbilityBeam extends Ability implements IAbilityEnergyBeam {
private float headSize = 0.6f;
// Data classes
private EnergyColorData colorData = new EnergyColorData(0xFFFFFF, 0x00AAFF, true, 0.4f, 0.5f, 6.0f);
private EnergyCombatData combatData = new EnergyCombatData(10.0f, 1.5f, 0.2f, false, 4.0f, 0.5f);
private EnergyHomingData homingData = new EnergyHomingData(0.4f, true, 0.1f, 15.0f);
private EnergyLightningData lightningData = new EnergyLightningData();
private EnergyLifespanData lifespanData = new EnergyLifespanData(25.0f, 200);
private EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyDisplayData colorData = new EnergyDisplayData(0xFFFFFF, 0x00AAFF, true, 0.4f, 0.5f, 6.0f);
private final EnergyCombatData combatData = new EnergyCombatData(10.0f, 1.5f, 0.2f, false, 4.0f, 0.5f);
private final EnergyHomingData homingData = new EnergyHomingData(0.4f, true, 0.1f, 15.0f);
private final EnergyLightningData lightningData = new EnergyLightningData();
private final EnergyLifespanData lifespanData = new EnergyLifespanData(25.0f, 200);
private final EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
// Transient state for beam entity (used during windup charging)
private transient EntityAbilityBeam beamEntity = null;
@@ -103,7 +104,7 @@ public class AbilityBeam extends Ability implements IAbilityEnergyBeam {
world, caster, target,
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
beamWidth, headSize,
colorData, combatData, homingData, lightningData, lifespanData,
colorData, combatData, homingData, lightningData, lifespanData, trajectoryData,
lockMovement.locksActive());
beamEntity.setupCharging(anchorData, windUpTicks, offsetDist);
@@ -32,19 +32,22 @@ public class AbilityBeamDual extends Ability {
private int dualFireDelay = 0;
// Data classes
private EnergyColorData[] colorData = new EnergyColorData[]{
new EnergyColorData(0xFFFFFF, 0x00AAFF, true, 0.4f, 0.5f, 6.0f),
new EnergyColorData(0xFFFFFF, 0xFF0000, true, 0.4f, 0.5f, 6.0f),
private final EnergyDisplayData[] displayData = new EnergyDisplayData[]{
new EnergyDisplayData(0xFFFFFF, 0x00AAFF, true, 0.4f, 0.5f, 6.0f),
new EnergyDisplayData(0xFFFFFF, 0xFF0000, true, 0.4f, 0.5f, 6.0f),
};
private EnergyCombatData combatData = new EnergyCombatData(10.0f, 1.5f, 0.2f, false, 4.0f, 0.5f);
private EnergyHomingData homingData = new EnergyHomingData(0.4f, true, 0.1f, 15.0f);
private EnergyLightningData[] lightningData = new EnergyLightningData[]{
private final EnergyCombatData combatData = new EnergyCombatData(10.0f, 1.5f, 0.2f, false, 4.0f, 0.5f);
private final EnergyHomingData homingData = new EnergyHomingData(0.4f, true, 0.1f, 15.0f);
private final EnergyLightningData[] lightningData = new EnergyLightningData[]{
new EnergyLightningData(), new EnergyLightningData()
};
private EnergyLifespanData lifespanData = new EnergyLifespanData(25.0f, 200);
private EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
private final EnergyLifespanData lifespanData = new EnergyLifespanData(25.0f, 200);
private final EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
new EnergyAnchorData(AnchorPoint.RIGHT_HAND), new EnergyAnchorData(AnchorPoint.LEFT_HAND)
};
private final EnergyTrajectoryData[] trajectoryData = new EnergyTrajectoryData[]{
new EnergyTrajectoryData(), new EnergyTrajectoryData()
};
// Transient state for beam entity (used during windup charging)
private transient EntityAbilityBeam beamEntity = null;
@@ -92,7 +95,7 @@ public class AbilityBeamDual extends Ability {
if (beamEntity2 != null && !beamEntity2.isDead && dualFireDelay <= 0) {
beamEntity2.startFiring(target);
}
} else {
} else if (beamEntity2 != null) {
beamEntity2.setDead();
}
@@ -114,7 +117,7 @@ public class AbilityBeamDual extends Ability {
world, caster, target,
spawnPos1.xCoord, spawnPos1.yCoord, spawnPos1.zCoord,
beamWidth, headSize,
colorData[0], combatData, homingData, lightningData[0], lifespanData,
displayData[0], combatData, homingData, lightningData[0], lifespanData, trajectoryData[0],
lockMovement.locksActive());
Vec3 spawnPos2 = AnchorPointHelper.calculateAnchorPosition(caster, anchorData[1], offsetDist);
@@ -122,11 +125,11 @@ public class AbilityBeamDual extends Ability {
world, caster, target,
spawnPos2.xCoord, spawnPos2.yCoord, spawnPos2.zCoord,
beamWidth, headSize,
colorData[1], combatData, homingData, lightningData[1], lifespanData,
displayData[1], combatData, homingData, lightningData[1], lifespanData, trajectoryData[1],
lockMovement.locksActive());
beamEntity.setSiblingUUID(beamEntity2.getPersistentID());
beamEntity2.setSiblingUUID(beamEntity.getPersistentID());
beamEntity.setSiblingEntityId(beamEntity2.getEntityId());
beamEntity2.setSiblingEntityId(beamEntity.getEntityId());
beamEntity.setupCharging(anchorData[0], windUpTicks, offsetDist);
beamEntity2.setupCharging(anchorData[1], windUpTicks, offsetDist);
@@ -219,12 +222,13 @@ public class AbilityBeamDual extends Ability {
NBTTagCompound beam1 = new NBTTagCompound();
NBTTagCompound beam2 = new NBTTagCompound();
anchorData[0].writeNBT(beam1);
anchorData[1].writeNBT(beam2);
colorData[0].writeNBT(beam1);
colorData[1].writeNBT(beam2);
lightningData[0].writeNBT(beam1);
lightningData[1].writeNBT(beam2);
for (int i = 0; i < 2; i++) {
NBTTagCompound beam = i == 0 ? beam1 : beam2;
anchorData[i].writeNBT(beam);
displayData[i].writeNBT(beam);
lightningData[i].writeNBT(beam);
trajectoryData[i].writeNBT(beam);
}
nbt.setTag("Beam_1", beam1);
nbt.setTag("Beam_2", beam2);
@@ -243,12 +247,13 @@ public class AbilityBeamDual extends Ability {
homingData.readNBT(nbt);
lifespanData.readNBT(nbt);
anchorData[0].readNBT(beam1);
anchorData[1].readNBT(beam2);
colorData[0].readNBT(beam1);
colorData[1].readNBT(beam2);
lightningData[0].readNBT(beam1);
lightningData[1].readNBT(beam2);
for (int i = 0; i < 2; i++) {
NBTTagCompound beam = i == 0 ? beam1 : beam2;
anchorData[i].readNBT(beam);
displayData[i].readNBT(beam);
lightningData[i].readNBT(beam);
trajectoryData[i].readNBT(beam);
}
}
// Getters & Setters - Standalone fields
@@ -261,9 +266,9 @@ public class AbilityBeamDual extends Ability {
public int getDualFireDelay() { return dualFireDelay; }
public void setDualFireDelay(int dualFireDelay) { this.dualFireDelay = dualFireDelay; }
private EnergyColorData getColorData(int beam) {
private EnergyDisplayData getColorData(int beam) {
beam = ValueUtil.clamp(beam, 0, 1);
return colorData[beam];
return displayData[beam];
}
private EnergyLightningData getLightningData(int beam) {
beam = ValueUtil.clamp(beam, 0, 1);
@@ -414,10 +419,10 @@ public class AbilityBeamDual extends Ability {
.visibleWhen(this::isExplosive),
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
// Visual tab - Beam 1
FieldDef.section("ability.section.beam1").tab("ability.tab.visual"),
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
() -> getAnchorPointEnum(0), v -> setAnchorPointEnum(0, v))
.tab("ability.tab.visual"),
FieldDef.section("ability.section.beam1").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor",
() -> getInnerColor(0), v -> setInnerColor(0, v))
.tab("ability.tab.visual"),
@@ -450,10 +455,10 @@ public class AbilityBeamDual extends Ability {
.range(0.1f, 100f).visibleWhen(() -> hasLightningEffect(0))
).tab("ability.tab.visual"),
// Visual tab - Beam 2
FieldDef.section("ability.section.beam2").tab("ability.tab.visual"),
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
() -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v))
.tab("ability.tab.visual"),
FieldDef.section("ability.section.beam2").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor",
() -> getInnerColor(1), v -> setInnerColor(1, v))
.tab("ability.tab.visual"),
@@ -494,7 +499,7 @@ public class AbilityBeamDual extends Ability {
if (npc == null || npc.worldObj == null) return null;
EntityAbilityBeam beam = new EntityAbilityBeam(npc.worldObj);
beam.setupPreview(npc, beamWidth, headSize, colorData[0], lightningData[0], anchorData[0], windUpTicks, 1.0f);
beam.setupPreview(npc, beamWidth, headSize, displayData[0], lightningData[0], anchorData[0], windUpTicks, 1.0f);
return beam;
}
@@ -40,12 +40,13 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
private int boomerangDelay = 40;
// Energy data classes
private EnergyColorData colorData = new EnergyColorData(0xFFFFFF, 0xFF8800, true, 0.4f, 0.5f, 5.0f);
private EnergyCombatData combatData = new EnergyCombatData(8.0f, 1.2f, 0.15f, false, 3.0f, 0.5f);
private EnergyHomingData homingData = new EnergyHomingData(0.6f, true, 0.12f, 18.0f);
private EnergyLightningData lightningData = new EnergyLightningData();
private EnergyLifespanData lifespanData = new EnergyLifespanData(35.0f, 200);
private EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyDisplayData colorData = new EnergyDisplayData(0xFFFFFF, 0xFF8800, true, 0.4f, 0.5f, 5.0f);
private final EnergyCombatData combatData = new EnergyCombatData(8.0f, 1.2f, 0.15f, false, 3.0f, 0.5f);
private final EnergyHomingData homingData = new EnergyHomingData(0.6f, true, 0.12f, 18.0f);
private final EnergyLightningData lightningData = new EnergyLightningData();
private final EnergyLifespanData lifespanData = new EnergyLifespanData(35.0f, 200);
private final EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
// Transient state for disc entity (used during windup charging)
private transient EntityAbilityDisc discEntity = null;
@@ -104,7 +105,7 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
world, caster, target,
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
discRadius, discThickness,
colorData, combatData, homingData, lightningData, lifespanData,
colorData, combatData, homingData, lightningData, lifespanData, trajectoryData,
boomerang, boomerangDelay);
discEntity.setupCharging(anchorData, windUpTicks);
@@ -40,19 +40,22 @@ public class AbilityDiscDual extends Ability {
private int dualFireDelay = 10;
// Energy data classes
private EnergyColorData[] colorData = new EnergyColorData[]{
new EnergyColorData(0xFFFFFF, 0xFF8800, true, 0.4f, 0.5f, 5.0f),
new EnergyColorData(0xFFFFFF, 0x8800FF, true, 0.4f, 0.5f, 5.0f)
private final EnergyDisplayData[] displayData = new EnergyDisplayData[]{
new EnergyDisplayData(0xFFFFFF, 0xFF8800, true, 0.4f, 0.5f, 5.0f),
new EnergyDisplayData(0xFFFFFF, 0x8800FF, true, 0.4f, 0.5f, 5.0f)
};
private EnergyCombatData combatData = new EnergyCombatData(8.0f, 1.2f, 0.15f, false, 3.0f, 0.5f);
private EnergyHomingData homingData = new EnergyHomingData(0.6f, true, 0.12f, 18.0f);
public final EnergyLightningData[] lightningData = new EnergyLightningData[]{
private final EnergyCombatData combatData = new EnergyCombatData(8.0f, 1.2f, 0.15f, false, 3.0f, 0.5f);
private final EnergyHomingData homingData = new EnergyHomingData(0.6f, true, 0.12f, 18.0f);
private final EnergyLightningData[] lightningData = new EnergyLightningData[]{
new EnergyLightningData(), new EnergyLightningData()
};
private EnergyLifespanData lifespanData = new EnergyLifespanData(35.0f, 200);
private EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
private final EnergyLifespanData lifespanData = new EnergyLifespanData(35.0f, 200);
private final EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
new EnergyAnchorData(AnchorPoint.LEFT_HAND), new EnergyAnchorData(AnchorPoint.RIGHT_HAND)
};
private final EnergyTrajectoryData[] trajectoryData = new EnergyTrajectoryData[]{
new EnergyTrajectoryData(), new EnergyTrajectoryData()
};
// Transient state for disc entity (used during windup charging)
private transient EntityAbilityDisc discEntity = null;
@@ -100,7 +103,7 @@ public class AbilityDiscDual extends Ability {
if (discEntity2 != null && !discEntity2.isDead && dualFireDelay <= 0) {
discEntity2.startMoving(target);
}
} else {
} else if (discEntity2 != null) {
discEntity2.setDead();
}
@@ -120,7 +123,7 @@ public class AbilityDiscDual extends Ability {
world, caster, target,
spawnPos1.xCoord, spawnPos1.yCoord, spawnPos1.zCoord,
discRadius, discThickness,
colorData[0], combatData, homingData, lightningData[0], lifespanData,
displayData[0], combatData, homingData, lightningData[0], lifespanData, trajectoryData[0],
boomerang, boomerangDelay);
Vec3 spawnPos2 = AnchorPointHelper.calculateAnchorPosition(caster, anchorData[1]);
@@ -128,11 +131,11 @@ public class AbilityDiscDual extends Ability {
world, caster, target,
spawnPos2.xCoord, spawnPos2.yCoord, spawnPos2.zCoord,
discRadius, discThickness,
colorData[1], combatData, homingData, lightningData[1], lifespanData,
displayData[1], combatData, homingData, lightningData[1], lifespanData, trajectoryData[1],
boomerang, boomerangDelay);
discEntity.setSiblingUUID(discEntity2.getPersistentID());
discEntity2.setSiblingUUID(discEntity.getPersistentID());
discEntity.setSiblingEntityId(discEntity2.getEntityId());
discEntity2.setSiblingEntityId(discEntity.getEntityId());
discEntity.setupCharging(anchorData[0], windUpTicks);
discEntity2.setupCharging(anchorData[1], windUpTicks);
@@ -230,12 +233,13 @@ public class AbilityDiscDual extends Ability {
NBTTagCompound disc1 = new NBTTagCompound();
NBTTagCompound disc2 = new NBTTagCompound();
anchorData[0].writeNBT(disc1);
anchorData[1].writeNBT(disc2);
colorData[0].writeNBT(disc1);
colorData[1].writeNBT(disc2);
lightningData[0].writeNBT(disc1);
lightningData[1].writeNBT(disc2);
for (int i = 0; i < 2; i++) {
NBTTagCompound disc = i == 0 ? disc1 : disc2;
anchorData[i].writeNBT(disc);
displayData[i].writeNBT(disc);
lightningData[i].writeNBT(disc);
trajectoryData[i].writeNBT(disc);
}
nbt.setTag("Disc_1", disc1);
nbt.setTag("Disc_2", disc2);
@@ -256,18 +260,19 @@ public class AbilityDiscDual extends Ability {
homingData.readNBT(nbt);
lifespanData.readNBT(nbt);
anchorData[0].readNBT(disc1);
anchorData[1].readNBT(disc2);
colorData[0].readNBT(disc1);
colorData[1].readNBT(disc2);
lightningData[0].readNBT(disc1);
lightningData[1].readNBT(disc2);
for (int i = 0; i < 2; i++) {
NBTTagCompound disc = i == 0 ? disc1 : disc2;
anchorData[i].readNBT(disc);
displayData[i].readNBT(disc);
lightningData[i].readNBT(disc);
trajectoryData[i].readNBT(disc);
}
}
// Getters & Setters
private EnergyColorData getColorData(int orb) {
private EnergyDisplayData getColorData(int orb) {
orb = ValueUtil.clamp(orb, 0, 1);
return colorData[orb];
return displayData[orb];
}
private EnergyLightningData getLightningData(int orb) {
orb = ValueUtil.clamp(orb, 0, 1);
@@ -424,10 +429,10 @@ public class AbilityDiscDual extends Ability {
.visibleWhen(this::isExplosive),
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
// Visual tab - Disc 1
FieldDef.section("ability.section.disc1").tab("ability.tab.visual"),
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
() -> getAnchorPointEnum(0), v -> setAnchorPointEnum(0, v))
.tab("ability.tab.visual"),
FieldDef.section("ability.section.disc1").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor",
() -> getInnerColor(0), v -> setInnerColor(0, v))
.tab("ability.tab.visual"),
@@ -460,10 +465,10 @@ public class AbilityDiscDual extends Ability {
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0))
).tab("ability.tab.visual"),
// Visual tab - Disc 2
FieldDef.section("ability.section.disc2").tab("ability.tab.visual"),
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
() -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v))
.tab("ability.tab.visual"),
FieldDef.section("ability.section.disc2").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor",
() -> getInnerColor(1), v -> setInnerColor(1, v))
.tab("ability.tab.visual"),
@@ -504,7 +509,7 @@ public class AbilityDiscDual extends Ability {
if (npc == null || npc.worldObj == null) return null;
EntityAbilityDisc disc = new EntityAbilityDisc(npc.worldObj);
disc.setupPreview(npc, discRadius, discThickness, colorData[0], lightningData[0], anchorData[0], windUpTicks);
disc.setupPreview(npc, discRadius, discThickness, displayData[0], lightningData[0], anchorData[0], windUpTicks);
return disc;
}
@@ -36,11 +36,12 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
private int lingerTicks = 8;
// Data classes
private final EnergyColorData colorData = new EnergyColorData(0xFFFFFF, 0xFF0000, true, 0.4f, 0.5f, 0.0f);
private final EnergyDisplayData colorData = new EnergyDisplayData(0xFFFFFF, 0xFF0000, true, 0.4f, 0.5f, 0.0f);
private final EnergyCombatData combatData = new EnergyCombatData(6.0f, 0.5f, 0.05f, false, 2.0f, 0.5f);
private final EnergyLightningData lightningData = new EnergyLightningData();
private final EnergyLifespanData lifespanData = new EnergyLifespanData(40.0f, 100);
private final EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
// Transient state for laser entity (used for movement locking)
private transient EntityAbilityLaser laserEntity = null;
@@ -53,7 +54,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
this.minRange = 3.0f;
this.cooldownTicks = 0;
this.windUpTicks = 15;
this.lockMovement = LockMovementType.WINDUP;
this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE;
this.telegraphType = TelegraphType.LINE;
this.showTelegraph = true;
// Default built-in animations
@@ -91,7 +92,7 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
world, caster, target,
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
laserWidth,
colorData, combatData, lightningData, lifespanData,
colorData, combatData, lightningData, lifespanData, trajectoryData,
expansionSpeed, lingerTicks
);
@@ -106,6 +107,12 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
public void onExecute(EntityLivingBase caster, EntityLivingBase target, World world) {
if (world.isRemote) {
signalCompletion();
return;
}
if (laserEntity == null) {
signalCompletion();
return;
}
laserEntity.startMoving(target);
@@ -271,6 +278,8 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
// Visual tab
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class, this::getAnchorPointEnum, this::setAnchorPointEnum)
.tab("ability.tab.visual"),
FieldDef.section("ability.section.colors").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor).tab("ability.tab.visual"),
FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled).tab("ability.tab.visual"),
@@ -36,12 +36,13 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
private float orbSize = 1.0f;
// Data classes for energy properties
private final EnergyColorData colorData = new EnergyColorData();
private final EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyCombatData combatData = new EnergyCombatData();
private final EnergyDisplayData displayData = new EnergyDisplayData();
private final EnergyHomingData homingData = new EnergyHomingData();
private final EnergyLightningData lightningData = new EnergyLightningData();
private final EnergyLifespanData lifespanData = new EnergyLifespanData();
private final EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.RIGHT_HAND);
private final EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
// Transient state for orb entity (used during windup charging)
private transient EntityAbilityOrb orbEntity = null;
@@ -99,7 +100,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
orbEntity = new EntityAbilityOrb(
world, caster, target,
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord, orbSize,
colorData, combatData, homingData, lightningData, lifespanData);
displayData, combatData, homingData, lightningData, lifespanData, trajectoryData);
orbEntity.setupCharging(anchorData, windUpTicks);
orbEntity.setEffects(this.effects);
@@ -161,11 +162,12 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
public void writeTypeNBT(NBTTagCompound nbt) {
nbt.setFloat("orbSize", orbSize);
anchorData.writeNBT(nbt);
colorData.writeNBT(nbt);
combatData.writeNBT(nbt);
displayData.writeNBT(nbt);
homingData.writeNBT(nbt);
lightningData.writeNBT(nbt);
lifespanData.writeNBT(nbt);
trajectoryData.writeNBT(nbt);
// Backward compat: old key was "orbSpeed"
nbt.setFloat("orbSpeed", homingData.speed);
}
@@ -174,11 +176,12 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
public void readTypeNBT(NBTTagCompound nbt) {
this.orbSize = nbt.hasKey("orbSize") ? nbt.getFloat("orbSize") : 1.0f;
anchorData.readNBT(nbt);
colorData.readNBT(nbt);
combatData.readNBT(nbt);
displayData.readNBT(nbt);
homingData.readNBT(nbt);
lightningData.readNBT(nbt);
lifespanData.readNBT(nbt);
trajectoryData.readNBT(nbt);
// Backward compat: old key was "orbSpeed"
if (nbt.hasKey("orbSpeed")) {
homingData.speed = nbt.getFloat("orbSpeed");
@@ -291,51 +294,51 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
}
public int getInnerColor() {
return colorData.innerColor;
return displayData.innerColor;
}
public void setInnerColor(int innerColor) {
colorData.innerColor = innerColor;
displayData.innerColor = innerColor;
}
public int getOuterColor() {
return colorData.outerColor;
return displayData.outerColor;
}
public void setOuterColor(int outerColor) {
colorData.outerColor = outerColor;
displayData.outerColor = outerColor;
}
public float getOuterColorWidth() {
return colorData.outerColorWidth;
return displayData.outerColorWidth;
}
public void setOuterColorWidth(float outerColorWidth) {
colorData.outerColorWidth = outerColorWidth;
displayData.outerColorWidth = outerColorWidth;
}
public float getOuterColorAlpha() {
return colorData.outerColorAlpha;
return displayData.outerColorAlpha;
}
public void setOuterColorAlpha(float outerColorAlpha) {
colorData.outerColorAlpha = outerColorAlpha;
displayData.outerColorAlpha = outerColorAlpha;
}
public boolean isOuterColorEnabled() {
return colorData.outerColorEnabled;
return displayData.outerColorEnabled;
}
public void setOuterColorEnabled(boolean outerColorEnabled) {
colorData.outerColorEnabled = outerColorEnabled;
displayData.outerColorEnabled = outerColorEnabled;
}
public float getRotationSpeed() {
return colorData.rotationSpeed;
return displayData.rotationSpeed;
}
public void setRotationSpeed(float rotationSpeed) {
colorData.rotationSpeed = rotationSpeed;
displayData.rotationSpeed = rotationSpeed;
}
public boolean hasLightningEffect() {
@@ -401,7 +404,7 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
if (npc == null || npc.worldObj == null) return null;
EntityAbilityOrb orb = new EntityAbilityOrb(npc.worldObj);
orb.setupPreview(npc, orbSize, colorData, lightningData, anchorData, windUpTicks);
orb.setupPreview(npc, orbSize, displayData, lightningData, anchorData, windUpTicks);
return orb;
}
@@ -37,7 +37,7 @@ public class AbilityOrbBarrage extends Ability {
private boolean dualCharging = true;
// Data classes for energy properties
private final EnergyColorData colorData = new EnergyColorData();
private final EnergyDisplayData colorData = new EnergyDisplayData();
private final EnergyCombatData combatData = new EnergyCombatData(4.0f, 0.0f, 0.0f, false, 1.5f, 0.5f);
private final EnergyHomingData homingData = new EnergyHomingData();
private final EnergyLightningData lightningData = new EnergyLightningData();
@@ -45,6 +45,8 @@ public class AbilityOrbBarrage extends Ability {
private final EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
new EnergyAnchorData(AnchorPoint.RIGHT_HAND), new EnergyAnchorData(AnchorPoint.LEFT_HAND)
};
private final EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
// Array to store entities
private transient List<EntityAbilityOrb> orbEntities = new ArrayList<>();
@@ -123,7 +125,7 @@ public class AbilityOrbBarrage extends Ability {
EntityAbilityOrb orbEntity = new EntityAbilityOrb(
world, caster, target,
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord, orbSize,
colorData, combatData, homingData, lightningData, lifespanData
colorData, combatData, homingData, lightningData, lifespanData, trajectoryData
);
orbEntity.setupCharging(anchorData[i], windUpTicks);
@@ -174,7 +176,7 @@ public class AbilityOrbBarrage extends Ability {
EntityAbilityOrb orb = new EntityAbilityOrb(
world, caster, target, spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
orbSize, colorData, combatData, homingData, lightningData, lifespanData
orbSize, colorData, combatData, homingData, lightningData, lifespanData, trajectoryData
);
world.spawnEntityInWorld(orb);
@@ -271,6 +273,7 @@ public class AbilityOrbBarrage extends Ability {
homingData.writeNBT(nbt);
lightningData.writeNBT(nbt);
lifespanData.writeNBT(nbt);
trajectoryData.writeNBT(nbt);
for (int i = 0; i < anchorData.length; i++) {
NBTTagCompound comp = new NBTTagCompound();
@@ -290,6 +293,7 @@ public class AbilityOrbBarrage extends Ability {
homingData.readNBT(nbt);
lightningData.readNBT(nbt);
lifespanData.readNBT(nbt);
trajectoryData.readNBT(nbt);
for (int i = 0; i < anchorData.length; i++) {
if (nbt.hasKey("Anchor_" + i, Constants.NBT.TAG_COMPOUND)) {
@@ -29,11 +29,11 @@ public class AbilityOrbDual extends Ability {
// Ability-specific properties
private float orbSize = 1.0f;
private boolean dualFire= true;
private int dualFireDelay = 20;
private int dualFireDelay = 5;
// Data classes for energy properties
public final EnergyColorData[] colorData = new EnergyColorData[]{
new EnergyColorData(), new EnergyColorData()
public final EnergyDisplayData[] displayData = new EnergyDisplayData[]{
new EnergyDisplayData(), new EnergyDisplayData()
};
public final EnergyCombatData combatData = new EnergyCombatData();
public final EnergyHomingData homingData = new EnergyHomingData();
@@ -41,9 +41,12 @@ public class AbilityOrbDual extends Ability {
new EnergyLightningData(), new EnergyLightningData()
};
public final EnergyLifespanData lifespanData = new EnergyLifespanData();
private EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
private final EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
new EnergyAnchorData(AnchorPoint.RIGHT_HAND), new EnergyAnchorData(AnchorPoint.LEFT_HAND)
};
private EnergyTrajectoryData[] trajectoryData = new EnergyTrajectoryData[]{
new EnergyTrajectoryData(), new EnergyTrajectoryData()
};
// Transient state for orb entity (used during windup charging)
private transient EntityAbilityOrb orbEntity = null;
@@ -61,8 +64,8 @@ public class AbilityOrbDual extends Ability {
this.telegraphType = TelegraphType.CIRCLE;
this.showTelegraph = true;
// Default built-in animation
this.windUpAnimationName = "Ability_BeamDual_Windup";
this.activeAnimationName = "Ability_BeamDual_Active";
this.windUpAnimationName = "Ability_OrbDual_Windup";
this.activeAnimationName = "Ability_OrbDual_Active";
}
@Override
@@ -91,7 +94,7 @@ public class AbilityOrbDual extends Ability {
if (orbEntity2 != null && !orbEntity2.isDead && dualFireDelay <= 0) {
orbEntity2.startMoving(target);
}
} else {
} else if (orbEntity2 != null) {
orbEntity2.setDead();
}
@@ -110,16 +113,16 @@ public class AbilityOrbDual extends Ability {
orbEntity = new EntityAbilityOrb(
world, caster, target,
spawnPos1.xCoord, spawnPos1.yCoord, spawnPos1.zCoord, orbSize,
colorData[0], combatData, homingData, lightningData[0], lifespanData);
displayData[0], combatData, homingData, lightningData[0], lifespanData, trajectoryData[0]);
Vec3 spawnPos2 = AnchorPointHelper.calculateAnchorPosition(caster, anchorData[1]);
orbEntity2 = new EntityAbilityOrb(
world, caster, target,
spawnPos2.xCoord, spawnPos2.yCoord, spawnPos2.zCoord, orbSize,
colorData[1], combatData, homingData, lightningData[1], lifespanData);
displayData[1], combatData, homingData, lightningData[1], lifespanData, trajectoryData[1]);
orbEntity.setSiblingUUID(orbEntity2.getPersistentID());
orbEntity2.setSiblingUUID(orbEntity.getPersistentID());
orbEntity.setSiblingEntityId(orbEntity2.getEntityId());
orbEntity2.setSiblingEntityId(orbEntity.getEntityId());
orbEntity.setupCharging(anchorData[0], windUpTicks);
orbEntity2.setupCharging(anchorData[1], windUpTicks);
@@ -217,12 +220,13 @@ public class AbilityOrbDual extends Ability {
NBTTagCompound orb1 = new NBTTagCompound();
NBTTagCompound orb2 = new NBTTagCompound();
anchorData[0].writeNBT(orb1);
anchorData[1].writeNBT(orb2);
colorData[0].writeNBT(orb1);
colorData[1].writeNBT(orb2);
lightningData[0].writeNBT(orb1);
lightningData[1].writeNBT(orb2);
for (int i = 0; i < 2; i++) {
NBTTagCompound orb = i == 0 ? orb1 : orb2;
anchorData[i].writeNBT(orb);
displayData[i].writeNBT(orb);
lightningData[i].writeNBT(orb);
trajectoryData[i].writeNBT(orb);
}
nbt.setTag("Orb_1", orb1);
nbt.setTag("Orb_2", orb2);
@@ -244,18 +248,19 @@ public class AbilityOrbDual extends Ability {
homingData.speed = nbt.getFloat("orbSpeed");
}
anchorData[0].readNBT(orb1);
anchorData[1].readNBT(orb2);
colorData[0].readNBT(orb1);
colorData[1].readNBT(orb2);
lightningData[0].readNBT(orb1);
lightningData[1].readNBT(orb2);
for (int i = 0; i < 2; i++) {
NBTTagCompound orb = i == 0 ? orb1 : orb2;
anchorData[i].readNBT(orb);
displayData[i].readNBT(orb);
lightningData[i].readNBT(orb);
trajectoryData[i].readNBT(orb);
}
}
// Getters & Setters
private EnergyColorData getColorData(int orb) {
private EnergyDisplayData getColorData(int orb) {
orb = ValueUtil.clamp(orb, 0, 1);
return colorData[orb];
return displayData[orb];
}
private EnergyLightningData getLightningData(int orb) {
orb = ValueUtil.clamp(orb, 0, 1);
@@ -484,10 +489,10 @@ public class AbilityOrbDual extends Ability {
FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius).visibleWhen(this::isExplosive),
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
// Visual tab - Orb 1
FieldDef.section("ability.section.orb1").tab("ability.tab.visual"),
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
() -> getAnchorPointEnum(0), v -> setAnchorPointEnum(0, v))
.tab("ability.tab.visual"),
FieldDef.section("ability.section.orb1").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor",
() -> getInnerColor(0), v -> setInnerColor(0, v))
.tab("ability.tab.visual"),
@@ -520,10 +525,10 @@ public class AbilityOrbDual extends Ability {
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0))
).tab("ability.tab.visual"),
// Visual tab - Orb 2
FieldDef.section("ability.section.orb2").tab("ability.tab.visual"),
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
() -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v))
.tab("ability.tab.visual"),
FieldDef.section("ability.section.orb2").tab("ability.tab.visual"),
FieldDef.colorSubGui("ability.innerColor",
() -> getInnerColor(1), v -> setInnerColor(1, v))
.tab("ability.tab.visual"),
@@ -564,7 +569,7 @@ public class AbilityOrbDual extends Ability {
if (npc == null || npc.worldObj == null) return null;
EntityAbilityOrb orb = new EntityAbilityOrb(npc.worldObj);
orb.setupPreview(npc, orbSize, colorData[0], lightningData[0], anchorData[0], windUpTicks);
orb.setupPreview(npc, orbSize, displayData[0], lightningData[0], anchorData[0], windUpTicks);
return orb;
}
@@ -5,7 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.LockMovementType;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.data.EnergyColorData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import noppes.npcs.client.gui.builder.FieldDef;
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
@@ -15,12 +15,10 @@ import kamkeel.npcs.entity.EntityAbilitySweeper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import noppes.npcs.LogWriter;
import noppes.npcs.api.ability.type.IAbilitySweeper;
import java.util.Arrays;
import java.util.List;
import noppes.npcs.entity.EntityNPCInterface;
/**
* Sweeper ability: A low sweeping beam that rotates around the NPC.
@@ -44,7 +42,7 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
private boolean lockOnTarget = false;
// Visual properties
private EnergyColorData colorData = new EnergyColorData(0xFF6600, 0xFF0000, true, 1.8f, 0.5f, 0.0f);
private EnergyDisplayData colorData = new EnergyDisplayData(0xFF6600, 0xFF0000, true, 1.8f, 0.5f, 0.0f);
// Runtime state (transient)
private transient EntityAbilitySweeper activeEntity = null;
@@ -1,6 +1,5 @@
package kamkeel.npcs.entity;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.data.*;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.Entity;
@@ -15,7 +14,6 @@ import noppes.npcs.LogWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Beam projectile - head with trailing path that curves with homing.
@@ -28,13 +26,6 @@ import java.util.UUID;
*/
public class EntityAbilityBeam extends EntityAbilityProjectile {
// Beam-specific movement properties
private float speed = 0.5f;
private boolean homing = true;
private float homingStrength = 0.35f; // Increased from 0.15 for better tracking
private float homingRange = 20.0f;
private UUID siblingUUID = null;
// Beam shape properties
private float beamWidth = 0.3f;
private float headSize = 0.5f;
@@ -59,7 +50,6 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
private int chargeDuration = 40;
private int chargeTick = 0;
private float chargeOffsetDistance = 1.0f;
private EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.FRONT);
// Trail fading for non-anchored beams (comet effect)
private boolean fadeTrail = false;
@@ -110,22 +100,20 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
* If false, beam is free-moving with trailing length (no tail orb).
*/
public EntityAbilityBeam(World world, EntityLivingBase owner, EntityLivingBase target,
double x, double y, double z,
float beamWidth, float headSize,
EnergyColorData color, EnergyCombatData combat,
EnergyHomingData homing, EnergyLightningData lightning,
EnergyLifespanData lifespan,
boolean anchoredMode) {
double x, double y, double z,
float beamWidth, float headSize,
EnergyDisplayData display, EnergyCombatData combat,
EnergyHomingData homing, EnergyLightningData lightning,
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory,
boolean anchoredMode) {
super(world);
// Initialize base properties via parent
initProjectile(owner, target, x, y, z, headSize, color, combat, lightning, lifespan);
initProjectile(owner, target, x, y, z, headSize, display, combat, lightning, lifespan, trajectory);
// Beam-specific properties from homing data
this.speed = homing.speed;
this.homing = homing.homing;
this.homingStrength = homing.homingStrength;
this.homingRange = homing.homingRange;
this.homingData = homing;
this.beamWidth = beamWidth;
this.headSize = headSize;
@@ -155,16 +143,16 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
double dz = target.posZ - z;
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (len > 0) {
this.motionX = (dx / len) * speed;
this.motionY = (dy / len) * speed;
this.motionZ = (dz / len) * speed;
this.motionX = (dx / len) * getSpeed();
this.motionY = (dy / len) * getSpeed();
this.motionZ = (dz / len) * getSpeed();
}
} else {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = (float) Math.toRadians(owner.rotationPitch);
this.motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
this.motionY = -Math.sin(pitch) * speed;
this.motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
this.motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
this.motionY = -Math.sin(pitch) * getSpeed();
this.motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
}
}
@@ -180,7 +168,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
this.motionZ = 0;
}
public void setupPreview(EntityLivingBase owner, float beamWidth, float headSize, EnergyColorData color, EnergyLightningData lightning, EnergyAnchorData anchor, int chargeDuration, float chargeOffsetDistance) {
public void setupPreview(EntityLivingBase owner, float beamWidth, float headSize, EnergyDisplayData display, EnergyLightningData lightning, EnergyAnchorData anchor, int chargeDuration, float chargeOffsetDistance) {
this.setPreviewMode(true);
this.setPreviewOwner(owner);
@@ -188,15 +176,8 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
this.beamWidth = beamWidth;
this.headSize = headSize;
this.size = headSize;
this.innerColor = color.innerColor;
this.outerColor = color.outerColor;
this.outerColorEnabled = color.outerColorEnabled;
this.outerColorWidth = color.outerColorWidth;
this.outerColorAlpha = color.outerColorAlpha;
this.rotationSpeed = color.rotationSpeed;
this.lightningEffect = lightning.lightningEffect;
this.lightningDensity = lightning.lightningDensity;
this.lightningRadius = lightning.lightningRadius;
this.displayData = display;
this.lightningData = lightning;
// Set charging state
this.setCharging(true);
@@ -252,15 +233,15 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
prevPosZ = posZ;
// Fire forward based on owner facing direction
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner != null) {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = 0; // Fire horizontally
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
motionY = -Math.sin(pitch) * speed;
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
motionY = -Math.sin(pitch) * getSpeed();
motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
} else {
motionX = speed;
motionX = getSpeed();
motionY = 0;
motionZ = 0;
}
@@ -303,7 +284,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
if (fadeTrail) trailPointAges.add(0);
// Calculate velocity toward target (head starts at origin = startX/Y/Z)
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (target != null) {
double dx = target.posX - startX;
@@ -311,16 +292,16 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
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;
motionX = (dx / len) * getSpeed();
motionY = (dy / len) * getSpeed();
motionZ = (dz / len) * getSpeed();
}
} 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;
motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
motionY = -Math.sin(pitch) * getSpeed();
motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
}
if (DEBUG_LOGGING && !worldObj.isRemote) {
@@ -338,9 +319,9 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
headOffsetY * headOffsetY +
headOffsetZ * headOffsetZ
);
boolean exceeded = distFromOrigin >= maxDistance;
boolean exceeded = distFromOrigin >= getMaxDistance();
if (exceeded && !worldObj.isRemote && DEBUG_LOGGING) {
LogWriter.info("[Beam] DEAD: Max distance exceeded. dist=" + distFromOrigin + " max=" + maxDistance);
LogWriter.info("[Beam] DEAD: Max distance exceeded. dist=" + distFromOrigin + " max=" + getMaxDistance());
}
return exceeded;
}
@@ -394,7 +375,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
// Update origin if attached to owner
if (attachedToOwner) {
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner != null) {
startX = owner.posX;
startY = owner.posY + owner.getEyeHeight() * 0.7;
@@ -438,7 +419,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner == null || owner.isDead) {
setDead();
return;
@@ -460,13 +441,11 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
);
}
// Offset downward by half headSize to center
double centeredY = pos.yCoord - headSize * 0.5;
setPosition(pos.xCoord, centeredY, pos.zCoord);
setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
// Also update origin for when firing starts
startX = pos.xCoord;
startY = centeredY;
startY = pos.yCoord;
startZ = pos.zCoord;
}
@@ -531,7 +510,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
// Update origin if attached to owner
if (attachedToOwner) {
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner != null) {
startX = owner.posX;
startY = owner.posY + owner.getEyeHeight() * 0.7;
@@ -552,9 +531,9 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
}
private void updateHoming() {
if (!homing) return;
if (!isHoming()) return;
Entity target = getTarget();
Entity target = getTargetEntity();
if (target == null || !target.isEntityAlive()) return;
// Calculate world position of head
@@ -567,18 +546,18 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
double dz = target.posZ - headWorldZ;
double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist <= homingRange && dist > 0) {
if (dist <= getHomingRange() && dist > 0) {
// Calculate effective homing strength - increases when closer to commit to target
float effectiveStrength = homingStrength;
if (dist < homingRange * 0.3) {
effectiveStrength = Math.min(1.0f, homingStrength * 2.5f);
} else if (dist < homingRange * 0.6) {
effectiveStrength = Math.min(0.8f, homingStrength * 1.5f);
float effectiveStrength = getHomingStrength();
if (dist < getHomingRange() * 0.3) {
effectiveStrength = Math.min(1.0f, getHomingStrength() * 2.5f);
} else if (dist < getHomingRange() * 0.6) {
effectiveStrength = Math.min(0.8f, getHomingStrength() * 1.5f);
}
double desiredVX = (dx / dist) * speed;
double desiredVY = (dy / dist) * speed;
double desiredVZ = (dz / dist) * speed;
double desiredVX = (dx / dist) * getSpeed();
double desiredVY = (dy / dist) * getSpeed();
double desiredVZ = (dz / dist) * getSpeed();
motionX += (desiredVX - motionX) * effectiveStrength;
motionY += (desiredVY - motionY) * effectiveStrength;
@@ -586,9 +565,9 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
double vLen = Math.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ);
if (vLen > 0) {
motionX = (motionX / vLen) * speed;
motionY = (motionY / vLen) * speed;
motionZ = (motionZ / vLen) * speed;
motionX = (motionX / vLen) * getSpeed();
motionY = (motionY / vLen) * getSpeed();
motionZ = (motionZ / vLen) * getSpeed();
}
}
}
@@ -606,7 +585,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
hasHit = true;
if (explosive) {
if (isExplosive()) {
posX = blockHit.hitVec.xCoord;
posY = blockHit.hitVec.yCoord;
posZ = blockHit.hitVec.zCoord;
@@ -634,7 +613,7 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
}
hasHit = true;
if (explosive) {
if (isExplosive()) {
posX = headX;
posY = headY;
posZ = headZ;
@@ -648,12 +627,6 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
}
}
@Override
protected boolean shouldIgnoreEntity(Entity entity) {
if (entity.getPersistentID().equals(siblingUUID)) return true;
return super.shouldIgnoreEntity(entity);
}
// ==================== GETTERS FOR RENDERER ====================
public float getBeamWidth() {
@@ -752,26 +725,10 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
return trailFadeTime;
}
public UUID getSiblingUUID() {
return siblingUUID;
}
public void setSiblingUUID(UUID siblingUUID) {
if (siblingUUID == null)
return;
if (this.siblingUUID == null)
this.siblingUUID = siblingUUID;
}
// ==================== NBT ====================
@Override
protected void readProjectileNBT(NBTTagCompound nbt) {
this.speed = nbt.hasKey("Speed") ? nbt.getFloat("Speed") : 0.5f;
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;
this.beamWidth = nbt.hasKey("BeamWidth") ? nbt.getFloat("BeamWidth") : 0.3f;
this.headSize = nbt.hasKey("HeadSize") ? nbt.getFloat("HeadSize") : 0.5f;
this.headOffsetX = nbt.hasKey("HeadOffsetX") ? nbt.getDouble("HeadOffsetX") : 0;
@@ -792,7 +749,6 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
this.fadeTrail = nbt.hasKey("FadeTrail") && nbt.getBoolean("FadeTrail");
this.trailFadeTime = nbt.hasKey("TrailFadeTime") ? nbt.getInteger("TrailFadeTime") : 20;
this.anchorData.readNBT(nbt);
// Read trail points (relative to origin)
trailPoints.clear();
@@ -807,16 +763,10 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
));
}
}
this.siblingUUID = nbt.hasKey("SiblingUUID") ? UUID.fromString(nbt.getString("SiblingUUID")) : null;
}
@Override
protected void writeProjectileNBT(NBTTagCompound nbt) {
nbt.setFloat("Speed", speed);
nbt.setBoolean("Homing", homing);
nbt.setFloat("HomingStrength", homingStrength);
nbt.setFloat("HomingRange", homingRange);
nbt.setFloat("BeamWidth", beamWidth);
nbt.setFloat("HeadSize", headSize);
nbt.setDouble("HeadOffsetX", headOffsetX);
@@ -843,9 +793,5 @@ public class EntityAbilityBeam extends EntityAbilityProjectile {
trailList.appendTag(pointNbt);
}
nbt.setTag("Trail", trailList);
if (siblingUUID instanceof UUID) {
nbt.setString("SiblingUUID", siblingUUID.toString());
}
}
}
@@ -1,6 +1,5 @@
package kamkeel.npcs.entity;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.data.*;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.Entity;
@@ -12,7 +11,6 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.List;
import java.util.UUID;
/**
* Disc projectile - flat spinning disc with optional boomerang behavior.
@@ -22,11 +20,7 @@ import java.util.UUID;
*/
public class EntityAbilityDisc extends EntityAbilityProjectile {
// Disc-specific movement properties
private float speed = 0.5f;
private boolean homing = true;
private float homingStrength = 0.35f; // Increased from 0.15 for better tracking
private float homingRange = 20.0f;
// Disc-specific movement propertie
// Boomerang properties
private boolean boomerang = false;
@@ -49,8 +43,6 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
// Data watcher index for charging state (synced to clients)
private static final int DW_CHARGING = 20;
private UUID siblingUUID = null;
public EntityAbilityDisc(World world) {
super(world);
}
@@ -87,22 +79,18 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
* Full constructor with all parameters using data classes.
*/
public EntityAbilityDisc(World world, EntityLivingBase owner, EntityLivingBase target,
double x, double y, double z,
float discRadius, float discThickness,
EnergyColorData color, EnergyCombatData combat,
EnergyHomingData homing, EnergyLightningData lightning,
EnergyLifespanData lifespan,
boolean boomerang, int boomerangDelay) {
double x, double y, double z,
float discRadius, float discThickness,
EnergyDisplayData display, EnergyCombatData combat,
EnergyHomingData homing, EnergyLightningData lightning,
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory,
boolean boomerang, int boomerangDelay) {
super(world);
// Initialize base properties
initProjectile(owner, target, x, y, z, discRadius, color, combat, lightning, lifespan);
initProjectile(owner, target, x, y, z, discRadius, display, combat, lightning, lifespan, trajectory);
// Disc-specific properties from homing data
this.speed = homing.speed;
this.homing = homing.homing;
this.homingStrength = homing.homingStrength;
this.homingRange = homing.homingRange;
this.homingData = homing;
this.boomerang = boomerang;
this.boomerangDelay = boomerangDelay;
@@ -117,16 +105,16 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
double dz = target.posZ - z;
double len = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (len > 0) {
this.motionX = (dx / len) * speed;
this.motionY = (dy / len) * speed;
this.motionZ = (dz / len) * speed;
this.motionX = (dx / len) * getSpeed();
this.motionY = (dy / len) * getSpeed();
this.motionZ = (dz / len) * getSpeed();
}
} else {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = (float) Math.toRadians(owner.rotationPitch);
this.motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
this.motionY = -Math.sin(pitch) * speed;
this.motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
this.motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
this.motionY = -Math.sin(pitch) * getSpeed();
this.motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
}
}
@@ -157,19 +145,13 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
* Follows anchor point and animations like in the real game.
* Can be fired when transitioning to active phase.
*/
public void setupPreview(EntityLivingBase owner, float discRadius, float discThickness, EnergyColorData color, EnergyLightningData lightning, EnergyAnchorData anchor, int chargeDuration) {
public void setupPreview(EntityLivingBase owner, float discRadius, float discThickness, EnergyDisplayData display, EnergyLightningData lightning, EnergyAnchorData anchor, int chargeDuration) {
this.setPreviewMode(true);
this.setPreviewOwner(owner);
// Set visual properties
this.innerColor = color.innerColor;
this.outerColor = color.outerColor;
this.outerColorEnabled = color.outerColorEnabled;
this.outerColorWidth = color.outerColorWidth;
this.rotationSpeed = color.rotationSpeed;
this.lightningEffect = lightning.lightningEffect;
this.lightningDensity = lightning.lightningDensity;
this.lightningRadius = lightning.lightningRadius;
this.displayData = display;
this.lightningData = lightning;
// Set charging state
this.setCharging(true);
@@ -219,15 +201,15 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
prevPosZ = posZ;
// Fire forward based on owner facing direction
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner != null) {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = 0; // Fire horizontally
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
motionY = -Math.sin(pitch) * speed;
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
motionY = -Math.sin(pitch) * getSpeed();
motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
} else {
motionX = speed;
motionX = getSpeed();
motionY = 0;
motionZ = 0;
}
@@ -248,7 +230,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
startZ = posZ;
// Calculate velocity toward target
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (target != null) {
double dx = target.posX - posX;
@@ -256,23 +238,23 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
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;
motionX = (dx / len) * getSpeed();
motionY = (dy / len) * getSpeed();
motionZ = (dz / len) * getSpeed();
}
} 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;
motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
motionY = -Math.sin(pitch) * getSpeed();
motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
}
}
@Override
protected void updateRotation() {
// Disc spins ONLY on Y axis (flat spin like a saw blade)
this.rotationValY += rotationSpeed;
this.rotationValY += getRotationSpeed();
// No wobble - keep X and Z at 0 for stable flight
if (this.rotationValY > 360.0f) this.rotationValY -= 360.0f;
}
@@ -315,7 +297,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
if (this.isCollidedHorizontally || this.isCollidedVertically) {
if (!worldObj.isRemote) {
hasHit = true;
if (explosive) {
if (isExplosive()) {
doExplosion();
}
}
@@ -334,14 +316,14 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
if (boomerang) {
// If not returning yet, check if we should start returning
if (!returning && !hasHit) {
if (distTraveled >= maxDistance * 0.8 || ticksSinceMiss >= boomerangDelay) {
if (distTraveled >= getMaxDistance() * 0.8 || ticksSinceMiss >= boomerangDelay) {
returning = true;
}
}
// If returning, only die when close to owner
if (returning) {
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner != null) {
double distToOwner = Math.sqrt(
(posX - owner.posX) * (posX - owner.posX) +
@@ -359,7 +341,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
}
// Non-boomerang: standard max distance check
return distTraveled >= maxDistance;
return distTraveled >= getMaxDistance();
}
/**
@@ -373,9 +355,9 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
}
private void updateHoming() {
if (!homing) return;
if (!isHoming()) return;
Entity target = getTarget();
Entity target = getTargetEntity();
if (target == null || !target.isEntityAlive()) return;
double dx = target.posX - posX;
@@ -383,18 +365,18 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
double dz = target.posZ - posZ;
double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist <= homingRange && dist > 0) {
if (dist <= getHomingRange() && dist > 0) {
// Calculate effective homing strength - increases when closer to commit to target
float effectiveStrength = homingStrength;
if (dist < homingRange * 0.3) {
effectiveStrength = Math.min(1.0f, homingStrength * 2.5f);
} else if (dist < homingRange * 0.6) {
effectiveStrength = Math.min(0.8f, homingStrength * 1.5f);
float effectiveStrength = getHomingStrength();
if (dist < getHomingRange() * 0.3) {
effectiveStrength = Math.min(1.0f, getHomingStrength() * 2.5f);
} else if (dist < getHomingRange() * 0.6) {
effectiveStrength = Math.min(0.8f, getHomingStrength() * 1.5f);
}
double desiredVX = (dx / dist) * speed;
double desiredVY = (dy / dist) * speed;
double desiredVZ = (dz / dist) * speed;
double desiredVX = (dx / dist) * getSpeed();
double desiredVY = (dy / dist) * getSpeed();
double desiredVZ = (dz / dist) * getSpeed();
motionX += (desiredVX - motionX) * effectiveStrength;
motionY += (desiredVY - motionY) * effectiveStrength;
@@ -402,15 +384,15 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
double vLen = Math.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ);
if (vLen > 0) {
motionX = (motionX / vLen) * speed;
motionY = (motionY / vLen) * speed;
motionZ = (motionZ / vLen) * speed;
motionX = (motionX / vLen) * getSpeed();
motionY = (motionY / vLen) * getSpeed();
motionZ = (motionZ / vLen) * getSpeed();
}
}
}
private void updateReturnToOwner() {
Entity owner = getOwner();
Entity owner = getOwnerEntity();
// If owner is gone (unloaded/dead), head back toward start position
double targetX, targetY, targetZ;
@@ -432,10 +414,10 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
if (dist > 0) {
// Stronger homing when returning
double returnStrength = Math.min(1.0, homingStrength * 2.5);
double desiredVX = (dx / dist) * speed;
double desiredVY = (dy / dist) * speed;
double desiredVZ = (dz / dist) * speed;
double returnStrength = Math.min(1.0, getHomingStrength() * 2.5);
double desiredVX = (dx / dist) * getSpeed();
double desiredVY = (dy / dist) * getSpeed();
double desiredVZ = (dz / dist) * getSpeed();
motionX += (desiredVX - motionX) * returnStrength;
motionY += (desiredVY - motionY) * returnStrength;
@@ -443,9 +425,9 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
double vLen = Math.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ);
if (vLen > 0) {
motionX = (motionX / vLen) * speed;
motionY = (motionY / vLen) * speed;
motionZ = (motionZ / vLen) * speed;
motionX = (motionX / vLen) * getSpeed();
motionY = (motionY / vLen) * getSpeed();
motionZ = (motionZ / vLen) * getSpeed();
}
}
}
@@ -458,7 +440,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
hasHit = true;
if (explosive) {
if (isExplosive()) {
posX = blockHit.hitVec.xCoord;
posY = blockHit.hitVec.yCoord;
posZ = blockHit.hitVec.zCoord;
@@ -485,7 +467,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
hasHit = true;
if (explosive) {
if (isExplosive()) {
doExplosion();
} else {
applyDamage(entity);
@@ -502,7 +484,7 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner == null || owner.isDead) {
setDead();
return;
@@ -544,14 +526,6 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
// ==================== GETTERS ====================
public float getSpeed() {
return speed;
}
public boolean isHoming() {
return homing;
}
public float getDiscRadius() {
return discRadius;
}
@@ -568,26 +542,10 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
return returning;
}
public UUID getSiblingUUID() {
return siblingUUID;
}
public void setSiblingUUID(UUID siblingUUID) {
if (siblingUUID == null)
return;
if (this.siblingUUID == null)
this.siblingUUID = siblingUUID;
}
// ==================== NBT ====================
@Override
protected void readProjectileNBT(NBTTagCompound nbt) {
this.speed = nbt.hasKey("Speed") ? nbt.getFloat("Speed") : 0.5f;
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;
this.boomerang = nbt.hasKey("Boomerang") && nbt.getBoolean("Boomerang");
this.boomerangDelay = nbt.hasKey("BoomerangDelay") ? nbt.getInteger("BoomerangDelay") : 40;
this.discRadius = nbt.hasKey("DiscRadius") ? nbt.getFloat("DiscRadius") : 1.0f;
@@ -601,16 +559,10 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
this.chargeTick = nbt.hasKey("ChargeTick") ? nbt.getInteger("ChargeTick") : 0;
this.targetDiscRadius = nbt.hasKey("TargetDiscRadius") ? nbt.getFloat("TargetDiscRadius") : this.discRadius;
this.targetDiscThickness = nbt.hasKey("TargetDiscThickness") ? nbt.getFloat("TargetDiscThickness") : this.discThickness;
this.anchorData.readNBT(nbt);
this.siblingUUID = nbt.hasKey("SiblingUUID") ? UUID.fromString(nbt.getString("SiblingUUID")) : null;
}
@Override
protected void writeProjectileNBT(NBTTagCompound nbt) {
nbt.setFloat("Speed", speed);
nbt.setBoolean("Homing", homing);
nbt.setFloat("HomingStrength", homingStrength);
nbt.setFloat("HomingRange", homingRange);
nbt.setBoolean("Boomerang", boomerang);
nbt.setInteger("BoomerangDelay", boomerangDelay);
nbt.setFloat("DiscRadius", discRadius);
@@ -622,12 +574,5 @@ public class EntityAbilityDisc extends EntityAbilityProjectile {
nbt.setInteger("ChargeTick", chargeTick);
nbt.setFloat("TargetDiscRadius", targetDiscRadius);
nbt.setFloat("TargetDiscThickness", targetDiscThickness);
// Anchor data
this.anchorData.writeNBT(nbt);
if (siblingUUID instanceof UUID) {
nbt.setString("SiblingUUID", siblingUUID.toString());
}
}
}
@@ -88,16 +88,16 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
* Full constructor with all parameters using data classes.
*/
public EntityAbilityLaser(World world, EntityLivingBase owner, EntityLivingBase target,
double x, double y, double z,
float laserWidth,
EnergyColorData color, EnergyCombatData combat,
EnergyLightningData lightning, EnergyLifespanData lifespan,
float expansionSpeed, int lingerTicks) {
double x, double y, double z,
float laserWidth,
EnergyDisplayData display, EnergyCombatData combat,
EnergyLightningData lightning, EnergyLifespanData lifespan,
EnergyTrajectoryData trajectory, float expansionSpeed, int lingerTicks) {
super(world);
// Initialize base properties (laser doesn't rotate)
initProjectile(owner, target, x, y, z, laserWidth, color, combat, lightning, lifespan);
this.rotationSpeed = 0.0f;
initProjectile(owner, target, x, y, z, laserWidth, display, combat, lightning, lifespan, trajectory);
this.displayData.rotationSpeed = 0.0f;
// Laser-specific properties
this.laserWidth = laserWidth;
@@ -171,8 +171,8 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
// Expand the laser
currentLength += expansionSpeed;
if (currentLength >= maxDistance) {
currentLength = maxDistance;
if (currentLength >= getMaxDistance()) {
currentLength = getMaxDistance();
fullyExtended = true;
}
@@ -206,7 +206,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
startZ = posZ;
// Calculate velocity toward target
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (target != null) {
double dx = target.posX - startX;
@@ -253,7 +253,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
endZ = blockHit.hitVec.zCoord;
fullyExtended = true;
if (explosive) {
if (isExplosive()) {
// Explode at hit point
double oldPosX = posX;
double oldPosY = posY;
@@ -275,7 +275,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner == null || owner.isDead) {
setDead();
return;
@@ -481,7 +481,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
* Setup this laser in preview mode for GUI display.
* Laser doesn't have charging state - spawns at active phase and fires immediately.
*/
public void setupPreview(EntityLivingBase owner, float laserWidth, EnergyColorData color,
public void setupPreview(EntityLivingBase owner, float laserWidth, EnergyDisplayData display,
EnergyLightningData lightning, float expansionSpeed, float maxDistance) {
this.setPreviewMode(true);
this.setPreviewOwner(owner);
@@ -489,15 +489,10 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
// Set visual properties
this.laserWidth = laserWidth;
this.size = laserWidth;
this.innerColor = color.innerColor;
this.outerColor = color.outerColor;
this.outerColorEnabled = color.outerColorEnabled;
this.outerColorWidth = color.outerColorWidth;
this.displayData = display;
this.expansionSpeed = expansionSpeed;
this.maxDistance = Math.min(maxDistance, 5.0f); // Limit for GUI preview
this.lightningEffect = lightning.lightningEffect;
this.lightningDensity = lightning.lightningDensity;
this.lightningRadius = lightning.lightningRadius;
this.lifespanData.maxDistance = Math.min(maxDistance, 5.0f); // Limit for GUI preview
this.lightningData = lightning;
// Position at chest height
double x = owner.posX;
@@ -1,6 +1,5 @@
package kamkeel.npcs.entity;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.data.*;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.Entity;
@@ -12,7 +11,6 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.List;
import java.util.UUID;
/**
* Orb projectile - spherical homing energy ball.
@@ -22,24 +20,15 @@ import java.util.UUID;
*/
public class EntityAbilityOrb extends EntityAbilityProjectile {
// Orb-specific movement properties
private float speed = 0.5f;
private boolean homing = true;
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 EnergyAnchorData anchorData = new EnergyAnchorData(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;
private UUID siblingUUID = null;
public EntityAbilityOrb(World world) {
super(world);
}
@@ -77,19 +66,15 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
*/
public EntityAbilityOrb(World world, EntityLivingBase owner, EntityLivingBase target,
double x, double y, double z, float orbSize,
EnergyColorData color, EnergyCombatData combat,
EnergyDisplayData display, EnergyCombatData combat,
EnergyHomingData homing, EnergyLightningData lightning,
EnergyLifespanData lifespan) {
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory) {
super(world);
// Initialize base properties
initProjectile(owner, target, x, y, z, orbSize, color, combat, lightning, lifespan);
initProjectile(owner, target, x, y, z, orbSize, display, combat, lightning, lifespan, trajectory);
// Orb-specific properties
this.speed = homing.speed;
this.homing = homing.homing;
this.homingStrength = homing.homingStrength;
this.homingRange = homing.homingRange;
this.homingData = homing;
// Calculate initial velocity toward target
if (target != null) {
@@ -136,20 +121,13 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
* Follows anchor point and animations like in the real game.
* Can be fired when transitioning to active phase.
*/
public void setupPreview(EntityLivingBase owner, float orbSize, EnergyColorData color, EnergyLightningData lightning, EnergyAnchorData anchor, int chargeDuration) {
public void setupPreview(EntityLivingBase owner, float orbSize, EnergyDisplayData display, EnergyLightningData lightning, EnergyAnchorData anchor, int chargeDuration) {
this.setPreviewMode(true);
this.setPreviewOwner(owner);
// Set visual properties
this.innerColor = color.innerColor;
this.outerColor = color.outerColor;
this.outerColorEnabled = color.outerColorEnabled;
this.outerColorWidth = color.outerColorWidth;
this.rotationSpeed = color.rotationSpeed;
this.lightningEffect = lightning.lightningEffect;
this.lightningDensity = lightning.lightningDensity;
this.lightningRadius = lightning.lightningRadius;
this.lightningFadeTime = lightning.lightningFadeTime;
this.displayData = display;
this.lightningData = lightning;
// Set charging state
this.setCharging(true);
@@ -198,16 +176,16 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
prevPosZ = posZ;
// Fire forward based on owner facing direction
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner != null) {
float yaw = (float) Math.toRadians(owner.rotationYaw);
float pitch = (float) Math.toRadians(0); // Fire horizontally
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
motionY = -Math.sin(pitch) * speed;
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
motionY = -Math.sin(pitch) * getSpeed();
motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
} else {
// Default: fire forward (positive X in model space)
motionX = speed;
motionX = getSpeed();
motionY = 0;
motionZ = 0;
}
@@ -228,7 +206,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
startZ = posZ;
// Calculate velocity toward target
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (target != null) {
double dx = target.posX - posX;
@@ -236,16 +214,16 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
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;
motionX = (dx / len) * getSpeed();
motionY = (dy / len) * getSpeed();
motionZ = (dz / len) * getSpeed();
}
} 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;
motionX = -Math.sin(yaw) * Math.cos(pitch) * getSpeed();
motionY = -Math.sin(pitch) * getSpeed();
motionZ = Math.cos(yaw) * Math.cos(pitch) * getSpeed();
}
}
@@ -267,7 +245,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
handleClientInterpolation();
} else {
// Server-side logic
updateHoming();
updateMovement();
checkBlockCollision();
checkEntityCollision();
this.moveEntity(motionX, motionY, motionZ);
@@ -277,7 +255,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
if (this.isCollidedHorizontally || this.isCollidedVertically) {
if (!worldObj.isRemote) {
hasHit = true;
if (explosive) {
if (isExplosive()) {
doExplosion();
}
}
@@ -295,10 +273,36 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
this.posZ += motionZ;
}
private void updateHoming() {
if (!homing) return;
private void updateMovement() {
if (!isTrajectoryConcluded()) {
updateTrajectory();
} else {
updateHoming();
}
}
Entity target = getTarget();
private void updateTrajectory() {
if (isTrajectoryConcluded()) return;
// i really fucking hate math
}
private boolean isTrajectoryConcluded() {
if (trajectoryData.isEmpty()) return true;
for (int i = 0; i < trajectoryData.size(); i++) {
if (!trajectoryData.getPath(i).isConcluded()) {
return false;
}
}
return true;
}
private void updateHoming() {
if (!isHoming()) return;
Entity target = getTargetEntity();
if (target == null || !target.isEntityAlive()) return;
double dx = target.posX - posX;
@@ -306,21 +310,21 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
double dz = target.posZ - posZ;
double dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist <= homingRange && dist > 0) {
if (dist <= getHomingRange() && dist > 0) {
// Calculate effective homing strength - increases when closer to commit to target
// This prevents orbiting behavior at close range
float effectiveStrength = homingStrength;
if (dist < homingRange * 0.3) {
float effectiveStrength = getHomingStrength();
if (dist < getHomingRange() * 0.3) {
// Within 30% of homing range, dramatically increase strength to commit
effectiveStrength = Math.min(1.0f, homingStrength * 2.5f);
} else if (dist < homingRange * 0.6) {
effectiveStrength = Math.min(1.0f, getHomingStrength() * 2.5f);
} else if (dist < getHomingRange() * 0.6) {
// Within 60% of homing range, moderately increase strength
effectiveStrength = Math.min(0.8f, homingStrength * 1.5f);
effectiveStrength = Math.min(0.8f, getHomingStrength() * 1.5f);
}
double desiredVX = (dx / dist) * speed;
double desiredVY = (dy / dist) * speed;
double desiredVZ = (dz / dist) * speed;
double desiredVX = (dx / dist) * getSpeed();
double desiredVY = (dy / dist) * getSpeed();
double desiredVZ = (dz / dist) * getSpeed();
motionX += (desiredVX - motionX) * effectiveStrength;
motionY += (desiredVY - motionY) * effectiveStrength;
@@ -329,9 +333,9 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
// Normalize to maintain speed
double vLen = Math.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ);
if (vLen > 0) {
motionX = (motionX / vLen) * speed;
motionY = (motionY / vLen) * speed;
motionZ = (motionZ / vLen) * speed;
motionX = (motionX / vLen) * getSpeed();
motionY = (motionY / vLen) * getSpeed();
motionZ = (motionZ / vLen) * getSpeed();
}
}
}
@@ -344,7 +348,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
if (blockHit != null && blockHit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
hasHit = true;
if (explosive) {
if (isExplosive()) {
posX = blockHit.hitVec.xCoord;
posY = blockHit.hitVec.yCoord;
posZ = blockHit.hitVec.zCoord;
@@ -369,7 +373,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
hasHit = true;
if (explosive) {
if (isExplosive()) {
doExplosion();
} else {
applyDamage(entity);
@@ -386,7 +390,7 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
private void updateCharging() {
chargeTick++;
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner == null || owner.isDead) {
setDead();
return;
@@ -423,47 +427,15 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
// ==================== GETTERS ====================
public float getSpeed() {
return speed;
}
public boolean isHoming() {
return homing;
}
public float getHomingStrength() {
return homingStrength;
}
public float getHomingRange() {
return homingRange;
}
// Legacy getter for renderer compatibility
public float getOrbSize() {
return size;
}
public UUID getSiblingUUID() {
return siblingUUID;
}
public void setSiblingUUID(UUID siblingUUID) {
if (siblingUUID == null)
return;
if (this.siblingUUID == null)
this.siblingUUID = siblingUUID;
}
// ==================== NBT ====================
@Override
protected void readProjectileNBT(NBTTagCompound nbt) {
this.speed = nbt.hasKey("OrbSpeed") ? nbt.getFloat("OrbSpeed") : 0.5f;
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;
@@ -471,27 +443,15 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
this.chargeDuration = nbt.hasKey("ChargeDuration") ? nbt.getInteger("ChargeDuration") : 40;
this.chargeTick = nbt.hasKey("ChargeTick") ? nbt.getInteger("ChargeTick") : 0;
this.targetSize = nbt.hasKey("TargetSize") ? nbt.getFloat("TargetSize") : this.size;
// Anchor data
this.anchorData.readNBT(nbt);
this.siblingUUID = nbt.hasKey("SiblingUUID") ? UUID.fromString(nbt.getString("SiblingUUID")) : null;
}
@Override
protected void writeProjectileNBT(NBTTagCompound nbt) {
nbt.setFloat("OrbSpeed", speed);
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);
anchorData.writeNBT(nbt);
nbt.setFloat("TargetSize", targetSize);
if (siblingUUID instanceof UUID) {
nbt.setString("SiblingUUID", siblingUUID.toString());
}
}
}
@@ -5,10 +5,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
import kamkeel.npcs.controllers.data.ability.data.EnergyColorData;
import kamkeel.npcs.controllers.data.ability.data.EnergyCombatData;
import kamkeel.npcs.controllers.data.ability.data.EnergyLifespanData;
import kamkeel.npcs.controllers.data.ability.data.EnergyLightningData;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.data.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -16,13 +14,16 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import noppes.npcs.NpcDamageSource;
import noppes.npcs.api.entity.IEnergyProjectile;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Base class for all ability projectiles (Orb, Disc, Beam, Laser).
@@ -30,49 +31,46 @@ import java.util.List;
*
* Design inspired by LouisXIV's energy attack system.
*/
public abstract class EntityAbilityProjectile extends Entity implements IEntityAdditionalSpawnData {
public abstract class EntityAbilityProjectile extends Entity implements IEnergyProjectile, IEntityAdditionalSpawnData {
// ==================== VISUAL PROPERTIES ====================
protected float size = 1.0f;
protected int innerColor = 0xFFFFFF;
protected int outerColor = 0x8888FF;
protected boolean outerColorEnabled = true;
protected float outerColorWidth = 0.4f; // Additive offset from inner size
protected float outerColorAlpha = 0.5f;
protected float rotationSpeed = 4.0f;
// ==================== COMBAT PROPERTIES ====================
protected float damage = 7.0f;
protected float knockback = 1.0f;
protected float knockbackUp = 0.1f;
protected EnergyCombatData combatData = new EnergyCombatData();
// ==================== EFFECT PROPERTIES ====================
protected List<AbilityEffect> effects = new ArrayList<>();
// ==================== EXPLOSION PROPERTIES ====================
protected boolean explosive = false;
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
protected EnergyLightningData lightningData = new EnergyLightningData();
// 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;
// ==================== DISPLAY PROPERTIES ====================
protected EnergyDisplayData displayData = new EnergyDisplayData();
// ==================== ANCHOR PROPERTIES ====================
protected EnergyAnchorData anchorData = new EnergyAnchorData(AnchorPoint.FRONT);
// ==================== LIFESPAN PROPERTIES ====================
protected EnergyLifespanData lifespanData = new EnergyLifespanData();
protected long deathWorldTime = -1; // World time when entity should die (-1 = not set)
// ==================== HOMING PROPERTIES ====================
protected EnergyHomingData homingData = new EnergyHomingData();
// ==================== TRAJECTORY PROPERTIES ====================
protected EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
protected Map<Integer, Integer> pathDelays;
// ==================== TRACKING ====================
protected double startX, startY, startZ;
protected int ownerEntityId = -1;
protected int targetEntityId = -1;
protected int siblingEntityId = -1;
// ==================== STATE ====================
protected boolean hasHit = false;
@@ -103,10 +101,11 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
/**
* Initialize common properties using data classes. Call from subclass constructors.
*/
protected void initProjectile(EntityLivingBase owner, EntityLivingBase target,
double x, double y, double z, float size,
EnergyColorData color, EnergyCombatData combat,
EnergyLightningData lightning, EnergyLifespanData lifespan) {
protected void initProjectile(EntityLivingBase owner, EntityLivingBase target, EntityAbilityProjectile sibling,
double x, double y, double z, float size,
EnergyDisplayData display, EnergyCombatData combat,
EnergyLightningData lightning, EnergyLifespanData lifespan,
EnergyTrajectoryData trajectory) {
this.setPosition(x, y, z);
this.startX = x;
this.startY = y;
@@ -114,42 +113,31 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
this.ownerEntityId = owner.getEntityId();
this.targetEntityId = target != null ? target.getEntityId() : -1;
this.siblingEntityId = sibling != null ? sibling.getEntityId() : -1;
// Visual
this.size = size;
this.innerColor = color.innerColor;
this.outerColor = color.outerColor;
this.outerColorEnabled = color.outerColorEnabled;
this.outerColorWidth = color.outerColorWidth;
this.outerColorAlpha = color.outerColorAlpha;
this.rotationSpeed = color.rotationSpeed;
// Combat
this.damage = combat.damage;
this.knockback = combat.knockback;
this.knockbackUp = combat.knockbackUp;
// Explosion
this.explosive = combat.explosive;
this.explosionRadius = combat.explosionRadius;
this.explosionDamageFalloff = combat.explosionDamageFalloff;
// Lifespan
this.maxDistance = lifespan.maxDistance;
this.maxLifetime = lifespan.maxLifetime;
// deathWorldTime will be set on first tick when world is available
// Lightning
this.lightningEffect = lightning.lightningEffect;
this.lightningDensity = lightning.lightningDensity;
this.lightningRadius = lightning.lightningRadius;
this.lightningFadeTime = lightning.lightningFadeTime;
this.displayData = display;
this.combatData = combat;
this.lifespanData = lifespan; // deathWorldTime will be set on first tick when world is available
this.lightningData = lightning;
this.trajectoryData = trajectory;
// Initialize render size
this.renderCurrentSize = size;
this.prevRenderSize = size;
}
// Initialize projectile without a sibling
protected void initProjectile(EntityLivingBase owner, EntityLivingBase target,
double x, double y, double z, float size,
EnergyDisplayData display, EnergyCombatData combat,
EnergyLightningData lightning, EnergyLifespanData lifespan,
EnergyTrajectoryData trajectory) {
initProjectile(owner, target, null, x, y, z, size, display, combat, lightning, lifespan, trajectory);
}
@Override
protected void entityInit() {
// No DataWatcher needed - using IEntityAdditionalSpawnData with NBT
@@ -207,7 +195,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
// Set death time on first tick if not already set (handles chunk load/unload)
if (deathWorldTime < 0 && worldObj != null) {
deathWorldTime = worldObj.getTotalWorldTime() + maxLifetime;
deathWorldTime = worldObj.getTotalWorldTime() + getMaxLifetime();
}
// Check lifespan using world time (survives chunk unload/reload)
@@ -236,9 +224,9 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
* Update rotation values. Override for custom rotation behavior.
*/
protected void updateRotation() {
this.rotationValX += rotationSpeed * 0.7f;
this.rotationValY += rotationSpeed;
this.rotationValZ += rotationSpeed * 0.5f;
this.rotationValX += getRotationSpeed() * 0.7f;
this.rotationValY += getRotationSpeed();
this.rotationValZ += getRotationSpeed() * 0.5f;
if (this.rotationValX > 360.0f) this.rotationValX -= 360.0f;
if (this.rotationValY > 360.0f) this.rotationValY -= 360.0f;
@@ -255,7 +243,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
(posY - startY) * (posY - startY) +
(posZ - startZ) * (posZ - startZ)
);
return distTraveled >= maxDistance;
return distTraveled >= getMaxDistance();
}
/**
@@ -327,12 +315,12 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
protected void applyDamage(EntityLivingBase target) {
if (previewMode) return; // Skip damage in preview mode
applyDamage(target, this.damage, this.knockback);
applyDamage(target, this.getDamage(), this.getKnockback());
}
protected void applyDamage(EntityLivingBase target, float dmg, float kb) {
if (previewMode) return; // Skip damage in preview mode
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (owner instanceof EntityNPCInterface) {
target.attackEntityFrom(new NpcDamageSource("npc_ability", (EntityNPCInterface) owner), dmg);
@@ -351,7 +339,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
if (len > 0) {
double kbX = (dx / len) * kb * 0.5;
double kbZ = (dz / len) * kb * 0.5;
double kbY = knockbackUp > 0 ? knockbackUp : 0.1;
double kbY = getKnockbackUp() > 0 ? getKnockbackUp() : 0.1;
target.addVelocity(kbX, kbY, kbZ);
target.velocityChanged = true;
}
@@ -377,11 +365,11 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
if (previewMode) return; // Skip explosion in preview mode
worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 1.0f, 1.0f);
Entity owner = getOwner();
Entity owner = getOwnerEntity();
AxisAlignedBB explosionBox = AxisAlignedBB.getBoundingBox(
posX - explosionRadius, posY - explosionRadius, posZ - explosionRadius,
posX + explosionRadius, posY + explosionRadius, posZ + explosionRadius
posX - getExplosionRadius(), posY - getExplosionRadius(), posZ - getExplosionRadius(),
posX + getExplosionRadius(), posY + getExplosionRadius(), posZ + getExplosionRadius()
);
@SuppressWarnings("unchecked")
@@ -396,20 +384,16 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
Math.pow(target.posZ - posZ, 2)
);
if (dist <= explosionRadius) {
float falloff = 1.0f - (float) (dist / explosionRadius) * explosionDamageFalloff;
applyDamage(target, damage * falloff, knockback * falloff);
if (dist <= getExplosionRadius()) {
float falloff = 1.0f - (float) (dist / getExplosionRadius()) * getExplosionDamageFalloff();
applyDamage(target, getDamage() * falloff, getKnockback() * falloff);
}
}
}
// ==================== ENTITY HELPERS ====================
public int getOwnerEntityId() {
return ownerEntityId;
}
protected Entity getOwner() {
public Entity getOwnerEntity() {
// In preview mode, use direct reference (no world lookup)
if (previewMode && previewOwner != null) {
return previewOwner;
@@ -418,6 +402,18 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
return worldObj.getEntityByID(ownerEntityId);
}
@Override
public int getOwnerEntityId() {
return ownerEntityId;
}
@Override
public IEntity getOwner() {
if (previewMode) return null;
if (getOwnerEntity() == null) return null;
return NpcAPI.Instance().getIEntity(getOwnerEntity());
}
/**
* Set the preview owner for GUI preview mode.
* This allows anchor point calculations without world entity lookup.
@@ -426,16 +422,45 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
this.previewOwner = owner;
}
protected Entity getTarget() {
@Override
public int getTargetEntityId() {
return targetEntityId;
}
public Entity getTargetEntity() {
if (targetEntityId == -1) return null;
return worldObj.getEntityByID(targetEntityId);
}
@Override
public IEntity getTarget() {
if (getTargetEntity() == null) return null;
return NpcAPI.Instance().getIEntity(getTargetEntity());
}
@Override
public int getSiblingEntityId() {
return siblingEntityId;
}
@Override
public void setSiblingEntityId(int siblingEntityId) {
if (!(worldObj.getEntityByID(siblingEntityId) instanceof EntityAbilityProjectile)) return;
this.siblingEntityId = siblingEntityId;
}
@Override
public IEnergyProjectile getSibling() {
if (siblingEntityId == -1) return null;
return (EntityAbilityProjectile) worldObj.getEntityByID(siblingEntityId);
}
/**
* Check if an entity should be ignored for collision.
*/
protected boolean shouldIgnoreEntity(Entity entity) {
Entity owner = getOwner();
Entity owner = getOwnerEntity();
if (entity == owner) return true;
if (owner instanceof EntityNPCInterface && entity instanceof EntityNPCInterface) {
@@ -443,73 +468,170 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
EntityNPCInterface targetNpc = (EntityNPCInterface) entity;
if (ownerNpc.faction.id == targetNpc.faction.id) return true;
}
if (entity.getEntityId() == getSiblingEntityId())
return true;
return false;
}
// ==================== VISUAL GETTERS ====================
@Override
public float getSize() {
return size;
}
@Override
public int getInnerColor() {
return innerColor;
return displayData.getInnerColor();
}
@Override
public int getOuterColor() {
return outerColor;
return displayData.getOuterColor();
}
@Override
public boolean isOuterColorEnabled() {
return outerColorEnabled;
return displayData.isOuterColorEnabled();
}
@Override
public float getOuterColorWidth() {
return outerColorWidth;
return displayData.getOuterColorWidth();
}
@Override
public float getOuterColorAlpha() {
return outerColorAlpha;
return displayData.getOuterColorAlpha();
}
@Override
public float getRotationSpeed() {
return rotationSpeed;
return displayData.getRotationSpeed();
}
// ==================== ROTATION GETTERS ====================
@Override
public float getInterpolatedRotationX(float partialTicks) {
return this.prevRotationValX + (this.rotationValX - this.prevRotationValX) * partialTicks;
}
@Override
public float getInterpolatedRotationY(float partialTicks) {
return this.prevRotationValY + (this.rotationValY - this.prevRotationValY) * partialTicks;
}
@Override
public float getInterpolatedRotationZ(float partialTicks) {
return this.prevRotationValZ + (this.rotationValZ - this.prevRotationValZ) * partialTicks;
}
@Override
public float getInterpolatedSize(float partialTicks) {
return this.prevRenderSize + (this.renderCurrentSize - this.prevRenderSize) * partialTicks;
}
// ==================== LIGHTNING GETTERS ====================
@Override
public boolean hasLightningEffect() {
return lightningEffect;
return lightningData.isLightningEffect();
}
@Override
public float getLightningDensity() {
return lightningDensity;
return lightningData.getLightningDensity();
}
@Override
public float getLightningRadius() {
return lightningRadius;
return lightningData.getLightningRadius();
}
@Override
public int getLightningFadeTime() {
return lightningFadeTime;
return lightningData.getLightningFadeTime();
}
// ==================== LIFESPAN GETTERS ====================
@Override
public float getMaxDistance() { return lifespanData.getMaxDistance(); }
@Override
public int getMaxLifetime() { return lifespanData.getMaxLifetime(); }
// ==================== COMBAT GETTERS ====================
@Override
public float getDamage() { return combatData.getDamage(); }
@Override
public float getKnockback() { return combatData.knockback; }
@Override
public float getKnockbackUp() { return combatData.knockbackUp; }
@Override
public boolean isExplosive() { return combatData.isExplosive(); }
@Override
public float getExplosionRadius() { return combatData.explosionRadius; }
@Override
public float getExplosionDamageFalloff() { return combatData.explosionDamageFalloff; }
// ==================== HOMING GETTERS ====================
@Override
public boolean isHoming() { return homingData.isHoming(); }
@Override
public float getHomingStrength() { return homingData.getHomingStrength(); }
@Override
public float getHomingRange() { return homingData.getHomingRange(); }
// ==================== TRAJECTORY GETTERS ====================
// ==================== ANCHOR GETTERS ====================
@Override
public float getSpeed() { return homingData.getSpeed(); }
public AnchorPoint getAnchorPoint() { return anchorData.getAnchorPoint(); }
@Override
public int getAnchor() { return anchorData.getAnchor(); }
@Override
public float getAnchorOffsetX() { return anchorData.getAnchorOffsetX(); }
@Override
public float getAnchorOffsetY() { return anchorData.getAnchorOffsetY(); }
@Override
public float getAnchorOffsetZ() { return anchorData.getAnchorOffsetZ(); }
// ==================== MOVEMENT GETTERS ====================
@Override public double getStartX() { return startX; }
@Override public double getStartY() { return startY; }
@Override public double getStartZ() { return startZ; }
@Override public double getMotionX() { return motionX; }
@Override public double getMotionY() { return motionY; }
@Override public double getMotionZ() { return motionZ; }
// ==================== BRIGHTNESS ====================
@Override
@@ -542,20 +664,6 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
*/
protected void readBaseNBT(NBTTagCompound nbt) {
this.size = nbt.getFloat("Size");
this.innerColor = nbt.getInteger("InnerColor");
this.outerColor = nbt.getInteger("OuterColor");
this.outerColorEnabled = !nbt.hasKey("OuterColorEnabled") || nbt.getBoolean("OuterColorEnabled");
this.outerColorAlpha = nbt.hasKey("OuterColorAlpha") ? nbt.getFloat("OuterColorAlpha") : 0.5f;
this.outerColorWidth = nbt.hasKey("OuterColorWidth") ? nbt.getFloat("OuterColorWidth") : 0.4f;
this.rotationSpeed = nbt.hasKey("RotationSpeed") ? nbt.getFloat("RotationSpeed") : 4.0f;
this.damage = nbt.getFloat("Damage");
this.knockback = nbt.getFloat("Knockback");
this.knockbackUp = nbt.getFloat("KnockbackUp");
this.explosive = nbt.getBoolean("Explosive");
this.explosionRadius = nbt.getFloat("ExplosionRadius");
this.explosionDamageFalloff = nbt.getFloat("ExplosionDamageFalloff");
// Read effects list
this.effects.clear();
@@ -566,8 +674,6 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
}
}
this.maxDistance = nbt.getFloat("MaxDistance");
this.maxLifetime = nbt.getInteger("MaxLifetime");
this.deathWorldTime = nbt.hasKey("DeathWorldTime") ? nbt.getLong("DeathWorldTime") : -1;
this.startX = nbt.getDouble("StartX");
@@ -576,21 +682,24 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
this.ownerEntityId = nbt.getInteger("OwnerId");
this.targetEntityId = nbt.getInteger("TargetId");
this.siblingEntityId = nbt.getInteger("SiblingId");
this.motionX = nbt.getDouble("MotionX");
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;
}
anchorData.readNBT(nbt);
combatData.readNBT(nbt);
displayData.readNBT(nbt);
homingData.readNBT(nbt);
lifespanData.readNBT(nbt);
lightningData.readNBT(nbt);
trajectoryData.readNBT(nbt);
}
/**
@@ -598,20 +707,6 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
*/
protected void writeBaseNBT(NBTTagCompound nbt) {
nbt.setFloat("Size", size);
nbt.setInteger("InnerColor", innerColor);
nbt.setInteger("OuterColor", outerColor);
nbt.setBoolean("OuterColorEnabled", outerColorEnabled);
nbt.setFloat("OuterColorWidth", outerColorWidth);
nbt.setFloat("OuterColorAlpha", outerColorAlpha);
nbt.setFloat("RotationSpeed", rotationSpeed);
nbt.setFloat("Damage", damage);
nbt.setFloat("Knockback", knockback);
nbt.setFloat("KnockbackUp", knockbackUp);
nbt.setBoolean("Explosive", explosive);
nbt.setFloat("ExplosionRadius", explosionRadius);
nbt.setFloat("ExplosionDamageFalloff", explosionDamageFalloff);
// Write effects list
if (!effects.isEmpty()) {
@@ -622,9 +717,7 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
nbt.setTag("Effects", effectsList);
}
nbt.setFloat("MaxDistance", maxDistance);
nbt.setLong("DeathWorldTime", deathWorldTime);
nbt.setInteger("MaxLifetime", maxLifetime);
nbt.setDouble("StartX", startX);
nbt.setDouble("StartY", startY);
@@ -632,16 +725,19 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
nbt.setInteger("OwnerId", ownerEntityId);
nbt.setInteger("TargetId", targetEntityId);
nbt.setInteger("SiblingId", targetEntityId);
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);
anchorData.writeNBT(nbt);
combatData.writeNBT(nbt);
displayData.writeNBT(nbt);
homingData.writeNBT(nbt);
lifespanData.writeNBT(nbt);
lightningData.writeNBT(nbt);
trajectoryData.writeNBT(nbt);
}
/**
@@ -4,7 +4,7 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.data.ability.data.EnergyColorData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -74,7 +74,7 @@ public class EntityAbilitySweeper extends Entity implements IEntityAdditionalSpa
public EntityAbilitySweeper(World world, EntityLivingBase owner, EntityLivingBase target,
float beamLength, float beamWidth, float beamHeight,
EnergyColorData colorData,
EnergyDisplayData displayData,
float sweepSpeed, int numberOfRotations,
float damage, int damageInterval, boolean piercing,
boolean lockOnTarget) {
@@ -85,10 +85,10 @@ public class EntityAbilitySweeper extends Entity implements IEntityAdditionalSpa
this.beamLength = beamLength;
this.beamWidth = beamWidth;
this.beamHeight = beamHeight;
this.innerColor = colorData.innerColor;
this.outerColor = colorData.outerColor;
this.outerColorEnabled = colorData.outerColorEnabled;
this.outerColorWidth = colorData.outerColorWidth;
this.innerColor = displayData.innerColor;
this.outerColor = displayData.outerColor;
this.outerColorEnabled = displayData.outerColorEnabled;
this.outerColorWidth = displayData.outerColorWidth;
this.sweepSpeed = sweepSpeed;
this.numberOfRotations = numberOfRotations;
this.damage = damage;
@@ -229,9 +229,8 @@ public class AnchorPointHelper {
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)
// Renderer applies glRotatef(180 - yaw) then glScalef(-1, -1, 1).
// Combined transform: x' = mx*cos(yaw) + mz*sin(yaw), z' = mx*sin(yaw) - mz*cos(yaw)
float bodyYaw = (float) Math.toRadians(entity.renderYawOffset);
double cosYaw = Math.cos(bodyYaw);
double sinYaw = Math.sin(bodyYaw);
+39 -8
View File
@@ -385,18 +385,49 @@ public class DataAbilities {
lastTarget = target;
ability.start(target);
// Spawn telegraph and send to clients
spawnTelegraph(ability, target);
// Play wind up sound if configured
playAbilitySound(ability.getWindUpSound());
// Play wind up animation if configured
playAbilityAnimation(ability.getWindUpAnimation());
if (ability.getPhase() == AbilityPhase.ACTIVE) {
// Windup was 0 — skip telegraph/windup and go straight to active
executeImmediate(ability, target);
} else {
// Normal windup flow
spawnTelegraph(ability, target);
playAbilitySound(ability.getWindUpSound());
playAbilityAnimation(ability.getWindUpAnimation());
}
return true;
}
/**
* Execute an ability immediately (no windup).
* Called when windUpTicks is 0.
*/
private void executeImmediate(Ability ability, EntityLivingBase target) {
// Lock rotation if movement is locked during ACTIVE phase
if (ability.isMovementLockedDuringActive()) {
captureLockedRotation();
}
// Play active sound and animation
playAbilitySound(ability.getActiveSound());
playAbilityAnimation(ability.getActiveAnimation());
// Fire execute event (cancelable)
AbilityEvent.ExecuteEvent executeEvent = new AbilityEvent.ExecuteEvent(
npc.wrappedNPC, ability, target);
if (NpcAPI.EVENT_BUS.post(executeEvent)) {
return;
}
// Call onExecute
ability.onExecute(npc, target, npc.worldObj);
// Check if ability completed during onExecute
if (ability.getPhase() == AbilityPhase.IDLE) {
handleAbilityCompletion(target);
}
}
/**
* Play a sound at the NPC's location.
*/
@@ -473,7 +473,7 @@ public class ClientProxy extends CommonProxy {
animNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
save = false;
}
return new GuiNPCManageAnimations(animNpc, save);
return new GuiNPCManageAnimations(animNpc, save, npc != null);
} else if (gui == EnumGuiType.ManageLinked)
return new GuiNPCManageLinked(npc);
@@ -509,7 +509,7 @@ public class ClientProxy extends CommonProxy {
abilityNpc = new EntityCustomNpc(Minecraft.getMinecraft().theWorld);
abilityNpc.display.texture = "customnpcs:textures/entity/humanmale/AnimationBody.png";
}
return new GuiNpcManageAbilities(abilityNpc);
return new GuiNpcManageAbilities(abilityNpc, npc != null);
}
else if (gui == EnumGuiType.MainMenuGlobal)
@@ -7,6 +7,7 @@ import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket;
import kamkeel.npcs.network.packets.request.ability.CustomAbilitySavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
@@ -568,7 +569,7 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
AbilitySlot slot = npcSlots.get(selectedAbilityIndex);
if (slot.isReference()) {
// For reference slots, save back to controller
// (The resolved copy was edited in-place)
PacketClient.sendClient(new CustomAbilitySavePacket(ability.writeNBT()));
} else {
// For inline slots, replace with the updated ability
npcSlots.set(selectedAbilityIndex, AbilitySlot.inline(ability));
@@ -359,6 +359,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
@Override
public void close() {
GuiNpcTextField.unfocus();
applyToAbility();
callback.onAbilitySaved(ability);
super.close();
@@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IScrollData;
@@ -39,6 +40,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
private HashMap<String, Integer> rawData = new HashMap<>();
private GuiCustomScroll scroll;
private String search = "";
private boolean waitingForLoad = false;
private int pendingLoadMode = -1;
@@ -48,7 +50,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
setBackground("menubg.png");
xSize = 220;
ySize = 180;
ySize = 216;
PacketClient.sendClient(new CustomAbilitiesGetPacket());
}
@@ -59,7 +61,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
setBackground("menubg.png");
xSize = 220;
ySize = 180;
ySize = 216;
PacketClient.sendClient(new CustomAbilitiesGetPacket());
}
@@ -75,7 +77,7 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
scroll.setSize(200, 110);
scroll.setSize(200, 140);
}
scroll.guiLeft = guiLeft + 10;
scroll.guiTop = y;
@@ -85,7 +87,12 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
}
addScroll(scroll);
y += 115;
y += 143;
// Search bar
addTextField(new GuiNpcTextField(10, this, fontRendererObj, guiLeft + 10, y, 200, 20, search));
y += 24;
addButton(new GuiNpcButton(0, guiLeft + 10, y, 95, 20, "gui.load"));
addButton(new GuiNpcButton(2, guiLeft + 115, y, 95, 20, "gui.cancel"));
@@ -94,7 +101,16 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
}
private List<String> getFilteredList() {
return new ArrayList<>(displayToUuid.keySet());
if (search.isEmpty()) {
return new ArrayList<>(displayToUuid.keySet());
}
List<String> list = new ArrayList<>();
for (String name : displayToUuid.keySet()) {
if (name.toLowerCase().contains(search.toLowerCase())) {
list.add(name);
}
}
return list;
}
@Override
@@ -116,6 +132,19 @@ public class SubGuiAbilityLoad extends SubGuiInterface implements ICustomScrollL
}
}
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
if (getTextField(10) != null && getTextField(10).isFocused()) {
String newSearch = getTextField(10).getText();
if (!search.equals(newSearch)) {
search = newSearch;
scroll.resetScroll();
scroll.setList(getFilteredList());
}
}
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiAbilityLoadMode) {
@@ -0,0 +1,95 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* SubGui for selecting an ability type when creating a new ability.
*/
public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomScrollListener {
private GuiCustomScroll scroll;
private final HashMap<String, String> displayNameToTypeId = new HashMap<>();
private String selectedTypeId = null;
public SubGuiAbilityTypeSelect() {
setBackground("menubg.png");
xSize = 200;
ySize = 216;
}
@Override
public void initGui() {
super.initGui();
addLabel(new GuiNpcLabel(0, "ability.selectType", guiLeft + 5, guiTop + 5));
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
scroll.setSize(190, 165);
}
scroll.guiLeft = guiLeft + 5;
scroll.guiTop = guiTop + 16;
addScroll(scroll);
List<String> list = buildTypeList();
scroll.setList(list);
addButton(new GuiNpcButton(0, guiLeft + 5, guiTop + 188, 90, 20, "gui.add"));
getButton(0).setEnabled(scroll.hasSelected());
addButton(new GuiNpcButton(1, guiLeft + 105, guiTop + 188, 90, 20, "gui.cancel"));
}
private List<String> buildTypeList() {
List<String> list = new ArrayList<>();
displayNameToTypeId.clear();
String[] types = AbilityController.Instance.getTypes();
for (String typeId : types) {
String displayName = I18n.format(typeId);
list.add(displayName);
displayNameToTypeId.put(displayName, typeId);
}
return list;
}
@Override
public void buttonEvent(GuiButton guibutton) {
if (guibutton.id == 0 && scroll.hasSelected()) {
String displayName = scroll.getSelected();
selectedTypeId = displayNameToTypeId.get(displayName);
close();
} else if (guibutton.id == 1) {
selectedTypeId = null;
close();
}
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
if (guiCustomScroll.id == 0) {
getButton(0).setEnabled(scroll.hasSelected());
}
}
@Override
public void customScrollDoubleClicked(String selection, GuiCustomScroll guiCustomScroll) {
if (guiCustomScroll.id == 0 && selection != null) {
selectedTypeId = displayNameToTypeId.get(selection);
close();
}
}
public String getSelectedTypeId() {
return selectedTypeId;
}
}
@@ -51,8 +51,8 @@ public class GuiNPCManageAnimations extends GuiModelInterface2 implements IScrol
// Track if current animation is built-in
private boolean currentIsBuiltIn = false;
public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save) {
super(npc);
public GuiNPCManageAnimations(EntityNPCInterface npc, boolean save, boolean hasMenuNpc) {
super(npc, hasMenuNpc);
this.setSave(save);
this.xOffset = -148 + 70;
this.yOffset = -170 + 137;
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.global;
import kamkeel.npcs.client.renderer.TelegraphRenderer;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import java.util.UUID;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.CustomAbilitiesGetPacket;
@@ -15,6 +16,7 @@ import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.advanced.SubGuiAbilityTypeSelect;
import noppes.npcs.client.gui.util.AbilityPreviewExecutor;
import noppes.npcs.client.gui.util.GuiAbilityInterface;
import noppes.npcs.client.gui.util.GuiCustomScroll;
@@ -64,8 +66,8 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
private AbilityPreviewExecutor previewExecutor;
private long prevTick = 0;
public GuiNpcManageAbilities(EntityNPCInterface npc) {
super(npc);
public GuiNpcManageAbilities(EntityNPCInterface npc, boolean hasMenuNpc) {
super(npc, hasMenuNpc);
// Layout offset
this.xOffset = -148 + 110;
@@ -87,14 +89,17 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
public void initGui() {
super.initGui();
// Edit button (above Remove)
addButton(new GuiNpcButton(100, guiLeft + 368, guiTop + 8, 45, 20, "gui.edit"));
getButton(100).setEnabled(selected != null && !selected.isEmpty() && selectedAbility != null);
// Add button
addButton(new GuiNpcButton(2, guiLeft + 368, guiTop + 8, 45, 20, "gui.add"));
// Remove button
addButton(new GuiNpcButton(1, guiLeft + 368, guiTop + 30, 45, 20, "gui.remove"));
getButton(1).setEnabled(selected != null && !selected.isEmpty() && displayToUuid.containsKey(selected));
// Edit button
addButton(new GuiNpcButton(100, guiLeft + 368, guiTop + 52, 45, 20, "gui.edit"));
getButton(100).setEnabled(selected != null && !selected.isEmpty() && selectedAbility != null);
// Scroll list of saved abilities (right side)
if (scroll == null) {
scroll = new GuiCustomScroll(this, 0);
@@ -211,7 +216,10 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
int id = guibutton.id;
if (id == 1 && selected != null && selectedUuid != null) {
if (id == 2) {
// Add — open type selection
setSubGui(new SubGuiAbilityTypeSelect());
} else if (id == 1 && selected != null && selectedUuid != null) {
GuiYesNo guiyesno = new GuiYesNo(this, selected, StatCollector.translateToLocal("gui.delete"), 1);
displayGuiScreen(guiyesno);
} else if (id == 100 && selectedAbility != null) {
@@ -329,6 +337,24 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiAbilityTypeSelect) {
String typeId = ((SubGuiAbilityTypeSelect) subgui).getSelectedTypeId();
if (typeId != null) {
Ability newAbility = AbilityController.Instance.create(typeId);
if (newAbility != null) {
newAbility.setId(UUID.randomUUID().toString());
newAbility.setName(newAbility.getTypeId());
// Save to server, then open config GUI
PacketClient.sendClient(new CustomAbilitySavePacket(newAbility.writeNBT()));
selectedAbility = newAbility;
selected = newAbility.getName();
selectedUuid = newAbility.getId();
previewExecutor.stop();
setSubGui(selectedAbility.createConfigGui(this));
return;
}
}
}
initGui();
}
@@ -81,7 +81,6 @@ public class AbilityPreviewExecutor {
this.previewAbility = ability;
this.previewNpc = npc;
this.phase = AbilityPhase.WINDUP;
this.currentTick = 0;
this.playing = true;
this.paused = false;
@@ -103,21 +102,30 @@ public class AbilityPreviewExecutor {
parentGui.startTrackingMovement();
}
// Create telegraph for preview
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
if (ability.getWindUpTicks() <= 0) {
// No windup — go straight to active
this.phase = AbilityPhase.ACTIVE;
transitionToActive();
} else {
// Normal windup flow
this.phase = AbilityPhase.WINDUP;
// Start windup animation
Animation windUpAnim = ability.getWindUpAnimation();
if (windUpAnim != null) {
AnimationData data = npc.display.animationData;
data.setEnabled(true);
data.setAnimation(windUpAnim);
data.animation.paused = false;
}
// Create telegraph for preview
previewTelegraph = ability.createTelegraph(npc, fakeTarget);
// Spawn preview entity on first tick if ability spawns during windup
if (ability.spawnPreviewDuringWindup()) {
spawnPreviewEntity();
// Start windup animation
Animation windUpAnim = ability.getWindUpAnimation();
if (windUpAnim != null) {
AnimationData data = npc.display.animationData;
data.setEnabled(true);
data.setAnimation(windUpAnim);
data.animation.paused = false;
}
// Spawn preview entity on first tick if ability spawns during windup
if (ability.spawnPreviewDuringWindup()) {
spawnPreviewEntity();
}
}
}
@@ -74,7 +74,16 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
public int yOffset = 0;
public GuiAbilityInterface(EntityNPCInterface npc) {
super(npc);
this(npc, true);
}
/**
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
public GuiAbilityInterface(EntityNPCInterface npc, boolean hasMenuNpc) {
super(hasMenuNpc ? npc : null);
this.npc = npc;
this.playerdata = ((EntityCustomNpc) npc).modelData;
this.drawDefaultBackground = false;
@@ -246,7 +246,10 @@ public abstract class GuiContainerNPCInterface extends GuiContainer {
}
public void closeSubGui(SubGuiInterface gui) {
subgui = null;
// Only null out subgui if it wasn't replaced by a new one during subGuiClosed
if (subgui == gui) {
subgui = null;
}
}
public boolean hasSubGui() {
@@ -30,10 +30,18 @@ public class GuiModelInterface2 extends GuiNPCInterface2 {
public EntityNPCInterface npc;
public GuiModelInterface2(EntityNPCInterface npc) {
super(npc);
this(npc, true);
}
/**
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
public GuiModelInterface2(EntityNPCInterface npc, boolean hasMenuNpc) {
super(hasMenuNpc ? npc : null);
this.npc = npc;
playerdata = ((EntityCustomNpc) npc).modelData;
//xSize = 380;
drawDefaultBackground = false;
}
@@ -536,7 +536,10 @@ public abstract class GuiNPCInterface extends GuiScreen {
pendingSubGuiResult = null;
handler.accept(gui);
}
subgui = null;
// Only null out subgui if it wasn't replaced by a new one during subGuiClosed
if (subgui == gui) {
subgui = null;
}
initGui();
}
@@ -229,16 +229,37 @@ public class PlayerAbilityData implements IPlayerAbilityData {
currentTarget = null; // Players don't have auto-targets
ability.start(null);
// Spawn telegraph
spawnTelegraph(ability, player, null);
// Play wind up sound and animation
playAbilitySound(player, ability.getWindUpSound());
playAbilityAnimation(ability.getWindUpAnimation());
if (ability.getPhase() == AbilityPhase.ACTIVE) {
// Windup was 0 — skip telegraph/windup and go straight to active
executeImmediate(ability, player);
} else {
// Normal windup flow
spawnTelegraph(ability, player, null);
playAbilitySound(player, ability.getWindUpSound());
playAbilityAnimation(ability.getWindUpAnimation());
}
return true;
}
/**
* Execute an ability immediately (no windup).
* Called when windUpTicks is 0.
*/
private void executeImmediate(Ability ability, EntityPlayer player) {
// Play active sound and animation
playAbilitySound(player, ability.getActiveSound());
playAbilityAnimation(ability.getActiveAnimation());
// Call onExecute
ability.onExecute(player, currentTarget, player.worldObj);
// Check if ability completed during onExecute
if (ability.getPhase() == AbilityPhase.IDLE) {
handleAbilityCompletion(player);
}
}
// ═══════════════════════════════════════════════════════════════════
// CLIENT SYNC
// ═══════════════════════════════════════════════════════════════════
@@ -12,14 +12,12 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.EnumNpcToolMaterial;
import noppes.npcs.enchants.EnchantInterface;
import noppes.npcs.entity.EntityMagicProjectile;
import noppes.npcs.entity.EntityProjectile;
import noppes.npcs.util.IProjectileCallback;
import org.lwjgl.opengl.GL11;
@@ -108,10 +106,11 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
combat.damage = damage;
combat.explosive = true;
EnergyColorData colorData = new EnergyColorData(getOrbColor(stack, false), getOrbColor(stack, true));
EnergyDisplayData colorData = new EnergyDisplayData(getOrbColor(stack, false), getOrbColor(stack, true));
EnergyLightningData lightning = new EnergyLightningData();
EnergyLifespanData lifespan = new EnergyLifespanData(100, 72000);
EnergyHomingData homing = new EnergyHomingData();
EnergyTrajectoryData trajectory = new EnergyTrajectoryData();
homing.speed = 0.5f;
homing.homingStrength = 0.35f;
@@ -120,7 +119,7 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
EntityAbilityOrb orb = new EntityAbilityOrb(
player.worldObj, player, null,
player.posX, player.posY + player.getEyeHeight(), player.posZ,
1.0f, colorData, combat, homing, lightning, lifespan
1.0f, colorData, combat, homing, lightning, lifespan, trajectory
);
orb.setupCharging(
@@ -17,7 +17,7 @@ import java.util.List;
* Mixin to inject auction information into item tooltips when viewing auction GUIs.
*/
@Mixin(Item.class)
public class MixinItem {
public abstract class MixinItem {
@SideOnly(Side.CLIENT)
@Inject(method = "addInformation", at = @At("HEAD"))
@@ -1,20 +1,9 @@
package noppes.npcs.mixin;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.util.AttributeItemUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.player.GuiAuctionInterface;
import noppes.npcs.client.gui.player.GuiAuctionListing;
import noppes.npcs.config.ConfigMarket;
import noppes.npcs.containers.ContainerAuctionListing;
import noppes.npcs.controllers.data.AuctionListing;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -14,4 +14,5 @@ public class EntityType {
public static final int ARROW = 10;
public static final int THROWABLE = 11;
public static final int FISH_HOOK = 12;
public static final int ENERGY_PROJECTILE = 13;
}
@@ -0,0 +1,266 @@
{
"Loop": 3,
"Speed": 1.0f,
"Frames": [
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 3.0f,
"FrameParts": [
{
"Pivot2": -6.0f,
"Part": "RIGHT_ARM",
"Rotation1": -80.0f,
"Rotation0": 0.0f,
"Pivot0": 3.0f,
"Pivot1": 2.0f,
"Rotation2": -45.0f
},
{
"Pivot2": -4.0f,
"Part": "HEAD",
"Rotation1": -37.0f,
"Rotation0": 56.0f,
"Pivot0": 2.0f,
"Pivot1": 3.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 3.0f,
"Part": "LEFT_LEG",
"Rotation1": -25.0f,
"Rotation0": 25.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": -202.0f,
"Rotation0": -75.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": 37.0f
},
{
"Pivot2": -4.0f,
"Part": "BODY",
"Rotation1": -31.0f,
"Rotation0": 31.0f,
"Pivot0": 2.0f,
"Pivot1": 2.0f,
"Rotation2": 0.0f
},
{
"Pivot2": -1.0f,
"Part": "RIGHT_LEG",
"Rotation1": 0.0f,
"Rotation0": 0.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
}
],
"Smooth": 0b,
"Duration": 2
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 2.0f,
"FrameParts": [
{
"Pivot2": 4.0f,
"Part": "RIGHT_ARM",
"Rotation1": 37.0f,
"Rotation0": -18.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": 18.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 6.0f,
"Rotation0": -25.0f,
"Pivot0": 1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_LEG",
"Rotation1": -12.0f,
"Rotation0": 18.0f,
"Pivot0": 1.0f,
"Pivot1": 0.0f,
"Rotation2": -18.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": 75.0f,
"Rotation0": -120.0f,
"Pivot0": -2.0f,
"Pivot1": -1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": 18.0f,
"Rotation0": -12.0f,
"Pivot0": 1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "RIGHT_LEG",
"Rotation1": 18.0f,
"Rotation0": 6.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 12.0f
}
],
"Smooth": 0b,
"Duration": 3
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 1.0f,
"FrameParts": [
{
"Pivot2": 4.0f,
"Part": "RIGHT_ARM",
"Rotation1": 37.0f,
"Rotation0": -18.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": 18.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 6.0f,
"Rotation0": -25.0f,
"Pivot0": 1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_LEG",
"Rotation1": -12.0f,
"Rotation0": 18.0f,
"Pivot0": 1.0f,
"Pivot1": 0.0f,
"Rotation2": -18.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": 75.0f,
"Rotation0": -120.0f,
"Pivot0": -2.0f,
"Pivot1": -1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": 18.0f,
"Rotation0": -12.0f,
"Pivot0": 1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "RIGHT_LEG",
"Rotation1": 18.0f,
"Rotation0": 6.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 12.0f
}
],
"Smooth": 0b,
"Duration": 3
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 0.25f,
"FrameParts": [
{
"Pivot2": 4.0f,
"Part": "RIGHT_ARM",
"Rotation1": 37.0f,
"Rotation0": -18.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": 18.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 6.0f,
"Rotation0": -25.0f,
"Pivot0": 1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_LEG",
"Rotation1": -12.0f,
"Rotation0": 18.0f,
"Pivot0": 1.0f,
"Pivot1": 0.0f,
"Rotation2": -18.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": 75.0f,
"Rotation0": -120.0f,
"Pivot0": -2.0f,
"Pivot1": -1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": 18.0f,
"Rotation0": -12.0f,
"Pivot0": 1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "RIGHT_LEG",
"Rotation1": 18.0f,
"Rotation0": 6.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 12.0f
}
],
"Smooth": 0b,
"Duration": 3
}
],
"CurrentFrameTime": 0,
"CurrentFrame": 3,
"Smooth": 0b,
"ID": 22,
"WhileAttacking": 1b,
"WhileWalking": 1b,
"Name": "Ability_OrbDual_Active",
"WhileStanding": 1b
}
@@ -0,0 +1,327 @@
{
"Loop": -1,
"Speed": 1.0f,
"Frames": [
{
"ColorMarker": 16777215,
"Comment": "",
"FrameParts": [
{
"Pivot2": 0.0f,
"Part": "RIGHT_ARM",
"Rotation1": -12.0f,
"Rotation0": -126.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": -63.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 18.0f,
"Rotation0": -12.0f,
"Pivot0": -1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 3.0f,
"Part": "LEFT_LEG",
"Rotation1": -50.0f,
"Rotation0": 6.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 6.0f,
"Part": "LEFT_ARM",
"Rotation1": -132.0f,
"Rotation0": -25.0f,
"Pivot0": -1.0f,
"Pivot1": 1.0f,
"Rotation2": -31.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": -31.0f,
"Rotation0": -12.0f,
"Pivot0": -1.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": -2.0f,
"Part": "RIGHT_LEG",
"Rotation1": 0.0f,
"Rotation0": 6.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
}
],
"Duration": 15
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 0.5f,
"FrameParts": [
{
"Pivot2": 6.0f,
"Part": "RIGHT_ARM",
"Rotation1": 88.0f,
"Rotation0": -151.0f,
"Pivot0": 2.0f,
"Pivot1": 0.0f,
"Rotation2": -18.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 12.0f,
"Rotation0": -31.0f,
"Pivot0": 2.0f,
"Pivot1": 1.0f,
"Rotation2": 12.0f
},
{
"Pivot2": -2.0f,
"Part": "LEFT_LEG",
"Rotation1": 0.0f,
"Rotation0": 0.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": -132.0f,
"Rotation0": -25.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": -31.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": 50.0f,
"Rotation0": -18.0f,
"Pivot0": 2.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 2.0f,
"Part": "RIGHT_LEG",
"Rotation1": 56.0f,
"Rotation0": 12.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
}
],
"Smooth": 0b,
"Duration": 4
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 0.75f,
"FrameParts": [
{
"Pivot2": 6.0f,
"Part": "RIGHT_ARM",
"Rotation1": 88.0f,
"Rotation0": -151.0f,
"Pivot0": 2.0f,
"Pivot1": 0.0f,
"Rotation2": -18.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 12.0f,
"Rotation0": -31.0f,
"Pivot0": 2.0f,
"Pivot1": 1.0f,
"Rotation2": 12.0f
},
{
"Pivot2": -2.0f,
"Part": "LEFT_LEG",
"Rotation1": 0.0f,
"Rotation0": 0.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": -132.0f,
"Rotation0": -25.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": -31.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": 50.0f,
"Rotation0": -18.0f,
"Pivot0": 2.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 2.0f,
"Part": "RIGHT_LEG",
"Rotation1": 56.0f,
"Rotation0": 12.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
}
],
"Smooth": 0b,
"Duration": 4
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 1.0f,
"FrameParts": [
{
"Pivot2": 6.0f,
"Part": "RIGHT_ARM",
"Rotation1": 88.0f,
"Rotation0": -151.0f,
"Pivot0": 2.0f,
"Pivot1": 0.0f,
"Rotation2": -18.0f
},
{
"Pivot2": 3.0f,
"Part": "HEAD",
"Rotation1": 12.0f,
"Rotation0": -31.0f,
"Pivot0": 2.0f,
"Pivot1": 1.0f,
"Rotation2": 12.0f
},
{
"Pivot2": -2.0f,
"Part": "LEFT_LEG",
"Rotation1": 0.0f,
"Rotation0": 0.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": -132.0f,
"Rotation0": -25.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": -31.0f
},
{
"Pivot2": 3.0f,
"Part": "BODY",
"Rotation1": 50.0f,
"Rotation0": -18.0f,
"Pivot0": 2.0f,
"Pivot1": 1.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 2.0f,
"Part": "RIGHT_LEG",
"Rotation1": 56.0f,
"Rotation0": 12.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
}
],
"Smooth": 0b,
"Duration": 4
},
{
"ColorMarker": 16777215,
"Comment": "",
"Speed": 3.0f,
"FrameParts": [
{
"Pivot2": -6.0f,
"Part": "RIGHT_ARM",
"Rotation1": -80.0f,
"Rotation0": 0.0f,
"Pivot0": 3.0f,
"Pivot1": 2.0f,
"Rotation2": -45.0f
},
{
"Pivot2": -4.0f,
"Part": "HEAD",
"Rotation1": -37.0f,
"Rotation0": 56.0f,
"Pivot0": 2.0f,
"Pivot1": 3.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 3.0f,
"Part": "LEFT_LEG",
"Rotation1": -25.0f,
"Rotation0": 25.0f,
"Pivot0": -1.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
},
{
"Pivot2": 0.0f,
"Part": "LEFT_ARM",
"Rotation1": -202.0f,
"Rotation0": -75.0f,
"Pivot0": 1.0f,
"Pivot1": 2.0f,
"Rotation2": 37.0f
},
{
"Pivot2": -4.0f,
"Part": "BODY",
"Rotation1": -31.0f,
"Rotation0": 31.0f,
"Pivot0": 2.0f,
"Pivot1": 2.0f,
"Rotation2": 0.0f
},
{
"Pivot2": -1.0f,
"Part": "RIGHT_LEG",
"Rotation1": 0.0f,
"Rotation0": 0.0f,
"Pivot0": 0.0f,
"Pivot1": 0.0f,
"Rotation2": 0.0f
}
],
"Smooth": 0b,
"Duration": 3
}
],
"CurrentFrameTime": 0,
"CurrentFrame": 0,
"Smooth": 0b,
"ID": 21,
"WhileAttacking": 1b,
"WhileWalking": 1b,
"Name": "Ability_OrbDual_Windup",
"WhileStanding": 1b
}
@@ -1824,9 +1824,20 @@ ability.dualFireDelay=Fire Delay
ability.save.confirm=Save ability preset
ability.save.overwrite=Overwrite existing preset
ability.load.select=Select ability to load:
ability.load.mode=How should this ability be loaded?
ability.clone=Clone
ability.reference=Reference
ability.delete.confirm=Delete ability preset
gui.load=Load
# Ability Edit Mode
ability.edit.mode=How should this ability be edited?
ability.cloneModify=Clone & Edit
ability.modifyParent=Edit Parent
# Ability Type Selection
ability.selectType=Select Ability Type:
# Global Abilities Manager
ability.manager.title=Ability Manager