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

Experience orbs spawned using World.spawn() are not merged correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • None
    • CraftBukkit version 4029-Spigot-c198da2-3337018 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT)
    • Yes

      As already posted in the Bukkit forums, I noticed a bug when two experience orbs are spawned at the same location.

      Spawning experience orbs using the /summon command either as a player or using command blocks is working fine even if they are spawned at the exact same location. They are simply merged together and the resulting orb also contains the summed amount of experience points.

      But, spawning an experience orb in a plugin by using World.spawn() results in also merging the orbs into one orb but the experience points are not added. So, if I spawn two orbs at the same location containing one experience point each, the resulting experience orb does not have two experience points but only one as the new one seem to replace the previous one without adding the points.

      Example code with can be used in a plugin class:

          @Override
          public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
              Player player = (Player) sender;
      
              Location location = player.getLocation();
      
              location.add(10, 0, 0);
      
              player.getWorld().spawn(location, ExperienceOrb.class).setExperience(1);
      
              return true;
          }
      

      The code for that command will spawn a single experience orb with one experience point. Without moving the player and executing the command over and over again shows that the orb is spawning and previous one disappears. After a few executions of that command, the player might walk to the experience orb to pick it up and all you get is a single experience point, regardless of how many times you executed the command.

            Unassigned Unassigned
            Programie Programie
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: