ClientboundRecipeBookAddPacket.java

net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket

信息

  • 全限定名:net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket
  • 类型:public record
  • 包:net.minecraft.network.protocol.game
  • 源码路径:src/main/java/net/minecraft/network/protocol/game/ClientboundRecipeBookAddPacket.java
  • 起始行号:L11
  • 实现:Packet
  • 职责:

    TODO

字段/常量

  • STREAM_CODEC
    • 类型: StreamCodec<RegistryFriendlyByteBuf,ClientboundRecipeBookAddPacket>
    • 修饰符: public static final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket.Entry
    • 类型: record
    • 修饰符: public
    • 源码定位: L29
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

public PacketType<ClientboundRecipeBookAddPacket> type() @ L20

  • 方法名:type
  • 源码定位:L20
  • 返回类型:PacketType
  • 修饰符:public

参数:

说明:

TODO

public void handle(ClientGamePacketListener listener) @ L25

  • 方法名:handle
  • 源码定位:L25
  • 返回类型:void
  • 修饰符:public

参数:

  • listener: ClientGamePacketListener

说明:

TODO

代码

public record ClientboundRecipeBookAddPacket(List<ClientboundRecipeBookAddPacket.Entry> entries, boolean replace) implements Packet<ClientGamePacketListener> {
    public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundRecipeBookAddPacket> STREAM_CODEC = StreamCodec.composite(
        ClientboundRecipeBookAddPacket.Entry.STREAM_CODEC.apply(ByteBufCodecs.list()),
        ClientboundRecipeBookAddPacket::entries,
        ByteBufCodecs.BOOL,
        ClientboundRecipeBookAddPacket::replace,
        ClientboundRecipeBookAddPacket::new
    );
 
    @Override
    public PacketType<ClientboundRecipeBookAddPacket> type() {
        return GamePacketTypes.CLIENTBOUND_RECIPE_BOOK_ADD;
    }
 
    public void handle(ClientGamePacketListener listener) {
        listener.handleRecipeBookAdd(this);
    }
 
    public record Entry(RecipeDisplayEntry contents, byte flags) {
        public static final byte FLAG_NOTIFICATION = 1;
        public static final byte FLAG_HIGHLIGHT = 2;
        public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundRecipeBookAddPacket.Entry> STREAM_CODEC = StreamCodec.composite(
            RecipeDisplayEntry.STREAM_CODEC,
            ClientboundRecipeBookAddPacket.Entry::contents,
            ByteBufCodecs.BYTE,
            ClientboundRecipeBookAddPacket.Entry::flags,
            ClientboundRecipeBookAddPacket.Entry::new
        );
 
        public Entry(RecipeDisplayEntry contents, boolean notification, boolean highlight) {
            this(contents, (byte)((notification ? 1 : 0) | (highlight ? 2 : 0)));
        }
 
        public boolean notification() {
            return (this.flags & 1) != 0;
        }
 
        public boolean highlight() {
            return (this.flags & 2) != 0;
        }
    }
}

引用的其他类