Class StructurePacks

java.lang.Object
com.ldtteam.structurize.storage.StructurePacks

public class StructurePacks extends Object
Class that contains all the structurepacks of the instance.
  • Field Details

    • selectedPack

      @Nullable @Deprecated public static @Nullable StructurePackMeta selectedPack
      Deprecated.
      -> Don't read/write directly, go through methods. 1.22 will make this a string.
      Selected pack on the client.
  • Constructor Details

    • StructurePacks

      public StructurePacks()
  • Method Details

    • waitUntilFinishedLoading

      public static boolean waitUntilFinishedLoading()
      Blocks the current thread until loading has finished
      Returns:
      true if finished; false if interrupted before finishing
    • setFinishedLoading

      public static void setFinishedLoading()
      Conclude loading.
    • getPackMetas

      public static Collection<StructurePackMeta> getPackMetas()
      Get the list of pack meta.
      Returns:
      the pack meta set.
    • getStructurePack

      @Nullable public static @Nullable StructurePackMeta getStructurePack(String key)
      Query a structure pack for a key.
      Parameters:
      key - the used key.
      Returns:
      the pack or null.
    • clearPacks

      public static void clearPacks()
      Reset pack state.
    • removePack

      public static StructurePackMeta removePack(String name)
      Remove a specific pack.
      Parameters:
      name - the packname.
    • getBlueprintFuture

      public static CompletableFuture<Blueprint> getBlueprintFuture(String structurePackId, String subPath)
      Get a blueprint future.
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the path of the specific blueprint in the pack.
      Returns:
      the blueprint future (might contain null).
    • getBlueprintDataFuture

      public static CompletableFuture<byte[]> getBlueprintDataFuture(String structurePackId, String subPath)
      Get a blueprint data future.
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the path of the specific blueprint in the pack.
      Returns:
      the blueprint data future (might contain null).
    • findBlueprintFuture

      public static CompletableFuture<Path> findBlueprintFuture(String structurePackId, String name)
      Find a blueprint future.
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      name - the filename.
      Returns:
      the blueprint future (might contain null).
    • getBlueprintsFuture

      public static CompletableFuture<List<Blueprint>> getBlueprintsFuture(String structurePackId, String subPath)
      Get a list blueprint future.
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the path of the set of blueprints (usually a folder).
      Returns:
      the blueprints list (might be empty).
    • getCategoriesFuture

      public static CompletableFuture<List<StructurePacks.Category>> getCategoriesFuture(String structurePackId, String subPath)
      Get a list of categories of a specific sub-path of a given structure pack.
      Parameters:
      structurePackId - the id of the pack.
      subPath - the sub-path.
      Returns:
      the list of categories.
    • getBlueprintFuture

      public static CompletableFuture<Blueprint> getBlueprintFuture(String packName, Path path)
      Get the blueprint directly with a path.
      Parameters:
      packName - the pack we're looking in.
      path - the path to search for.
      Returns:
      the blueprint.
    • findBlueprintFuture

      public static CompletableFuture<Blueprint> findBlueprintFuture(String structurePackId, Predicate<Blueprint> blueprintPredicate)
      Find the blueprint async
      Parameters:
      blueprintPredicate - the predicate to define the blueprint we're looking for.
      Returns:
      the blueprint future.
    • getBlueprintFuture

      public static CompletableFuture<Blueprint> getBlueprintFuture(String structurePackId, String subPath, boolean suppressError)
      Get a blueprint future.
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the path of the specific blueprint in the pack.
      suppressError - log exception or not.
      Returns:
      the blueprint future (might contain null).
    • getBlueprintFuture

      public static CompletableFuture<Blueprint> getBlueprintFuture(String packName, Path path, boolean suppressError)
      Get the blueprint directly with a path.
      Parameters:
      packName - the pack we're looking in.
      path - the path to search for.
      suppressError - log exception or not.
      Returns:
      the blueprint.
    • getBlueprint

      @Nullable public static @Nullable Blueprint getBlueprint(String structurePackId, String subPath)
      Get a blueprint directly (careful IO, might be slow).
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the folder containing the blueprints.
      Returns:
      the blueprint or null.
    • getBlueprint

      public static Blueprint getBlueprint(String pack, Path path)
      Get the blueprint directly with a path.
      Parameters:
      pack - the pack this belongs to.
      path - the path to search for.
      Returns:
      the blueprint.
    • findBlueprint

      public static Path findBlueprint(String structurePackId, String name)
      Find a blueprint by name.
      Parameters:
      structurePackId - the pack to search in.
      name - the name we're searching for.
      Returns:
      the path or null.
    • findBlueprint

      public static Optional<Path> findBlueprint(Path subPath, String name)
      Find blueprint at path. Recursively goes through folder structure.
      Parameters:
      subPath - the sub path to check.
      name - the name of the file we're looking for.
      Returns:
      the path of the file or null.
    • findBlueprint

      public static Blueprint findBlueprint(String structurePackId, Predicate<Blueprint> blueprintPredicate)
      Find a blueprint by name.
      Parameters:
      structurePackId - the pack to search in.
      blueprintPredicate - matches the blueprint.
      Returns:
      the blueprint or null.
    • findBlueprint

      public static Blueprint findBlueprint(String pack, Path subPath, Predicate<Blueprint> blueprintPredicate)
      Find blueprint at path. Recursively goes through folder structure.
      Parameters:
      pack - the pack we're looking in.
      subPath - the sub path to check.
      blueprintPredicate - matches the blueprint.
      Returns:
      the path of the file or null.
    • getBlueprint

      @Nullable public static @Nullable Blueprint getBlueprint(String structurePackId, String subPath, boolean suppressError)
      Get a blueprint directly (careful IO, might be slow).
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the folder containing the blueprints.
      suppressError - log exception or not.
      Returns:
      the blueprint or null.
    • getBlueprint

      public static Blueprint getBlueprint(String pack, Path path, boolean suppressError)
      Get the blueprint directly with a path.
      Parameters:
      pack - the pack this belongs to.
      path - the path to search for.
      suppressError - log exception or not.
      Returns:
      the blueprint.
    • getBlueprintData

      public static byte[] getBlueprintData(String structurePackId, String subPath)
      Get blueprint data directly (careful IO, might be slow).
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the folder containing the blueprints.
      Returns:
      the blueprint data in a byte array or null.
    • getBlueprints

      public static List<Blueprint> getBlueprints(String structurePackId, String subPath)
      Get a list of blueprints directly (careful IO, might be slow).
      Parameters:
      structurePackId - the structure pack the blueprint is in.
      subPath - the folder containing the blueprints.
      Returns:
      the list of blueprints or empty
    • getCategories

      public static List<StructurePacks.Category> getCategories(String structurePackId, String subPath)
      Get a list of categories of a specific sub-path of a given structure pack. This has IO, this may be slow.
      Parameters:
      structurePackId - the id of the pack.
      subPath - the sub-path.
      Returns:
      the list of categories.
    • discoverPackAtPath

      public static void discoverPackAtPath(Path element, boolean immutable, List<String> modList, boolean clientPack, String owner)
      Discover a structure pack at a given path.
      Parameters:
      element - the path to check for.
      immutable - if jar (true), else false.
      modList - the list of mods loaded on this instance.
      clientPack - if this is a client pac.
    • storeBlueprint

      public static Future<Blueprint> storeBlueprint(String packName, net.minecraft.nbt.CompoundTag compoundTag, Path path)
      Store a blueprint at a given path.
      Parameters:
      packName - the pack we're storing it in.
      compoundTag - compound to store.
      path - path to store it at.
    • hasPack

      public static boolean hasPack(String key)
      Check if the pack exists.
      Parameters:
      key - the pack id to check.
      Returns:
      true if so.
    • getSelectedPack

      @Nullable public static @Nullable StructurePackMeta getSelectedPack()
      Get the currently selected pack.
      Returns:
      the random pack.
    • switchSelectedPack

      public static void switchSelectedPack(StructurePackMeta packMeta)
      Set the currently selected pack.
      Parameters:
      packMeta - the new pack meta.
    • switchSelectedPack

      public static void switchSelectedPack(String packName)
      Set the currently selected pack.
      Parameters:
      packName - the new pack name.
    • ensureSelectedPack

      public static void ensureSelectedPack()
      Ensure that we have a selected pack.