Interface Villager

All Superinterfaces:
AbstractVillager, Ageable, Attributable, Breedable, CommandSender, Creature, Damageable, Entity, InventoryHolder, LivingEntity, Lootable, Merchant, Metadatable, Mob, Nameable, NPC, Permissible, PersistentDataHolder, ProjectileSource, ServerOperator

public interface Villager extends AbstractVillager
Represents a villager NPC
  • Method Details

    • getProfession

      @NotNull Villager.Profession getProfession()
      Gets the current profession of this villager.
      Current profession.
    • setProfession

      void setProfession(@NotNull Villager.Profession profession)
      Sets the new profession of this villager.
      profession - New profession.
    • getVillagerType

      @NotNull Villager.Type getVillagerType()
      Gets the current type of this villager.
      Current type.
    • setVillagerType

      void setVillagerType(@NotNull Villager.Type type)
      Sets the new type of this villager.
      type - New type.
    • getVillagerLevel

      int getVillagerLevel()
      Gets the level of this villager. A villager with a level of 1 and no experience is liable to lose its profession.
      this villager's level
    • setVillagerLevel

      void setVillagerLevel(int level)
      Sets the level of this villager. A villager with a level of 1 and no experience is liable to lose its profession.
      level - the new level
      IllegalArgumentException - if level not between [1, 5]
    • getVillagerExperience

      int getVillagerExperience()
      Gets the trading experience of this villager.
      trading experience
    • setVillagerExperience

      void setVillagerExperience(int experience)
      Sets the trading experience of this villager.
      experience - new experience
      IllegalArgumentException - if experience < 0
    • sleep

      boolean sleep(@NotNull Location location)
      Attempts to make this villager sleep at the given location.
      The location must be in the current world and have a bed placed at the location. The villager will put its head on the specified block while sleeping.
      location - the location of the bed
      whether the sleep was successful
    • wakeup

      void wakeup()
      Causes this villager to wake up if he's currently sleeping.
      IllegalStateException - if not sleeping
    • shakeHead

      void shakeHead()
      Causes this villager to shake his head.
    • zombify

      @Nullable ZombieVillager zombify()
      Convert this Villager into a ZombieVillager as if it was killed by a Zombie. Note: this will fire a EntityTransformEvent
      the converted entity ZombieVillager or null if the conversion its cancelled