Can't addPotionEffect to mobs

Discussion in 'Plugin Development' started by Qwahchees, Jan 19, 2014.

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

    Qwahchees

    Code:
                                    Entity e = world.spawnEntity(m.loc, m.ent);
                                    if (m.name.contentEquals("zombie")) {
                                        Zombie zombie = (Zombie) e;
                                        EntityEquipment zombieEquips = zombie.getEquipment();
                                        zombieEquips.setHelmet(new ItemStack(helmet, 1));
                                        zombieEquips.setChestplate(new ItemStack(chestPlate, 1));
                                        zombieEquips.setLeggings(new ItemStack(leggings, 1));
                                        zombieEquips.setBoots(new ItemStack(boots, 1));
                                        zombie.setCustomName(mobName);
                                        zombie.setCustomNameVisible(visibleName);
                                        zombie.resetMaxHealth();
                                        zombie.setMaxHealth(hp);
                                        zombie.setHealth(zombie.getMaxHealth());
                                        //Potion Effects are in ticks
                                        zombie.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 1000), true);
                                        zombie.addPotionEffect(new PotionEffect(effect1, potionEffect1Duration, potionEffect1Level), true);
                                        zombie.addPotionEffect(new PotionEffect(effect2, potionEffect2Duration, potionEffect2Level), true);
    Everything else works, just the potion effects won't go through.

    Seems that speed doesn't apply :(
     
  2. Offline

    MistPhizzle

    Code:java
    1.  
    2. zombie.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000, 1000), true);
    3.  

    Check your syntax for PotionEffectType. The value 1000 is a bit long. I do believe the proper code is:
    Code:java
    1.  
    2. zombie.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 0/1/2, 1000);
    3.  


    The middle argument is the level of the potion effect, 0 = Potion Level 1, 1 = Potion Level 2, 2 = Potion Level 3.

    I may be wrong here, as I don't have eclipse open, if that doesn't work, switch the final two arguments. One is time (In Ticks)
     
  3. Offline

    Gater12

Thread Status:
Not open for further replies.

Share This Page