接口 Structure

所有超级接口:
PersistentDataHolder

public interface Structure extends PersistentDataHolder
表示一个结构。

结构是一个可变的模板,包含已捕获的方块和实体,可以复制回世界中。 通过 Server.getStructureManager() 获取的 StructureManager 允许你创建新结构、加载现有结构和保存结构。

为了使结构能被结构方块使用,需要在 StructureManager 中 注册, 或者位于主世界文件夹、数据包或服务器自身的默认资源中,以便 StructureManager 能找到它。

  • 方法详细资料

    • getSize

      获取结构的当前尺寸。

      原文: Gets the current size of the structure.

      The size of the structure may not be fixed.

      返回:
      表示结构沿各轴尺寸的新向量。
    • getPalettes

      @NotNull @NotNull List<Palette> getPalettes()
      获取可用的方块调色板列表。

      原文: Gets a list of available block palettes.

      返回:
      此结构的可用变体列表。
    • getPaletteCount

      int getPaletteCount()
      获取此结构中调色板的数量。

      原文: Gets the number of palettes in this structure.

      返回:
      此结构中调色板的数量。
    • getEntities

      @NotNull @NotNull List<Entity> getEntities()
      获取已包含在结构中的实体列表。

      原文: Gets a list of entities that have been included in the Structure. The entity positions are offsets relative to the structure's position that is provided once the structure is placed into the world.

      返回:
      包含在结构中的实体列表。
    • getEntityCount

      int getEntityCount()
      获取此结构中实体的数量。

      原文: Gets the number of entities in this structure.

      返回:
      此结构中实体的数量。
    • place

      void place(@NotNull @NotNull Location location, boolean includeEntities, @NotNull @NotNull StructureRotation structureRotation, @NotNull @NotNull Mirror mirror, int palette, float integrity, @NotNull @NotNull Random random)
      将结构放置到世界中。

      原文: Place a structure in the world.

      参数:
      location - 放置结构的位置。
      includeEntities - 是否生成结构中存在的实体。
      structureRotation - 结构的旋转。
      mirror - 结构的镜像设置。
      palette - 要使用的结构调色板索引,从 0 开始,或使用 -1 随机选择调色板。
      integrity - 通过随机跳过放置方块来决定建筑的损坏程度。此值范围为 0 到 1。 0 表示移除所有方块,1 表示以原始状态生成结构。
      random - 用于设置结构 LootTable 和完整性的随机数生成器。
    • place

      @Experimental void place(@NotNull @NotNull Location location, boolean includeEntities, @NotNull @NotNull StructureRotation structureRotation, @NotNull @NotNull Mirror mirror, int palette, float integrity, @NotNull @NotNull Random random, @NotNull @NotNull Collection<BlockTransformer> blockTransformers, @NotNull @NotNull Collection<EntityTransformer> entityTransformers)
      将结构放置到世界中。

      原文: Place a structure in the world.

      参数:
      location - 放置结构的位置。
      includeEntities - 是否生成结构中存在的实体。
      structureRotation - 结构的旋转。
      mirror - 结构的镜像设置。
      palette - 要使用的结构调色板索引,从 0 开始,或使用 -1 随机选择调色板。
      integrity - 通过随机跳过放置方块来决定建筑的损坏程度。此值范围为 0 到 1。 0 表示移除所有方块,1 表示以原始状态生成结构。
      random - 用于设置结构 LootTable 和完整性的随机数生成器。
      blockTransformers - 应用于结构的 BlockTransformer 集合。
      entityTransformers - 应用于结构的 EntityTransformer 集合。
    • place

      void place(@NotNull @NotNull RegionAccessor regionAccessor, @NotNull @NotNull BlockVector location, boolean includeEntities, @NotNull @NotNull StructureRotation structureRotation, @NotNull @NotNull Mirror mirror, int palette, float integrity, @NotNull @NotNull Random random)
      将结构放置到世界中。

      原文: Place a structure in the world.

      参数:
      regionAccessor - 要放置结构的世界。
      location - 放置结构的位置。
      includeEntities - 是否生成结构中存在的实体。
      structureRotation - 结构的旋转。
      mirror - 结构的镜像设置。
      palette - 要使用的结构调色板索引,从 0 开始,或使用 -1 随机选择调色板。
      integrity - 通过随机跳过放置方块来决定建筑的损坏程度。此值范围为 0 到 1。 0 表示移除所有方块,1 表示以原始状态生成结构。
      random - 用于设置结构 LootTable 和完整性的随机数生成器。
    • place

      @Experimental void place(@NotNull @NotNull RegionAccessor regionAccessor, @NotNull @NotNull BlockVector location, boolean includeEntities, @NotNull @NotNull StructureRotation structureRotation, @NotNull @NotNull Mirror mirror, int palette, float integrity, @NotNull @NotNull Random random, @NotNull @NotNull Collection<BlockTransformer> blockTransformers, @NotNull @NotNull Collection<EntityTransformer> entityTransformers)
      将结构放置到世界中。

      原文: Place a structure in the world.

      参数:
      regionAccessor - 要放置结构的世界。
      location - 放置结构的位置。
      includeEntities - 是否生成结构中存在的实体。
      structureRotation - 结构的旋转。
      mirror - 结构的镜像设置。
      palette - 要使用的结构调色板索引,从 0 开始,或使用 -1 随机选择调色板。
      integrity - 通过随机跳过放置方块来决定建筑的损坏程度。此值范围为 0 到 1。 0 表示移除所有方块,1 表示以原始状态生成结构。
      random - 用于设置结构 LootTable 和完整性的随机数生成器。
      blockTransformers - 应用于结构的 BlockTransformer 集合。
      entityTransformers - 应用于结构的 EntityTransformer 集合。
    • fill

      void fill(@NotNull @NotNull Location corner1, @NotNull @NotNull Location corner2, boolean includeEntities)
      从世界中的一个区域填充结构。原点和尺寸将根据提供的两个角自动计算。

      原文: Fills the structure from an area in a world. The origin and size will be calculated automatically from the two corners provided.

      Be careful as this will override the current data of the structure.

      Be aware that this method allows for creating structures larger than the 48x48x48 size that Minecraft's Structure blocks support. Any structures saved this way can not be loaded by using a structure block. Using the API however will still work.

      参数:
      corner1 - 结构的一个角。
      corner2 - 与 corner1 相对的角。
      includeEntities - 是否在保存的结构中包含实体。
    • fill

      void fill(@NotNull @NotNull Location origin, @NotNull @NotNull BlockVector size, boolean includeEntities)
      从世界中的一个区域填充结构,从指定的原点开始,沿各轴按指定的尺寸向量扩展。

      原文: Fills the Structure from an area in a world, starting at the specified origin and extending in each axis according to the specified size vector.

      Be careful as this will override the current data of the structure.

      Be aware that this method allows for saving structures larger than the 48x48x48 size that Minecraft's Structure blocks support. Any structures saved this way can not be loaded by using a structure block. Using the API however will still work.

      参数:
      origin - 结构的原点。
      size - 结构的尺寸,必须至少为 1x1x1。
      includeEntities - 是否在保存的结构中包含实体。
      抛出:
      IllegalArgumentException - 如果尺寸小于 1x1x1 则抛出异常。