Skip to main content
Added minecraft-fabric tag
Link
The point of the question body is not to communicate with other users (and also, I don't think a new tag is necessary)
Source Link
Perry
  • 3.9k
  • 26
  • 40
  • 51

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.

Also can someone with 1500+ rep please create minecraft-fabric tag?

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.

Also can someone with 1500+ rep please create minecraft-fabric tag?

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.

Source Link
DownloadPizza
  • 3.5k
  • 1
  • 17
  • 28

How to get minecraft path with Fabric

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.

Also can someone with 1500+ rep please create minecraft-fabric tag?