Interface Leashable

All Superinterfaces:
Audience, CommandSender, Entity, HoverEventSource<HoverEvent.ShowEntity>, Metadatable, Nameable, Permissible, PersistentDataHolder, PersistentDataViewHolder, Pointered, ServerOperator, Sound.Emitter
All Known Subinterfaces:
AbstractHorse, AbstractSkeleton, AbstractVillager, Ageable, Allay, Ambient, Animals, Armadillo, Axolotl, Bat, Bee, Blaze, Boat, Bogged, Breedable, Breeze, Camel, Cat, CaveSpider, ChestBoat, ChestedHorse, Chicken, Cod, Cow, Creature, Creeper, Dolphin, Donkey, Drowned, ElderGuardian, EnderDragon, Enderman, Endermite, Evoker, Fish, Flying, Fox, Frog, Ghast, Giant, GlowSquid, Goat, Golem, Guardian, Hoglin, Horse, Husk, Illager, Illusioner, IronGolem, Llama, MagmaCube, Mob, Monster, Mule, MushroomCow, NPC, Ocelot, Panda, Parrot, Phantom, Pig, Piglin, PiglinAbstract, PiglinBrute, PigZombie, Pillager, PolarBear, PufferFish, Rabbit, Raider, RangedEntity, Ravager, Salmon, SchoolableFish, Sheep, Shulker, Silverfish, Skeleton, SkeletonHorse, Slime, Sniffer, Snowman, Spellcaster, Spider, Squid, Steerable, Stray, Strider, Tadpole, Tameable, TraderLlama, TropicalFish, Turtle, Vex, Villager, Vindicator, WanderingTrader, Warden, WaterMob, Witch, Wither, WitherSkeleton, Wolf, Zoglin, Zombie, ZombieHorse, ZombieVillager

@NullMarked public interface Leashable extends Entity
Represents an entity that can be leashed.
  • Method Details

    • isLeashed

      boolean isLeashed()
      Returns whether the entity is currently leashed.
      Returns:
      whether the entity is leashed
    • getLeashHolder

      Entity getLeashHolder() throws IllegalStateException
      Gets the entity that is currently leading this entity.
      Returns:
      the entity holding the leash
      Throws:
      IllegalStateException - if not currently leashed
    • setLeashHolder

      boolean setLeashHolder(@Nullable Entity holder)
      Sets the leash on this entity to be held by the supplied entity.

      This method has no effect on players.

      Parameters:
      holder - the entity to leash this entity to, or null to unleash
      Returns:
      whether the operation was successful