use of com.wynntils.mc.mixin.accessors.OptionsAccessor in project Artemis by Wynntils.
the class KeyManager method registerKeybind.
public static void registerKeybind(KeyHolder toAdd) {
if (hasName(toAdd.getName())) {
throw new IllegalStateException("Can not add " + toAdd + " since the name already exists");
}
keyHolders.add(toAdd);
Options options = Minecraft.getInstance().options;
if (options == null) {
// loaded later by a mixin
return;
}
synchronized (options) {
KeyMapping[] keyMappings = options.keyMappings;
List<KeyMapping> newKeyMappings = Lists.newArrayList(keyMappings);
newKeyMappings.add(toAdd.getKeybind());
((OptionsAccessor) options).setKeyBindMixins(newKeyMappings.toArray(new KeyMapping[0]));
}
}
use of com.wynntils.mc.mixin.accessors.OptionsAccessor in project Artemis by Wynntils.
the class KeyManager method unregisterKeybind.
public static void unregisterKeybind(KeyHolder toAdd) {
if (keyHolders.remove(toAdd)) {
Options options = Minecraft.getInstance().options;
synchronized (options) {
KeyMapping[] keyMappings = options.keyMappings;
List<KeyMapping> newKeyMappings = Lists.newArrayList(keyMappings);
newKeyMappings.remove(toAdd.getKeybind());
((OptionsAccessor) options).setKeyBindMixins(newKeyMappings.toArray(new KeyMapping[0]));
}
}
}
Aggregations