Skip to content

26.2 API and Library Integration

Rifa edited this page Aug 21, 2026 · 1 revision

📚 DasikLibrary API Integration

Parameter Specification
Core Dependency net.dasik.social:dasik-library
Declared Constraint dasik-library: >=1.7.0 (Active Build: 1.7.4)
Isolation Helper Class net.instantgratification.collapsiblegamerules.util.DasikMetadataHelper
Queried API Method DynamicGameRuleManager.getGeneratedTranslations()
Runtime Enforcement Hard check in CollapsibleGameRulesFabric.onInitialize()

📖 Overview

Collapsible Game Rules integrates with DasikLibrary to provide dynamic category translation and metadata formatting for modern Minecraft mods.

To maintain absolute JVM stability, all direct class references to DasikLibrary are isolated inside a dedicated lazy-loaded helper class (DasikMetadataHelper).


🔒 ClassLoading Isolation Architecture

In modern Java runtimes, referencing a class from another library within a hot class (such as a Mixin) will trigger immediate JVM classloading of the target library. If the library is absent, the JVM throws a fatal NoClassDefFoundError before the mod can gracefully report the error.

By isolating all DynamicGameRuleManager calls into DasikMetadataHelper, the JVM only attempts to load DasikLibrary classes when DasikMetadataHelper is explicitly invoked:

┌─────────────────────────────────────────────────────────────────────────────┐
│                      CLASSLOADING ISOLATION PATTERN                         │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│   AbstractGameRulesScreenRuleListMixin                                      │
│        │                                                                    │
│        ▼ (Checks FabricLoader.isModLoaded("dasik-library"))                 │
│   ┌─────────────────────────────────────────────────────────────────────┐   │
│   │ if (FabricLoader.getInstance().isModLoaded("dasik-library")) {      │   │
│   │     categoryKey = DasikMetadataHelper.getCategoryTranslation(...);  │   │
│   │ }                                                                   │   │
│   └─────────────────────────────────────────────────────────────────────┘   │
│        │                                                                    │
│        ▼ (Only loads DasikMetadataHelper when confirmed safe)               │
│   DasikMetadataHelper ──> net.dasik.social.api.gamerule.DynamicGameRuleManager│
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

💻 Metadata Query Implementation

Inside DasikMetadataHelper.java:

public final class DasikMetadataHelper {

    private static final Logger LOGGER = LoggerFactory.getLogger("collapsible-game-rules");

    private DasikMetadataHelper() {}

    /**
     * Retrieves the localized name for a category from DasikLibrary metadata.
     * Enforced Hard Dependency: This method makes direct calls to DasikLibrary.
     */
    public static String getCategoryTranslation(String categoryLabel) {
        Map<String, String> translations =
                DynamicGameRuleManager.getGeneratedTranslations();

        return translations.getOrDefault(
                "gamerule.category." + categoryLabel.toLowerCase(Locale.ROOT),
                categoryLabel
        );
    }
}

🛡️ Hard Dependency Enforcement

In compliance with the Core Sovereign Architecture, the mod verifies that dasik-library is present during ModInitializer.onInitialize():

public class CollapsibleGameRulesFabric implements ModInitializer {
    public static final String MOD_ID = "collapsible-game-rules";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    @Override
    public void onInitialize() {
        ModVersionGuard.checkClass("Collapsible Game Rules", "net.minecraft.world.level.gamerules.GameRules");
        LOGGER.info("Initializing Collapsible Game Rules [Core Align 2.1]");

        // Hard Dependency Enforcement
        if (!FabricLoader.getInstance().isModLoaded("dasik-library")) {
            throw new RuntimeException("Collapsible Game Rules requires DasikLibrary to function. Please install it.");
        }
    }
}

🔗 Related Documentation

Clone this wiki locally