Energy Explosion API and some changes to Energy Projectile API

This commit is contained in:
Kam committed 2026-03-03 17:11:12 -05:00
1 parent 6f6e080ee0
commit b59f0b8f2f
14 files changed
+476 -101

No files matched your search

@@ -16,6 +16,7 @@ import kamkeel.npcs.entity.EntityAbilityLaser;
import kamkeel.npcs.entity.EntityAbilityOrb;
import kamkeel.npcs.entity.EntityEnergyPanel;
import kamkeel.npcs.entity.EntityEnergySweeper;
import kamkeel.npcs.entity.EntityEnergyExplosion;
import kamkeel.npcs.entity.EntityEnergyProjectile;
import kamkeel.npcs.entity.EntityEnergySlicer;
import net.minecraft.block.Block;
@@ -102,6 +103,7 @@ import noppes.npcs.scripted.entity.ScriptDBCPlayer;
import noppes.npcs.scripted.entity.ScriptEnergyBeam;
import noppes.npcs.scripted.entity.ScriptEnergyDisc;
import noppes.npcs.scripted.entity.ScriptEnergyDome;
import noppes.npcs.scripted.entity.ScriptEnergyExplosion;
import noppes.npcs.scripted.entity.ScriptEnergyLaser;
import noppes.npcs.scripted.entity.ScriptEnergyOrb;
import noppes.npcs.scripted.entity.ScriptEnergyPanel;
@@ -466,6 +468,8 @@ public class NpcAPI extends AbstractNpcAPI {
data = new ScriptEntityData(new ScriptEnergyPanel<>((EntityEnergyPanel) entity));
else if (entity instanceof EntityEnergySweeper)
data = new ScriptEntityData(new ScriptEnergySweeper<>((EntityEnergySweeper) entity));
else if (entity instanceof EntityEnergyExplosion)
data = new ScriptEntityData(new ScriptEnergyExplosion<>((EntityEnergyExplosion) entity));
else if (entity instanceof EntityAbilityZone)
data = new ScriptEntityData(new ScriptEnergyZone<>((EntityAbilityZone) entity));
else
@@ -23,4 +23,5 @@ public class EntityType {
public static final int ENERGY_BARRIER = 19;
public static final int ENERGY_DOME = 20;
public static final int ENERGY_PANEL = 21;
public static final int ENERGY_EXPLOSION = 22;
}
@@ -60,7 +60,7 @@ public class ScriptEnergyBeam<T extends EntityAbilityBeam> extends ScriptEnergyP
// ==================== FIRE ====================
@Override
public void fire(IEntity target) {
public void fireAt(IEntity target) {
ensureSpawned();
EntityLivingBase mcTarget = null;
if (target != null && target.getMCEntity() instanceof EntityLivingBase) {
@@ -70,7 +70,7 @@ public class ScriptEnergyBeam<T extends EntityAbilityBeam> extends ScriptEnergyP
}
@Override
public void fire(double x, double y, double z) {
public void fireAt(double x, double y, double z) {
ensureSpawned();
double dx = x - entity.posX;
double dy = y - entity.posY;
@@ -76,7 +76,7 @@ public class ScriptEnergyDisc<T extends EntityAbilityDisc> extends ScriptEnergyP
// ==================== FIRE ====================
@Override
public void fire(IEntity target) {
public void fireAt(IEntity target) {
ensureSpawned();
EntityLivingBase mcTarget = null;
if (target != null && target.getMCEntity() instanceof EntityLivingBase) {
@@ -86,7 +86,7 @@ public class ScriptEnergyDisc<T extends EntityAbilityDisc> extends ScriptEnergyP
}
@Override
public void fire(double x, double y, double z) {
public void fireAt(double x, double y, double z) {
ensureSpawned();
double dx = x - entity.posX;
double dy = y - entity.posY;
@@ -0,0 +1,109 @@
package noppes.npcs.scripted.entity;
import kamkeel.npcs.entity.EntityEnergyExplosion;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.data.energyexplosion.EnergyExplosionSpawnPacket;
import noppes.npcs.api.entity.IEnergyExplosion;
import noppes.npcs.scripted.constants.EntityType;
import java.util.UUID;
/**
* Script wrapper for standalone energy explosion entities.
*/
public class ScriptEnergyExplosion<T extends EntityEnergyExplosion> extends ScriptEnergyAbility<T> implements IEnergyExplosion {
public ScriptEnergyExplosion(T entity) {
super(entity);
}
// ==================== TYPE ====================
@Override
public int getType() {
return EntityType.ENERGY_EXPLOSION;
}
@Override
public boolean typeOf(int type) {
return type == EntityType.ENERGY_EXPLOSION || super.typeOf(type);
}
// ==================== RADIUS & DURATION ====================
@Override
public float getRadius() {
return entity.getExplosionRadius();
}
@Override
public void setRadius(float radius) {
entity.setExplosionRadius(radius);
}
@Override
public int getDuration() {
return entity.getDurationTicks();
}
// ==================== DAMAGE ====================
@Override
public float getDamage() {
return entity.getDamage();
}
@Override
public void setDamage(float damage) {
entity.setDamage(damage);
}
@Override
public float getKnockback() {
return entity.getKnockback();
}
@Override
public void setKnockback(float knockback) {
entity.setKnockback(knockback);
}
@Override
public float getKnockbackUp() {
return entity.getKnockbackUp();
}
@Override
public void setKnockbackUp(float knockbackUp) {
entity.setKnockbackUp(knockbackUp);
}
@Override
public float getDamageFalloff() {
return entity.getDamageFalloff();
}
@Override
public void setDamageFalloff(float falloff) {
entity.setDamageFalloff(falloff);
}
// ==================== SPAWNING ====================
@Override
public void spawn() {
if (entity.addedToChunk || entity.worldObj == null) return;
if (!entity.worldObj.isRemote) {
// Send visual to clients via packet (explosion is packet-driven, not a tracked entity)
String instanceId = "energy_explosion_" + UUID.randomUUID();
PacketHandler.Instance.sendToAll(new EnergyExplosionSpawnPacket(
instanceId, entity.exportSpawnNBT()));
// Spawn server-side for damage logic (if damage enabled)
if (entity.isDamageEnabled()) {
entity.worldObj.spawnEntityInWorld(entity);
}
}
}
}
@@ -92,7 +92,7 @@ public class ScriptEnergyLaser<T extends EntityAbilityLaser> extends ScriptEnerg
// ==================== FIRE ====================
@Override
public void fire(IEntity target) {
public void fireAt(IEntity target) {
ensureSpawned();
EntityLivingBase mcTarget = null;
if (target != null && target.getMCEntity() instanceof EntityLivingBase) {
@@ -102,7 +102,7 @@ public class ScriptEnergyLaser<T extends EntityAbilityLaser> extends ScriptEnerg
}
@Override
public void fire(double x, double y, double z) {
public void fireAt(double x, double y, double z) {
ensureSpawned();
double dx = x - entity.posX;
double dy = y - entity.posY;
@@ -28,7 +28,7 @@ public class ScriptEnergyOrb<T extends EntityAbilityOrb> extends ScriptEnergyPro
}
@Override
public void fire(IEntity target) {
public void fireAt(IEntity target) {
ensureSpawned();
EntityLivingBase mcTarget = null;
if (target != null && target.getMCEntity() instanceof EntityLivingBase) {
@@ -38,7 +38,7 @@ public class ScriptEnergyOrb<T extends EntityAbilityOrb> extends ScriptEnergyPro
}
@Override
public void fire(double x, double y, double z) {
public void fireAt(double x, double y, double z) {
ensureSpawned();
double dx = x - entity.posX;
double dy = y - entity.posY;
@@ -259,7 +259,7 @@ public class ScriptEnergyProjectile<T extends EntityEnergyProjectile> extends Sc
// ==================== FIRE ====================
public void fire(IEntity target) {
public void fireAt(IEntity target) {
if (target != null) {
Entity mcTarget = target.getMCEntity();
setMotionToward(mcTarget.posX, mcTarget.posY + mcTarget.getEyeHeight(), mcTarget.posZ);
@@ -267,12 +267,12 @@ public class ScriptEnergyProjectile<T extends EntityEnergyProjectile> extends Sc
ensureSpawned();
}
public void fire(double x, double y, double z) {
public void fireAt(double x, double y, double z) {
setMotionToward(x, y, z);
ensureSpawned();
}
public void fire(float yaw, float pitch) {
public void fireDirection(float yaw, float pitch) {
float yawRad = (float) Math.toRadians(yaw);
float pitchRad = (float) Math.toRadians(pitch);
entity.motionX = -Math.sin(yawRad) * Math.cos(pitchRad) * entity.getSpeed();
@@ -281,16 +281,16 @@ public class ScriptEnergyProjectile<T extends EntityEnergyProjectile> extends Sc
ensureSpawned();
}
public void fire(IEntityLivingBase caster) {
public void fireFrom(IEntityLivingBase caster) {
if (caster == null) return;
initFromCaster(caster);
fire(caster.getRotation(), caster.getPitch());
fireDirection(caster.getRotation(), caster.getPitch());
}
public void fire(IEntityLivingBase caster, IEntity target) {
public void fireFrom(IEntityLivingBase caster, IEntity target) {
if (caster == null) return;
initFromCaster(caster);
fire(target);
fireAt(target);
}
/**
@@ -48,7 +48,7 @@ public class ScriptEnergySlicer<T extends EntityEnergySlicer> extends ScriptEner
// ==================== FIRE ====================
@Override
public void fire(IEntity target) {
public void fireAt(IEntity target) {
ensureSpawned();
EntityLivingBase mcTarget = null;
if (target != null && target.getMCEntity() instanceof EntityLivingBase) {
@@ -58,7 +58,7 @@ public class ScriptEnergySlicer<T extends EntityEnergySlicer> extends ScriptEner
}
@Override
public void fire(double x, double y, double z) {
public void fireAt(double x, double y, double z) {
ensureSpawned();
double dx = x - entity.posX;
double dy = y - entity.posY;