The field "canEngage" on the NPCTrainer object disallows players to throw a pokeball at the NPC to battle it. These trainers are still able to engage in a battle via code. This is useful for sidemods and plugins, however, currently, it despawns the trainer after every battle, due to a couple lines in TrainerParticipant#endBattle(BattleEndCause cause), here:
Code: Select all if (!this.trainer.canEngage) {
this.trainer.remove();
this.trainer.unloadEntity();
}
Not only that, but NPCTrainer#remove() is called twice in that, once visible, and the next call is directly inside the NPCTrainer#unloadEntity().
I don't believe this is intended, and if it is, may it please be explained why, and possibly give sidemod/plugin developers an alternative field to disallow a pokeball being thrown at the NPC to battle it? Said additional field would be put in NPCTrainer.class and only accessed once in NPCTrainer#canStartBattle(PlayerEntity opponent, boolean printMessages), returning false if the additional field is false, exactly as canEngage does now.