3

I have a mod that wants to read a file splits.yml in the minecraft directory where the other configs are (config.txt, etc.). I have no idea how I would do that. My first idea was using a Mixin

@Mixin(GameOptions.class) public class GameOptionsMixin { @Shadow @Final private File optionsFile; @Inject(method = "load", at = @At("RETURN")) private void load(CallbackInfo info) { File splits = new File(optionsFile.getParent(), "splits.yml"); } } 

But I have no idea how I would extract the value. I also cannot trust that the folder will be .minecraft as a lot of fabric users use MultiMC.

1 Answer 1

7

Ok, I figured it out now.

You can use FabricLoader.getInstance().getConfigDir() to get the directory as a Path and FabricLoader.getInstance().getConfigDir().resolve("splits.yml") to get the File i need. Hope this helps anyone in the future

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.