### Nexo Maker Asset References Example (JavaScript) Source: https://nexo-maker.gitbook.io/nexo-maker-docs/main.js/api/plugin-expansion/getting-started Shows examples of asset references for textures and models within the Nexo Maker data model. These are provided as arrays of relative file paths, crucial for loading visual assets associated with an item. ```javascript item.textures // string[]: Texture file paths (e.g., ["item/magic_sword.png"]) item.models // string[]: Model file paths (e.g., ["item/magic_sword.json"]) ``` -------------------------------- ### Register Export Format API Configuration (JavaScript) Source: https://nexo-maker.gitbook.io/nexo-maker-docs/main.js/api/plugin-expansion/getting-started An example demonstrating the full configuration object for registering an export format via the Nexo Maker API. It includes optional parameters like 'files' for file structure and 'hooks' for lifecycle management. ```javascript api.nexomaker.registerExportFormat({ id: 'my_format', name: 'My Custom Format', transform: (item) => ({ /* transformed data */ }), files: { /* file configuration */ }, hooks: { /* lifecycle hooks */ }, }); ``` -------------------------------- ### Nexo Maker Module Data Example (JavaScript) Source: https://nexo-maker.gitbook.io/nexo-maker-docs/main.js/api/plugin-expansion/getting-started Provides an example of how module data is exposed in Nexo Maker. Module data is a flat object containing all registered module values for a specific item, allowing access to custom properties defined by expansions. ```javascript { expansion_magic_power: 150, baseMaterial: "DIAMOND_SWORD", durability: 1000, // Additional module data as defined by active expansions } ``` -------------------------------- ### Register Export Format API Source: https://nexo-maker.gitbook.io/nexo-maker-docs/main.js/api/plugin-expansion/getting-started Demonstrates how to register a custom export format using the `registerExportFormat` method. ```APIDOC ## POST /api/nexomaker/registerExportFormat ### Description Registers a custom export format with the NexoMaker export system, allowing for custom data transformation and file handling. ### Method POST ### Endpoint /api/nexomaker/registerExportFormat ### Parameters #### Request Body - **config** (object) - Required - Export format configuration object - **id** (string) - Required - Unique identifier for the export format - **name** (string) - Required - Human-readable display name - **transform** (function) - Required - Item transformation function - **files** (object) - Optional - File structure configuration - **hooks** (object) - Optional - Lifecycle hook implementations ### Request Example ```json { "config": { "id": "my_format", "name": "My Custom Format", "transform": "(item) => ({ /* transformed data */ })", "files": "{ /* file configuration */ }", "hooks": "{ /* lifecycle hooks */ }" } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful registration. #### Response Example ```json { "message": "Export format 'my_format' registered successfully." } ``` ``` -------------------------------- ### Basic useLibraries() Setup in JavaScript Source: https://nexo-maker.gitbook.io/nexo-maker-docs/modular/imports/libraries Shows the initial setup required to use the `useLibraries()` utility by including it in the `module.exports` function. This is a prerequisite for importing any libraries. ```javascript module.exports = ({ useLibraries }) => { // Your code here }; ``` -------------------------------- ### Nexo Maker Data Model Properties (JavaScript) Source: https://nexo-maker.gitbook.io/nexo-maker-docs/main.js/api/plugin-expansion/getting-started Illustrates the core properties guaranteed on normalized items processed by Nexo Maker. These include unique identifiers, display names, item types, and namespace information, essential for consistent data handling. ```javascript item.id // string: Unique identifier (e.g., "magic_sword") item.name // string: Display name (e.g., "Magic Sword") item.type // string: Item type - "item" | "block" | "entity" | "furniture" item.namespace // string: Namespace identifier (e.g., "nexo" or custom namespace) ``` -------------------------------- ### Simple Keybinding Example Source: https://nexo-maker.gitbook.io/nexo-maker-docs/modular/imports/libraries/keybinding Shows a basic implementation of the Keybinding component. It sets up a listener for the 'Ctrl + K' shortcut, which increments a counter when pressed. This example highlights the direct mapping of keys to actions. ```javascript module.exports = ({ useState, useLibraries }) => { const { KeyBinding } = useLibraries(); const [count, setCount] = useState(0); return (
Press Ctrl + K to increment: {count}
The switch is {isOn ? 'ON' : 'OFF'}
Total Clicks: ${stats.clicks}
Total Toggles: ${stats.toggles}
Current Position: (${Math.round(position.x)}, ${Math.round(position.y)})
Last Interaction: ${stats.lastInteraction ? new Date(stats.lastInteraction).toLocaleString() : 'Never'}
Overlay Visible: ${isVisible ? '✅ Yes' : '❌ No'}
Context: ${placeholders.context}
Project ID: ${placeholders.projectId}
🔥 Shortcuts:
• Ctrl+Shift+O: Toggle overlay
• Ctrl+Shift+R: Reset position
• Drag to move overlay