How Do I Spawn Experience Orbs?

Discussion in 'Plugin Development' started by r0306, Apr 15, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    r0306

    Anyone know how to spawn experience orbs and drop them like items? The way I do it is deprecated and so it doesn't work with 1.2.5. :C
     
  2. Offline

    Njol

    Try world.spawn(location, ExperienceOrb.class);
     
  3. Offline

    r0306

    Yup, I'm using it right now and it's not working, although its not giving me any errors either. Heres the code:
    Code:
                      float Exp = playerquit.getExp();
                      int ExpOrbs = (int) Exp;
                      ExperienceOrb orb = null;
                      World world = playerquit.getWorld();
                      ((ExperienceOrb)world.spawn(playerquit.getLocation(), ExperienceOrb.class)).setExperience( ExpOrbs );
    Update: It IS working. But I can't seem to make the player drop ALL their Exp. As of now, they only drop Exp equal to one level. Their overall level stays the same. :C

    Update: It works now! :D I used the experience/level equation to find the how much exp should be dropped and then set their level to zero. Thanks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
Thread Status:
Not open for further replies.

Share This Page