Allow Null Owners in Energy

This commit is contained in:
Kam committed 2026-03-09 17:47:13 -04:00
1 parent c423ab43f1
commit d8b18d7058
5 files changed
+12 -10

No files matched your search

@@ -78,7 +78,7 @@ public class EntityEnergySweeper extends EntityEnergyAbility {
boolean lockOnTarget) {
this(world);
this.ownerEntityId = owner.getEntityId();
this.ownerEntityId = owner != null ? owner.getEntityId() : -1;
this.targetEntityId = target != null ? target.getEntityId() : -1;
this.beamLength = beamLength;
this.beamWidth = beamWidth;
@@ -95,16 +95,18 @@ public class EntityEnergySweeper extends EntityEnergyAbility {
this.maxTicks = (int) ((360.0f * numberOfRotations) / sweepSpeed) + 10;
// Calculate base yaw
if (lockOnTarget && target != null) {
if (lockOnTarget && target != null && owner != null) {
double dx = target.posX - owner.posX;
double dz = target.posZ - owner.posZ;
this.baseYaw = (float) Math.toDegrees(Math.atan2(-dx, dz));
} else {
} else if (owner != null) {
this.baseYaw = owner.rotationYaw;
}
// Position at beam center (bottom at feet, top at feet + beamHeight)
this.setPosition(owner.posX, owner.posY + beamHeight / 2.0, owner.posZ);
if (owner != null) {
this.setPosition(owner.posX, owner.posY + beamHeight / 2.0, owner.posZ);
}
// Ready to deal damage immediately
this.ticksSinceDamage = damageInterval;