Skip to content

Commit

Permalink
improv: biome key stream codec
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed Oct 8, 2024
1 parent 60508fa commit f46b633
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
Expand All @@ -36,6 +39,7 @@ public final class BlockStateRecipeUtil {
? DataResult.success(TagKey.create(Registries.BIOME, ResourceLocation.parse(to.replace("#", ""))))
: DataResult.error(() -> "Value is not a tag key"), (from) -> "#" + from.location());
public static Codec<Either<ResourceKey<Biome>, TagKey<Biome>>> KEY_CODEC = Codec.xor(RESOURCE_KEY_CODEC, TAG_KEY_CODEC);
public static StreamCodec<RegistryFriendlyByteBuf, Either<ResourceKey<Biome>, TagKey<Biome>>> STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(KEY_CODEC);

/**
* Executes an {@link CacheableFunction}.
Expand Down

0 comments on commit f46b633

Please sign in to comment.