|
1 | | -# YetAnotherConfigLib 3.4.4 |
| 1 | +# YetAnotherConfigLib 3.5.0 |
2 | 2 |
|
3 | 3 | This build supports the following versions: |
4 | 4 | - Fabric 1.20.1 |
5 | 5 | - Fabric 1.20.4 |
6 | 6 | - Fabric 1.20.6 (also supports 1.20.5) |
| 7 | +- Fabric 1.21 |
7 | 8 | - NeoForge 1.20.6 (also supports 1.20.5) |
8 | 9 | - NeoForge 1.20.4 |
9 | 10 | - MinecraftForge 1.20.1 |
10 | 11 |
|
11 | | -## Bug Fixes |
| 12 | +## *Experimental* Codec Config |
12 | 13 |
|
13 | | -- Fix Kotlin DSL not being included |
| 14 | +This update brings a new experimental config API that utilises Mojang's Codec for (de)serialization. |
| 15 | + |
| 16 | +```java |
| 17 | +public class CodecConfig extends JsonFileCodecConfig/*or*/CodecConfig { |
| 18 | + public static final CodecConfig INSTANCE = new CodecConfig(); |
| 19 | + |
| 20 | + public final ConfigEntry<Integer> myInt = |
| 21 | + register("my_int", 0, Codec.INT); |
| 22 | + |
| 23 | + public final ReadonlyConfigEntry<InnerCodecConfig> myInnerConfig = |
| 24 | + register("my_inner_config", InnerCodecConfig.INSTANCE); |
| 25 | + |
| 26 | + public CodecConfig() { |
| 27 | + super(path); |
| 28 | + } |
| 29 | + |
| 30 | + void test() { |
| 31 | + loadFromFile(); // load like this |
| 32 | + saveToFile(); // save like this |
| 33 | + |
| 34 | + // or if you just extend CodecConfig instead of JsonFileConfig: |
| 35 | + JsonElement element = null; |
| 36 | + this.decode(element, JsonOps.INSTANCE); // load |
| 37 | + DataResult<JsonElement> encoded = this.encodeStart(JsonOps.INSTANCE); // save |
| 38 | + } |
| 39 | +} |
| 40 | +``` |
| 41 | +or in Kotlin... |
| 42 | +```kotlin |
| 43 | +object CodecConfig : JsonFileCodecConfig(path) { |
| 44 | + val myInt by register<Int>(0, Codec.INT) |
| 45 | + |
| 46 | + val myInnerConfig by register(InnerCodecConfig) |
| 47 | + |
| 48 | + fun test() { |
| 49 | + loadFromFile() |
| 50 | + saveToFile() |
| 51 | + |
| 52 | + // blah blah blah |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +## Rewritten Kotlin DSL |
| 58 | + |
| 59 | +Completely rewrote the Kotlin DSL! |
| 60 | + |
| 61 | +```kotlin |
| 62 | +YetAnotherConfigLib("namespace") { |
| 63 | + val category by categories.registering { |
| 64 | + val option by rootOptions.registering<Int> { |
| 65 | + controller = slider(range = 5..10) |
| 66 | + binding(::thisProp, default) |
| 67 | + |
| 68 | + val otherOption by categories["category"]["group"].futureRef<Boolean>() |
| 69 | + otherOption.onReady { it.setAvailable(false) } |
| 70 | + } |
| 71 | + |
| 72 | + // translation key is generated automagically |
| 73 | + val label by rootOptions.registeringLabel |
| 74 | + |
| 75 | + val group by groups.registering { |
| 76 | + val otherOption = options.register<Boolean>("otherOption") { |
| 77 | + controller = tickBox() |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +## Changes |
| 85 | + |
| 86 | +- Fix dropdown controllers erroneously showing their dropdown - Crendgrim |
| 87 | +- Make cancel/reset and undo buttons public for accessing |
| 88 | +- Add compatibility for 1.21 |
0 commit comments