com.mojang.serialization.Codec Java Examples

The following examples show how to use com.mojang.serialization.Codec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Func.java    From DataFixerUpper with MIT License 5 votes vote down vote up
@Override
protected Codec<Function<A, B>> buildCodec() {
    return Codec.of(
        Encoder.error("Cannot save a function"),
        Decoder.error("Cannot read a function")
    );
}
 
Example #2
Source File: TaggedChoice.java    From DataFixerUpper with MIT License 5 votes vote down vote up
@Override
protected Codec<Pair<K, ?>> buildCodec() {
    return new KeyDispatchCodec<K, Pair<K, ?>>(
        name,
        keyType.codec(),
        p -> DataResult.success(p.getFirst()),
        k -> getCodec(k).map(c -> c.map(v -> Pair.of(k, v))),
        this::encoder
    ).codec();
}
 
Example #3
Source File: Check.java    From DataFixerUpper with MIT License 5 votes vote down vote up
@Override
protected Codec<A> buildCodec() {
    return Codec.<A>of(
        delegate.codec(),
        this::read
    );
}
 
Example #4
Source File: EitherCodec.java    From DataFixerUpper with MIT License 4 votes vote down vote up
public EitherCodec(final Codec<F> first, final Codec<S> second) {
    this.first = first;
    this.second = second;
}
 
Example #5
Source File: MoonVillageFeature.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public MoonVillageFeature(Codec<StructurePoolFeatureConfig> codec) {
    super(codec);
}
 
Example #6
Source File: CompoundListCodec.java    From DataFixerUpper with MIT License 4 votes vote down vote up
public CompoundListCodec(final Codec<K> keyCodec, final Codec<V> elementCodec) {
    this.keyCodec = keyCodec;
    this.elementCodec = elementCodec;
}
 
Example #7
Source File: EmptyPart.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
protected Codec<Unit> buildCodec() {
    return Codec.EMPTY.codec();
}
 
Example #8
Source File: EmptyPartPassthrough.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
public Codec<Dynamic<?>> buildCodec() {
    return Codec.PASSTHROUGH;
}
 
Example #9
Source File: Type.java    From DataFixerUpper with MIT License 4 votes vote down vote up
public final Codec<A> codec() {
    if (codec == null) {
        codec = buildCodec();
    }
    return codec;
}
 
Example #10
Source File: Sum.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
protected Codec<Either<F, G>> buildCodec() {
    return Codec.either(first.codec(), second.codec());
}
 
Example #11
Source File: CompoundList.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
protected Codec<List<Pair<K, V>>> buildCodec() {
    return Codec.compoundList(key.codec(), element.codec());
}
 
Example #12
Source File: List.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
public Codec<java.util.List<A>> buildCodec() {
    return Codec.list(element.codec());
}
 
Example #13
Source File: Tag.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
protected Codec<A> buildCodec() {
    return element.codec().fieldOf(name).codec();
}
 
Example #14
Source File: Const.java    From DataFixerUpper with MIT License 4 votes vote down vote up
public PrimitiveType(final Codec<A> codec) {
    this.codec = codec;
}
 
Example #15
Source File: Const.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
protected Codec<A> buildCodec() {
    return codec;
}
 
Example #16
Source File: Product.java    From DataFixerUpper with MIT License 4 votes vote down vote up
@Override
public Codec<Pair<F, G>> buildCodec() {
    return Codec.pair(first.codec(), second.codec());
}
 
Example #17
Source File: TaggedChoice.java    From DataFixerUpper with MIT License 4 votes vote down vote up
private DataResult<? extends Codec<?>> getCodec(final K k) {
    return Optional.ofNullable(types.get(k)).map(t -> DataResult.success(t.codec())).orElseGet(() -> DataResult.error("Unsupported key: " + k));
}
 
Example #18
Source File: MoonBiomeSource.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
@Override
protected Codec<? extends BiomeSource> method_28442() {
    return CODEC;
}
 
Example #19
Source File: RecordCodecBuilder.java    From DataFixerUpper with MIT License 3 votes vote down vote up
public static <O> Codec<O> create(final Function<Instance<O>, ? extends App<Mu<O>, O>> builder) {
    return build(builder.apply(instance())).codec();
}
 
Example #20
Source File: GCOreFeature.java    From Galacticraft-Rewoven with MIT License 3 votes vote down vote up
public GCOreFeature(Codec<GCOreFeatureConfig> codec) {
    super(codec);
}
 
Example #21
Source File: MoonSurfaceBuilder.java    From Galacticraft-Rewoven with MIT License 3 votes vote down vote up
public MoonSurfaceBuilder(Codec<C> codec) {
    super(codec);
}
 
Example #22
Source File: MultiBlockSurfaceBuilder.java    From Galacticraft-Rewoven with MIT License 3 votes vote down vote up
public MultiBlockSurfaceBuilder(Codec<MultiBlockSurfaceConfig> function) {
    super(function);
}
 
Example #23
Source File: MoonChunkGenerator.java    From Galacticraft-Rewoven with MIT License 3 votes vote down vote up
protected Codec<? extends ChunkGenerator> method_28506() {
    return CODEC;
}
 
Example #24
Source File: MyBlockStateParticleType.java    From multiconnect with MIT License 3 votes vote down vote up
@Override
public Codec<BlockStateParticleEffect> method_29138() {
    return BlockStateParticleEffect.method_29128(this);
}
 
Example #25
Source File: Codecked.java    From multiconnect with MIT License 3 votes vote down vote up
public Codecked(Codec<T> codec, T value) {
    this.codec = codec;
    this.value = value;
}
 
Example #26
Source File: Codecked.java    From multiconnect with MIT License 3 votes vote down vote up
public Codec<T> getCodec() {
    return codec;
}
 
Example #27
Source File: UnboundedMapCodec.java    From DataFixerUpper with MIT License 3 votes vote down vote up
public UnboundedMapCodec(final Codec<K> keyCodec, final Codec<V> elementCodec) {
    this.keyCodec = keyCodec;
    this.elementCodec = elementCodec;
}
 
Example #28
Source File: UnboundedMapCodec.java    From DataFixerUpper with MIT License 3 votes vote down vote up
@Override
public Codec<K> keyCodec() {
    return keyCodec;
}
 
Example #29
Source File: UnboundedMapCodec.java    From DataFixerUpper with MIT License 3 votes vote down vote up
@Override
public Codec<V> elementCodec() {
    return elementCodec;
}
 
Example #30
Source File: SimpleMapCodec.java    From DataFixerUpper with MIT License 3 votes vote down vote up
public SimpleMapCodec(final Codec<K> keyCodec, final Codec<V> elementCodec, final Keyable keys) {
    this.keyCodec = keyCodec;
    this.elementCodec = elementCodec;
    this.keys = keys;
}