Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6842

Methods to control the despawning and DespawnDelay of trader llamas

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version dev-Spigot-dbf4938-8b98c8e (MC: 1.18) (Implementing API version 1.18-R0.1-SNAPSHOT)
    • Yes

      The following two cases are not yet covered by the API:
      Goal 1: Set the DespawnDelay of trader llamas.
      Goal 2: Prevent trader llamas from despawning at all.

      Goal 1 could be covered by adding methods similar to those of wandering traders (https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/a4d1824184548849aa6f499eb599f7346bce33ff).

      However, trader llamas behave slightly differently to wandering traders in how they use their DespawnDelay property:

      • If they are leashed to a wandering trader, they dynamically adopt the wandering trader's DespawnDelay. I.e. any DespawnDelay explicitly set by plugins is dynamically replaced each tick with the wandering trader's DespawnDelay. For unleashed trader llamas the DespawnDelay would work as 'expected'.
      • By default, unlike for the wandering trader, there are no special DespawnDelay values that would prevent the trader llama from despawning at all (setting the DespawnDelay of a wandering trader to 0 or something negative will prevent it from despawning). It is possible to prevent the despawning by setting the trader llamas as 'tamed'. However, this will then have other effects as well.

      Possible related API additions I can think of (that ideally do not  require storing new custom Bukkit entity properties):

      • Maybe introduce some kind of special DespawnDelay value (e.g. 0 and/or negative values, or MAX_INTEGER) that would indicate that the trader llama is supposed to skip this whole should-despawn logic, similar to wandering traders. However, this would make this DespawnDelay logic diverge from vanilla Minecraft when trader llamas can somehow end up with these particular DespawnDelay value(s) by other means.
      • Maybe add a cancellable EntityDespawnEvent (or something more specific to trader llamas / wandering traders) for the despawning of trader llamas (and maybe wandering traders). However, in order to not spam this event every tick when it keeps getting cancelled, the server should probably set the entity's DespawnDelay to some new value (either provided by plugins via the event, or reset to its initial default).

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: