接口 Damageable

所有超级接口:
CommandSender, Entity, Metadatable, Nameable, Permissible, PersistentDataHolder, ServerOperator
所有已知子接口:
AbstractHorse, AbstractSkeleton, AbstractVillager, Ageable, Allay, Ambient, Animals, Armadillo, ArmorStand, Axolotl, Bat, Bee, Blaze, Bogged, Breedable, Breeze, Camel, Cat, CaveSpider, ChestedHorse, Chicken, Cod, ComplexLivingEntity, Cow, Creature, Creeper, Dolphin, Donkey, Drowned, ElderGuardian, EnderDragon, EnderDragonPart, Enderman, Endermite, Enemy, Evoker, Fish, Flying, Fox, Frog, Ghast, Giant, GlowSquid, Goat, Golem, Guardian, Hoglin, Horse, HumanEntity, Husk, Illager, Illusioner, IronGolem, LivingEntity, Llama, MagmaCube, Mob, Monster, Mule, MushroomCow, NPC, Ocelot, Panda, Parrot, Phantom, Pig, Piglin, PiglinAbstract, PiglinBrute, PigZombie, Pillager, Player, PolarBear, PufferFish, Rabbit, Raider, Ravager, Salmon, 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

public interface Damageable extends Entity
表示一个有生命值和可以被伤害的实体(Entity)。
  • 方法详细资料

    • damage

      void damage(double amount)
      给予这个实体一定的伤害.

      原文: Deals the given amount of damage to this entity.

      参数:
      amount - 伤害的数量
    • damage

      void damage(double amount, @Nullable @Nullable Entity source)
      强制某实体伤害这个实体.

      原文: Deals the given amount of damage to this entity from a specified Entity.

      参数:
      amount - 伤害的数量
      source - 伤害来源
    • damage

      @Experimental void damage(double amount, @NotNull @NotNull DamageSource damageSource)
      Deals the given amount of damage to this entity from a specified DamageSource.
      参数:
      amount - amount of damage to deal
      damageSource - source to which the damage should be attributed
    • getHealth

      double getHealth()
      获取当前实体的血量,从0到 getMaxHealth(),当血量为 0 时为死亡状态.。

      原文: Gets the entity's health from 0 to getMaxHealth(), where 0 is dead.

      返回:
      玩家血量,范围是0到最大
    • setHealth

      void setHealth(double health)
      设置这个实体的血量,范围是 0 到 getMaxHealth(),当血量为 0 时为死亡状态。

      原文: Sets the entity's health from 0 to getMaxHealth(), where 0 is dead.

      参数:
      health - 新的血量,范围是 0 到最大.
      抛出:
      IllegalArgumentException - Thrown if the health is < 0 or > getMaxHealth()
    • getAbsorptionAmount

      double getAbsorptionAmount()
      Gets the entity's absorption amount.
      返回:
      absorption amount from 0
    • setAbsorptionAmount

      void setAbsorptionAmount(double amount)
      Sets the entity's absorption amount.

      Note: The amount is capped to the value of Attribute.GENERIC_MAX_ABSORPTION. The effect of this method on that attribute is currently unspecified and subject to change.

      参数:
      amount - new absorption amount from 0
      抛出:
      IllegalArgumentException - thrown if health is < 0 or non-finite.
    • getMaxHealth

      @Deprecated double getMaxHealth()
      已过时。
      获取这个实体所能拥有的最大血量。

      原文: Gets the maximum health this entity has.

      返回:
      最大血量
    • setMaxHealth

      @Deprecated void setMaxHealth(double health)
      已过时。
      设置这个实体所能拥有的最大血量。

      如果当前血量高于这个值,那么新的血量将会设置为这个值。

      Tips: 如果实体有血条,比如(PlayerEnderDragonWither, etc...} 也将会有他们相应的血条样式。

      原文: Sets the maximum health this entity can have.

      If the health of the entity is above the value provided it will be set to that value.

      Note: An entity with a health bar (Player, EnderDragon, Wither, etc...} will have their bar scaled accordingly.

      参数:
      health - amount of health to set the maximum to
    • resetMaxHealth

      @Deprecated void resetMaxHealth()
      已过时。
      重置最大血量为 20。

      原文: Resets the max health to the original amount.