Create Barrier Abilities + Heavy Refactoring

This commit is contained in:
Kam committed 2026-02-17 14:32:13 -05:00
1 parent d1f2c9695c
commit c07e9e7006
53 files changed
+1890 -1460

No files matched your search

@@ -2,6 +2,15 @@ package kamkeel.npcs.controllers.data.ability;
import kamkeel.npcs.controllers.data.ability.type.*;
import kamkeel.npcs.controllers.SyncController;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityBeam;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityDisc;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityDome;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityLaserShot;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityOrb;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityShield;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilitySlicer;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilitySweeper;
import kamkeel.npcs.controllers.data.ability.type.energy.AbilityWall;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
@@ -100,10 +109,10 @@ public class AbilityController implements IAbilityHandler {
registerType("cnpc:hazard", AbilityHazard::new);
registerType("cnpc:trap", AbilityTrap::new);
registerType("cnpc:energy_dome", AbilityEnergyDome::new);
registerType("cnpc:energy_wall", AbilityEnergyWall::new);
registerType("cnpc:energy_shield", AbilityEnergyShield::new);
registerType("cnpc:energy_slicer", AbilityEnergySlicer::new);
registerType("cnpc:dome", AbilityDome::new);
registerType("cnpc:wall", AbilityWall::new);
registerType("cnpc:shield", AbilityShield::new);
registerType("cnpc:slicer", AbilitySlicer::new);
}
// ═══════════════════════════════════════════════════════════════════════════
@@ -10,12 +10,25 @@ import java.util.Map;
* Handles health/durability, duration, and per-projectile-type damage multipliers.
*/
public class EnergyBarrierData {
// Knockback target display keys
private static final String[] KNOCKBACK_TARGET_KEYS = {"gui.both", "gui.players", "gui.npcs"};
public float maxHealth = 100.0f;
public boolean useHealth = true;
public int durationTicks = 200;
public boolean useDuration = true;
public float defaultMultiplier = 1.0f;
// Knockback settings
public boolean knockbackEnabled = false;
public float knockbackStrength = 1.0f;
/** 0=Both, 1=Player only, 2=NPC only */
public int knockbackTarget = 0;
// Melee settings
public boolean meleeEnabled = false;
public float meleeDamageMultiplier = 1.0f;
/**
* Per-projectile-type damage multipliers.
* Key is the ability typeId (e.g., "ability.cnpc.orb", "ability.cnpc.beam").
@@ -72,6 +85,22 @@ public class EnergyBarrierData {
public float getDefaultMultiplier() { return defaultMultiplier; }
public void setDefaultMultiplier(float defaultMultiplier) { this.defaultMultiplier = defaultMultiplier; }
// Knockback target key helpers
public static String[] getKnockbackTargetKeys() { return KNOCKBACK_TARGET_KEYS; }
public String getKnockbackTargetKey() {
return KNOCKBACK_TARGET_KEYS[Math.max(0, Math.min(knockbackTarget, 2))];
}
public void setKnockbackTargetFromKey(String key) {
for (int i = 0; i < KNOCKBACK_TARGET_KEYS.length; i++) {
if (KNOCKBACK_TARGET_KEYS[i].equals(key)) {
knockbackTarget = i;
return;
}
}
}
// ==================== NBT ====================
public void writeNBT(NBTTagCompound nbt) {
@@ -80,6 +109,11 @@ public class EnergyBarrierData {
nbt.setInteger("barrierDuration", durationTicks);
nbt.setBoolean("barrierUseDuration", useDuration);
nbt.setFloat("barrierDefaultMult", defaultMultiplier);
nbt.setBoolean("barrierKnockback", knockbackEnabled);
nbt.setFloat("barrierKnockbackStr", knockbackStrength);
nbt.setInteger("barrierKnockbackTarget", knockbackTarget);
nbt.setBoolean("barrierMelee", meleeEnabled);
nbt.setFloat("barrierMeleeMult", meleeDamageMultiplier);
NBTTagCompound multNbt = new NBTTagCompound();
for (Map.Entry<String, Float> entry : damageMultipliers.entrySet()) {
@@ -89,11 +123,16 @@ public class EnergyBarrierData {
}
public void readNBT(NBTTagCompound nbt) {
maxHealth = nbt.getFloat("barrierMaxHealth");
useHealth = nbt.getBoolean("barrierUseHealth");
durationTicks = nbt.getInteger("barrierDuration");
useDuration = nbt.getBoolean("barrierUseDuration");
maxHealth = nbt.hasKey("barrierMaxHealth") ? nbt.getFloat("barrierMaxHealth") : 100.0f;
useHealth = !nbt.hasKey("barrierUseHealth") || nbt.getBoolean("barrierUseHealth");
durationTicks = nbt.hasKey("barrierDuration") ? nbt.getInteger("barrierDuration") : 200;
useDuration = !nbt.hasKey("barrierUseDuration") || nbt.getBoolean("barrierUseDuration");
defaultMultiplier = nbt.hasKey("barrierDefaultMult") ? nbt.getFloat("barrierDefaultMult") : 1.0f;
knockbackEnabled = nbt.hasKey("barrierKnockback") && nbt.getBoolean("barrierKnockback");
knockbackStrength = nbt.hasKey("barrierKnockbackStr") ? nbt.getFloat("barrierKnockbackStr") : 1.0f;
knockbackTarget = nbt.hasKey("barrierKnockbackTarget") ? nbt.getInteger("barrierKnockbackTarget") : 0;
meleeEnabled = nbt.hasKey("barrierMelee") && nbt.getBoolean("barrierMelee");
meleeDamageMultiplier = nbt.hasKey("barrierMeleeMult") ? nbt.getFloat("barrierMeleeMult") : 1.0f;
damageMultipliers.clear();
if (nbt.hasKey("barrierMultipliers")) {
@@ -109,6 +148,11 @@ public class EnergyBarrierData {
public EnergyBarrierData copy() {
EnergyBarrierData copy = new EnergyBarrierData(maxHealth, useHealth, durationTicks, useDuration);
copy.defaultMultiplier = defaultMultiplier;
copy.knockbackEnabled = knockbackEnabled;
copy.knockbackStrength = knockbackStrength;
copy.knockbackTarget = knockbackTarget;
copy.meleeEnabled = meleeEnabled;
copy.meleeDamageMultiplier = meleeDamageMultiplier;
copy.damageMultipliers = new HashMap<>(damageMultipliers);
return copy;
}
@@ -13,8 +13,13 @@ public class EnergyDisplayData implements IEnergyDisplayData {
public boolean outerColorEnabled = true;
public float outerColorWidth = 0.4f;
public float outerColorAlpha = 0.5f;
public float innerAlpha = 1.0f;
public float rotationSpeed = 4.0f;
// TODO: Skybox Feature
// public boolean skyboxEnabled = false;
// public String skyboxTexture = "";
public EnergyDisplayData() {}
public EnergyDisplayData(int innerColor, int outerColor) {
@@ -32,6 +37,12 @@ public class EnergyDisplayData implements IEnergyDisplayData {
this.rotationSpeed = rotationSpeed;
}
public EnergyDisplayData(int innerColor, int outerColor, boolean outerColorEnabled,
float outerColorWidth, float outerColorAlpha, float innerAlpha, float rotationSpeed) {
this(innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed);
this.innerAlpha = innerAlpha;
}
@Override
public int getInnerColor() {
return innerColor;
@@ -82,6 +93,16 @@ public class EnergyDisplayData implements IEnergyDisplayData {
this.outerColorAlpha = outerColorAlpha;
}
@Override
public float getInnerAlpha() {
return innerAlpha;
}
@Override
public void setInnerAlpha(float innerAlpha) {
this.innerAlpha = innerAlpha;
}
@Override
public float getRotationSpeed() {
return rotationSpeed;
@@ -98,7 +119,11 @@ public class EnergyDisplayData implements IEnergyDisplayData {
nbt.setBoolean("outerColorEnabled", outerColorEnabled);
nbt.setFloat("outerColorWidth", outerColorWidth);
nbt.setFloat("outerColorAlpha", outerColorAlpha);
nbt.setFloat("innerAlpha", innerAlpha);
nbt.setFloat("rotationSpeed", rotationSpeed);
// TODO: Skybox Feature
// nbt.setBoolean("skyboxEnabled", skyboxEnabled);
// nbt.setString("skyboxTexture", skyboxTexture);
}
public void readNBT(NBTTagCompound nbt) {
@@ -107,10 +132,18 @@ public class EnergyDisplayData implements IEnergyDisplayData {
outerColorEnabled = nbt.getBoolean("outerColorEnabled");
outerColorWidth = nbt.getFloat("outerColorWidth");
outerColorAlpha = nbt.getFloat("outerColorAlpha");
innerAlpha = nbt.hasKey("innerAlpha") ? nbt.getFloat("innerAlpha") : 1.0f;
rotationSpeed = nbt.getFloat("rotationSpeed");
// TODO: Skybox Feature
// skyboxEnabled = nbt.hasKey("skyboxEnabled") && nbt.getBoolean("skyboxEnabled");
// skyboxTexture = nbt.hasKey("skyboxTexture") ? nbt.getString("skyboxTexture") : "";
}
public EnergyDisplayData copy() {
return new EnergyDisplayData(innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, rotationSpeed);
EnergyDisplayData copy = new EnergyDisplayData(innerColor, outerColor, outerColorEnabled, outerColorWidth, outerColorAlpha, innerAlpha, rotationSpeed);
// TODO: Skybox Feature
// copy.skyboxEnabled = skyboxEnabled;
// copy.skyboxTexture = skyboxTexture;
return copy;
}
}
@@ -63,8 +63,8 @@ public class EnergyPanelData {
public void readNBT(NBTTagCompound nbt) {
panelWidth = nbt.hasKey("panelWidth") ? nbt.getFloat("panelWidth") : 3.0f;
panelHeight = nbt.hasKey("panelHeight") ? nbt.getFloat("panelHeight") : 3.0f;
heightOffset = nbt.getFloat("panelHeightOffset");
launching = nbt.getBoolean("panelLaunching");
heightOffset = nbt.hasKey("panelHeightOffset") ? nbt.getFloat("panelHeightOffset") : 0.0f;
launching = nbt.hasKey("panelLaunching") && nbt.getBoolean("panelLaunching");
launchSpeed = nbt.hasKey("panelLaunchSpeed") ? nbt.getFloat("panelLaunchSpeed") : 0.5f;
launchDamage = nbt.hasKey("panelLaunchDamage") ? nbt.getFloat("panelLaunchDamage") : 8.0f;
launchKnockback = nbt.hasKey("panelLaunchKnockback") ? nbt.getFloat("panelLaunchKnockback") : 2.0f;
@@ -1,9 +1,8 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.LockMovementType;
import kamkeel.npcs.controllers.data.ability.RotationMode;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
@@ -25,7 +24,7 @@ import java.util.List;
* Energy Beam ability: A homing head with a trailing path.
* Supports 1-8 projectiles with shared visuals and per-projectile anchor points.
*/
public class AbilityBeam extends AbstractEnergyProjectileAbility<EntityAbilityBeam> implements IAbilityEnergyBeam {
public class AbilityBeam extends AbilityEnergyProjectile<EntityAbilityBeam> implements IAbilityEnergyBeam {
private float beamWidth = 0.4f;
private float headSize = 0.6f;
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -23,7 +23,7 @@ import java.util.List;
* Supports 1-8 projectiles with shared visuals and per-projectile anchor points.
* Has optional boomerang behavior to return to owner.
*/
public class AbilityDisc extends AbstractEnergyProjectileAbility<EntityAbilityDisc> implements IAbilityDisc {
public class AbilityDisc extends AbilityEnergyProjectile<EntityAbilityDisc> implements IAbilityDisc {
private float discRadius = 1.0f;
private float discThickness = 0.2f;
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -8,6 +8,7 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.data.EnergyBarrierData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityEnergyBarrier;
import kamkeel.npcs.entity.EntityEnergyDome;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -22,38 +23,38 @@ import java.util.List;
* Blocks incoming energy projectiles with configurable damage multipliers.
* Duration and/or HP based.
*/
public class AbilityEnergyDome extends AbstractEnergyBarrierAbility {
public class AbilityDome extends AbilityEnergyBarrier {
private float domeRadius = 5.0f;
private boolean followCaster = false;
public AbilityEnergyDome() {
public AbilityDome() {
super(
new EnergyDisplayData(0x44CCFF, 0x2288FF, true, 0.3f, 0.35f, 0.0f),
new EnergyDisplayData(0x44CCFF, 0x2288FF, true, 0.3f, 0.35f, 0.5f, 0.0f),
new EnergyBarrierData(100.0f, true, 200, true)
);
this.typeId = "ability.cnpc.energy_dome";
this.name = "Energy Dome";
this.typeId = "ability.cnpc.dome";
this.name = "Dome";
this.targetingMode = TargetingMode.SELF;
this.maxRange = 0;
this.minRange = 0;
this.cooldownTicks = 100;
this.windUpTicks = 30;
this.lockMovement = LockMovementType.WINDUP;
this.telegraphType = TelegraphType.RING;
this.showTelegraph = true;
this.windUpAnimationName = "Ability_EnergyDome_Windup";
this.activeAnimationName = "Ability_EnergyDome_Active";
this.windUpAnimationName = "";
this.activeAnimationName = "";
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@Override
protected Entity createBarrierEntity(EntityLivingBase caster, EntityLivingBase target) {
protected EntityEnergyBarrier createBarrierEntity(EntityLivingBase caster, EntityLivingBase target) {
EntityEnergyDome dome = new EntityEnergyDome(
caster.worldObj, caster,
caster.posX, caster.posY, caster.posZ,
domeRadius, displayData.copy(), lightningData.copy(), barrierData.copy()
);
dome.setFollowCaster(followCaster);
dome.setSourceAbility(this);
return dome;
}
@@ -79,14 +80,14 @@ public class AbilityEnergyDome extends AbstractEnergyBarrierAbility {
public List<AbilityVariant> getVariants() {
return Arrays.asList(
new AbilityVariant("ability.variant.small", a -> {
AbilityEnergyDome dome = (AbilityEnergyDome) a;
a.setName("Small Energy Dome");
AbilityDome dome = (AbilityDome) a;
a.setName("Small Dome");
dome.setDomeRadius(3.0f);
dome.setBarrierMaxHealth(60.0f);
}),
new AbilityVariant("ability.variant.large", a -> {
AbilityEnergyDome dome = (AbilityEnergyDome) a;
a.setName("Large Energy Dome");
AbilityDome dome = (AbilityDome) a;
a.setName("Large Dome");
dome.setDomeRadius(8.0f);
dome.setBarrierMaxHealth(200.0f);
dome.setBarrierDuration(300);
@@ -99,11 +100,13 @@ public class AbilityEnergyDome extends AbstractEnergyBarrierAbility {
@Override
protected void writeBarrierTypeNBT(NBTTagCompound nbt) {
nbt.setFloat("domeRadius", domeRadius);
nbt.setBoolean("followCaster", followCaster);
}
@Override
protected void readBarrierTypeNBT(NBTTagCompound nbt) {
this.domeRadius = nbt.hasKey("domeRadius") ? nbt.getFloat("domeRadius") : 5.0f;
this.followCaster = nbt.hasKey("followCaster") && nbt.getBoolean("followCaster");
}
// ==================== GETTERS & SETTERS ====================
@@ -111,6 +114,9 @@ public class AbilityEnergyDome extends AbstractEnergyBarrierAbility {
public float getDomeRadius() { return domeRadius; }
public void setDomeRadius(float radius) { this.domeRadius = Math.max(1.0f, radius); }
public boolean isFollowCaster() { return followCaster; }
public void setFollowCaster(boolean follow) { this.followCaster = follow; }
// ==================== TYPE-SPECIFIC GUI ====================
@SideOnly(Side.CLIENT)
@@ -118,5 +124,7 @@ public class AbilityEnergyDome extends AbstractEnergyBarrierAbility {
protected void addBarrierTypeDefinitions(List<FieldDef> defs) {
defs.add(FieldDef.floatField("ability.domeRadius", this::getDomeRadius, this::setDomeRadius)
.range(1.0f, 30.0f));
defs.add(FieldDef.boolField("ability.followCaster", this::isFollowCaster, this::setFollowCaster)
.hover("ability.hover.followCaster"));
}
}
@@ -0,0 +1,134 @@
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.EnergyLightningData;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.gui.builder.FieldDef;
import java.util.List;
/**
* Abstract base for all energy-based abilities (Projectile, Barrier, Sweeper, etc.).
* Provides shared visual data (colors, lightning) and corresponding API/GUI/NBT.
*/
public abstract class AbilityEnergy extends Ability {
protected EnergyDisplayData displayData;
protected EnergyLightningData lightningData;
protected AbilityEnergy(EnergyDisplayData displayData) {
this.displayData = displayData;
this.lightningData = new EnergyLightningData();
}
// ==================== DISPLAY DATA ====================
public int getInnerColor() { return displayData.innerColor; }
public void setInnerColor(int color) { displayData.innerColor = color; }
public float getInnerAlpha() { return displayData.innerAlpha; }
public void setInnerAlpha(float alpha) { displayData.innerAlpha = alpha; }
public int getOuterColor() { return displayData.outerColor; }
public void setOuterColor(int color) { displayData.outerColor = color; }
public boolean isOuterColorEnabled() { return displayData.outerColorEnabled; }
public void setOuterColorEnabled(boolean enabled) { displayData.outerColorEnabled = enabled; }
public float getOuterColorWidth() { return displayData.outerColorWidth; }
public void setOuterColorWidth(float width) { displayData.outerColorWidth = width; }
public float getOuterColorAlpha() { return displayData.outerColorAlpha; }
public void setOuterColorAlpha(float alpha) { displayData.outerColorAlpha = alpha; }
public float getRotationSpeed() { return displayData.rotationSpeed; }
public void setRotationSpeed(float speed) { displayData.rotationSpeed = speed; }
// ==================== LIGHTNING DATA ====================
public boolean hasLightningEffect() { return lightningData.lightningEffect; }
public void setLightningEffect(boolean enabled) { lightningData.lightningEffect = enabled; }
public float getLightningDensity() { return lightningData.lightningDensity; }
public void setLightningDensity(float density) { lightningData.lightningDensity = density; }
public float getLightningRadius() { return lightningData.lightningRadius; }
public void setLightningRadius(float radius) { lightningData.lightningRadius = radius; }
public int getLightningFadeTime() { return lightningData.lightningFadeTime; }
public void setLightningFadeTime(int fadeTime) { lightningData.lightningFadeTime = fadeTime; }
// ==================== NBT HELPERS ====================
protected void writeEnergyNBT(NBTTagCompound nbt) {
displayData.writeNBT(nbt);
lightningData.writeNBT(nbt);
}
protected void readEnergyNBT(NBTTagCompound nbt) {
displayData.readNBT(nbt);
lightningData.readNBT(nbt);
}
// ==================== GUI HELPERS ====================
/**
* Add complete visual tab definitions (colors section + effects/lightning section).
* Subclasses can call this directly or use the individual methods for more control.
*/
@SideOnly(Side.CLIENT)
protected void addEnergyVisualDefinitions(List<FieldDef> defs) {
addEnergyColorDefinitions(defs);
addEnergyEffectDefinitions(defs);
}
/**
* Add the colors section to the visual tab.
*/
@SideOnly(Side.CLIENT)
protected void addEnergyColorDefinitions(List<FieldDef> defs) {
defs.add(FieldDef.section("ability.section.colors").tab("ability.tab.visual"));
defs.add(FieldDef.row(
FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor),
FieldDef.floatField("ability.innerAlpha", this::getInnerAlpha, this::setInnerAlpha).range(0, 1)
).tab("ability.tab.visual"));
defs.add(FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled)
.tab("ability.tab.visual"));
defs.add(FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled));
defs.add(FieldDef.row(
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
.visibleWhen(this::isOuterColorEnabled),
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
).tab("ability.tab.visual"));
}
/**
* Add the effects section (lightning) to the visual tab.
* Override to insert additional fields before lightning (e.g., rotationSpeed).
*/
@SideOnly(Side.CLIENT)
protected void addEnergyEffectDefinitions(List<FieldDef> defs) {
defs.add(FieldDef.section("ability.section.effects").tab("ability.tab.visual"));
addEnergyLightningDefinitions(defs);
}
/**
* Add just the lightning fields (no section header) to the visual tab.
*/
@SideOnly(Side.CLIENT)
protected void addEnergyLightningDefinitions(List<FieldDef> defs) {
defs.add(FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect)
.tab("ability.tab.visual"));
defs.add(FieldDef.row(
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
.visibleWhen(this::hasLightningEffect).range(0.01f, 100f),
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
.range(0.1f, 100f).visibleWhen(this::hasLightningEffect)
).tab("ability.tab.visual"));
}
}
@@ -1,39 +1,31 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.data.EnergyBarrierData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.EnergyLightningData;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import net.minecraft.entity.Entity;
import kamkeel.npcs.entity.EntityEnergyBarrier;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import noppes.npcs.client.gui.builder.FieldDef;
import java.util.List;
import java.util.Map;
/**
* Abstract base for energy barrier abilities (Dome, Wall, Shield).
* Handles shared visual data, barrier configuration, and lifecycle management.
*/
public abstract class AbstractEnergyBarrierAbility extends Ability {
public abstract class AbilityEnergyBarrier extends AbilityEnergy {
protected EnergyDisplayData displayData;
protected EnergyLightningData lightningData;
protected final EnergyBarrierData barrierData;
// Runtime entity tracking
protected transient Entity barrierEntity;
protected transient EntityEnergyBarrier barrierEntity;
protected AbstractEnergyBarrierAbility(EnergyDisplayData displayData, EnergyBarrierData barrierData) {
this.displayData = displayData;
protected AbilityEnergyBarrier(EnergyDisplayData displayData, EnergyBarrierData barrierData) {
super(displayData);
this.barrierData = barrierData;
this.lightningData = new EnergyLightningData();
}
// ==================== ABSTRACT METHODS ====================
@@ -41,7 +33,7 @@ public abstract class AbstractEnergyBarrierAbility extends Ability {
/**
* Create and spawn the barrier entity during execution.
*/
protected abstract Entity createBarrierEntity(EntityLivingBase caster, EntityLivingBase target);
protected abstract EntityEnergyBarrier createBarrierEntity(EntityLivingBase caster, EntityLivingBase target);
/**
* Add type-specific GUI field definitions.
@@ -71,11 +63,30 @@ public abstract class AbstractEnergyBarrierAbility extends Ability {
return false; // Barriers are defensive
}
@Override
public void onWindUpTick(EntityLivingBase caster, EntityLivingBase target, int tick) {
if (caster.worldObj.isRemote) return;
if (tick == 1) {
barrierEntity = createBarrierEntity(caster, target);
if (barrierEntity != null) {
barrierEntity.setupCharging(getWindUpTicks());
spawnAbilityEntity(barrierEntity);
}
}
}
@Override
public void onExecute(EntityLivingBase caster, EntityLivingBase target) {
barrierEntity = createBarrierEntity(caster, target);
if (barrierEntity != null) {
spawnAbilityEntity(barrierEntity);
if (barrierEntity != null && !barrierEntity.isDead) {
// Barrier was spawned during windup — transition to active
barrierEntity.finishCharging();
} else {
// No windup or entity died — create fresh
barrierEntity = createBarrierEntity(caster, target);
if (barrierEntity != null) {
spawnAbilityEntity(barrierEntity);
}
}
}
@@ -115,49 +126,20 @@ public abstract class AbstractEnergyBarrierAbility extends Ability {
@Override
public final void writeTypeNBT(NBTTagCompound nbt) {
writeBarrierTypeNBT(nbt);
displayData.writeNBT(nbt);
lightningData.writeNBT(nbt);
writeEnergyNBT(nbt);
barrierData.writeNBT(nbt);
}
@Override
public final void readTypeNBT(NBTTagCompound nbt) {
readBarrierTypeNBT(nbt);
displayData.readNBT(nbt);
lightningData.readNBT(nbt);
readEnergyNBT(nbt);
barrierData.readNBT(nbt);
}
// ==================== API GETTERS & SETTERS ====================
// Display data
public int getInnerColor() { return displayData.innerColor; }
public void setInnerColor(int color) { displayData.innerColor = color; }
public int getOuterColor() { return displayData.outerColor; }
public void setOuterColor(int color) { displayData.outerColor = color; }
public boolean isOuterColorEnabled() { return displayData.outerColorEnabled; }
public void setOuterColorEnabled(boolean enabled) { displayData.outerColorEnabled = enabled; }
public float getOuterColorWidth() { return displayData.outerColorWidth; }
public void setOuterColorWidth(float width) { displayData.outerColorWidth = width; }
public float getOuterColorAlpha() { return displayData.outerColorAlpha; }
public void setOuterColorAlpha(float alpha) { displayData.outerColorAlpha = alpha; }
// Lightning data
public boolean hasLightningEffect() { return lightningData.lightningEffect; }
public void setLightningEffect(boolean enabled) { lightningData.lightningEffect = enabled; }
public float getLightningDensity() { return lightningData.lightningDensity; }
public void setLightningDensity(float density) { lightningData.lightningDensity = density; }
public float getLightningRadius() { return lightningData.lightningRadius; }
public void setLightningRadius(float radius) { lightningData.lightningRadius = radius; }
public int getLightningFadeTime() { return lightningData.lightningFadeTime; }
public void setLightningFadeTime(int fadeTime) { lightningData.lightningFadeTime = fadeTime; }
// Display and lightning data inherited from AbilityEnergy
// Barrier data
public float getBarrierMaxHealth() { return barrierData.maxHealth; }
@@ -178,6 +160,20 @@ public abstract class AbstractEnergyBarrierAbility extends Ability {
public void setDamageMultiplier(String typeId, float mult) { barrierData.setMultiplier(typeId, mult); }
public float getDamageMultiplier(String typeId) { return barrierData.getMultiplier(typeId); }
// Knockback data
public boolean isKnockbackEnabled() { return barrierData.knockbackEnabled; }
public void setKnockbackEnabled(boolean enabled) { barrierData.knockbackEnabled = enabled; }
public float getKnockbackStrength() { return barrierData.knockbackStrength; }
public void setKnockbackStrength(float strength) { barrierData.knockbackStrength = strength; }
public String getKnockbackTargetKey() { return barrierData.getKnockbackTargetKey(); }
public void setKnockbackTargetKey(String key) { barrierData.setKnockbackTargetFromKey(key); }
// Melee data
public boolean isMeleeEnabled() { return barrierData.meleeEnabled; }
public void setMeleeEnabled(boolean enabled) { barrierData.meleeEnabled = enabled; }
public float getMeleeDamageMultiplier() { return barrierData.meleeDamageMultiplier; }
public void setMeleeDamageMultiplier(float mult) { barrierData.meleeDamageMultiplier = mult; }
// ==================== GUI ====================
@SideOnly(Side.CLIENT)
@@ -196,29 +192,24 @@ public abstract class AbstractEnergyBarrierAbility extends Ability {
.range(1, 6000).visibleWhen(this::isUseDuration));
defs.add(FieldDef.floatField("ability.defaultMultiplier", this::getDefaultMultiplier, this::setDefaultMultiplier));
// Visual tab
defs.add(FieldDef.section("ability.section.colors").tab("ability.tab.visual"));
defs.add(FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor)
.tab("ability.tab.visual"));
defs.add(FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled)
.tab("ability.tab.visual"));
defs.add(FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled));
// Knockback section
defs.add(FieldDef.section("ability.section.knockback"));
defs.add(FieldDef.boolField("ability.knockbackEnabled", this::isKnockbackEnabled, this::setKnockbackEnabled));
defs.add(FieldDef.row(
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
.visibleWhen(this::isOuterColorEnabled),
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
).tab("ability.tab.visual"));
FieldDef.floatField("ability.knockbackStrength", this::getKnockbackStrength, this::setKnockbackStrength)
.range(0, 10).visibleWhen(this::isKnockbackEnabled),
FieldDef.stringEnumField("ability.knockbackTarget", EnergyBarrierData.getKnockbackTargetKeys(),
this::getKnockbackTargetKey, this::setKnockbackTargetKey)
.visibleWhen(this::isKnockbackEnabled)
));
defs.add(FieldDef.section("ability.section.effects").tab("ability.tab.visual"));
defs.add(FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect)
.tab("ability.tab.visual"));
defs.add(FieldDef.row(
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
.visibleWhen(this::hasLightningEffect).range(0.01f, 100f),
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
.range(0.1f, 100f).visibleWhen(this::hasLightningEffect)
).tab("ability.tab.visual"));
// Melee section
defs.add(FieldDef.section("ability.section.melee"));
defs.add(FieldDef.boolField("ability.meleeEnabled", this::isMeleeEnabled, this::setMeleeEnabled));
defs.add(FieldDef.floatField("ability.meleeDamageMultiplier", this::getMeleeDamageMultiplier, this::setMeleeDamageMultiplier)
.range(0, 10).visibleWhen(this::isMeleeEnabled));
// Visual tab - colors + effects (from AbilityEnergy)
addEnergyVisualDefinitions(defs);
}
}
@@ -1,16 +1,14 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.data.*;
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityAbilityProjectile;
import kamkeel.npcs.entity.EntityEnergyProjectile;
import kamkeel.npcs.util.AnchorPointHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
@@ -30,8 +28,8 @@ import java.util.List;
*
* @param <E> The entity type this ability spawns
*/
public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityProjectile>
extends Ability implements IAbilityEnergyProjectile {
public abstract class AbilityEnergyProjectile<E extends EntityEnergyProjectile>
extends AbilityEnergy implements IAbilityEnergyProjectile {
protected static final int MAX_PROJECTILES = 8;
@@ -39,9 +37,7 @@ public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityPro
protected int projectileCount = 1;
protected int fireDelay = 0;
// Shared visual data
protected EnergyDisplayData displayData;
protected EnergyLightningData lightningData;
// Trajectory data
protected EnergyTrajectoryData trajectoryData;
// Shared combat/movement data
@@ -57,17 +53,16 @@ public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityPro
// ==================== CONSTRUCTOR ====================
protected AbstractEnergyProjectileAbility(
protected AbilityEnergyProjectile(
EnergyDisplayData displayData,
EnergyCombatData combatData,
EnergyHomingData homingData,
EnergyLifespanData lifespanData
) {
this.displayData = displayData;
super(displayData);
this.combatData = combatData;
this.homingData = homingData;
this.lifespanData = lifespanData;
this.lightningData = new EnergyLightningData();
this.trajectoryData = new EnergyTrajectoryData();
initProjectiles(1);
}
@@ -390,8 +385,7 @@ public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityPro
nbt.setInteger("fireDelay", fireDelay);
// Shared data classes
displayData.writeNBT(nbt);
lightningData.writeNBT(nbt);
writeEnergyNBT(nbt);
combatData.writeNBT(nbt);
homingData.writeNBT(nbt);
lifespanData.writeNBT(nbt);
@@ -415,8 +409,7 @@ public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityPro
this.fireDelay = nbt.getInteger("fireDelay");
// Shared data classes
displayData.readNBT(nbt);
lightningData.readNBT(nbt);
readEnergyNBT(nbt);
combatData.readNBT(nbt);
homingData.readNBT(nbt);
lifespanData.readNBT(nbt);
@@ -474,37 +467,7 @@ public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityPro
public float getHomingRange() { return homingData.homingRange; }
public void setHomingRange(float range) { homingData.homingRange = range; }
// Display data - primary colors
@Override public int getInnerColor() { return displayData.innerColor; }
@Override public void setInnerColor(int color) { displayData.innerColor = color; }
@Override public int getOuterColor() { return displayData.outerColor; }
@Override public void setOuterColor(int color) { displayData.outerColor = color; }
@Override public boolean isOuterColorEnabled() { return displayData.outerColorEnabled; }
@Override public void setOuterColorEnabled(boolean enabled) { displayData.outerColorEnabled = enabled; }
@Override public float getOuterColorWidth() { return displayData.outerColorWidth; }
@Override public void setOuterColorWidth(float width) { displayData.outerColorWidth = width; }
@Override public float getOuterColorAlpha() { return displayData.outerColorAlpha; }
@Override public void setOuterColorAlpha(float alpha) { displayData.outerColorAlpha = alpha; }
public float getRotationSpeed() { return displayData.rotationSpeed; }
public void setRotationSpeed(float speed) { displayData.rotationSpeed = speed; }
// Lightning data
@Override public boolean hasLightningEffect() { return lightningData.lightningEffect; }
@Override public void setLightningEffect(boolean enabled) { lightningData.lightningEffect = enabled; }
@Override public float getLightningDensity() { return lightningData.lightningDensity; }
@Override public void setLightningDensity(float density) { lightningData.lightningDensity = density; }
@Override public float getLightningRadius() { return lightningData.lightningRadius; }
@Override public void setLightningRadius(float radius) { lightningData.lightningRadius = radius; }
public int getLightningFadeTime() { return lightningData.lightningFadeTime; }
public void setLightningFadeTime(int fadeTime) { lightningData.lightningFadeTime = fadeTime; }
// Display and lightning data inherited from AbilityEnergy
// Anchor - default to projectile 0
public AnchorPoint getAnchorPointEnum() { return projectiles[0].anchor.anchorPoint; }
@@ -557,33 +520,14 @@ public abstract class AbstractEnergyProjectileAbility<E extends EntityAbilityPro
// Type-specific fields first
addTypeDefinitions(defs);
// Shared visual tab - primary colors
defs.add(FieldDef.section("ability.section.colors").tab("ability.tab.visual"));
defs.add(FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor)
.tab("ability.tab.visual"));
defs.add(FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled)
.tab("ability.tab.visual"));
defs.add(FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled));
defs.add(FieldDef.row(
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
.visibleWhen(this::isOuterColorEnabled),
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
).tab("ability.tab.visual"));
// Shared visual tab - colors + effects (from AbilityEnergy)
addEnergyColorDefinitions(defs);
// Shared visual tab - effects
// Effects section with projectile-specific rotationSpeed before lightning
defs.add(FieldDef.section("ability.section.effects").tab("ability.tab.visual"));
defs.add(FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed)
.tab("ability.tab.visual"));
defs.add(FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect)
.tab("ability.tab.visual"));
defs.add(FieldDef.row(
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
.visibleWhen(this::hasLightningEffect).range(0.01f, 100f),
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
.range(0.1f, 100f).visibleWhen(this::hasLightningEffect)
).tab("ability.tab.visual"));
addEnergyLightningDefinitions(defs);
// Shared visual tab - per-projectile sections
for (int i = 0; i < MAX_PROJECTILES; i++) {
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -25,7 +25,7 @@ import java.util.List;
* Travels in a straight line from origin, damaging all entities it passes through.
* Single-projectile only (always projectileCount=1).
*/
public class AbilityLaserShot extends AbstractEnergyProjectileAbility<EntityAbilityLaser> implements IAbilityLaserShot {
public class AbilityLaserShot extends AbilityEnergyProjectile<EntityAbilityLaser> implements IAbilityLaserShot {
private float laserWidth = 0.3f;
private float expansionSpeed = 3.0f;
@@ -73,7 +73,7 @@ public class AbilityLaserShot extends AbstractEnergyProjectileAbility<EntityAbil
/**
* LINE telegraph: positioned at caster, aimed toward target.
* Overrides the circle telegraph from AbstractEnergyProjectileAbility.
* Overrides the circle telegraph from AbilityEnergyProjectile.
*/
@Override
public TelegraphInstance createTelegraph(EntityLivingBase caster, EntityLivingBase target) {
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -22,7 +22,7 @@ import java.util.List;
* Orb ability: Spawns homing projectile sphere(s) that track target.
* Supports 1-8 projectiles with shared visuals and per-projectile anchor points.
*/
public class AbilityOrb extends AbstractEnergyProjectileAbility<EntityAbilityOrb> implements IAbilityOrb {
public class AbilityOrb extends AbilityEnergyProjectile<EntityAbilityOrb> implements IAbilityOrb {
private float orbSize = 1.0f;
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -10,6 +10,7 @@ import kamkeel.npcs.controllers.data.ability.data.EnergyBarrierData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.EnergyPanelData;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityEnergyBarrier;
import kamkeel.npcs.entity.EntityEnergyPanel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -24,35 +25,33 @@ import java.util.List;
* The shield follows the caster's position and rotates with their look direction.
* Cannot be placed — it's always held.
*/
public class AbilityEnergyShield extends AbstractEnergyBarrierAbility {
public class AbilityShield extends AbilityEnergyBarrier {
private float shieldWidth = 2.5f;
private float shieldHeight = 2.5f;
public AbilityEnergyShield() {
public AbilityShield() {
super(
new EnergyDisplayData(0xFFDD44, 0xFFAA00, true, 0.3f, 0.4f, 0.0f),
new EnergyDisplayData(0xFFDD44, 0xFFAA00, true, 0.3f, 0.4f, 0.5f, 0.0f),
new EnergyBarrierData(60.0f, true, 120, true)
);
this.typeId = "ability.cnpc.energy_shield";
this.name = "Energy Shield";
this.typeId = "ability.cnpc.shield";
this.name = "Shield";
this.targetingMode = TargetingMode.SELF;
this.maxRange = 0;
this.minRange = 0;
this.cooldownTicks = 60;
this.windUpTicks = 10;
this.lockMovement = LockMovementType.NO;
this.lockMovement = LockMovementType.WINDUP_AND_ACTIVE;
this.telegraphType = TelegraphType.NONE;
this.showTelegraph = false;
this.windUpAnimationName = "Ability_EnergyShield_Windup";
this.activeAnimationName = "Ability_EnergyShield_Active";
this.windUpAnimationName = "";
this.activeAnimationName = "";
this.allowedBy = UserType.BOTH;
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@Override
protected Entity createBarrierEntity(EntityLivingBase caster, EntityLivingBase target) {
protected EntityEnergyBarrier createBarrierEntity(EntityLivingBase caster, EntityLivingBase target) {
EnergyPanelData panelData = new EnergyPanelData(shieldWidth, shieldHeight, 0.0f);
float frontDist = 1.5f;
@@ -92,15 +91,15 @@ public class AbilityEnergyShield extends AbstractEnergyBarrierAbility {
public List<AbilityVariant> getVariants() {
return Arrays.asList(
new AbilityVariant("ability.variant.small", a -> {
AbilityEnergyShield shield = (AbilityEnergyShield) a;
a.setName("Small Energy Shield");
AbilityShield shield = (AbilityShield) a;
a.setName("Small Shield");
shield.setShieldWidth(1.5f);
shield.setShieldHeight(1.5f);
shield.setBarrierMaxHealth(40.0f);
}),
new AbilityVariant("ability.variant.large", a -> {
AbilityEnergyShield shield = (AbilityEnergyShield) a;
a.setName("Large Energy Shield");
AbilityShield shield = (AbilityShield) a;
a.setName("Large Shield");
shield.setShieldWidth(4.0f);
shield.setShieldHeight(4.0f);
shield.setBarrierMaxHealth(120.0f);
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -20,23 +20,23 @@ import java.util.List;
/**
* Energy Slicer ability: Fires a thin, wide blade projectile in a straight line.
* JJK Cleave/Dismantle inspired. Piercing by default.
* Extends AbstractEnergyProjectileAbility to leverage the existing projectile infrastructure.
* Extends AbilityEnergyProjectile to leverage the existing projectile infrastructure.
*/
public class AbilityEnergySlicer extends AbstractEnergyProjectileAbility<EntityEnergySlicer> {
public class AbilitySlicer extends AbilityEnergyProjectile<EntityEnergySlicer> {
private float sliceWidth = 3.0f;
private float sliceThickness = 0.15f;
private boolean piercing = true;
public AbilityEnergySlicer() {
public AbilitySlicer() {
super(
new EnergyDisplayData(0xFF4444, 0xFF0000, true, 0.2f, 0.6f, 0.0f),
new EnergyCombatData(12.0f, 0.5f, 0.0f, false, 3.0f, 0.5f),
new EnergyHomingData(0.8f, false, 0.0f, 0.0f),
new EnergyLifespanData(40.0f, 100)
);
this.typeId = "ability.cnpc.energy_slicer";
this.name = "Energy Slicer";
this.typeId = "ability.cnpc.slicer";
this.name = "Slicer";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 30.0f;
this.minRange = 3.0f;
@@ -45,8 +45,8 @@ public class AbilityEnergySlicer extends AbstractEnergyProjectileAbility<EntityE
this.lockMovement = LockMovementType.WINDUP;
this.telegraphType = TelegraphType.LINE;
this.showTelegraph = true;
this.windUpAnimationName = "Ability_EnergySlicer_Windup";
this.activeAnimationName = "Ability_EnergySlicer_Active";
this.windUpAnimationName = "";
this.activeAnimationName = "";
}
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@@ -99,15 +99,15 @@ public class AbilityEnergySlicer extends AbstractEnergyProjectileAbility<EntityE
public List<AbilityVariant> getVariants() {
return Arrays.asList(
new AbilityVariant("ability.variant.single", a -> {
a.setName("Energy Slicer");
a.setName("Slicer");
}),
new AbilityVariant("ability.variant.dual", a -> {
AbilityEnergySlicer slicer = (AbilityEnergySlicer) a;
AbilitySlicer slicer = (AbilitySlicer) a;
a.setName("Double Slicer");
slicer.setProjectileCount(2);
slicer.setFireDelay(5);
a.setWindUpAnimationName("Ability_EnergySlicerDual_Windup");
a.setActiveAnimationName("Ability_EnergySlicerDual_Active");
a.setWindUpAnimationName("");
a.setActiveAnimationName("");
})
);
}
@@ -1,12 +1,10 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.LockMovementType;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.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;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
@@ -14,8 +12,8 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityAbilitySweeper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.ability.type.IAbilitySweeper;
import noppes.npcs.client.gui.builder.FieldDef;
import java.util.Arrays;
import java.util.List;
@@ -28,7 +26,7 @@ import java.util.List;
* All damage logic is handled by the EntityAbilitySweeper entity to ensure
* visual and damage hitbox alignment.
*/
public class AbilitySweeper extends Ability implements IAbilitySweeper {
public class AbilitySweeper extends AbilityEnergy implements IAbilitySweeper {
// Type-specific parameters
private float beamLength = 10.0f;
@@ -41,13 +39,11 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
private int numberOfRotations = 2; // How many full rotations before ability ends
private boolean lockOnTarget = false;
// Visual properties
private EnergyDisplayData colorData = new EnergyDisplayData(0xFF6600, 0xFF0000, true, 1.8f, 0.5f, 0.0f);
// Runtime state (transient)
private transient EntityAbilitySweeper activeEntity = null;
public AbilitySweeper() {
super(new EnergyDisplayData(0xFF6600, 0xFF0000, true, 1.8f, 0.5f, 0.0f));
this.typeId = "ability.cnpc.sweeper";
this.name = "Sweeper";
this.targetingMode = TargetingMode.AGGRO_TARGET;
@@ -83,7 +79,7 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
// Player: target is null — sweep rotates around caster's facing direction, lockOnTarget has no effect.
activeEntity = new EntityAbilitySweeper(caster.worldObj, caster, target,
beamLength, beamWidth, beamHeight,
colorData,
displayData,
sweepSpeed, numberOfRotations,
damage, damageInterval, piercing,
lockOnTarget);
@@ -93,9 +89,6 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
}
spawnAbilityEntity(activeEntity);
// Ability stays active until entity dies (prevents firing another while projectile is alive)
// Movement locking is handled separately by the base class
}
@Override
@@ -162,7 +155,7 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
nbt.setFloat("sweepSpeed", sweepSpeed);
nbt.setInteger("numberOfRotations", numberOfRotations);
nbt.setBoolean("lockOnTarget", lockOnTarget);
colorData.writeNBT(nbt);
writeEnergyNBT(nbt);
}
@Override
@@ -176,10 +169,10 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
this.sweepSpeed = nbt.getFloat("sweepSpeed");
this.numberOfRotations = nbt.getInteger("numberOfRotations");
this.lockOnTarget = nbt.getBoolean("lockOnTarget");
colorData.readNBT(nbt);
readEnergyNBT(nbt);
}
// Getters & Setters
// Getters & Setters (type-specific only; color/lightning inherited from AbilityEnergy)
public float getBeamLength() { return beamLength; }
public void setBeamLength(float beamLength) { this.beamLength = beamLength; }
public float getBeamWidth() { return beamWidth; }
@@ -198,14 +191,6 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
public void setNumberOfRotations(int numberOfRotations) { this.numberOfRotations = numberOfRotations; }
public boolean isLockOnTarget() { return lockOnTarget; }
public void setLockOnTarget(boolean lockOnTarget) { this.lockOnTarget = lockOnTarget; }
public int getInnerColor() { return colorData.innerColor; }
public void setInnerColor(int innerColor) { colorData.innerColor = innerColor; }
public int getOuterColor() { return colorData.outerColor; }
public void setOuterColor(int outerColor) { colorData.outerColor = outerColor; }
public float getOuterColorWidth() { return colorData.outerColorWidth; }
public void setOuterColorWidth(float outerColorWidth) { colorData.outerColorWidth = outerColorWidth; }
public boolean isOuterColorEnabled() { return colorData.outerColorEnabled; }
public void setOuterColorEnabled(boolean outerColorEnabled) { colorData.outerColorEnabled = outerColorEnabled; }
@Override
public int getMaxPreviewDuration() {
@@ -216,7 +201,6 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
@Override
public void getAbilityDefinitions(List<FieldDef> defs) {
defs.addAll(Arrays.asList(
FieldDef.row(
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval)
@@ -237,18 +221,10 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
FieldDef.boolField("ability.lockTarget", this::isLockOnTarget, this::setLockOnTarget)
.hover("ability.hover.lockTarget")
),
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
// Visual tab
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"),
FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled),
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled)
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
));
// Visual tab - colors + effects (from AbilityEnergy)
addEnergyVisualDefinitions(defs);
}
}
@@ -1,4 +1,4 @@
package kamkeel.npcs.controllers.data.ability.type;
package kamkeel.npcs.controllers.data.ability.type.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -9,6 +9,7 @@ import kamkeel.npcs.controllers.data.ability.data.EnergyBarrierData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.EnergyPanelData;
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
import kamkeel.npcs.entity.EntityEnergyBarrier;
import kamkeel.npcs.entity.EntityEnergyPanel;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -23,18 +24,18 @@ import java.util.List;
* Can float above ground (configurable height offset).
* Optional launching mode fires the wall forward with damage/knockback.
*/
public class AbilityEnergyWall extends AbstractEnergyBarrierAbility {
public class AbilityWall extends AbilityEnergyBarrier {
private final EnergyPanelData panelData;
public AbilityEnergyWall() {
public AbilityWall() {
super(
new EnergyDisplayData(0x44FFCC, 0x22CCAA, true, 0.3f, 0.4f, 0.0f),
new EnergyDisplayData(0x44FFCC, 0x22CCAA, true, 0.3f, 0.4f, 0.5f, 0.0f),
new EnergyBarrierData(80.0f, true, 160, true)
);
this.panelData = new EnergyPanelData(4.0f, 3.0f, 0.0f);
this.typeId = "ability.cnpc.energy_wall";
this.name = "Energy Wall";
this.typeId = "ability.cnpc.wall";
this.name = "Wall";
this.targetingMode = TargetingMode.AGGRO_TARGET;
this.maxRange = 15.0f;
this.minRange = 2.0f;
@@ -43,8 +44,8 @@ public class AbilityEnergyWall extends AbstractEnergyBarrierAbility {
this.lockMovement = LockMovementType.WINDUP;
this.telegraphType = TelegraphType.LINE;
this.showTelegraph = true;
this.windUpAnimationName = "Ability_EnergyWall_Windup";
this.activeAnimationName = "Ability_EnergyWall_Active";
this.windUpAnimationName = "";
this.activeAnimationName = "";
}
@Override
@@ -55,7 +56,7 @@ public class AbilityEnergyWall extends AbstractEnergyBarrierAbility {
// ==================== ABSTRACT IMPLEMENTATIONS ====================
@Override
protected Entity createBarrierEntity(EntityLivingBase caster, EntityLivingBase target) {
protected EntityEnergyBarrier createBarrierEntity(EntityLivingBase caster, EntityLivingBase target) {
// Place wall between caster and target
double placeX, placeY, placeZ;
float yaw;
@@ -64,12 +65,21 @@ public class AbilityEnergyWall extends AbstractEnergyBarrierAbility {
double dx = target.posX - caster.posX;
double dz = target.posZ - caster.posZ;
double dist = Math.sqrt(dx * dx + dz * dz);
double placeDist = Math.min(dist * 0.5, 5.0);
placeX = caster.posX + (dx / dist) * placeDist;
placeY = caster.posY;
placeZ = caster.posZ + (dz / dist) * placeDist;
yaw = (float) (Math.atan2(-dx, dz) * 180.0 / Math.PI);
if (dist < 0.01) {
// Target at same position — fall through to look-direction placement
float yawRad = (float) Math.toRadians(caster.rotationYaw);
placeX = caster.posX + (-Math.sin(yawRad) * 3.0);
placeY = caster.posY;
placeZ = caster.posZ + (Math.cos(yawRad) * 3.0);
yaw = caster.rotationYaw;
} else {
double placeDist = Math.min(dist * 0.5, 5.0);
placeX = caster.posX + (dx / dist) * placeDist;
placeY = caster.posY;
placeZ = caster.posZ + (dz / dist) * placeDist;
yaw = (float) (Math.atan2(-dx, dz) * 180.0 / Math.PI);
}
} else {
float yawRad = (float) Math.toRadians(caster.rotationYaw);
placeX = caster.posX + (-Math.sin(yawRad) * 3.0);
@@ -105,7 +115,7 @@ public class AbilityEnergyWall extends AbstractEnergyBarrierAbility {
a.setName("Static Wall");
}),
new AbilityVariant("ability.variant.launched", a -> {
AbilityEnergyWall wall = (AbilityEnergyWall) a;
AbilityWall wall = (AbilityWall) a;
a.setName("Launched Wall");
wall.panelData.launching = true;
wall.panelData.launchSpeed = 0.6f;