Client-Sided API for Minecraft 1.14
|
há 6 anos atrás | |
---|---|---|
gradle | há 6 anos atrás | |
src | há 6 anos atrás | |
.gitignore | há 6 anos atrás | |
.travis.yml | há 6 anos atrás | |
LICENSE | há 6 anos atrás | |
README.md | há 6 anos atrás | |
build.gradle | há 6 anos atrás | |
gradle.properties | há 6 anos atrás | |
gradlew | há 6 anos atrás | |
gradlew.bat | há 6 anos atrás | |
settings.gradle | há 6 anos atrás |
repositories {
maven { url "https://minecraft.curseforge.com/api/maven"}
}
dependencies {
mmodCompile "cloth-config:ClothConfig:{RANDOMVERSION}"
}
Start by using ConfigScreenBuilder.create
, inside it you can do addCategory
to get the category instance. Do addOption
with the category instance to add an option.
ConfigScreenBuilder builder = ConfigScreenBuilder.create(parentScreen, screenTitleKey, saveConsumer);
builder.addCategory("text.category.key").addOption(option);
There are multiple builtin option types:
toString()
in the enum for names)And you can always build your own entry. Example of a boolean entry:
builder.addCategory("text.category.key").addOption(new BooleanListEntry(fieldKey, value, save));
fieldKey
will be translated automatically using I18n
, value
is the true
or false
, for save
, it will only be called when you press save.
Infect, you should do something like this:
AtomicBoolean configBool = new AtomicBoolean(false);
builder.addCategory("text.category.key").addOption(new BooleanListEntry("text.value.key", configBool, bool -> configBool.set(bool)));
builder.setOnSave(savedConfig -> {
// Save your config data file here
});
Lastly, you can open the screen like this:
MinecraftClient.getInstance().openScreen(builder.build());
Start by using ConfigBuilder.create
, inside it you can do getOrCreateCategory
to get the category instance. Do addEntry
with the category instance to add an option.
ConfigBuilder builder = ConfigBuilder.create().setParentScreen(parentScreen).setTitle(screenTitleKey).set(setSavingRunnable);
builder.getOrCreateCategory("text.category.key").addEntry(option);
To start adding fields, do ConfigEntryBuilder.create()
to get the entry builder instance.
Example to add a boolean field:
ConfigEntryBuilder entryBuilder = ConfigEntryBuilder.create();
category.addEntry(entryBuilder.startBooleanToggle("path.to.your.key", false).buildEntry());
All builtin entry builders can be found in ConfigEntryBuilder.
Lastly, you can open the screen like this:
MinecraftClient.getInstance().openScreen(builder.build());