Solved Mobs not dropping items on death

Discussion in 'Plugin Development' started by Jedd Lupoy, Jan 10, 2017.

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

    Jedd Lupoy

    Hi, I am coding a custom mob drops plugin with a drop chance feature. Eclipse is not showing any errors, no console errors, nothing.

        public void death(EntityDeathEvent e) {
            Entity entity = e.getEntity();
            Location location = entity.getLocation();
            Random random = new Random(2);
            ItemStack iron = new ItemStack(Material.IRON_NUGGET);
            ItemStack gold = new ItemStack(Material.GOLD_NUGGET);
            int number = random.nextInt() + 1;
            if (e.getEntity() instanceof Monster) {
                if (number == 1) {
                    location.getWorld().dropItem(location, iron);
                if (number == 2) {
                    location.getWorld().dropItem(location, gold);
    I have a feeling it is something to do with the dropItem code.
  2. @Jedd Lupoy
    1. Did you register the class?
    2. You can't provide arguments for Random. Not only that, but you should be using ThreadLocalRandom.current to get the random instance.
    3. Itemstack's amounts are defaulted to 1. No need to set the amount.
    4. nextInt should require the range. That is where you put the 2.
  3. Offline

    Jedd Lupoy

    Thank you so much! It's working :D

    (fixed point 2. and 4.)
    Last edited: Jan 11, 2017
  4. @Jedd Lupoy
    If your problem has been solved, mark this thread as solved.
Thread Status:
Not open for further replies.

Share This Page