接口 HumanEntity

所有超级接口:
AnimalTamer, Attributable, CommandSender, Damageable, Entity, InventoryHolder, LivingEntity, Metadatable, Nameable, Permissible, PersistentDataHolder, ProjectileSource, ServerOperator
所有已知子接口:
Player

public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder
代表人类实体, 比如一个NPC或一名玩家
  • 方法详细资料

    • getName

      返回该玩家的玩家名.

      原文:Returns the name of this player

      指定者:
      getName 在接口中 AnimalTamer
      指定者:
      getName 在接口中 CommandSender
      返回:
      玩家名
    • getInventory

      获取玩家的物品栏(俗称背包).

      原文:Get the player's inventory.

      指定者:
      getInventory 在接口中 InventoryHolder
      返回:
      玩家物品栏, 包含盔甲槽
    • getEnderChest

      @NotNull @NotNull Inventory getEnderChest()
      获取玩家的末影箱物品栏.

      原文:Get the player's EnderChest inventory

      返回:
      玩家的末影箱
    • getMainHand

      @NotNull @NotNull MainHand getMainHand()
      获取玩家设置的主手.

      原文:Gets the player's selected main hand

      返回:
      玩家主手
    • setWindowProperty

      boolean setWindowProperty(@NotNull InventoryView.Property prop, int value)
      若玩家当前打开了一个物品栏窗口, 此方法将设置窗口的属性, 比如酿造台的酿造进度.

      原文:If the player currently has an inventory window open, this method will set a property of that window, such as the state of a progress bar.

      参数:
      prop - 窗口属性
      value - 要设置的属性值
      返回:
      若属性成功设置返回true
    • getEnchantmentSeed

      int getEnchantmentSeed()
      Gets the player's current enchantment seed. The Seed is used to generate enchantment options in the enchanting table for the player.
      返回:
      the player's enchantment seed
    • setEnchantmentSeed

      void setEnchantmentSeed(int seed)
      Sets the player's enchantment seed. The Seed is used to generate enchantment options in the enchanting table for the player.
      参数:
      seed - the player's new enchantment seed
    • getOpenInventory

      @NotNull @NotNull InventoryView getOpenInventory()
      获取玩家正在查看的物品栏. 如果他们没有打开任何物品栏窗口, 将返回他们的内部合成视图(玩家背包的那四个格子?).

      原文:Gets the inventory view the player is currently viewing. If they do not have an inventory window open, it returns their internal crafting view.

      返回:
      物品栏视图
    • openInventory

      打开一个物品栏, 窗口顶部为你指定的物品栏, 底部为玩家物品栏(背包).

      原文:Opens an inventory window with the specified inventory on the top and the player's inventory on the bottom.

      参数:
      inventory - 要打开的物品栏
      返回:
      新打开的物品栏的视图
    • openWorkbench

      @Nullable @Nullable InventoryView openWorkbench(@Nullable @Nullable Location location, boolean force)
      打开一个空白工作台物品栏界面, 玩家物品栏(背包)在底部.

      原文:Opens an empty workbench inventory window with the player's inventory on the bottom.

      参数:
      location - 工作台位置. 若为null, 将使用玩家所处位置
      force - 若为false, 同时指定位置不是工作台方块, 将不会打开工作台物品栏, 并返回null(true就是不管怎样都向 玩家展示工作台界面)
      返回:
      新打开的物品栏的视图, 如果不能打开返回null
    • openEnchanting

      @Nullable @Nullable InventoryView openEnchanting(@Nullable @Nullable Location location, boolean force)
      打开一个空白附魔台物品栏界面, 玩家物品栏(背包)在底部.

      原文:Opens an empty enchanting inventory window with the player's inventory on the bottom.

      参数:
      location - 附魔台位置. 若为null, 将使用玩家所处位置
      force - 若为false, 同时指定位置不是附魔台方块, 将不会打开工作台物品栏, 并返回null(true就是不管怎样都向 玩家展示附魔台界面)
      返回:
      新打开的物品栏的视图, 如果不能打开返回null
    • openInventory

      void openInventory(@NotNull @NotNull InventoryView inventory)
      打开指定的物品栏.

      原文:Opens an inventory window to the specified inventory view.

      参数:
      inventory - 要打开的物品栏视图
    • openMerchant

      @Nullable @Nullable InventoryView openMerchant(@NotNull @NotNull Villager trader, boolean force)
      与某村民开始交易. 注意: 同一时间内只有一名玩家可以与此村民进行交易. 欲使多名玩家能同时与此村民进行交易, 请将“force”参数设为true.

      原文:Starts a trade between the player and the villager. Note that only one player may trade with a villager at once. You must use the force parameter for this.

      参数:
      trader - 与哪位村民交易. 不能为null
      force - 是否强制开始交易, 即使另一名玩家正在与此村民交易
      返回:
      新打开的物品栏的视图, 如果不能打开返回null
    • openMerchant

      @Nullable @Nullable InventoryView openMerchant(@NotNull @NotNull Merchant merchant, boolean force)
      与某商人开始交易. 注意: 同一时间内只有一名玩家可以与此商人进行交易. 欲使多名玩家能同时与此商人进行交易, 请将“force”参数设为true.

      原文:Starts a trade between the player and the merchant. Note that only one player may trade with a merchant at once. You must use the force parameter for this.

      参数:
      merchant - 与哪个商人交易. 不能为null
      force - 是否强制开始交易, 即使另一名玩家正在与此商人交易
      返回:
      新打开的物品栏的视图, 如果不能打开返回null
    • closeInventory

      void closeInventory()
      强制关闭玩家当前打开的物品栏视图.

      原文:Force-closes the currently open inventory view for this player, if any.

    • getItemInHand

      已过时。
      人类现能双持, 请使用 PlayerInventory 中更明确的方法
      返回你手握的物品, 可能为空.

      原文:Returns the ItemStack currently in your hand, can be empty.

      返回:
      你正在握持的物品的ItemStack(物品堆)对象
    • setItemInHand

      @Deprecated void setItemInHand(@Nullable @Nullable ItemStack item)
      已过时。
      人类现能双持, 请使用 PlayerInventory 中更明确的方法
      设置你手握的物品, 将替换你所持的任何物品.

      原文:Sets the item to the given ItemStack, this will replace whatever the user was holding.

      参数:
      item - 要设置的物品堆
    • getItemOnCursor

      @NotNull @NotNull ItemStack getItemOnCursor()
      返回你的鼠标正在拖动的物品, 可能为空. 如果玩家没有打开任何窗口, 将永远为空(AIR).

      译注:这个方法是适用于物品拖动场景的, 只有鼠标指针在物品上而没有拖动它是获取不到的(AIR).

      原文:Returns the ItemStack currently on your cursor, can be empty. Will always be empty if the player currently has no open window.

      返回:
      你正在拖动的物品的ItemStack对象
    • setItemOnCursor

      void setItemOnCursor(@Nullable @Nullable ItemStack item)
      设置你正在拖动的物品, 将替换你所拖动的任何物品. 如果玩家没有打开任何窗口, 将永远为空(AIR).

      原文:Sets the item to the given ItemStack, this will replace whatever the user was moving. Will always be empty if the player currently has no open window.

      参数:
      item - 要设置的物品堆
    • hasCooldown

      boolean hasCooldown(@NotNull @NotNull Material material)
      检查指定物品是否处于冷却状态.

      原文:Check whether a cooldown is active on the specified material.

      参数:
      material - 要检查的物品种类
      返回:
      该物品是否进入了冷却
      抛出:
      IllegalArgumentException - 如果 material 不是物品
    • getCooldown

      int getCooldown(@NotNull @NotNull Material material)
      获取指定物品的冷却时长 (以tick为单位).

      原文:Get the cooldown time in ticks remaining for the specified material.

      参数:
      material - 要检查的物品种类
      返回:
      剩余冷却时长 (以tick为单位)
      抛出:
      IllegalArgumentException - 如果 material 不是物品
    • setCooldown

      void setCooldown(@NotNull @NotNull Material material, int ticks)
      设置指定物品的冷却时长. 设为0 tick将导致移除此物品的冷却.

      冷却被服务器用来针对某些物品比如末影珍珠、盾牌等以防止它们被经常重复使用.

      请注意: 冷却时间自身不会阻止某个物品被用来使用或攻击.

      原文:Set a cooldown on the specified material for a certain amount of ticks. ticks. 0 ticks will result in the removal of the cooldown.

      Cooldowns are used by the server for items such as ender pearls and shields to prevent them from being used repeatedly.

      Note that cooldowns will not by themselves stop an item from being used for attacking.

      参数:
      material - 为哪个物品设置冷却
      ticks - 冷却时长(以tick为单位)或设为0来移除它
      抛出:
      IllegalArgumentException - 如果 material 不是物品
    • getSleepTicks

      int getSleepTicks()
      获取玩家的睡眠时间 (以tick为单位), 该值可能有上限.

      原文:Get the sleep ticks of the player. This value may be capped.

      返回:
      玩家睡了多久
    • sleep

      boolean sleep(@NotNull @NotNull Location location, boolean force)
      Attempts to make the entity sleep at the given location.
      The location must be in the current world and have a bed placed at the location. The game may also enforce other requirements such as proximity to bed, monsters, and dimension type if force is not set.
      参数:
      location - the location of the bed
      force - whether to try and sleep at the location even if not normally possible
      返回:
      whether the sleep was successful
    • wakeup

      void wakeup(boolean setSpawnLocation)
      Causes the player to wakeup if they are currently sleeping.
      参数:
      setSpawnLocation - whether to set their spawn location to the bed they are currently sleeping in
      抛出:
      IllegalStateException - if not sleeping
    • getBedLocation

      @NotNull @NotNull Location getBedLocation()
      Gets the location of the bed the player is currently sleeping in
      返回:
      location
      抛出:
      IllegalStateException - if not sleeping
    • getGameMode

      @NotNull @NotNull GameMode getGameMode()
      获取此人类当前的游戏模式.

      原文:Gets this human's current GameMode

      返回:
      游戏模式
    • setGameMode

      void setGameMode(@NotNull @NotNull GameMode mode)
      设置此人类的游戏模式.

      原文:Sets this human's current GameMode

      参数:
      mode - 新游戏模式
    • isBlocking

      boolean isBlocking()
      检查玩家是否正在格挡 (换言之, 就是他们使用盾牌, 进入了格挡状态).

      原文:Check if the player is currently blocking (ie with a shield).

      返回:
      玩家是否正在格挡
    • isHandRaised

      boolean isHandRaised()
      检查玩家是否举起了他们的手 (换言之, 就是他们刚使用盾牌(这时isBlocking返回false), 数百毫秒后将进入格挡状态(这时isBlocking返回true)).

      原文:Check if the player currently has their hand raised (ie about to begin blocking).

      返回:
      玩家是否举起了他们的手
    • getItemInUse

      @Nullable @Nullable ItemStack getItemInUse()
      Gets the item that the player is using (eating food, drawing back a bow, blocking, etc.)
      返回:
      the item being used by the player, or null if they are not using an item
    • getExpToLevel

      int getExpToLevel()
      获取玩家升级所需经验总额.

      原文:Get the total amount of experience required for the player to level

      返回:
      升级所需经验
    • getAttackCooldown

      float getAttackCooldown()
      Gets the current cooldown for a player's attack. This is used to calculate damage, with 1.0 representing a fully charged attack and 0.0 representing a non-charged attack
      返回:
      A float between 0.0-1.0 representing the progress of the charge
    • discoverRecipe

      boolean discoverRecipe(@NotNull @NotNull NamespacedKey recipe)
      Discover a recipe for this player such that it has not already been discovered. This method will add the key's associated recipe to the player's recipe book.
      参数:
      recipe - the key of the recipe to discover
      返回:
      whether or not the recipe was newly discovered
    • discoverRecipes

      int discoverRecipes(@NotNull @NotNull Collection<NamespacedKey> recipes)
      Discover a collection of recipes for this player such that they have not already been discovered. This method will add the keys' associated recipes to the player's recipe book. If a recipe in the provided collection has already been discovered, it will be silently ignored.
      参数:
      recipes - the keys of the recipes to discover
      返回:
      the amount of newly discovered recipes where 0 indicates that none were newly discovered and a number equal to recipes.size() indicates that all were new
    • undiscoverRecipe

      boolean undiscoverRecipe(@NotNull @NotNull NamespacedKey recipe)
      Undiscover a recipe for this player such that it has already been discovered. This method will remove the key's associated recipe from the player's recipe book.
      参数:
      recipe - the key of the recipe to undiscover
      返回:
      whether or not the recipe was successfully undiscovered (i.e. it was previously discovered)
    • undiscoverRecipes

      int undiscoverRecipes(@NotNull @NotNull Collection<NamespacedKey> recipes)
      Undiscover a collection of recipes for this player such that they have already been discovered. This method will remove the keys' associated recipes from the player's recipe book. If a recipe in the provided collection has not yet been discovered, it will be silently ignored.
      参数:
      recipes - the keys of the recipes to undiscover
      返回:
      the amount of undiscovered recipes where 0 indicates that none were undiscovered and a number equal to recipes.size() indicates that all were undiscovered
    • hasDiscoveredRecipe

      boolean hasDiscoveredRecipe(@NotNull @NotNull NamespacedKey recipe)
      Check whether or not this entity has discovered the specified recipe.
      参数:
      recipe - the key of the recipe to check
      返回:
      true if discovered, false otherwise
    • getDiscoveredRecipes

      @NotNull @NotNull Set<NamespacedKey> getDiscoveredRecipes()
      Get an immutable set of recipes this entity has discovered.
      返回:
      all discovered recipes
    • getShoulderEntityLeft

      @Deprecated @Nullable @Nullable Entity getShoulderEntityLeft()
      已过时。
      Bukkit中目前还没有关于序列化实体的语义(格式)的良好定义. 请谨慎使用.
      获取栖息在玩家左肩上的实体 (通常情况下这是鹦鹉的行为, 目前客户端没有为其他实体定义这一行为), 若没有则返回null.

      返回的实体不会在世界内生成, 因此除非这个实体是首次生成的, 大部分对该实体的操作是无效的.

      原文:Gets the entity currently perched on the left shoulder or null if no entity.
      The returned entity will not be spawned within the world, so most operations are invalid unless the entity is first spawned in.

      返回:
      坐在玩家左肩的实体
    • setShoulderEntityLeft

      @Deprecated void setShoulderEntityLeft(@Nullable @Nullable Entity entity)
      已过时。
      Bukkit中目前还没有关于序列化实体的语义(格式)的良好定义. 请谨慎使用.
      设置栖息在玩家左肩上的实体(设为null则移除). 该方法将从世界中删除该实体.

      请注意: 只有实体的副本将被设置为显示在肩膀上的实体.

      也请注意游戏客户端目前只会渲染鹦鹉的坐在肩膀上的行为.

      原文:Sets the entity currently perched on the left shoulder, or null to remove. This method will remove the entity from the world.
      Note that only a copy of the entity will be set to display on the shoulder.
      Also note that the client will currently only render Parrot entities.

      参数:
      entity - 坐在玩家左肩的实体
    • getShoulderEntityRight

      @Deprecated @Nullable @Nullable Entity getShoulderEntityRight()
      已过时。
      Bukkit中目前还没有关于序列化实体的语义(格式)的良好定义. 请谨慎使用.
      获取栖息在玩家右肩上的实体, 若没有则返回null.

      返回的实体不会在世界内生成, 因此除非这个实体是首次生成的, 大部分对该实体的操作是无效的.

      原文:Gets the entity currently perched on the right shoulder or null if no entity.
      The returned entity will not be spawned within the world, so most operations are invalid unless the entity is first spawned in.

      返回:
      坐在玩家右肩的实体
    • setShoulderEntityRight

      @Deprecated void setShoulderEntityRight(@Nullable @Nullable Entity entity)
      已过时。
      Bukkit中目前还没有关于序列化实体的语义(格式)的良好定义. 请谨慎使用.
      设置栖息在玩家右肩上的实体(设为null则移除). 该方法将从世界中删除该实体.

      请注意: 只有实体的副本将被设置为显示在肩膀上的实体.

      也请注意游戏客户端目前只会渲染鹦鹉的坐在肩膀上的行为.

      原文:Sets the entity currently perched on the right shoulder, or null to remove. This method will remove the entity from the world.
      Note that only a copy of the entity will be set to display on the shoulder.
      Also note that the client will currently only render Parrot entities.

      参数:
      entity - 坐在玩家右肩的实体
    • dropItem

      boolean dropItem(boolean dropAll)
      Make the entity drop the item in their hand.
      This will force the entity to drop the item they are holding with an option to drop the entire ItemStack or just 1 of the items.
      参数:
      dropAll - True to drop entire stack, false to drop 1 of the stack
      返回:
      True if item was dropped successfully
    • getExhaustion

      float getExhaustion()
      获取玩家的疲劳度.

      疲劳度控制者玩家的饥饿消耗. 当玩家达到一定的疲劳度时, 你的饱食度就会下降, 并且疲劳度归零.

      译注:如果饱食度为0, 那么就扣饥饿度.

      译注2:运动会产生疲劳度.

      原文:Gets the players current exhaustion level.

      Exhaustion controls how fast the food level drops. While you have a certain amount of exhaustion, your saturation will drop to zero, and then your food will drop to zero.

      返回:
      疲劳度
    • setExhaustion

      void setExhaustion(float value)
      设置玩家的疲劳度.

      原文:Sets the players current exhaustion level

      参数:
      value - 疲劳度
    • getSaturation

      float getSaturation()
      获取玩家的饱食度(不是饥饿度).

      饱食度是一个饥饿度的缓存. 当你的饱食度 > 0的时候,饥饿度是不会下降的.

      译注:就是说, 吃东西的时候, 你的饥饿度被填满了, 而多出来的部分就是隐藏的饱食度. 当你的疲劳值(见getExhaustion()) 达到一定程度时, 如果饱食度不为0, 那么先扣饱食度. 只有当没饱食度时, 才会扣饥饿度. 其实饱食度就是饥饿度, 只不过是隐藏的.

      原文:Gets the players current saturation level.

      Saturation is a buffer for food level. Your food level will not drop if you are saturated > 0.

      返回:
      饱食度
    • setSaturation

      void setSaturation(float value)
      设置玩家的饱食度(不是饥饿度).

      原文:Sets the players current saturation level

      参数:
      value - 饱食度
    • getFoodLevel

      int getFoodLevel()
      获取玩家的饥饿度(不是饱食度).

      原文:Gets the players current food level

      返回:
      饥饿度
    • setFoodLevel

      void setFoodLevel(int value)
      设置玩家的饥饿度(不是饱食度).

      原文:Sets the players current food level

      参数:
      value - 饥饿度
    • getSaturatedRegenRate

      int getSaturatedRegenRate()
      Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have saturation and their food level is >= 20. Default is 10.
      返回:
      the regeneration rate
    • setSaturatedRegenRate

      void setSaturatedRegenRate(int ticks)
      Set the regeneration rate (1 health per x ticks) of the HumanEntity when they have saturation and their food level is >= 20. Default is 10. Not affected if the world's difficulty is peaceful.
      参数:
      ticks - the amount of ticks to gain 1 health.
    • getUnsaturatedRegenRate

      int getUnsaturatedRegenRate()
      Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have no saturation and their food level is >= 18. Default is 80.
      返回:
      the regeneration rate
    • setUnsaturatedRegenRate

      void setUnsaturatedRegenRate(int ticks)
      Get the regeneration rate (1 health per x ticks) of the HumanEntity when they have no saturation and their food level is >= 18. Default is 80. Not affected if the world's difficulty is peaceful.
      参数:
      ticks - the amount of ticks to gain 1 health.
    • getStarvationRate

      int getStarvationRate()
      Get the starvation rate (1 health per x ticks) of the HumanEntity. Default is 80.
      返回:
      the starvation rate
    • setStarvationRate

      void setStarvationRate(int ticks)
      Get the starvation rate (1 health per x ticks) of the HumanEntity. Default is 80.
      参数:
      ticks - the amount of ticks to lose 1 health
    • getLastDeathLocation

      @Nullable @Nullable Location getLastDeathLocation()
      Gets the player's last death location.
      返回:
      the last death location if it exists, otherwise null.
    • setLastDeathLocation

      void setLastDeathLocation(@Nullable @Nullable Location location)
      Sets the player's last death location.
      Note: This data is updated in the player's client only when the player respawns.
      参数:
      location - where to set the last death player location
    • fireworkBoost

      @Nullable @Nullable Firework fireworkBoost(@NotNull @NotNull ItemStack fireworkItemStack)
      Perform a firework boost.

      This method will only work such that LivingEntity.isGliding() is true and the entity is actively gliding with an elytra. Additionally, the supplied fireworkItemStack must be a firework rocket. The power of the boost will directly correlate to FireworkMeta.getPower().

      参数:
      fireworkItemStack - the firework item stack to use to glide
      返回:
      the attached Firework, or null if the entity could not be boosted
      抛出:
      IllegalArgumentException - if the fireworkItemStack is not a firework