Spawning a Villager

Discussion in 'Plugin Development' started by diamondcodes, Nov 14, 2014.

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

    diamondcodes

    Hello,

    I am spawning a Villager with this code,
    Code:java
    1. private void spawnVillager(Location loc) {
    2. Villager v = (Villager) loc.getWorld().spawn(loc, Villager.class);
    3. v.setProfession(Villager.Profession.LIBRARIAN);
    4. v.setCustomName("Ā§dĀ§lTutorial");
    5. v.setCustomNameVisible(true);
    6. v.setAdult();
    7. v.setAgeLock(true);
    8. }


    I am wondering how I would make it so that the Villager does not take damage and he also does not move(Cannot get pushed around & Can not walk)
     
  2. Offline

    Skionz

    setNoDamageTicks(), NMS. Slowness pot, Teleportation, NMS.
     
  3. Offline

    TheCodingCat

    EntityVillager#getAttributeInstance()
    look into that to set their walking speed to ZERO
    Also nonpunishable would require NMS and overriding the method "g" OR you could use the way pf getting fields and setting them (I Think its called reflection i'm not to familiar with NMS :p)
    EDIT: typo :p
     
Thread Status:
Not open for further replies.

Share This Page