File Structure Configuration

Basic Usage (Template String)

files: {
  perNamespace: true,
  output: 'resources/{projectId}/configuration/{folder}/{namespace}.yml',
  assets: 'resources/{projectId}/assets/{namespace}/{asset}',  // Simple template
}

This puts all assets in: resources/myproject/assets/mynamespace/textures/item.png and resources/myproject/assets/mynamespace/models/item.json

Advanced Usage (Function)

files: {
  perNamespace: true,
  output: 'resources/{projectId}/configuration/{folder}/{namespace}.yml',
  
  // Use a function for complex logic!
  assets: (context) => {
    const { item, assetType, assetName, projectId, namespace, folder } = context;
    
    // Custom logic based on item type
    if (item.type === 'block') {
      if (assetType === 'model') {
        return `resources/${projectId}/assets/${namespace}/models/blocks/${assetName}`;
      } else if (assetType === 'texture') {
        return `resources/${projectId}/assets/${namespace}/customtextures/${assetName}`;
      }
    }
    
    if (item.type === 'item') {
      if (assetType === 'model') {
        return `resources/${projectId}/assets/${namespace}/models/items/${assetName}`;
      } else if (assetType === 'texture') {
        return `resources/${projectId}/assets/${namespace}/textures/items/${assetName}`;
      }
    }
    
    // Default fallback
    return `resources/${projectId}/assets/${namespace}/${assetType}s/${assetName}`;
  }
}

Function Context

The function receives an object with:

  • item - The full item data (item.type, item.id, item.subtype, etc.)

  • assetType - Either 'texture' or 'model'

  • assetName - The filename (e.g., 'myweapon.png' or 'myweapon.json')

  • projectId - The project name (e.g., 'myproject')

  • namespace - The item's namespace (e.g., 'mynamespace')

  • folder - The folder name (e.g., 'myfolder')

  • textureCount - Number of textures this item has (e.g., 3)

  • modelCount - Number of models this item has (e.g., 1)

Example: Organize by Item Subtype

Example: Organize by Custom Module

This would create:

  • resources/myproject/assets/mynamespace/textures/legendary/excalibur.png

  • resources/myproject/assets/mynamespace/textures/common/stick.png

Example: Different Texture Folders by Type

Example: Organize by Asset Count

This creates:

  • resources/myproject/assets/mynamespace/multitexture/complexitem/texture1.png

  • resources/myproject/assets/mynamespace/multitexture/complexitem/texture2.png

  • resources/myproject/assets/mynamespace/multitexture/complexitem/texture3.png

  • resources/myproject/assets/mynamespace/textures/simpleitem.png (single texture)

Return Value

The function should return a string representing the relative path from the export root.

Do NOT include the base output path - that's added automatically.

✅ Good: resources/myproject/assets/mynamespace/textures/item.png ❌ Bad: C:/Users/.../Exports/craftengine/resources/...

Backwards Compatibility

Template strings still work! You can use either:

  • String template: 'resources/{projectId}/assets/{namespace}/{asset}'

  • Function: (context) => { ... }

Both options are fully supported.

Last updated