Update android research codecs to map codec
This commit is contained in:
parent
27a93a8133
commit
4f2978010b
@ -89,18 +89,13 @@ interface AndroidResearchResult {
|
||||
}
|
||||
|
||||
companion object : Type<Feature> {
|
||||
override val codec: Codec<Feature> by lazy {
|
||||
Codec
|
||||
.either(ResourceLocation.CODEC, RecordCodecBuilder.create<Feature> { // KT-52757
|
||||
it.group(
|
||||
ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id),
|
||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional)
|
||||
).apply(it, ::Feature)
|
||||
})
|
||||
.xmap<Feature>(
|
||||
{ c -> c.map({ Feature(it) }, { it }) },
|
||||
{ c -> if (c.optional) Either.left(c.id) else Either.right(c) }
|
||||
)
|
||||
override val codec: MapCodec<Feature> by lazy {
|
||||
RecordCodecBuilder.mapCodec<Feature> { // KT-52757
|
||||
it.group(
|
||||
ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id),
|
||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional)
|
||||
).apply(it, ::Feature)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,19 +130,14 @@ interface AndroidResearchResult {
|
||||
}
|
||||
|
||||
companion object : Type<FeatureLevel> {
|
||||
override val codec: Codec<FeatureLevel> by lazy {
|
||||
Codec
|
||||
.either(ResourceLocation.CODEC, RecordCodecBuilder.create<FeatureLevel> { // KT-52757
|
||||
it.group(
|
||||
ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id),
|
||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional),
|
||||
Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels),
|
||||
).apply(it, ::FeatureLevel)
|
||||
})
|
||||
.xmap(
|
||||
{ c -> c.map({ FeatureLevel(it) }, { it }) },
|
||||
{ c -> if (c.optional && c.levels == 1) Either.left(c.id) else Either.right(c) }
|
||||
)
|
||||
override val codec: MapCodec<FeatureLevel> by lazy {
|
||||
RecordCodecBuilder.mapCodec<FeatureLevel> { // KT-52757
|
||||
it.group(
|
||||
ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id),
|
||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional),
|
||||
Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels),
|
||||
).apply(it, ::FeatureLevel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user