com.llamalad7.mixinextras.utils.Blackboard Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mixinextras-fabric Show documentation
Show all versions of mixinextras-fabric Show documentation
Companion library to Mixin with lots of features to improve the compatibility and concision of your mixins!
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.