Giving a mob potion effects and enchantments when summoned

Discussion in 'Plugin Development' started by PlusUltra, Dec 18, 2018.

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

    PlusUltra

    I have been researching for a couple hours and trying random stuff but cant seem to figure it out. Im using 1.8.3 snapshot API. Im trying to get a mob to spawn with potion effects(Health, damage, other) and enchantments. If there is any other way of doing it without using potion effects that would be nice
    Code:
    Player p = (Player) sender;
    LivingEntity zombie = (LivingEntity) p.getWorld().getSpawnLocation().getWorld().spawn(p.getLocation().add(2, 0, 0), Zombie.class);
    zombie.setCustomName(ChatColor.BOLD + "SpaceWarrior");
    zombie.setCustomNameVisible(true);
    zombie.getEquipment().setHelmet(new ItemStack(Material.GLASS));
    zombie.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
    zombie.getEquipment().setLeggings(new ItemStack(Material.GOLD_LEGGINGS));
    zombie.getEquipment().setBoots(new ItemStack(Material.LEATHER_BOOTS));
    zombie.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_AXE));
    EDIT by Moderator: Replaced download with code tags
     
    Last edited by a moderator: Dec 18, 2018
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    PlusUltra

  4. Offline

    timtower Administrator Administrator Moderator

    Did you look at the constructors of PotionEffect?
     
  5. Offline

    PlusUltra

    I cant get it to work. Ive looked at the constructors, tried other stuff but still wont work
     
  6. Offline

    timtower Administrator Administrator Moderator

    And what code have you tried?
     
Thread Status:
Not open for further replies.

Share This Page