Creeper spawning change chance

Discussion in 'Plugin Development' started by bobhull517, Mar 29, 2014.

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


    Hello, I am making a plugin for my own server and I would like some help. I need to figure out how in the world you give a spawned creeper, a 50% chance to become charged automaticly! I have been searching and searching for a while and its getting on my nerves. Another question, is this possible? Thanks for your time!
  2. Offline


    Here you go:
    1. @EventHandler
    2. public void onCreatureSpawn(CreatureSpawnEvent event) {
    3. if (event.getEntityType() == EntityType.CREEPER) {
    4. double change = (double)(Math.random());
    5. if (change < 0.5) {
    6. Creeper creeper = (Creeper)event.getEntity();
    7. creeper.setPowered(true);
    8. }
    9. }
    10. }
  3. Offline


Thread Status:
Not open for further replies.

Share This Page