程序包 org.bukkit

接口 RegionAccessor

所有已知子接口:
LimitedRegion, World

public interface RegionAccessor
RegionAccessor 提供了获取、修改和生成 生物群系、方块状态 和 实体 的能力, 同时也支持生成一些基础结构。
  • 方法详细资料

    • getBiome

      获取指定位置的生物群系.

      原文:Gets the Biome at the given Location.

      参数:
      location - 位置
      返回:
      此位置处的生物群系
    • getBiome

      @NotNull @NotNull Biome getBiome(int x, int y, int z)
      获取指定坐标的生物群系.

      原文:Gets the Biome at the given coordinates.

      参数:
      x - 方块的x坐标
      y - 方块的y坐标
      z - 方块的z坐标
      返回:
      指定坐标位置处的生物群系
    • setBiome

      void setBiome(@NotNull @NotNull Location location, @NotNull @NotNull Biome biome)
      设置指定位置的生物群系.

      原文:Sets the Biome at the given Location.

      参数:
      location - 位置
      biome - 此方块的新生物群系
    • setBiome

      void setBiome(int x, int y, int z, @NotNull @NotNull Biome biome)
      设置指定方块坐标的生物群系.

      原文:Sets the Biome for the given block coordinates.

      参数:
      x - 方块的x坐标
      y - 方块的y坐标
      z - 方块的z坐标
      biome - 此方块的新生物群系
    • getBlockState

      获取指定位置的方块状态.

      原文:Gets the BlockState at the given Location.

      参数:
      location - 方块状态的位置
      返回:
      指定位置的方块状态
    • getBlockState

      @NotNull @NotNull BlockState getBlockState(int x, int y, int z)
      获取指定坐标的方块状态.

      原文:Gets the BlockState at the given coordinates.

      参数:
      x - 方块状态的x坐标
      y - 方块状态的y坐标
      z - 方块状态的z坐标
      返回:
      指定坐标处的方块状态
    • getBlockData

      获取指定位置的方块数据.

      原文:Gets the BlockData at the given Location.

      参数:
      location - 方块数据的位置
      返回:
      指定位置的方块数据
    • getBlockData

      @NotNull @NotNull BlockData getBlockData(int x, int y, int z)
      获取指定坐标的方块数据.

      原文:Gets the BlockData at the given coordinates.

      参数:
      x - 方块数据的x坐标
      y - 方块数据的y坐标
      z - 方块数据的z坐标
      返回:
      指定坐标处的方块数据
    • getType

      获取指定位置的方块类型.

      原文:Gets the type of the block at the given Location.

      参数:
      location - 方块的位置
      返回:
      指定坐标处的材质类型
    • getType

      @NotNull @NotNull Material getType(int x, int y, int z)
      获取指定坐标的方块类型.

      原文:Gets the type of the block at the given coordinates.

      参数:
      x - 方块的x坐标
      y - 方块的y坐标
      z - 方块的z坐标
      返回:
      指定坐标处的材质类型
    • setBlockData

      void setBlockData(@NotNull @NotNull Location location, @NotNull @NotNull BlockData blockData)
      设置指定位置的方块数据.

      原文:Sets the BlockData at the given Location.

      参数:
      location - 方块的位置
      blockData - 要设置的方块数据
    • setBlockData

      void setBlockData(int x, int y, int z, @NotNull @NotNull BlockData blockData)
      设置指定坐标的方块数据.

      原文:Sets the BlockData at the given coordinates.

      参数:
      x - 方块的x坐标
      y - 方块的y坐标
      z - 方块的z坐标
      blockData - 要设置的方块数据
    • setType

      void setType(@NotNull @NotNull Location location, @NotNull @NotNull Material material)
      设置指定位置的方块类型.

      原文:Sets the Material at the given Location.

      参数:
      location - 方块的位置
      material - 要设置的方块类型
    • setType

      void setType(int x, int y, int z, @NotNull @NotNull Material material)
      设置指定坐标的方块类型.

      原文:Sets the Material at the given coordinates.

      参数:
      x - 方块的x坐标
      y - 方块的y坐标
      z - 方块的z坐标
      material - 要设置的方块类型
    • generateTree

      boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type)
      在指定位置创建一棵树.

      原文:Creates a tree at the given Location.

      参数:
      location - 生成树的位置
      random - 用于生成树的随机数生成器
      type - 要创建的树的类型
      返回:
      如果树创建成功则返回true,否则返回false
    • generateTree

      boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type, @Nullable @Nullable Consumer<? super BlockState> stateConsumer)
      在指定位置创建一棵树.

      提供的 consumer 会在因树木生成而改变的每个方块上调用。当 consumer 被调用时, 世界尚未被修改。这意味着在 consumer 中调用 getBlockState(Location) 会返回生成前方块的状态。

      在 consumer 中对 方块状态 的修改会被保留, 因此无需调用 BlockState.update().

      原文:Creates a tree at the given Location. The provided consumer gets called for every block which gets changed as a result of the tree generation. When the consumer gets called no modifications to the world are done yet. Which means, that calling getBlockState(Location) in the consumer while return the state of the block before the generation. Modifications done to the BlockState in the consumer are respected, which means that it is not necessary to call BlockState.update().

      参数:
      location - 生成树的位置
      random - 用于生成树的随机数生成器
      type - 要创建的树的类型
      stateConsumer - 在每个被改变的方块上调用的 consumer
      返回:
      如果树创建成功则返回true,否则返回false
    • generateTree

      boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type, @Nullable @Nullable Predicate<? super BlockState> statePredicate)
      在指定位置创建一棵树.

      提供的 predicate 会在因树木生成而改变的每个方块上调用。当 predicate 被调用时, 世界尚未被修改。这意味着在 predicate 中调用 getBlockState(Location) 会返回生成前方块的状态。

      如果 predicate 返回 true,则该方块会被设置到世界中。 如果返回 false,则该方块不会被设置到世界中。

      原文:Creates a tree at the given Location. The provided predicate gets called for every block which gets changed as a result of the tree generation. When the predicate gets called no modifications to the world are done yet. Which means, that calling getBlockState(Location) in the predicate will return the state of the block before the generation. If the predicate returns true the block gets set in the world. If it returns false the block won't get set in the world.

      参数:
      location - 生成树的位置
      random - 用于生成树的随机数生成器
      type - 要创建的树的类型
      statePredicate - 用于测试是否应设置方块的 predicate
      返回:
      如果树创建成功则返回true,否则返回false
    • spawnEntity

      在指定的位置创建一个实体.

      原文: Creates a entity at the given Location

      参数:
      location - 生成实体的位置
      type - 生成的实体
      返回:
      生成成功则返回此方法创建的实体
    • spawnEntity

      @NotNull @NotNull Entity spawnEntity(@NotNull @NotNull Location loc, @NotNull @NotNull EntityType type, boolean randomizeData)
      在指定位置创建一个新实体.

      原文:Creates a new entity at the given Location.

      参数:
      loc - 实体将被生成的位置
      type - 决定要生成的实体类型的实体类型
      randomizeData - 是否应在生成前随机化实体的数据。默认情况下,实体在生成前会根据其装备、年龄、 属性等进行随机化。随机化的例子包括羊的颜色、怪物装备上的随机附魔, 甚至僵尸成为骑鸡小僵尸。如果设置为false,实体在生成前不会被随机化, 这意味着它们的所有数据将保持默认状态,不会对实体进行进一步修改。 值得注意的是,只有继承 Mob 接口的实体 才提供生成随机化逻辑,因此此参数对其他类型的实体无效。
      返回:
      生成的实体实例
    • getEntities

      @NotNull @NotNull List<Entity> getEntities()
      获取此 RegionAccessor 中所有实体的列表.

      原文:Get a list of all entities in this RegionAccessor.

      返回:
      当前驻留在此世界访问器中的所有实体的列表
    • getLivingEntities

      @NotNull @NotNull List<LivingEntity> getLivingEntities()
      获取此 RegionAccessor 中所有生物实体的列表.

      原文:Get a list of all living entities in this RegionAccessor.

      返回:
      当前驻留在此世界访问器中的所有生物实体的列表
    • getEntitiesByClass

      @NotNull <T extends Entity> @NotNull Collection<T> getEntitiesByClass(@NotNull @NotNull Class<T> cls)
      获取此 RegionAccessor 中匹配给定类/接口的所有实体的集合.

      原文:Get a collection of all entities in this RegionAccessor matching the given class/interface.

      类型参数:
      T - 实体子类
      参数:
      cls - 表示要匹配的实体类型的类
      返回:
      当前驻留在此世界访问器中的所有匹配给定类/接口的实体的列表
    • getEntitiesByClasses

      @NotNull @NotNull Collection<Entity> getEntitiesByClasses(@NotNull @NotNull Class<?>... classes)
      获取此 RegionAccessor 中匹配给定任意类/接口的所有实体的集合.

      原文:Get a collection of all entities in this RegionAccessor matching any of the given classes/interfaces.

      参数:
      classes - 表示要匹配的实体类型的类
      返回:
      当前驻留在此世界访问器中的所有匹配给定一个或多个类/接口的实体的列表
    • createEntity

      @NotNull <T extends Entity> T createEntity(@NotNull @NotNull Location location, @NotNull @NotNull Class<T> clazz)
      在指定位置创建一个特定类的实体,但不会将其生成到世界中.

      注意:创建的实体会保持对其创建时所在世界的引用, 应注意确保实体的生命周期不超过世界实例,否则会导致内存泄漏。

      原文:Creates an entity of a specific class at the given Location but does not spawn it in the world. Note: The created entity keeps a reference to the world it was created in, care should be taken that the entity does not outlive the world instance as this will lead to memory leaks.

      类型参数:
      T - 要创建的实体的类
      参数:
      location - 创建实体的位置
      clazz - 要生成的实体的类
      返回:
      创建的实体实例
      另请参阅:
    • spawn

      @NotNull <T extends Entity> T spawn(@NotNull @NotNull Location location, @NotNull @NotNull Class<T> clazz) throws IllegalArgumentException
      在指定的位置根据给定的类生成一个实体.

      原文:Spawn an entity of a specific class at the given Location

      类型参数:
      T - 生成实体的类
      参数:
      location - 生成实体的位置
      clazz - 生成实体的类
      返回:
      一个生成的实体实例
      抛出:
      IllegalArgumentException - 如果参数为空或被要求生成的实体不能被生成则抛出错误
    • spawn

      @NotNull <T extends Entity> T spawn(@NotNull @NotNull Location location, @NotNull @NotNull Class<T> clazz, @Nullable @Nullable Consumer<? super T> function) throws IllegalArgumentException
      在指定位置根据给定的类生成一个实体,并在实体被添加到世界之前运行提供的函数.
      请注意,当函数运行时,实体实际上尚未进入世界。在此函数返回之前, 任何涉及传送实体等操作都是未定义的。

      原文:Spawn an entity of a specific class at the given Location, with the supplied function run before the entity is added to the world. Note that when the function is run, the entity will not be actually in the world. Any operation involving such as teleporting the entity is undefined until after this function returns.

      类型参数:
      T - 要生成的实体的类
      参数:
      location - 生成实体的位置
      clazz - 要生成的实体的类
      function - 在实体生成前运行的函数
      返回:
      生成的实体实例
      抛出:
      IllegalArgumentException - 如果参数为空或被要求生成的实体不能被生成则抛出错误
    • spawn

      @NotNull <T extends Entity> T spawn(@NotNull @NotNull Location location, @NotNull @NotNull Class<T> clazz, boolean randomizeData, @Nullable @Nullable Consumer<? super T> function) throws IllegalArgumentException
      在指定位置创建一个新实体.

      提供的函数会在实体被添加到世界之前运行。
      请注意,当函数运行时,实体实际上尚未进入世界。在此函数返回之前, 任何涉及传送实体等操作都是未定义的。 传入的函数在潜在的实体生成随机化之后运行,因此已经允许访问 mob 的值, 无论这些值是否已被随机化,例如属性或实体装备。

      原文:Creates a new entity at the given Location with the supplied function run before the entity is added to the world. Note that when the function is run, the entity will not be actually in the world. Any operation involving such as teleporting the entity is undefined until after this function returns. The passed function however is run after the potential entity's spawn randomization and hence already allows access to the values of the mob, whether or not those were randomized, such as attributes or the entity equipment.

      类型参数:
      T - 要生成的实体的泛型类型
      参数:
      location - 实体将被生成的位置
      clazz - 要生成的实体的类
      randomizeData - 是否应在生成前随机化实体的数据。默认情况下,实体在生成前会根据其装备、年龄、 属性等进行随机化。随机化的例子包括羊的颜色、怪物装备上的随机附魔, 甚至僵尸成为骑鸡小僵尸。如果设置为false,实体在生成前不会被随机化, 这意味着它们的所有数据将保持默认状态,不会对实体进行进一步修改。 值得注意的是,只有继承 Mob 接口的实体 才提供生成随机化逻辑,因此此参数对其他类型的实体无效。
      function - 在实体生成前运行的函数
      返回:
      生成的实体实例
      抛出:
      IllegalArgumentException - 如果 world 或 clazz 参数为空
    • getHighestBlockYAt

      int getHighestBlockYAt(int x, int z)
      获取指定坐标处最高非空(不可通过)方块的坐标.

      原文:Gets the highest non-empty (impassable) coordinate at the given coordinates.

      参数:
      x - 方块的x坐标
      z - 方块的z坐标
      返回:
      最高非空方块的y坐标
    • getHighestBlockYAt

      int getHighestBlockYAt(@NotNull @NotNull Location location)
      获取指定位置处最高非空(不可通过)方块的坐标.

      原文:Gets the highest non-empty (impassable) coordinate at the given Location.

      参数:
      location - 方块的位置
      返回:
      最高非空方块的y坐标
    • getHighestBlockYAt

      int getHighestBlockYAt(int x, int z, @NotNull @NotNull HeightMap heightMap)
      获取指定坐标处对应于高度图的最高坐标.

      原文:Gets the highest coordinate corresponding to the HeightMap at the given coordinates.

      参数:
      x - 方块的x坐标
      z - 方块的z坐标
      heightMap - 用于确定最高点的高度图
      返回:
      对应于高度图的最高方块的y坐标
    • getHighestBlockYAt

      int getHighestBlockYAt(@NotNull @NotNull Location location, @NotNull @NotNull HeightMap heightMap)
      获取指定位置处对应于高度图的最高坐标.

      原文:Gets the highest coordinate corresponding to the HeightMap at the given Location.

      参数:
      location - 方块的位置
      heightMap - 用于确定最高点的高度图
      返回:
      对应于高度图的最高方块的y坐标
    • addEntity

      @NotNull <T extends Entity> T addEntity(@NotNull T entity)
      在世界中生成一个先前创建的实体.
      提供的实体必须尚未在世界中生成。

      原文:Spawns a previously created entity in the world. The provided entity must not have already been spawned in a world.

      类型参数:
      T - 要添加的实体的泛型类型
      参数:
      entity - 要添加的实体
      返回:
      现在位于世界中的实体