How do you spawn a green villager?

Discussion in 'Plugin Development' started by bob9, Jul 19, 2012.

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

    bob9

  2. You spawn a villager and then set the profesion ...
    Pseudocode:
    Code:
    Villager villager = (Villager)world.spawnCreature(location, EntityType.VILLAGER);
    villager.setProfession(Villager.Profession.LIBRARIAN);
    So don't just copy paste the code and then complain it doesn't work.

    Read the wiki to find which profession has which robe color.
     
  3. Offline

    bob9

    The profession with the green robe is just "Villager". There is no Profession.VILLAGER so you can't do it the way you said.
     
  4. Offline

    LucasEmanuel

    Well what happens if you dont set a profession?
     
  5. Offline

    bob9

    it's brown, not green.
     
  6. bob9 likes this.
  7. Offline

    bob9

    Would anyone mind doing this? I hope this is added to the next release.
     
  8. Offline

    Scizzr

    Code forked and edited, pull request sent to the CraftBukkit project. :D
     
    V10lator likes this.
  9. Nice work. But please open a bug report at https://bukkit.atlassian.net and link the request to the report and vice-versa. As far as I know the bukkit team doesn't accept pull requests if no report exists. ;)
     
  10. Offline

    Scizzr

    Done :)
    https://bukkit.atlassian.net/browse/BUKKIT-1941

    Apparently the staff don't want this because Minecraft will be changing the code in the future.
    Looks like we'll have to wait for 1.3! ^_^

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
    V10lator and bob9 like this.
  11. :(
    Or use CB/Notch code in the meantime (untested):
    Code:java
    1. Villager villager = (Villager)world.spawnCEntity(location, EntityType.VILLAGER);
    2. ((CraftVillager)villager).getHandle().setProfession(5);
     
    bob9 and TheGreenGamerHD like this.
  12. Offline

    Scizzr

    Good point. :D

    Btw --
    Code:java
    1. Location loc = p.getTargetBlock(null, 120).getLocation().add(0, 1, 0);
    2. Villager mob = (Villager)loc.getWorld().spawn(loc, Villager.class);
    3. ((CraftVillager)mob).getHandle().setProfession(5);


    [​IMG]
     
  13. Offline

    bob9

    just saw this, thanks :)
     
  14. Offline

    Dr. Villager

    bob i know how to spawn a green villager easier all u need to do is /summon Villager ~0 ~0 ~0 {Profession:-1} and he should spawn.
     
Thread Status:
Not open for further replies.

Share This Page