Disable EnderDragon exp drop (1.9)

Discussion in 'Spigot Plugin Development' started by Sabbertran, May 29, 2016.

  1. Hey,
    I'm trying to disable the dropping of experience when an EnderDragon dies.
    Using EntityDeathEvent#setDroppedExp(0) does not work, probably because the event is called when the dragons health actually goes down to 0 and not when it drops the exp after flying to the portal location (I'm using 1.9).

    Any help would be appreciated.
    Greetings,
    Sabbertran
     
  2. You could deny XP from spawning in the end if the amount of XP that it's going to give is above a certain threshold.
     
  3. EntityEnderDragon.Class

    Code (Text):

     boolean flag = this.world.getGameRules().getBoolean("doMobLoot");
      short short0 = 500;

      if ((this.bI != null) && (!this.bI.d())) {
      short0 = 12000;
      }

      if (!this.world.isClientSide) {
      if ((this.bF > 150) && (this.bF % 5 == 0) && (flag)) {
      a(MathHelper.d(short0 * 0.08F));
      }

     
    set doMoobLoot to false or create a custom entityEnderdragon and override this method:

    Code (Text):

      private void a(int i)
      {
      while (i > 0) {
      int j = EntityExperienceOrb.getOrbValue(i);

      i -= j;
      this.world.addEntity(new EntityExperienceOrb(this.world, this.locX, this.locY, this.locZ, j));
      }
      }
     
     
  4. I thought you might be able to use EntitySpawnEvent and use the location relative to the dragon's death to remove the exp, on second thought it'd probably be more reliable if you just modified the entity directly as coco_gigpn said.
     
  5. Except he can't override a private method.