Pixelmon Mod - Bug tracker

[9.1.2] NPCTrainer objects with canEngage false despawn after every battle. ticket expired

Ticket description:
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.

Comments

No comments have been made

Ticket details

  • Ticket ID: 19989
  • Project: Pixelmon Mod
  • Status: Ticket Expired
  • Component: (unknown)
  • Project version: 1.16.5-9.x.x
  • Priority: Normal
  • Severity: Normal
  • Forge/Sponge: (unknown)
  • What else would be useful to know?: (unknown)
  • Assigned to: (unassigned)
  • Reported by: Neovitalism (Send PM)
  • Reporter's tickets: (List all tickets)
  • Reported on: 27 Jan 2023 13:50
  • Ticket last visited by: Rasgnarok on 13 Nov 2023 18:17
JOIN THE TEAM