mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 06:29:41 +00:00
Some Ability Helpers
This commit is contained in:
1 parent
8fc0155df8
commit
8aa6e926f6
12 files changed
+326
-92
No files matched your search
@@ -192,6 +192,19 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
|
||||
|
||||
// Skip lifetime/distance checks in preview mode
|
||||
if (!previewMode) {
|
||||
// Failsafe: if owner entity is gone, dead, or NPC was killed/reset, self-destruct
|
||||
if (ownerEntityId >= 0 && ticksExisted > 5) {
|
||||
Entity owner = worldObj.getEntityByID(ownerEntityId);
|
||||
if (owner == null || owner.isDead) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
if (owner instanceof EntityNPCInterface && ((EntityNPCInterface) owner).isKilled()) {
|
||||
this.setDead();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Set death time on first tick if not already set (handles chunk load/unload)
|
||||
if (deathWorldTime < 0 && worldObj != null) {
|
||||
deathWorldTime = worldObj.getTotalWorldTime() + maxLifetime;
|
||||
@@ -392,6 +405,10 @@ public abstract class EntityAbilityProjectile extends Entity implements IEntityA
|
||||
|
||||
// ==================== ENTITY HELPERS ====================
|
||||
|
||||
public int getOwnerEntityId() {
|
||||
return ownerEntityId;
|
||||
}
|
||||
|
||||
protected Entity getOwner() {
|
||||
// In preview mode, use direct reference (no world lookup)
|
||||
if (previewMode && previewOwner != null) {
|
||||
|
||||
Reference in new issue
Block a user