/* * Decompiled with CFR 0.152. * * Could not load the following classes: * io.netty.buffer.ByteBuf */ package net.minecraft.network.protocol; import io.netty.buffer.ByteBuf; import net.minecraft.network.PacketListener; import net.minecraft.network.codec.IdDispatchCodec; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketFlow; import net.minecraft.network.protocol.PacketType; public class ProtocolCodecBuilder { private final IdDispatchCodec.Builder, PacketType>> dispatchBuilder = IdDispatchCodec.builder(Packet::type); private final PacketFlow flow; public ProtocolCodecBuilder(PacketFlow flow) { this.flow = flow; } public > ProtocolCodecBuilder add(PacketType type, StreamCodec serializer) { if (type.flow() != this.flow) { throw new IllegalArgumentException("Invalid packet flow for packet " + String.valueOf(type) + ", expected " + this.flow.name()); } this.dispatchBuilder.add(type, serializer); return this; } public StreamCodec> build() { return this.dispatchBuilder.build(); } }