Skip to content

Commit

Permalink
Merge branch '1.21-CodecToEndec_NbtFixes' of https://github.com/Drago…
Browse files Browse the repository at this point in the history
…n-Seeker/owo-lib into 1.21-CodecToEndec_NbtFixes
  • Loading branch information
Dragon-Seeker committed Sep 17, 2024
2 parents e1894a5 + 7a5a080 commit 08d5534
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/main/java/io/wispforest/owo/serialization/CodecUtils.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.wispforest.owo.serialization;

import com.mojang.datafixers.util.Either;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.*;
import io.netty.buffer.ByteBuf;
Expand All @@ -13,7 +12,6 @@
import io.wispforest.endec.format.forwarding.ForwardingSerializer;
import io.wispforest.owo.mixin.ForwardingDynamicOpsAccessor;
import io.wispforest.owo.mixin.RegistryOpsAccessor;
import io.wispforest.owo.serialization.endec.EitherEndec;
import io.wispforest.owo.serialization.endec.MinecraftEndecs;
import io.wispforest.owo.serialization.format.ContextHolder;
import io.wispforest.owo.serialization.format.ContextedDelegatingOps;
Expand Down Expand Up @@ -140,26 +138,6 @@ public static <T> Endec<T> toEndecWithRegistries(Codec<T> codec, PacketCodec<Reg
);
}

/**
* Create an endec which serializes an instance of {@link Either}, using {@code first}
* for the left and {@code second} for the right variant
* <p>
* In a self-describing format, the serialized representation is simply that of the endec of
* whichever variant is represented. In the general for non-self-described formats, the
* which variant is represented must also be stored
*/
public static <F, S> Endec<Either<F, S>> eitherEndec(Endec<F> first, Endec<S> second) {
return new EitherEndec<>(first, second, false);
}

/**
* Like {@link #eitherEndec(Endec, Endec)}, but ensures when decoding from a self-described format
* that only {@code first} or {@code second}, but not both, succeed
*/
public static <F, S> Endec<Either<F, S>> xorEndec(Endec<F> first, Endec<S> second) {
return new EitherEndec<>(first, second, true);
}

//--

/**
Expand Down

0 comments on commit 08d5534

Please sign in to comment.