接口 RegionAccessor
- 所有已知子接口:
LimitedRegion,World
-
方法概要
修饰符和类型方法说明<T extends Entity>
TaddEntity(T entity) 在世界中生成一个先前创建的实体.<T extends Entity>
TcreateEntity(@NotNull Location location, @NotNull Class<T> clazz) 在指定位置创建一个特定类的实体,但不会将其生成到世界中.boolean在指定位置创建一棵树.booleangenerateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer<? super BlockState> stateConsumer) 在指定位置创建一棵树.booleangenerateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate<? super BlockState> statePredicate) 在指定位置创建一棵树.getBiome(int x, int y, int z) 获取指定坐标的生物群系.getBlockData(int x, int y, int z) 获取指定坐标的方块数据.getBlockData(@NotNull Location location) getBlockState(int x, int y, int z) 获取指定坐标的方块状态.getBlockState(@NotNull Location location) 获取此 RegionAccessor 中所有实体的列表.<T extends Entity>
@NotNull Collection<T>getEntitiesByClass(@NotNull Class<T> cls) 获取此 RegionAccessor 中匹配给定类/接口的所有实体的集合.getEntitiesByClasses(@NotNull Class<?>... classes) 获取此 RegionAccessor 中匹配给定任意类/接口的所有实体的集合.intgetHighestBlockYAt(int x, int z) 获取指定坐标处最高非空(不可通过)方块的坐标.intgetHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap) 获取指定坐标处对应于高度图的最高坐标.intgetHighestBlockYAt(@NotNull Location location) 获取指定位置处最高非空(不可通过)方块的坐标.intgetHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap) 获取此 RegionAccessor 中所有生物实体的列表.getType(int x, int y, int z) 获取指定坐标的方块类型.void设置指定方块坐标的生物群系.voidvoidsetBlockData(int x, int y, int z, @NotNull BlockData blockData) 设置指定坐标的方块数据.voidsetBlockData(@NotNull Location location, @NotNull BlockData blockData) void设置指定坐标的方块类型.void<T extends Entity>
T在指定的位置根据给定的类生成一个实体.<T extends Entity>
Tspawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<? super T> function) 在指定位置创建一个新实体.<T extends Entity>
T在指定位置根据给定的类生成一个实体,并在实体被添加到世界之前运行提供的函数.spawnEntity(@NotNull Location location, @NotNull EntityType type) 在指定的位置创建一个实体.spawnEntity(@NotNull Location loc, @NotNull EntityType type, boolean randomizeData) 在指定位置创建一个新实体.
-
方法详细资料
-
getBiome
- 参数:
location- 位置- 返回:
- 此位置处的生物群系
-
getBiome
获取指定坐标的生物群系.原文:Gets the
Biomeat the given coordinates.- 参数:
x- 方块的x坐标y- 方块的y坐标z- 方块的z坐标- 返回:
- 指定坐标位置处的生物群系
-
setBiome
- 参数:
location- 位置biome- 此方块的新生物群系
-
setBiome
- 参数:
x- 方块的x坐标y- 方块的y坐标z- 方块的z坐标biome- 此方块的新生物群系
-
getBlockState
- 参数:
location- 方块状态的位置- 返回:
- 指定位置的方块状态
-
getBlockState
获取指定坐标的方块状态.原文:Gets the
BlockStateat the given coordinates.- 参数:
x- 方块状态的x坐标y- 方块状态的y坐标z- 方块状态的z坐标- 返回:
- 指定坐标处的方块状态
-
getBlockData
- 参数:
location- 方块数据的位置- 返回:
- 指定位置的方块数据
-
getBlockData
- 参数:
x- 方块数据的x坐标y- 方块数据的y坐标z- 方块数据的z坐标- 返回:
- 指定坐标处的方块数据
-
getType
- 参数:
location- 方块的位置- 返回:
- 指定坐标处的材质类型
-
getType
获取指定坐标的方块类型.原文:Gets the type of the block at the given coordinates.
- 参数:
x- 方块的x坐标y- 方块的y坐标z- 方块的z坐标- 返回:
- 指定坐标处的材质类型
-
setBlockData
- 参数:
location- 方块的位置blockData- 要设置的方块数据
-
setBlockData
- 参数:
x- 方块的x坐标y- 方块的y坐标z- 方块的z坐标blockData- 要设置的方块数据
-
setType
- 参数:
location- 方块的位置material- 要设置的方块类型
-
setType
- 参数:
x- 方块的x坐标y- 方块的y坐标z- 方块的z坐标material- 要设置的方块类型
-
generateTree
boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type) - 参数:
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 callinggetBlockState(Location)in the consumer while return the state of the block before the generation. Modifications done to theBlockStatein the consumer are respected, which means that it is not necessary to callBlockState.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 callinggetBlockState(Location)in the predicate will return the state of the block before the generation. If the predicate returnstruethe block gets set in the world. If it returnsfalsethe block won't get set in the world.- 参数:
location- 生成树的位置random- 用于生成树的随机数生成器type- 要创建的树的类型statePredicate- 用于测试是否应设置方块的 predicate- 返回:
- 如果树创建成功则返回true,否则返回false
-
spawnEntity
@NotNull @NotNull Entity spawnEntity(@NotNull @NotNull Location location, @NotNull @NotNull EntityType type) - 参数:
location- 生成实体的位置type- 生成的实体- 返回:
- 生成成功则返回此方法创建的实体
-
spawnEntity
@NotNull @NotNull Entity spawnEntity(@NotNull @NotNull Location loc, @NotNull @NotNull EntityType type, boolean randomizeData) - 参数:
loc- 实体将被生成的位置type- 决定要生成的实体类型的实体类型randomizeData- 是否应在生成前随机化实体的数据。默认情况下,实体在生成前会根据其装备、年龄、 属性等进行随机化。随机化的例子包括羊的颜色、怪物装备上的随机附魔, 甚至僵尸成为骑鸡小僵尸。如果设置为false,实体在生成前不会被随机化, 这意味着它们的所有数据将保持默认状态,不会对实体进行进一步修改。 值得注意的是,只有继承Mob接口的实体 才提供生成随机化逻辑,因此此参数对其他类型的实体无效。- 返回:
- 生成的实体实例
-
getEntities
获取此 RegionAccessor 中所有实体的列表.原文:Get a list of all entities in this RegionAccessor.
- 返回:
- 当前驻留在此世界访问器中的所有实体的列表
-
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
获取此 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
Locationbut 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. -
spawn
-
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. -
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
Locationwith 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
获取指定位置处最高非空(不可通过)方块的坐标.原文:Gets the highest non-empty (impassable) coordinate at the given
Location.- 参数:
location- 方块的位置- 返回:
- 最高非空方块的y坐标
-
getHighestBlockYAt
获取指定坐标处对应于高度图的最高坐标.原文:Gets the highest coordinate corresponding to the
HeightMapat the given coordinates.- 参数:
x- 方块的x坐标z- 方块的z坐标heightMap- 用于确定最高点的高度图- 返回:
- 对应于
高度图的最高方块的y坐标
-
getHighestBlockYAt
获取指定位置处对应于高度图的最高坐标.原文:Gets the highest coordinate corresponding to the
HeightMapat the givenLocation.- 参数:
location- 方块的位置heightMap- 用于确定最高点的高度图- 返回:
- 对应于
高度图的最高方块的y坐标
-
addEntity
在世界中生成一个先前创建的实体.
提供的实体必须尚未在世界中生成。原文:Spawns a previously created entity in the world. The provided entity must not have already been spawned in a world.
- 类型参数:
T- 要添加的实体的泛型类型- 参数:
entity- 要添加的实体- 返回:
- 现在位于世界中的实体
-