# Minecraft Mods

### Prerequisites

* Forge/Fabric mod development environment
* Gradle
* SunLicense API credentials

### Integration Steps

#### 1. Add Repository and Dependency

In your `build.gradle`:

```gradle
repositories {
    maven {
        url "https://repo.hapangama.com/releases"
    }
}

dependencies {
    implementation 'com.hapangama:SunLicenseAPI:1.0.3'
}
```

#### 2. Create License Manager

```java
public class ModLicenseManager {
    private final SunLicenseAPI licenseApi;
    private static final Logger LOGGER = LogManager.getLogger();

    public ModLicenseManager() {
        this.licenseApi = SunLicenseAPI.getLicense(
            "YOUR-LICENSE-KEY",
            YOUR_PRODUCT_ID,
            "1.0.0",
            "YOUR_API_URL"
        );
    }

    public boolean validateLicense() {
        try {
            licenseApi.validate();
            return true;
        } catch (IOException e) {
            LOGGER.error("License validation failed: " + e.getMessage());
            return false;
        }
    }
}
```

#### 3. Implement in Mod Main Class

```java
public class YourMod {
    private ModLicenseManager licenseManager;

    public void onInitialize() { // For Fabric
    // OR
    public void init(FMLCommonSetupEvent event) { // For Forge
        licenseManager = new ModLicenseManager();
        
        if (!licenseManager.validateLicense()) {
            LOGGER.error("Invalid license - Mod will not function!");
            // Disable mod functionality
            return;
        }
        
        // Continue with mod initialization
    }
}
```

### Best Practices

1. **Mod Loading**
   * Validate before initializing features
   * Provide clear feedback to users
   * Handle offline mode gracefully
2. **Feature Management**
   * Graceful feature disabling
   * Clear user communication
   * Cache validation results

### Common Issues

1. **Mod Loading Failures**
   * Verify license key
   * Check network connectivity
   * Confirm dependency inclusion
2. **Runtime Problems**
   * Monitor mod logs
   * Check for network issues
   * Verify license status


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sunlicense.hapangama.com/product-integrations/minecraft-mods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
