mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 18:57:32 +00:00
Fix Persistent Ability Entities
This commit is contained in:
1 parent
ef276b8145
commit
4dde214f94
5 files changed
+10
-186
No files matched your search
@@ -366,47 +366,11 @@ public class EntityAbilitySweeper extends EntityEnergyAbility {
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
readEnergyBaseNBT(nbt);
|
||||
this.beamLength = sanitize(nbt.getFloat("BeamLength"), 10.0f, MAX_ENTITY_SIZE);
|
||||
this.beamWidth = sanitize(nbt.getFloat("BeamWidth"), 0.3f, MAX_ENTITY_SIZE);
|
||||
this.beamHeight = sanitize(nbt.getFloat("BeamHeight"), 1.0f, MAX_ENTITY_SIZE);
|
||||
this.sweepSpeed = nbt.hasKey("SweepSpeed") ? nbt.getFloat("SweepSpeed") : 3.0f;
|
||||
if (Float.isNaN(sweepSpeed) || Float.isInfinite(sweepSpeed) || sweepSpeed <= 0) sweepSpeed = 3.0f;
|
||||
this.numberOfRotations = nbt.hasKey("NumRotations") ? nbt.getInteger("NumRotations") : 2;
|
||||
if (numberOfRotations <= 0) numberOfRotations = 1;
|
||||
this.completedRotations = nbt.getInteger("CompletedRotations");
|
||||
this.maxTicks = nbt.hasKey("MaxTicks") ? nbt.getInteger("MaxTicks") : 400;
|
||||
if (maxTicks <= 0) maxTicks = 400;
|
||||
this.targetEntityId = nbt.getInteger("TargetId");
|
||||
this.currentAngle = nbt.getFloat("CurrentAngle");
|
||||
this.prevAngle = currentAngle;
|
||||
this.baseYaw = nbt.getFloat("BaseYaw");
|
||||
this.deathWorldTime = nbt.getLong("DeathWorldTime");
|
||||
this.damage = nbt.hasKey("Damage") ? nbt.getFloat("Damage") : 5.0f;
|
||||
if (Float.isNaN(damage) || Float.isInfinite(damage)) damage = 5.0f;
|
||||
this.damageInterval = nbt.hasKey("DamageInterval") ? nbt.getInteger("DamageInterval") : 5;
|
||||
if (damageInterval <= 0) damageInterval = 1;
|
||||
this.piercing = !nbt.hasKey("Piercing") || nbt.getBoolean("Piercing");
|
||||
this.lockOnTarget = nbt.getBoolean("LockOnTarget");
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
writeEnergyBaseNBT(nbt);
|
||||
nbt.setFloat("BeamLength", beamLength);
|
||||
nbt.setFloat("BeamWidth", beamWidth);
|
||||
nbt.setFloat("BeamHeight", beamHeight);
|
||||
nbt.setFloat("SweepSpeed", sweepSpeed);
|
||||
nbt.setInteger("NumRotations", numberOfRotations);
|
||||
nbt.setInteger("CompletedRotations", completedRotations);
|
||||
nbt.setInteger("MaxTicks", maxTicks);
|
||||
nbt.setInteger("TargetId", targetEntityId);
|
||||
nbt.setFloat("CurrentAngle", currentAngle);
|
||||
nbt.setFloat("BaseYaw", baseYaw);
|
||||
nbt.setLong("DeathWorldTime", deathWorldTime);
|
||||
nbt.setFloat("Damage", damage);
|
||||
nbt.setInteger("DamageInterval", damageInterval);
|
||||
nbt.setBoolean("Piercing", piercing);
|
||||
nbt.setBoolean("LockOnTarget", lockOnTarget);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
}
|
||||
@@ -716,130 +716,12 @@ public class EntityAbilityZone extends Entity implements IEntityAdditionalSpawnD
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
int zoneTypeOrd = nbt.getInteger("ZoneType");
|
||||
this.zoneType = (zoneTypeOrd >= 0 && zoneTypeOrd < ZoneType.values().length) ? ZoneType.values()[zoneTypeOrd] : ZoneType.TRAP;
|
||||
try {
|
||||
this.shape = ZoneShape.valueOf(nbt.getString("ShapeName"));
|
||||
} catch (Exception e) {
|
||||
this.shape = ZoneShape.CIRCLE;
|
||||
}
|
||||
|
||||
this.ownerEntityId = nbt.getInteger("OwnerId");
|
||||
this.radius = nbt.hasKey("Radius") ? nbt.getFloat("Radius") : 4.0f;
|
||||
this.durationTicks = nbt.hasKey("Duration") ? nbt.getInteger("Duration") : 200;
|
||||
this.maxTicks = nbt.hasKey("MaxTicks") ? nbt.getInteger("MaxTicks") : 200;
|
||||
this.innerColor = nbt.hasKey("InnerColor") ? nbt.getInteger("InnerColor") : 0xFF6600;
|
||||
this.outerColor = nbt.hasKey("OuterColor") ? nbt.getInteger("OuterColor") : 0xFF0000;
|
||||
this.outerColorEnabled = !nbt.hasKey("OuterColorEnabled") || nbt.getBoolean("OuterColorEnabled");
|
||||
this.zoneHeight = nbt.hasKey("ZoneHeight") ? nbt.getFloat("ZoneHeight") : 2.0f;
|
||||
this.particleDensity = nbt.hasKey("ParticleDensity") ? nbt.getFloat("ParticleDensity") : 1.0f;
|
||||
this.particleScale = nbt.hasKey("ParticleScale") ? nbt.getFloat("ParticleScale") : 1.0f;
|
||||
this.animSpeed = nbt.hasKey("AnimSpeed") ? nbt.getFloat("AnimSpeed") : 1.0f;
|
||||
this.lightningDensity = nbt.hasKey("LightningDensity") ? nbt.getFloat("LightningDensity") : 1.0f;
|
||||
this.deathWorldTime = nbt.getLong("DeathWorldTime");
|
||||
|
||||
// Visual layer fields
|
||||
this.groundFill = nbt.getBoolean("GroundFill");
|
||||
this.groundAlpha = nbt.getFloat("GroundAlpha");
|
||||
this.rings = nbt.getBoolean("Rings");
|
||||
this.ringCount = nbt.getInteger("RingCount");
|
||||
this.border = nbt.getBoolean("Border");
|
||||
this.borderSpeed = nbt.getFloat("BorderSpeed");
|
||||
this.accents = nbt.getBoolean("Accents");
|
||||
this.accentStyle = nbt.getInteger("AccentStyle");
|
||||
this.lightning = nbt.getBoolean("Lightning");
|
||||
this.particles = nbt.getBoolean("Particles");
|
||||
this.particleMotion = nbt.getInteger("ParticleMotion");
|
||||
this.particleDir = nbt.getString("ParticleDir");
|
||||
this.particleSize = nbt.getInteger("ParticleSize");
|
||||
this.particleGlow = nbt.getBoolean("ParticleGlow");
|
||||
|
||||
// Trap
|
||||
this.armTime = nbt.getInteger("ArmTime");
|
||||
this.triggerRadius = nbt.getFloat("TriggerRadius");
|
||||
this.maxTriggers = nbt.getInteger("MaxTriggers");
|
||||
this.triggerCooldown = nbt.getInteger("TriggerCooldown");
|
||||
this.damage = nbt.getFloat("Damage");
|
||||
this.damageRadius = nbt.getFloat("DamageRadius");
|
||||
this.knockback = nbt.getFloat("Knockback");
|
||||
this.visible = nbt.getBoolean("Visible");
|
||||
|
||||
// Hazard
|
||||
this.damagePerSecond = nbt.hasKey("DamagePerSecond") ? nbt.getFloat("DamagePerSecond") : 1.0f;
|
||||
this.damageInterval = nbt.hasKey("DamageInterval") ? nbt.getInteger("DamageInterval") : 20;
|
||||
if (damageInterval <= 0) damageInterval = 1;
|
||||
this.ignoreInvulnFrames = nbt.getBoolean("IgnoreInvuln");
|
||||
this.affectsCaster = nbt.getBoolean("AffectsCaster");
|
||||
|
||||
// Effects
|
||||
effects.clear();
|
||||
if (nbt.hasKey("Effects")) {
|
||||
NBTTagList effectList = nbt.getTagList("Effects", 10);
|
||||
for (int i = 0; i < effectList.tagCount(); i++) {
|
||||
AbilityPotionEffect effect = AbilityPotionEffect.fromNBT(effectList.getCompoundTagAt(i));
|
||||
if (effect != null && effect.isValid()) {
|
||||
effects.add(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("ZoneType", zoneType.ordinal());
|
||||
nbt.setString("ShapeName", shape.name());
|
||||
nbt.setInteger("OwnerId", ownerEntityId);
|
||||
nbt.setFloat("Radius", radius);
|
||||
nbt.setInteger("Duration", durationTicks);
|
||||
nbt.setInteger("MaxTicks", maxTicks);
|
||||
nbt.setInteger("InnerColor", innerColor);
|
||||
nbt.setInteger("OuterColor", outerColor);
|
||||
nbt.setBoolean("OuterColorEnabled", outerColorEnabled);
|
||||
nbt.setFloat("ZoneHeight", zoneHeight);
|
||||
nbt.setFloat("ParticleDensity", particleDensity);
|
||||
nbt.setFloat("ParticleScale", particleScale);
|
||||
nbt.setFloat("AnimSpeed", animSpeed);
|
||||
nbt.setFloat("LightningDensity", lightningDensity);
|
||||
nbt.setLong("DeathWorldTime", deathWorldTime);
|
||||
|
||||
// Visual layer fields
|
||||
nbt.setBoolean("GroundFill", groundFill);
|
||||
nbt.setFloat("GroundAlpha", groundAlpha);
|
||||
nbt.setBoolean("Rings", rings);
|
||||
nbt.setInteger("RingCount", ringCount);
|
||||
nbt.setBoolean("Border", border);
|
||||
nbt.setFloat("BorderSpeed", borderSpeed);
|
||||
nbt.setBoolean("Accents", accents);
|
||||
nbt.setInteger("AccentStyle", accentStyle);
|
||||
nbt.setBoolean("Lightning", lightning);
|
||||
nbt.setBoolean("Particles", particles);
|
||||
nbt.setInteger("ParticleMotion", particleMotion);
|
||||
nbt.setString("ParticleDir", particleDir);
|
||||
nbt.setInteger("ParticleSize", particleSize);
|
||||
nbt.setBoolean("ParticleGlow", particleGlow);
|
||||
|
||||
// Trap
|
||||
nbt.setInteger("ArmTime", armTime);
|
||||
nbt.setFloat("TriggerRadius", triggerRadius);
|
||||
nbt.setInteger("MaxTriggers", maxTriggers);
|
||||
nbt.setInteger("TriggerCooldown", triggerCooldown);
|
||||
nbt.setFloat("Damage", damage);
|
||||
nbt.setFloat("DamageRadius", damageRadius);
|
||||
nbt.setFloat("Knockback", knockback);
|
||||
nbt.setBoolean("Visible", visible);
|
||||
|
||||
// Hazard
|
||||
nbt.setFloat("DamagePerSecond", damagePerSecond);
|
||||
nbt.setInteger("DamageInterval", damageInterval);
|
||||
nbt.setBoolean("IgnoreInvuln", ignoreInvulnFrames);
|
||||
nbt.setBoolean("AffectsCaster", affectsCaster);
|
||||
|
||||
// Effects
|
||||
NBTTagList effectList = new NBTTagList();
|
||||
for (AbilityPotionEffect effect : effects) {
|
||||
effectList.appendTag(effect.writeNBT());
|
||||
}
|
||||
nbt.setTag("Effects", effectList);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -599,17 +599,11 @@ public class EntityEnergyDome extends EntityEnergyBarrier {
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
readBarrierBaseNBT(nbt);
|
||||
this.setDomeRadius(sanitize(nbt.getFloat("DomeRadius"), 5.0f, MAX_ENTITY_RADIUS));
|
||||
this.targetDomeRadius = sanitize(nbt.hasKey("TargetDomeRadius") ? nbt.getFloat("TargetDomeRadius") : domeRadius, 5.0f, MAX_ENTITY_RADIUS);
|
||||
this.followCaster = nbt.hasKey("FollowCaster") && nbt.getBoolean("FollowCaster");
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
writeBarrierBaseNBT(nbt);
|
||||
nbt.setFloat("DomeRadius", domeRadius);
|
||||
nbt.setFloat("TargetDomeRadius", targetDomeRadius);
|
||||
nbt.setBoolean("FollowCaster", followCaster);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
}
|
||||
@@ -556,25 +556,11 @@ public class EntityEnergyPanel extends EntityEnergyBarrier {
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
readBarrierBaseNBT(nbt);
|
||||
this.panelYaw = nbt.getFloat("PanelYaw");
|
||||
int modeOrdinal = nbt.getInteger("PanelMode");
|
||||
this.mode = (modeOrdinal >= 0 && modeOrdinal < PanelMode.values().length)
|
||||
? PanelMode.values()[modeOrdinal] : PanelMode.PLACED;
|
||||
panelData.readNBT(nbt);
|
||||
panelData.panelWidth = sanitize(panelData.panelWidth, 3.0f, MAX_ENTITY_SIZE);
|
||||
panelData.panelHeight = sanitize(panelData.panelHeight, 3.0f, MAX_ENTITY_SIZE);
|
||||
this.targetPanelWidth = sanitize(nbt.hasKey("TargetPanelWidth") ? nbt.getFloat("TargetPanelWidth") : panelData.panelWidth, 3.0f, MAX_ENTITY_SIZE);
|
||||
this.targetPanelHeight = sanitize(nbt.hasKey("TargetPanelHeight") ? nbt.getFloat("TargetPanelHeight") : panelData.panelHeight, 3.0f, MAX_ENTITY_SIZE);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
writeBarrierBaseNBT(nbt);
|
||||
nbt.setFloat("PanelYaw", panelYaw);
|
||||
nbt.setInteger("PanelMode", mode.ordinal());
|
||||
nbt.setFloat("TargetPanelWidth", targetPanelWidth);
|
||||
nbt.setFloat("TargetPanelHeight", targetPanelHeight);
|
||||
panelData.writeNBT(nbt);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
}
|
||||
@@ -926,14 +926,12 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
readBaseNBT(nbt);
|
||||
readProjectileNBT(nbt);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
writeBaseNBT(nbt);
|
||||
writeProjectileNBT(nbt);
|
||||
// Intentionally empty — ability entities are transient (not saved to world)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user