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> {
|
companion object : Type<Feature> {
|
||||||
override val codec: Codec<Feature> by lazy {
|
override val codec: MapCodec<Feature> by lazy {
|
||||||
Codec
|
RecordCodecBuilder.mapCodec<Feature> { // KT-52757
|
||||||
.either(ResourceLocation.CODEC, RecordCodecBuilder.create<Feature> { // KT-52757
|
it.group(
|
||||||
it.group(
|
ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id),
|
||||||
ResourceLocation.CODEC.fieldOf("id").forGetter(Feature::id),
|
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional)
|
||||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(Feature::optional)
|
).apply(it, ::Feature)
|
||||||
).apply(it, ::Feature)
|
}
|
||||||
})
|
|
||||||
.xmap<Feature>(
|
|
||||||
{ c -> c.map({ Feature(it) }, { it }) },
|
|
||||||
{ c -> if (c.optional) Either.left(c.id) else Either.right(c) }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,19 +130,14 @@ interface AndroidResearchResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : Type<FeatureLevel> {
|
companion object : Type<FeatureLevel> {
|
||||||
override val codec: Codec<FeatureLevel> by lazy {
|
override val codec: MapCodec<FeatureLevel> by lazy {
|
||||||
Codec
|
RecordCodecBuilder.mapCodec<FeatureLevel> { // KT-52757
|
||||||
.either(ResourceLocation.CODEC, RecordCodecBuilder.create<FeatureLevel> { // KT-52757
|
it.group(
|
||||||
it.group(
|
ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id),
|
||||||
ResourceLocation.CODEC.fieldOf("id").forGetter(FeatureLevel::id),
|
Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional),
|
||||||
Codec.BOOL.optionalFieldOf("optional", false).forGetter(FeatureLevel::optional),
|
Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels),
|
||||||
Codec.INT.optionalFieldOf("levels", 1).forGetter(FeatureLevel::levels),
|
).apply(it, ::FeatureLevel)
|
||||||
).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) }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user