Interface Structure

All Superinterfaces:
PersistentDataHolder, PersistentDataViewHolder

public interface Structure extends PersistentDataHolder
Represents a structure.

A structure is a mutable template of captured blocks and entities that can be copied back into the world. The StructureManager, retrieved via Server.getStructureManager(), allows you to create new structures, load existing structures, and save structures.

In order for a structure to be usable by structure blocks, it needs to be null registered with the StructureManager, or located in the primary world folder, a DataPack, or the server's own default resources, so that the StructureManager can find it.

  • Method Details

    • getSize

      Gets the current size of the structure.

      The size of the structure may not be fixed.

      Returns:
      A new vector that represents the size of the structure along each axis.
    • getPalettes

      @NotNull @NotNull List<Palette> getPalettes()
      Gets a list of available block palettes.
      Returns:
      a list of available variants of this structure.
    • getPaletteCount

      int getPaletteCount()
      Gets the number of palettes in this structure.
      Returns:
      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.
      Returns:
      a list of Entities included in the Structure.
    • getEntityCount

      int getEntityCount()
      Gets the number of entities in this structure.
      Returns:
      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.
      Parameters:
      location - The location to place the structure at.
      includeEntities - If the entities present in the structure should be spawned.
      structureRotation - The rotation of the structure.
      mirror - The mirror settings of the structure.
      palette - The palette index of the structure to use, starting at 0, or -1 to pick a random palette.
      integrity - Determines how damaged the building should look by randomly skipping blocks to place. This value can range from 0 to 1. With 0 removing all blocks and 1 spawning the structure in pristine condition.
      random - The randomizer used for setting the structure's LootTables and integrity.
    • 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.
      Parameters:
      location - The location to place the structure at.
      includeEntities - If the entities present in the structure should be spawned.
      structureRotation - The rotation of the structure.
      mirror - The mirror settings of the structure.
      palette - The palette index of the structure to use, starting at 0, or -1 to pick a random palette.
      integrity - Determines how damaged the building should look by randomly skipping blocks to place. This value can range from 0 to 1. With 0 removing all blocks and 1 spawning the structure in pristine condition.
      random - The randomizer used for setting the structure's LootTables and integrity.
      blockTransformers - A collection of BlockTransformers to apply to the structure.
      entityTransformers - A collection of EntityTransformers to apply to the structure.
    • 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.
      Parameters:
      regionAccessor - The world to place the structure in.
      location - The location to place the structure at.
      includeEntities - If the entities present in the structure should be spawned.
      structureRotation - The rotation of the structure.
      mirror - The mirror settings of the structure.
      palette - The palette index of the structure to use, starting at 0, or -1 to pick a random palette.
      integrity - Determines how damaged the building should look by randomly skipping blocks to place. This value can range from 0 to 1. With 0 removing all blocks and 1 spawning the structure in pristine condition.
      random - The randomizer used for setting the structure's LootTables and integrity.
    • 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.
      Parameters:
      regionAccessor - The world to place the structure in.
      location - The location to place the structure at.
      includeEntities - If the entities present in the structure should be spawned.
      structureRotation - The rotation of the structure.
      mirror - The mirror settings of the structure.
      palette - The palette index of the structure to use, starting at 0, or -1 to pick a random palette.
      integrity - Determines how damaged the building should look by randomly skipping blocks to place. This value can range from 0 to 1. With 0 removing all blocks and 1 spawning the structure in pristine condition.
      random - The randomizer used for setting the structure's LootTables and integrity.
      blockTransformers - A collection of BlockTransformers to apply to the structure.
      entityTransformers - A collection of EntityTransformers to apply to the structure.
    • 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.

      Parameters:
      corner1 - A corner of the structure.
      corner2 - The corner opposite from corner1.
      includeEntities - true if entities should be included in the saved structure.
    • 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.

      Parameters:
      origin - The origin of the structure.
      size - The size of the structure, must be at least 1x1x1.
      includeEntities - true if entities should be included in the saved structure.
      Throws:
      IllegalArgumentException - Thrown if size is smaller than 1x1x1