Xp Orb Stacker

Discussion in 'Plugin Requests' started by heyheyehey, Nov 2, 2015.

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

    heyheyehey

    hello everyone,
    for the past couple of hours i've been looking for a plugin that would make xp orbs stack...
    i only want xp to stack and not anything else.

    i got a massive xp farm where i kill 1k to 2k mobs and get 2.2k to 5k exp orbs entities.

    i just let you imagine how much time it takes me to pick it up ( 15 -20 min if you didnt guess untill now)

    i know that there is stacked xp orb ( those we are getting from the dragon )

    but i want normal xp orbs to stack... if above a certain number.

    is it possible as a server addon only?

    thanks for your help,
    Botnik
     
    Last edited: Nov 2, 2015
  2. Offline

    timtower Administrator Administrator Moderator

    Client and server are 2 different parts, you probably mean server only.
     
  3. Offline

    heyheyehey

    i was realy rushing when i wrote the message... i know that...
    dumb mistake :) sorry and thanks for telling me
     
  4. I'm pretty sure this already exists in vanilla minecraft, at least in 1.8. Throw down ten bottles of experience and you should see only one xp orb come out.
     
  5. Offline

    heyheyehey

    im on craftbukkit 1.8.8 and killing 2k mobs make 4k exp orbs entities... a cloud of orbs... i want a way to stack those xp orbs

    hello, i know abit of java... not much... im more of a C# guy...

    i dont think this plugin is hard to make... i would still love to get a plugin made by a better coder than me...
    but i can code myself... i just need to know how do you use the listeners and how do you control the size of the orb

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 3, 2015
  6. Offline

    heyheyehey

  7. Offline

    heyheyehey

  8. Offline

    JRL1004

    If a dev wants to take this, feel free. I was going to but I don't feel like trying to make it auto-condense the orbs and I don't think that OP wants to try to type out a command with that many orbs around them (granted, this is on the assumption that 4k entities hurts their fps). Here is what I typed up so far:
    Something that looks like code (open)

    Code:
    public class SimpleEXPStacker extends JavaPlugin {
    
        public void stackExperienceInRadius(Location center, double radius) {
            World world = center.getWorld();
            List<ExperienceOrb> experienceOrbs = new ArrayList<ExperienceOrb>(); // Get a list ready for the EXP orbs
            for (Entity entity : world.getEntities()) {
                if (entity.getType() != EntityType.EXPERIENCE_ORB || !(entity instanceof ExperienceOrb)) continue;
                if (!smartDistanceCheck(center, entity.getLocation(), radius)) continue;
                experienceOrbs.add((ExperienceOrb) entity);
            }
            int totalExperience = 0;
            for (ExperienceOrb experienceOrb : experienceOrbs) { // Loop through all the orbs in the radius
                totalExperience += experienceOrb.getExperience(); // Add up the total experience
                experienceOrb.remove(); // Remove the exp orb
            }
            experienceOrbs.clear(); // Don't need to store these anymore
            ExperienceOrb mergedOrb = (ExperienceOrb) world.spawnEntity(center, EntityType.EXPERIENCE_ORB);
            mergedOrb.setExperience(totalExperience); // Make this orb worth a crud ton of experience
        }
    
        private boolean smartDistanceCheck(Location center, Location check, double distance) {
            if (Math.abs(center.getX() - check.getX()) > distance) return false;
            if (Math.abs(center.getY() - check.getY()) > distance) return false;
            if (Math.abs(center.getZ() - check.getZ()) > distance) return false;
            return center.distance(check) <= distance;
        }
    }
    
     
Thread Status:
Not open for further replies.

Share This Page