Class Namespace

java.lang.Object
com.github.darksoulq.abyssallib.server.resource.Namespace

public class Namespace extends Object
Represents a logical namespace inside a resource pack.

All emitted files are placed under assets/<namespace>/. This class provides factory methods for all supported asset types (textures, models, lang, etc.) and maintains a list of registered assets for the final emission process.

  • Constructor Details

    • Namespace

      public Namespace(@NotNull @NotNull String namespace, @NotNull @NotNull ResourcePack pack)
      Creates a new namespace.
      Parameters:
      namespace - The namespace string (ID).
      pack - The parent resource pack.
  • Method Details

    • atlas

      @NotNull public @NotNull Atlas atlas(@NotNull @NotNull String id, boolean autoLoad)
    • atlas

      @NotNull public @NotNull Atlas atlas(@NotNull @NotNull String id, byte[] data)
    • coreShader

      public CoreShader coreShader(String name)
    • coreShader

      public CoreShader coreShader(String name, byte[] vsh, byte[] fsh, byte[] json)
    • coreShader

      public CoreShader coreShader(String name, String vsh, String fsh, String json)
    • texture

      @NotNull public @NotNull Texture texture(@NotNull @NotNull String path)
      Registers a texture and attempts to load it from the plugin's JAR resources.
      Parameters:
      path - The relative path to the texture (e.g., "item/sword").
      Returns:
      The registered Texture asset.
    • texture

      @NotNull public @NotNull Texture texture(@NotNull @NotNull String path, byte @Nullable [] data)
      Registers a texture with optional raw byte data.
      Parameters:
      path - The relative path to the texture.
      data - The raw PNG bytes; if null, the system attempts to load from the JAR.
      Returns:
      The registered Texture asset.
    • mcmeta

      public McMeta mcmeta(String path, boolean autoLoad)
      Registers an .mcmeta file for texture animations or metadata.
      Parameters:
      path - The path matching the texture file.
      autoLoad - Whether to automatically pull the file from the plugin JAR.
      Returns:
      The registered McMeta asset.
    • mcmeta

      public McMeta mcmeta(String path, byte[] data)
      Registers an .mcmeta file with provided data.
      Parameters:
      path - The file path.
      data - The raw JSON bytes for the metadata.
      Returns:
      The registered McMeta asset.
    • waypointStyle

      public WaypointStyle waypointStyle(String name, boolean autoLoad)
      Registers a waypoints style asset (common in technical modding libraries).
      Parameters:
      name - The style name.
      autoLoad - Load from JAR.
      Returns:
      The registered WaypointStyle asset.
    • waypointStyle

      public WaypointStyle waypointStyle(String name, byte[] data)
      Registers a waypoint style with provided data.
      Parameters:
      name - Style name.
      data - Raw JSON bytes.
      Returns:
      The registered WaypointStyle asset.
    • postEffect

      public PostEffect postEffect(String name, boolean autoLoad)
      Registers a post-processing effect asset (Shaders).
      Parameters:
      name - Effect name.
      autoLoad - Load from JAR.
      Returns:
      The registered PostEffect asset.
    • postEffect

      public PostEffect postEffect(String name, byte[] data)
      Registers a post-processing effect with provided data.
      Parameters:
      name - Effect name.
      data - Raw JSON bytes.
      Returns:
      The registered PostEffect asset.
    • font

      @NotNull public @NotNull Font font(@NotNull @NotNull String name, boolean autoLoad)
      Registers a font configuration asset.
      Parameters:
      name - Font ID.
      autoLoad - Load from JAR.
      Returns:
      The registered Font asset.
    • font

      @NotNull public @NotNull Font font(@NotNull @NotNull String name, byte[] data)
      Registers a font configuration with provided data.
      Parameters:
      name - Font ID.
      data - Raw JSON bytes.
      Returns:
      The registered Font asset.
    • model

      @NotNull public @NotNull Model model(@NotNull @NotNull String name, boolean autoLoad)
      Registers a 3D or 2D item/block model asset.
      Parameters:
      name - The name of the model.
      autoLoad - Load from JAR.
      Returns:
      The registered Model asset.
    • model

      @NotNull public @NotNull Model model(@NotNull @NotNull String name, byte[] data)
      Registers a model with provided raw data.
      Parameters:
      name - Model name.
      data - Raw JSON bytes.
      Returns:
      The registered Model asset.
    • model

      @NotNull public @NotNull Model model(@NotNull @NotNull String name, int texWidth, int texHeight)
      Registers a blank model with specific texture resolution hints.
      Parameters:
      name - Model name.
      texWidth - Target texture width.
      texHeight - Target texture height.
      Returns:
      The registered Model asset.
    • blockstate

      public BlockState blockstate(String name, boolean autoLoad)
      Registers a blockstate configuration asset.
      Parameters:
      name - Block ID.
      autoLoad - Load from JAR.
      Returns:
      The registered BlockState asset.
    • blockstate

      public BlockState blockstate(String name, byte[] data)
      Registers a blockstate with provided data.
      Parameters:
      name - Block ID.
      data - Raw JSON bytes.
      Returns:
      The registered BlockState asset.
    • lang

      @NotNull public @NotNull Lang lang(@NotNull @NotNull String locale, boolean autoLoad)
      Registers a translation language file (e.g., en_us.json).
      Parameters:
      locale - The locale code.
      autoLoad - Load from JAR.
      Returns:
      The registered Lang asset.
    • lang

      @NotNull public @NotNull Lang lang(@NotNull @NotNull String locale, byte[] data)
      Registers a language file with provided data.
      Parameters:
      locale - Locale code.
      data - Raw JSON bytes.
      Returns:
      The registered Lang asset.
    • sounds

      @NotNull public @NotNull Sounds sounds()
      Registers the sounds.json registry for this namespace.
      Returns:
      The registered Sounds asset.
    • itemDefinition

      @NotNull public @NotNull ItemDefinition itemDefinition(@NotNull @NotNull String name)
      Registers an ItemDefinition asset from the plugin's JAR.
      Parameters:
      name - The item name.
      Returns:
      The registered definition.
    • itemDefinition

      @NotNull public @NotNull ItemDefinition itemDefinition(@NotNull @NotNull String name, byte[] data)
      Registers an ItemDefinition with provided data.
      Parameters:
      name - The item name.
      data - Raw JSON bytes.
      Returns:
      The registered definition.
    • itemDefinition

      public ItemDefinition itemDefinition(@NotNull @NotNull String name, @NotNull @NotNull Selector selector)
      Programmatically registers an item definition using a selector.
      Parameters:
      name - Item name.
      selector - The Selector defining which model to show.
      Returns:
      The registered definition.
    • itemDefinition

      public ItemDefinition itemDefinition(@NotNull @NotNull String name, @NotNull @NotNull Selector selector, boolean handAnimationOnSwap)
      Programmatically registers an item definition with toggleable swap animation.
      Parameters:
      name - Item name.
      selector - Model selector.
      handAnimationOnSwap - If true, plays the "swing" animation when swapping to this item.
      Returns:
      The registered definition.
    • itemDefinition

      public ItemDefinition itemDefinition(@NotNull @NotNull String name, @NotNull @NotNull Selector selector, double swapAnimationScale)
      Programmatically registers an item definition with custom GUI animation scale.
      Parameters:
      name - Item name.
      selector - Model selector.
      swapAnimationScale - Scaling factor for the GUI movement on swap.
      Returns:
      The registered definition.
    • itemDefinition

      public ItemDefinition itemDefinition(@NotNull @NotNull String name, @NotNull @NotNull Selector selector, boolean handAnimationOnSwap, boolean oversizedInGui, double swapAnimationScale)
      The master method for programmatic item definitions.
      Parameters:
      name - Item name.
      selector - Model selector.
      handAnimationOnSwap - Swing animation toggle.
      oversizedInGui - Whether the item appears larger in inventories.
      swapAnimationScale - Animation speed/scale.
      Returns:
      The registered definition.
    • equipment

      public Equipment equipment(String path, boolean autoLoad)
      Registers an equipment asset for armor or player-held items.
      Parameters:
      path - Asset path.
      autoLoad - Load from JAR.
      Returns:
      The registered Equipment asset.
    • equipment

      public Equipment equipment(String path, byte[] data)
      Registers an equipment asset with provided data.
      Parameters:
      path - Asset path.
      data - Raw JSON bytes.
      Returns:
      The registered Equipment asset.
    • json

      public JsonAsset json(String path, boolean autoLoad)
      Registers a generic JSON file asset within the namespace.
      Parameters:
      path - Path relative to assets/ns/ (excluding .json).
      autoLoad - Load from JAR.
      Returns:
      The registered JsonAsset.
    • icon

      public void icon(byte[] data)
      Sets the icon for this Namespace to show in menus using raw image data.
      Parameters:
      data - The PNG bytes.
    • icon

      public void icon()
      Autoloads the icon for this Namespace from textures/item/icon.png.
    • emit

      public void emit(@NotNull @NotNull Map<String,byte[]> files)
      Iterates through all registered assets and writes them into the provided map.
      Parameters:
      files - The map containing output file paths and byte data.
    • id

      @NotNull public @NotNull String id(@NotNull @NotNull String path)
      Formats a path into a namespaced ID (e.g., "myplugin:sword").
      Parameters:
      path - The local path string.
      Returns:
      A namespaced ID.
    • getPlugin

      @NotNull public @NotNull org.bukkit.plugin.Plugin getPlugin()
      Returns:
      The Bukkit Plugin associated with this namespace.
    • getNamespace

      @NotNull public @NotNull String getNamespace()
      Returns:
      The ID of this namespace.
    • getPack

      @NotNull public @NotNull ResourcePack getPack()
      Returns:
      The parent ResourcePack.
    • getIcon

      public Texture getIcon()
      Returns:
      The Texture used as an icon for this namespace, or null.