Changing Mobs Health And Color

Discussion in 'Plugin Development' started by xNamesi, Feb 23, 2014.

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

    xNamesi

    So ive got a command /isheep and its suppost to spawn a purple sheep thats invincible with the name "InviSheep". Ive got it to spawn but not sure how to change the name, color and health. heres what ive got:
    Code:java
    1. //Invincible sheep
    2. if(label.equalsIgnoreCase("isheep")) {
    3. if(!sender.hasPermission("ezcmd.isheep")) {
    4. sender.sendMessage(ChatColor.YELLOW + "eZCommand" + ChatColor.DARK_GRAY + ChatColor.BOLD + ">" + ChatColor.RED + " You Don't Have Permission!");
    5. return true;
    6. }
    7. //Code To Spawn Invincible Sheep Here!
    8. p.sendMessage("Your Invincible Sheep Has Been Spawned");
    9. Location loc = p.getLocation();
    10. LivingEntity mob = (LivingEntity)p.getWorld().spawnEntity(loc, EntityType.SHEEP);
    11. }


    Please help somone :(
     
  2. Offline

    Brendyn Todd

    To set the name you can use: setCustomName(ChatColor.COLOR + name);

    And you can make it always visible, instead of only visible when a player looks at it, with setCustomNameVisible(true);

    To set the color I believe sheep have a setColor() method that takes DyeColors.
     
  3. Offline

    xNamesi

    where would i put this. could you add it in to the code above then paste it again to show me
     
  4. Offline

    thepluginbros


    Code:java
    1. //Invincible sheep
    2. if(label.equalsIgnoreCase("isheep")) {
    3. if(!sender.hasPermission("ezcmd.isheep")) {
    4. sender.sendMessage(ChatColor.YELLOW + "eZCommand" + ChatColor.DARK_GRAY + ChatColor.BOLD + ">" + ChatColor.RED + " You Don't Have Permission!");
    5. return true;
    6. }
    7. p.sendMessage("Your Invincible Sheep Has Been Spawned");
    8. Location loc = p.getLocation();
    9.  
    10. Sheep sheep = p.getWorld().spawn(loc, Sheep.class);
    11. sheep.setColor(DyeColor.PINK);
    12. sheep.setCustomName("YourCustomName");
    13. sheep.setCustomNameVisible(true);
    14. }
     
  5. Offline

    xNamesi

    Thanks ill try ti out :D
     
Thread Status:
Not open for further replies.

Share This Page