Interface StructureTemplate

All Superinterfaces:
Keyed, Registerable<StructureTemplate>, Wrapper

@NullMarked @AsOf("3.4.0") public interface StructureTemplate extends Wrapper, Keyed, Registerable<StructureTemplate>
A structure template: the NBT file a jigsaw piece or a template feature stamps into the world.
Since:
3.4.0
See Also:
  • Method Details

    • key

      @AsOf("3.4.0") ResourceKey key()
      The identifier of the template.
      Specified by:
      key in interface Keyed
      Returns:
      the identifier of the template
      Since:
      3.4.0
    • source

      @AsOf("3.4.0") Optional<URL> source()
      The NBT file this template is loaded from when registered.
      Returns:
      the source file, if present
      Since:
      3.4.0
    • register

      @AsOf("3.4.0") StructureTemplate register()
      Loads this template's source file into the server's template manager under its key.

      Call this once the server exists.onLoad or later and before any structure that places the template generates.

      Specified by:
      register in interface Registerable<StructureTemplate>
      Returns:
      this template
      Throws:
      IllegalStateException - if this template has no source file, or no server is running yet
      UncheckedIOException - if the source file cannot be read as a structure template
      Since:
      3.4.0
    • of

      @AsOf("3.4.0") static StructureTemplate of(ResourceKey key)
      Names a template Minecraft already knows about, from a data pack or the world's generated folder.
      Parameters:
      key - the identifier of the template
      Returns:
      a handle onto that template
      Since:
      3.4.0
    • of

      @AsOf("3.4.0") static StructureTemplate of(ResourceKey key, Path nbtFile)
      Creates a template loaded from an NBT file on disk, such as one saved with a structure block.
      Parameters:
      key - the identifier to register the template under
      nbtFile - the gzip-compressed .nbt file
      Returns:
      a template that can be registered
      Since:
      3.4.0
    • of

      @AsOf("3.4.0") static StructureTemplate of(ResourceKey key, URL nbtResource)
      Creates a template loaded from an NBT resource, such as one inside a plugin jar obtained with Class.getResource(String).
      Parameters:
      key - the identifier to register the template under
      nbtResource - the gzip-compressed .nbt resource
      Returns:
      a template that can be registered
      Since:
      3.4.0
    • minecraft

      @AsOf("3.4.0") static StructureTemplate minecraft(String path)
      Names the template stored under the given identifier in the minecraft namespace.
      Parameters:
      path - the path of the template
      Returns:
      a handle onto that template
      Since:
      3.4.0