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

Spawning of experience orbs cannot be cancelled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • OS: Windows 11

      Java: Temurin 17.0.5

      IDE: IntelliJ IDEA CE 2023.2.2

      Using a custom run configuration to execute spigot-1.20.2.jar, which was created after running java -jar BuildTools.jar

    • 3946-Spigot-b60a866-7580463 (MC: 1.20.2) (Implementing API version 1.20.2-R0.1-SNAPSHOT)
    • Yes

      I'm trying to disable the spawning of experience orbs. However, it seems like Spigot's XP orb merging logic isn't firing the EntitySpawnEvent event.

      After running BuildTools.jar, this is what the resulting org.bukkit.craftbukkit.event.CraftEventFactory class looks like starting on line 696:
       

              // Spigot start
              } else if (entity instanceof EntityExperienceOrb) {
                  EntityExperienceOrb xp = (EntityExperienceOrb) entity;
                  double radius = world.spigotConfig.expMerge;
                  if (radius > 0) {
                      List<Entity> entities = world.getEntities(entity, entity.getBoundingBox().inflate(radius, radius, radius));
                      for (Entity e : entities) {
                          if (e instanceof EntityExperienceOrb) {
                              EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                              if (!loopItem.isRemoved()) {
                                  xp.value += loopItem.value;
                                  loopItem.discard();
                              }
                          }
                      }
                  }
              // Spigot end
              } else if (!(entity instanceof EntityPlayer)) {
                  event = CraftEventFactory.callEntitySpawnEvent(entity);
              }
      
              if (event != null && (event.isCancelled() || entity.isRemoved())) {

      As you can see, the XP orb merging logic seems to be missing the call to CraftEventFactory.callEntitySpawnEvent, which results in the next block being skipped.

            Unassigned Unassigned
            whizvox Corneilious Eanes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: