/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.google.common.base.Suppliers * com.mojang.datafixers.util.Function10 * com.mojang.datafixers.util.Function11 * com.mojang.datafixers.util.Function12 * com.mojang.datafixers.util.Function3 * com.mojang.datafixers.util.Function4 * com.mojang.datafixers.util.Function5 * com.mojang.datafixers.util.Function6 * com.mojang.datafixers.util.Function7 * com.mojang.datafixers.util.Function8 * com.mojang.datafixers.util.Function9 * io.netty.buffer.ByteBuf */ package net.minecraft.network.codec; import com.google.common.base.Suppliers; import com.mojang.datafixers.util.Function10; import com.mojang.datafixers.util.Function11; import com.mojang.datafixers.util.Function12; import com.mojang.datafixers.util.Function3; import com.mojang.datafixers.util.Function4; import com.mojang.datafixers.util.Function5; import com.mojang.datafixers.util.Function6; import com.mojang.datafixers.util.Function7; import com.mojang.datafixers.util.Function8; import com.mojang.datafixers.util.Function9; import io.netty.buffer.ByteBuf; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; import java.util.function.UnaryOperator; import net.minecraft.network.codec.StreamDecoder; import net.minecraft.network.codec.StreamEncoder; import net.minecraft.network.codec.StreamMemberEncoder; public interface StreamCodec extends StreamEncoder, StreamDecoder { public static StreamCodec of(final StreamEncoder encoder, final StreamDecoder decoder) { return new StreamCodec(){ @Override public V decode(B input) { return decoder.decode(input); } @Override public void encode(B output, V value) { encoder.encode(output, value); } }; } public static StreamCodec ofMember(final StreamMemberEncoder encoder, final StreamDecoder decoder) { return new StreamCodec(){ @Override public V decode(B input) { return decoder.decode(input); } @Override public void encode(B output, V value) { encoder.encode(value, output); } }; } public static StreamCodec unit(final V instance) { return new StreamCodec(){ @Override public V decode(B input) { return instance; } @Override public void encode(B output, V value) { if (!value.equals(instance)) { throw new IllegalStateException("Can't encode '" + String.valueOf(value) + "', expected '" + String.valueOf(instance) + "'"); } } }; } default public StreamCodec apply(CodecOperation operation) { return operation.apply(this); } default public StreamCodec map(final Function to, final Function from) { return new StreamCodec(){ @Override public O decode(B input) { return to.apply(StreamCodec.this.decode(input)); } @Override public void encode(B output, O value) { StreamCodec.this.encode(output, from.apply(value)); } }; } default public StreamCodec mapStream(final Function operation) { return new StreamCodec(){ @Override public V decode(O input) { Object wrappedStream = operation.apply(input); return StreamCodec.this.decode(wrappedStream); } @Override public void encode(O output, V value) { Object wrappedStream = operation.apply(output); StreamCodec.this.encode(wrappedStream, value); } }; } default public StreamCodec dispatch(final Function type, final Function> codec) { return new StreamCodec(){ @Override public U decode(B input) { Object key = StreamCodec.this.decode(input); StreamCodec valueCodec = (StreamCodec)codec.apply(key); return valueCodec.decode(input); } @Override public void encode(B output, U value) { Object key = type.apply(value); StreamCodec valueCodec = (StreamCodec)codec.apply(key); StreamCodec.this.encode(output, key); valueCodec.encode(output, value); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final Function constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); return constructor.apply(v1); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final BiFunction constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); return constructor.apply(v1, v2); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final Function3 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); return constructor.apply(v1, v2, v3); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final Function4 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); return constructor.apply(v1, v2, v3, v4); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final Function5 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); return constructor.apply(v1, v2, v3, v4, v5); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final Function6 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final StreamCodec codec7, final Function getter7, final Function7 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); Object v7 = codec7.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6, v7); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); codec7.encode(output, getter7.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final StreamCodec codec7, final Function getter7, final StreamCodec codec8, final Function getter8, final Function8 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); Object v7 = codec7.decode(input); Object v8 = codec8.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6, v7, v8); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); codec7.encode(output, getter7.apply(value)); codec8.encode(output, getter8.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final StreamCodec codec7, final Function getter7, final StreamCodec codec8, final Function getter8, final StreamCodec codec9, final Function getter9, final Function9 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); Object v7 = codec7.decode(input); Object v8 = codec8.decode(input); Object v9 = codec9.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); codec7.encode(output, getter7.apply(value)); codec8.encode(output, getter8.apply(value)); codec9.encode(output, getter9.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final StreamCodec codec7, final Function getter7, final StreamCodec codec8, final Function getter8, final StreamCodec codec9, final Function getter9, final StreamCodec codec10, final Function getter10, final Function10 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); Object v7 = codec7.decode(input); Object v8 = codec8.decode(input); Object v9 = codec9.decode(input); Object v10 = codec10.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); codec7.encode(output, getter7.apply(value)); codec8.encode(output, getter8.apply(value)); codec9.encode(output, getter9.apply(value)); codec10.encode(output, getter10.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final StreamCodec codec7, final Function getter7, final StreamCodec codec8, final Function getter8, final StreamCodec codec9, final Function getter9, final StreamCodec codec10, final Function getter10, final StreamCodec codec11, final Function getter11, final Function11 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); Object v7 = codec7.decode(input); Object v8 = codec8.decode(input); Object v9 = codec9.decode(input); Object v10 = codec10.decode(input); Object v11 = codec11.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); codec7.encode(output, getter7.apply(value)); codec8.encode(output, getter8.apply(value)); codec9.encode(output, getter9.apply(value)); codec10.encode(output, getter10.apply(value)); codec11.encode(output, getter11.apply(value)); } }; } public static StreamCodec composite(final StreamCodec codec1, final Function getter1, final StreamCodec codec2, final Function getter2, final StreamCodec codec3, final Function getter3, final StreamCodec codec4, final Function getter4, final StreamCodec codec5, final Function getter5, final StreamCodec codec6, final Function getter6, final StreamCodec codec7, final Function getter7, final StreamCodec codec8, final Function getter8, final StreamCodec codec9, final Function getter9, final StreamCodec codec10, final Function getter10, final StreamCodec codec11, final Function getter11, final StreamCodec codec12, final Function getter12, final Function12 constructor) { return new StreamCodec(){ @Override public C decode(B input) { Object v1 = codec1.decode(input); Object v2 = codec2.decode(input); Object v3 = codec3.decode(input); Object v4 = codec4.decode(input); Object v5 = codec5.decode(input); Object v6 = codec6.decode(input); Object v7 = codec7.decode(input); Object v8 = codec8.decode(input); Object v9 = codec9.decode(input); Object v10 = codec10.decode(input); Object v11 = codec11.decode(input); Object v12 = codec12.decode(input); return constructor.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); } @Override public void encode(B output, C value) { codec1.encode(output, getter1.apply(value)); codec2.encode(output, getter2.apply(value)); codec3.encode(output, getter3.apply(value)); codec4.encode(output, getter4.apply(value)); codec5.encode(output, getter5.apply(value)); codec6.encode(output, getter6.apply(value)); codec7.encode(output, getter7.apply(value)); codec8.encode(output, getter8.apply(value)); codec9.encode(output, getter9.apply(value)); codec10.encode(output, getter10.apply(value)); codec11.encode(output, getter11.apply(value)); codec12.encode(output, getter12.apply(value)); } }; } public static StreamCodec recursive(final UnaryOperator> factory) { return new StreamCodec(){ private final Supplier> inner = Suppliers.memoize(() -> (StreamCodec)factory.apply(this)); @Override public T decode(B input) { return this.inner.get().decode(input); } @Override public void encode(B output, T value) { this.inner.get().encode(output, value); } }; } default public StreamCodec cast() { return this; } @FunctionalInterface public static interface CodecOperation { public StreamCodec apply(StreamCodec var1); } }