Potion effect on creature spawn event

Discussion in 'Plugin Development' started by Pomppujatka, Dec 4, 2013.

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

    Pomppujatka

    Hello, Im trying to make a plugin what makes mobs harder.
    This is my code now

    Code:
    public void onMobSpawn(CreatureSpawnEvent event){
     
    if (event.getEntity() instanceof LivingEntity) {
       
    event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 3));
     
    }
    }
     
  2. Offline

    Likaos

    You will boost animals too like that, remove them, creature spawn is for sure a LivingEntity.
    Use multiplication if you want to easy calculate the lenght of the boost.

    Code:java
    1. static int duration = 20 * 60 * 5; //for 5mn example
    2. public void onMobSpawn(CreatureSpawnEvent event) {
    3. if (monster instanceof Animals || monster instanceof WaterMob) return;
    4. else {
    5. event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, duration , 3));
    6. }
    7. }
     
Thread Status:
Not open for further replies.

Share This Page