CurseForge · Minecraft mod
Reloadable File Config and Utils
Another config library plus other utils I may want
Quick answer
Which Reloadable File Config and Utils release should I use?
Reloadable File Config and Utils mod-utils-1.19.0-1.1.0.jar targets 1.19 with Fabric. The project page does not say whether this file belongs on the client, dedicated server, or both. No extra mods listed for this file.
Where it goes
Is Reloadable File Config and Utils required on the client, server, or both?
The project page does not say whether this file belongs on the client, dedicated server, or both.
The source does not explicitly classify this release as client-only or server-only.
What else does Reloadable File Config and Utils mod-utils-1.19.0-1.1.0.jar need?
mod-utils-1.19.0-1.1.0.jar. Change the file and its required mods may change too.
This file does not list any required mods. Do not add a library just because a different file uses it.
This file does not list any required or optional mods.
Before you install it
Add Reloadable File Config and Utils without breaking your instance.
Built for Reloadable File Config and Utils mod-utils-1.19.0-1.1.0.jar. Pick another file and the loader, install side or required mods may change.
- 01
Stick to this file
Use mod-utils-1.19.0-1.1.0.jar. It targets 1.19 with Fabric; another release may have different loader, side or dependency requirements.
- 02
Bring the mods it needs
This file does not list any required mods. Do not add a library just because a different file uses it.
- 03
Put it on the correct side
The project page does not say whether this file belongs on the client, dedicated server, or both.
- 04
Pick the file you checked
Use the “Get this file” button beside mod-utils-1.19.0-1.1.0.jar. It opens that exact file at the source.
About this project
What does Reloadable File Config and Utils add?
Mod Utils
This repository will hold custom utilities useful in Minecraft modding. Currently, it contains:
- A watch service to detect changes to a given file
- A configuration handler which can hot-reload from a configuration file
- A parent class that can be used to implement a mixin on the NarratorMode enum
Configuration Handling
Aren't there enough Minecraft Mod configuration managers already? Well, I made another one.
This configuration handler allows users to:
- Create custom configuration classes with sensible configuration elements
- Populate those configuration classes using JSON or YAML
- Have those classes be hot-reloadable from disk
To use this code for handling configurations in a mod:
Create a Concrete Configuration Class
- Create a java-bean style public class with private instance variables for your configurations
- Extend AbstractConfig
- Add getters and setters for each configuration
- Implement the methods getDefaultConfigPaths and equals
public class MyModConfig extends AbstractConfig {
private int config1;
private String config2;
private List<String> config3;
public int getConfig1() {
return config1;
}
public void setConfig1(int x) {
config1 = x;
}
public String getConfig2() {
return config2;
}
public void setConfig2(String x) {
config2 = x;
}
public List<String> getConfig3() {
return config3;
}
public void setConfig3(List<String> x) {
config3 = x;
}
@Override
public List<Path> getDefaultConfigPaths() {
return List.of(Path.of("config", "mymod.json"),
Path.of("config", "mymod.yml"));
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MyModConfig that = (MyModConfig) o;
return config1 == that.config1 &&
Objects.equals(config2, that.config2) &&
Objects.equals(config3, that.config3);
}
}
Use the ConfigHandler
- Create an instance of ConfigHandler using your configuration class as the parameter
- Initialize it (defaults to using the default configuration paths)
- Optionally, register one or more subscribers to be notified when there is a change detected on the configurations (subscribers must implement Reloadable)
- Always reference the configurations through configHandler.get()in order to get the latest values in case the configurations get reloaded
public class MyClass implements Reloadable {
private final ConfigHandler<MyModConfig> configHandler;
public MyClass() {
configHandler = new ConfigHandler<>(MyModConfig.class);
configHandler.initialize();
configHandler.registerSubscriber(this);
List<String> configStrings = configHandler.get().getConfig3();
...
}
...
}
NarratorModeMixin Support
The NarratorMode enum defines what narration modes Minecraft offers through the Accessibility Settings options. Creating a mixin on the enum can allow a mod to define new narration modes.
Given this mod, another mod would need to write the following class definition:
@Mixin(NarratorMode.class)
@Unique
public abstract class MyNarratorModeMixin {
private static class NarratorModeMixinHelper extends NarratorModeMixinHelperParent {
@Override
public NarratorMode narratorModeInvokeInit(
final String internalName,
final int internalId,
final int id,
final String name) {
return MyNarratorModeMixin.narratorModeInvokeInit(internalName, internalId, id, name);
}
}
@Shadow
@Final
@Mutable
private static NarratorMode[] field_18183;
@Shadow
@Final
@Mutable
private static NarratorMode[] VALUES;
private final static NarratorModeMixinHelper HELPER = new NarratorModeMixinHelper();
// Custom NarratorModes go here:
private static final NarratorMode EXAMPLE1 =
addNarratorMode("EXAMPLE1", 4, "options.narrator.example1");
private static final NarratorMode EXAMPLE2 =
addNarratorMode("EXAMPLE2", 5, "options.narrator.example2");
[...]
@Invoker("<init>")
public static NarratorMode narratorModeInvokeInit(
final String internalName,
final int internalId,
final int id,
final String name) {
throw new AssertionError();
}
private static NarratorMode addNarratorMode(final String internalName, final int id, final String name) {
final Object[] output = HELPER.addNarratorMode(VALUES, field_18183, internalName, id, name);
VALUES = (NarratorMode[]) output[0];
field_18183 = (NarratorMode[]) output[1];
return (NarratorMode) output[2];
}
}
There is still a fair amount of boilerplate required by the implementer, but it can be almost entirely copy-pasted and the most finicky logic is safely tucked away in the parent class.Note that the Fabric framework does not allow the new NarratorMode(s) to be made easily accessible by being defined as public. Also, and more annoyingly, the id does not necessarily match the ordinal or work with the NarratorMode.byId(int) method, unfortunately, so the implementer must be very careful in accessing the new modes, especially if they may be in an environment with multiple NarratorMode mixins.
Gradle
Use it in your mod! In gradle:
modImplementation "com.casewalker:mod-utils:<VERSION>"
Or to include it inside the JAR file:
include(modImplementation("com.casewalker:mod-utils:<VERSION>"))
License
Licensed under the MIT License (MIT). Copyright © 2022 Case Walker.
Project description from CurseForge.
Pick your setup
Reloadable File Config and Utils by Minecraft version and loader
Choose the version and loader you play, then open the matching release.
1.18.1
1 loader build1.17.1
1 loader buildCheck the dependencies, then try the file in a copied instance before changing a world you care about.
Recent files
Reloadable File Config and Utils versions and loaders
mod-utils-1.19.0-1.1.0.jar
25 Jun 2022
mod-utils-1.18.1-1.1.0.jar
23 Jun 2022
mod-utils-1.18.1-1.0.0.jar
16 Dec 2021
mod-utils-1.17.1-1.0.0.jar
15 Dec 2021
Looking for an older file? The official CurseForge project page is in Resources.