程序包 org.bukkit

接口 RegionAccessor

所有已知子接口:
LimitedRegion, World

public interface RegionAccessor
A RegionAccessor gives access to getting, modifying and spawning Biome, BlockState and Entity, as well as generating some basic structures.
  • 方法详细资料

    • 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-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      biome - New Biome type for this block
    • getBlockState

      Gets the BlockState at the given Location.
      参数:
      location - The location of the block state
      返回:
      Block state at the given location
    • getBlockState

      @NotNull @NotNull BlockState getBlockState(int x, int y, int z)
      Gets the BlockState at the given coordinates.
      参数:
      x - X-coordinate of the block state
      y - Y-coordinate of the block state
      z - Z-coordinate of the block state
      返回:
      Block state at the given coordinates
    • getBlockData

      Gets the BlockData at the given Location.
      参数:
      location - The location of the block data
      返回:
      Block data at the given location
    • getBlockData

      @NotNull @NotNull BlockData getBlockData(int x, int y, int z)
      Gets the BlockData at the given coordinates.
      参数:
      x - X-coordinate of the block data
      y - Y-coordinate of the block data
      z - Z-coordinate of the block data
      返回:
      Block data at the given coordinates
    • getType

      Gets the type of the block at the given Location.
      参数:
      location - The location of the block
      返回:
      Material at the given coordinates
    • getType

      @NotNull @NotNull Material getType(int x, int y, int z)
      Gets the type of the block at the given coordinates.
      参数:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      返回:
      Material at the given coordinates
    • setBlockData

      void setBlockData(@NotNull @NotNull Location location, @NotNull @NotNull BlockData blockData)
      Sets the BlockData at the given Location.
      参数:
      location - The location of the block
      blockData - The block data to set the block to
    • setBlockData

      void setBlockData(int x, int y, int z, @NotNull @NotNull BlockData blockData)
      Sets the BlockData at the given coordinates.
      参数:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      blockData - The block data to set the block to
    • setType

      void setType(@NotNull @NotNull Location location, @NotNull @NotNull Material material)
      Sets the Material at the given Location.
      参数:
      location - The location of the block
      material - The type to set the block to
    • setType

      void setType(int x, int y, int z, @NotNull @NotNull Material material)
      Sets the Material at the given coordinates.
      参数:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      material - The type to set the block to
    • generateTree

      boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type)
      Creates a tree at the given Location
      参数:
      location - Location to spawn the tree
      random - Random to use to generated the tree
      type - Type of the tree to create
      返回:
      true if the tree was created successfully, otherwise false
    • generateTree

      boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type, @Nullable @Nullable Consumer<? super BlockState> stateConsumer)
      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 - Location to spawn the tree
      random - Random to use to generated the tree
      type - Type of the tree to create
      stateConsumer - The consumer which should get called for every block which gets changed
      返回:
      true if the tree was created successfully, otherwise false
    • generateTree

      boolean generateTree(@NotNull @NotNull Location location, @NotNull @NotNull Random random, @NotNull @NotNull TreeType type, @Nullable @Nullable Predicate<? super BlockState> statePredicate)
      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 - Location to spawn the tree
      random - Random to use to generated the tree
      type - Type of the tree to create
      statePredicate - The predicate which should get used to test if a block should be set or not.
      返回:
      true if the tree was created successfully, otherwise 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 - the location at which the entity will be spawned.
      type - the entity type that determines the entity to spawn.
      randomizeData - whether or not the entity's data should be randomised before spawning. By default entities are randomised before spawning in regards to their equipment, age, attributes, etc. An example of this randomization would be the color of a sheep, random enchantments on the equipment of mobs or even a zombie becoming a chicken jockey. If set to false, the entity will not be randomised before spawning, meaning all their data will remain in their default state and not further modifications to the entity will be made. Notably only entities that extend the Mob interface provide randomisation logic for their spawn. This parameter is hence useless for any other type of entity.
      返回:
      the spawned entity instance.
    • getEntities

      @NotNull @NotNull List<Entity> getEntities()
      Get a list of all entities in this RegionAccessor
      返回:
      A List of all Entities currently residing in this world accessor
    • getLivingEntities

      @NotNull @NotNull List<LivingEntity> getLivingEntities()
      Get a list of all living entities in this RegionAccessor
      返回:
      A List of all LivingEntities currently residing in this world accessor
    • getEntitiesByClass

      @NotNull <T extends Entity> @NotNull Collection<T> getEntitiesByClass(@NotNull @NotNull Class<T> cls)
      Get a collection of all entities in this RegionAccessor matching the given class/interface
      类型参数:
      T - an entity subclass
      参数:
      cls - The class representing the type of entity to match
      返回:
      A List of all Entities currently residing in this world accessor that match the given class/interface
    • getEntitiesByClasses

      @NotNull @NotNull Collection<Entity> getEntitiesByClasses(@NotNull @NotNull Class<?>... classes)
      Get a collection of all entities in this RegionAccessor matching any of the given classes/interfaces
      参数:
      classes - The classes representing the types of entity to match
      返回:
      A List of all Entities currently residing in this world accessor that match one or more of the given classes/interfaces
    • 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 - the class of the Entity to create
      参数:
      location - the Location to create the entity at
      clazz - the class of the Entity to spawn
      返回:
      an instance of the created Entity
      另请参阅:
    • 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 - the class of the Entity to spawn
      参数:
      location - the Location to spawn the entity at
      clazz - the class of the Entity to spawn
      function - the function to be run before the entity is spawned.
      返回:
      an instance of the spawned Entity
      抛出:
      IllegalArgumentException - if either parameter is null or the Entity requested cannot be spawned
    • 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
      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 - the generic type of the entity that is being created.
      参数:
      location - the location at which the entity will be spawned.
      clazz - the class of the Entity that is to be spawned.
      randomizeData - whether or not the entity's data should be randomised before spawning. By default entities are randomised before spawning in regards to their equipment, age, attributes, etc. An example of this randomization would be the color of a sheep, random enchantments on the equipment of mobs or even a zombie becoming a chicken jockey. If set to false, the entity will not be randomised before spawning, meaning all their data will remain in their default state and not further modifications to the entity will be made. Notably only entities that extend the Mob interface provide randomisation logic for their spawn. This parameter is hence useless for any other type of entity.
      function - the function to be run before the entity is spawned.
      返回:
      the spawned entity instance.
      抛出:
      IllegalArgumentException - if either the world or clazz parameter are null.
    • getHighestBlockYAt

      int getHighestBlockYAt(int x, int z)
      Gets the highest non-empty (impassable) coordinate at the given coordinates.
      参数:
      x - X-coordinate of the blocks
      z - Z-coordinate of the blocks
      返回:
      Y-coordinate of the highest non-empty block
    • getHighestBlockYAt

      int getHighestBlockYAt(@NotNull @NotNull Location location)
      Gets the highest non-empty (impassable) coordinate at the given Location.
      参数:
      location - Location of the blocks
      返回:
      Y-coordinate of the highest non-empty block
    • 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-coordinate of the blocks
      z - Z-coordinate of the blocks
      heightMap - the heightMap that is used to determine the highest point
      返回:
      Y-coordinate of the highest block corresponding to the HeightMap
    • getHighestBlockYAt

      int getHighestBlockYAt(@NotNull @NotNull Location location, @NotNull @NotNull HeightMap heightMap)
      Gets the highest coordinate corresponding to the HeightMap at the given Location.
      参数:
      location - Location of the blocks
      heightMap - the heightMap that is used to determine the highest point
      返回:
      Y-coordinate of the highest block corresponding to the HeightMap
    • 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 - the generic type of the entity that is being added.
      参数:
      entity - the entity to add
      返回:
      the entity now in the world