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

Setting Villager profession doesn't persist

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-766dab2-e2bbf62 (MC: 1.14) (Implementing API version 1.14-R0.1-SNAPSHOT)
    • Yes

       When setting the villager profession, the new profession is applied for a tick or so, and then resets back to the default profession.

      For example:

      Entity entity = location.getWorld().spawnEntity(location, EntityType.VILLAGER);
      Villager villager = (Villager) entity;
      System.out.println("Spawned Villager. Current Profession: " + villager.getProfession().name());
                      
      villager.setProfession(Profession.BUTCHER);
      System.out.println("Modified Villager. Current Profession: " + villager.getProfession().name());
                      
       final Villager villagerFinal = villager;
       getServer().getScheduler().scheduleSyncDelayedTask(instance, new Runnable() {
        @Override
        public void run() {
          try {
            System.out.println("1 Second Wait. Current Profession: " + villagerFinal.getProfession().name());
          }
          catch (Exception e) {
            e.printStackTrace();
          }
        }
      }, 20);
      

      Console Output:

      [23:23:14] [Server thread/INFO]: Spawned Villager. Current Profession: NONE
      [23:23:14] [Server thread/INFO]: Modified Villager. Current Profession: BUTCHER
      [23:23:15] [Server thread/INFO]: 1 Second Wait. Current Profession: NONE

      Expected Output: (CraftBukkit version git-Spigot-e5e5c7c-c24abab (MC: 1.13.2) (Implementing API version 1.13.2-R0.1-SNAPSHOT))

      [23:30:14 INFO]: Spawned Villager. Current Profession: LIBRARIAN
      [23:30:14 INFO]: Modified Villager. Current Profession: BUTCHER
      [23:30:15 INFO]: 1 Second Wait. Current Profession: BUTCHER

            Unassigned Unassigned
            Intelli Intelli
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: