Class Platform

java.lang.Object
dev.architectury.platform.Platform

public final class Platform extends Object
  • Method Details

    • isFabric

      public static boolean isFabric()
    • isForge

      public static boolean isForge()
    • getMinecraftVersion

      public static String getMinecraftVersion()
    • getGameFolder

      public static Path getGameFolder()
      Gets the root directory for the current instance of Minecraft.

      The returned path is guaranteed to be absolute and normalized.

    • getConfigFolder

      public static Path getConfigFolder()
      Gets the main config folder for the current instance of Minecraft.

      The returned path is guaranteed to be absolute and normalized.

    • getModsFolder

      public static Path getModsFolder()
      Gets the mods folder of the current instance of Minecraft.

      The returned path is guaranteed to be absolute and normalized.

    • getEnvironment

      public static Env getEnvironment()
      Returns the current Environment the game is running in, being one of either CLIENT or SERVER.

      The class returned is a platform-agnostic wrapper around the EnvType and Dist enums, respectively.

      Returns:
      The current Environment, as an instance of Env
      See Also:
    • getEnv

      public static net.fabricmc.api.EnvType getEnv()
      Returns the current Environment the game is running in, as a member of the EnvType enum. This is remapped on Forge to be the Dist enum, instead.
      Returns:
      The current Environment, as an instance of EnvType (or Dist on Forge)
    • isModLoaded

      public static boolean isModLoaded(String id)
      Checks whether a mod with the given mod ID is present.
      Parameters:
      id - The mod ID to check.
      Returns:
      true if the mod is loaded, false otherwise.
    • getMod

      public static Mod getMod(String id)
      Gets a Mod container by its mod ID.
      Parameters:
      id - The mod ID to look for.
      Returns:
      The mod container, if found.
      Throws:
      NoSuchElementException - if no mod with the given ID exists
    • getOptionalMod

      public static Optional<Mod> getOptionalMod(String id)
      Optionally gets a Mod container by its mod ID if it exists.
      Parameters:
      id - The mod ID to look for.
      Returns:
      An optional representing the mod container, if found, or an empty optional otherwise.
    • getMods

      public static Collection<Mod> getMods()
      Gets a collection of Mod containers for all currently-loaded mods.
      Returns:
      A collection of mod containers.
    • getModIds

      public static Collection<String> getModIds()
      Gets a collection of Strings representing the mod IDs of all currently-loaded mods.
      Returns:
      A collection of all loaded mod IDs.
    • isDevelopmentEnvironment

      public static boolean isDevelopmentEnvironment()