ClientboundStopSoundPacket.java

net.minecraft.network.protocol.game.ClientboundStopSoundPacket

信息

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

    TODO

字段/常量

  • STREAM_CODEC

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

      TODO

  • HAS_SOURCE

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L15
    • 说明:

      TODO

  • HAS_SOUND

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L16
    • 说明:

      TODO

  • name

    • 类型: Identifier
    • 修饰符: private final
    • 源码定位: L17
    • 说明:

      TODO

  • source

    • 类型: SoundSource
    • 修饰符: private final
    • 源码定位: L18
    • 说明:

      TODO

内部类/嵌套类型

构造器

public ClientboundStopSoundPacket(Identifier name, SoundSource source) @ L20

  • 构造器名:ClientboundStopSoundPacket
  • 源码定位:L20
  • 修饰符:public

参数:

  • name: Identifier
  • source: SoundSource

说明:

TODO

private ClientboundStopSoundPacket(FriendlyByteBuf input) @ L25

  • 构造器名:ClientboundStopSoundPacket
  • 源码定位:L25
  • 修饰符:private

参数:

  • input: FriendlyByteBuf

说明:

TODO

方法

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

private void write(FriendlyByteBuf output) @ L40

  • 方法名:write
  • 源码定位:L40
  • 返回类型:void
  • 修饰符:private

参数:

  • output: FriendlyByteBuf

说明:

TODO

public PacketType<ClientboundStopSoundPacket> type() @ L58

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

参数:

说明:

TODO

public void handle(ClientGamePacketListener listener) @ L63

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

参数:

  • listener: ClientGamePacketListener

说明:

TODO

public Identifier getName() @ L67

  • 方法名:getName
  • 源码定位:L67
  • 返回类型:Identifier
  • 修饰符:public

参数:

说明:

TODO

public SoundSource getSource() @ L71

  • 方法名:getSource
  • 源码定位:L71
  • 返回类型:SoundSource
  • 修饰符:public

参数:

说明:

TODO

代码

public class ClientboundStopSoundPacket implements Packet<ClientGamePacketListener> {
    public static final StreamCodec<FriendlyByteBuf, ClientboundStopSoundPacket> STREAM_CODEC = Packet.codec(
        ClientboundStopSoundPacket::write, ClientboundStopSoundPacket::new
    );
    private static final int HAS_SOURCE = 1;
    private static final int HAS_SOUND = 2;
    private final @Nullable Identifier name;
    private final @Nullable SoundSource source;
 
    public ClientboundStopSoundPacket(@Nullable Identifier name, @Nullable SoundSource source) {
        this.name = name;
        this.source = source;
    }
 
    private ClientboundStopSoundPacket(FriendlyByteBuf input) {
        int flags = input.readByte();
        if ((flags & 1) > 0) {
            this.source = input.readEnum(SoundSource.class);
        } else {
            this.source = null;
        }
 
        if ((flags & 2) > 0) {
            this.name = input.readIdentifier();
        } else {
            this.name = null;
        }
    }
 
    private void write(FriendlyByteBuf output) {
        if (this.source != null) {
            if (this.name != null) {
                output.writeByte(3);
                output.writeEnum(this.source);
                output.writeIdentifier(this.name);
            } else {
                output.writeByte(1);
                output.writeEnum(this.source);
            }
        } else if (this.name != null) {
            output.writeByte(2);
            output.writeIdentifier(this.name);
        } else {
            output.writeByte(0);
        }
    }
 
    @Override
    public PacketType<ClientboundStopSoundPacket> type() {
        return GamePacketTypes.CLIENTBOUND_STOP_SOUND;
    }
 
    public void handle(ClientGamePacketListener listener) {
        listener.handleStopSoundEvent(this);
    }
 
    public @Nullable Identifier getName() {
        return this.name;
    }
 
    public @Nullable SoundSource getSource() {
        return this.source;
    }
}

引用的其他类