All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.llamalad7.mixinextras.utils.Blackboard Maven / Gradle / Ivy

Go to download

Companion library to Mixin with lots of features to improve the compatibility and concision of your mixins!

There is a newer version: 0.5.0-beta.4
Show newest version
package com.llamalad7.mixinextras.utils;

import org.spongepowered.asm.service.IGlobalPropertyService;
import org.spongepowered.asm.service.MixinService;

/**
 * Helpers for the Mixin property service.
 * We have to use arrays as the backing values because on ModLauncher the properties are immutable, for some reason.
 */
@SuppressWarnings("unchecked")
public class Blackboard {
    private static final IGlobalPropertyService SERVICE = MixinService.getGlobalPropertyService();

    public static  T get(String key) {
        Object[] impl = SERVICE.getProperty(SERVICE.resolveKey(key));
        return impl == null ? null : (T) impl[0];
    }

    public static void put(String key, Object value) {
        SERVICE.setProperty(SERVICE.resolveKey(key), new Object[1]);
        SERVICE.getProperty(SERVICE.resolveKey(key))[0] = value;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy