Adding additional CLI arguments #194
-
I can't make sense of the code that parses the launch arguments. How could I go about adding my own arguments to configure my mod? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
OK, I'll answer to myself here because I figured it out and I think it could be useful to others: |
Beta Was this translation helpful? Give feedback.
OK, I'll answer to myself here because I figured it out and I think it could be useful to others:
In Minecraft's main function, define an OptionSpec (like the others, one under each other), like
OptionSpec<String> myModArgument = optionparser.accepts("myArgumentName").withRequiredArg();
. You can explore other methods available, like.withOptionalArg()
, or use different types, likeFile
s. Once you have that, go below the argument definitions and write code that uses your new shiny optionspec object calledmyModArgument
, usingparseArgument(optionSet, myModArgument)
. I have no idea why this took me so long, but that's literally it.