Improved Natural Despawn Handling PR 4 - Natural Spawns

This commit is contained in:
Kam committed 2026-02-23 05:44:45 -05:00
1 parent 6abd29b12d
commit 37b38daa00
5 files changed
+46 -10

No files matched your search

@@ -255,7 +255,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
setFaction(faction.id);
setSize(1, 1);
this.updateTasks();
this.func_110163_bv();
this.syncDespawnPersistence();
if (!this.isRemote() && this.wrappedNPC == null) {
this.wrappedNPC = new ScriptNpc<>(this);
@@ -1203,7 +1203,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange);
this.updateTasks();
this.func_110163_bv();
this.syncDespawnPersistence();
}
@Override
@@ -1404,6 +1404,26 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
field_20062_v += d1 * 0.25D;
}
@Override
protected void despawnEntity() {
syncDespawnPersistence();
super.despawnEntity();
}
public void syncDespawnPersistence() {
if (stats == null) {
if (!this.persistenceRequired) {
this.func_110163_bv();
}
return;
}
if (stats.canDespawn) {
this.persistenceRequired = false;
} else if (!this.persistenceRequired) {
this.func_110163_bv();
}
}
@Override
protected boolean canDespawn() {
return stats.canDespawn;