Problem/Bug I need help with fixing a bug (Please read)

Discussion in 'General Help' started by MuffinSwag, Apr 5, 2015.

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

    MuffinSwag

    hello bukkit, today I tried to make a plugin to reduce the amount of wither skeletons that will spawn in nether skeleton grinders because the spawn rate at the moment is OP and people are able to get withers fast to use on raids etc. for some reason though , now, in the nether, skeletons don't spawn at all, and neither do wither skeletons. Anybody know what I did wrong? I assume it has something to do with the "random" code I used, however its the same code I use in my crates plugin so if it doesn't work please give me some example code of what will? here is my code:


    import java.util.Random;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Skeleton;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.CreatureSpawnEvent;

    public class Wskelnerf implements Listener {

    @EventHandler

    public void SpawnWSkelley(CreatureSpawnEvent e){

    Entity entity = e.getEntity();

    if(entity instanceof Skeleton){

    Skeleton skeleton = (Skeleton) entity;

    if(skeleton.getWorld().getName().equalsIgnoreCase("world_nether")){

    Random rand = new Random();

    int r = rand.nextInt(5);

    if(r > 4){

    } else {

    e.setCancelled(true);

    }

    }

    }

    }

    }

    please note: I DID register the events in the Main class, thats not the problem. any ideas?

    and I did test it, skeletons spawn in the overworked, but no matter what they won't spawn in the nether

    EDIT: PROBLEM SOLVED. instead of:

    Random rand = new Random();

    int r = rand.nextInt(5);

    if(r > 4){

    } else {

    e.setCancelled(true);

    You need to make the if statement if(r>=4) (rather than if(r>4) )
     
    Last edited: Apr 5, 2015
Thread Status:
Not open for further replies.

Share This Page