Creeper spawning change chance

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

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

    bobhull517

    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

    2MBKindiegames

    Here you go:
    Code:java
    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

    bobhull517

Thread Status:
Not open for further replies.

Share This Page