Class StreamPacket.ToClient

java.lang.Object
io.netty.buffer.ByteBuf
net.minecraft.network.FriendlyByteBuf
net.minecraft.network.RegistryFriendlyByteBuf
codechicken.lib.packet.StreamPacket
codechicken.lib.packet.StreamPacket.ToClient
All Implemented Interfaces:
CCFriendlyByteBufExtension, CCRegistryFriendlyByteBufExtension, io.netty.buffer.ByteBufConvertible, io.netty.util.ReferenceCounted, Comparable<io.netty.buffer.ByteBuf>, net.minecraft.network.protocol.common.custom.CustomPacketPayload, net.neoforged.neoforge.common.extensions.IFriendlyByteBufExtension
Enclosing class:
StreamPacket

public static final class StreamPacket.ToClient extends StreamPacket
A client-bound packet, write your data, then use one of the various send methods, or toVanilla() to send it out a vanilla path.
  • Nested Class Summary

    Nested classes/interfaces inherited from class codechicken.lib.packet.StreamPacket

    StreamPacket.ToClient, StreamPacket.ToServer

    Nested classes/interfaces inherited from interface net.minecraft.network.protocol.common.custom.CustomPacketPayload

    net.minecraft.network.protocol.common.custom.CustomPacketPayload.FallbackProvider<B extends net.minecraft.network.FriendlyByteBuf>, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>, net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B extends net.minecraft.network.FriendlyByteBuf,T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
  • Field Summary

    Fields inherited from class net.minecraft.network.FriendlyByteBuf

    MAX_COMPONENT_STRING_LENGTH, MAX_STRING_LENGTH
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    sendToAllAround(double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.
    void
    sendToAllAround(net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.
    void
    Sends the given packet to all connected clients.
    void
    sendToChunk(net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ)
    Send the given packet to all players watching the specified chunk in the specified dimension.
    void
    sendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
    Send the given packet to all players watching the chunk specified by the given BlockPos in the specified dimension.
    void
    sendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
    Send the given packet to all players watching the specified chunk in the specified dimension.
    void
    sendToChunk(net.minecraft.world.level.block.entity.BlockEntity tile)
    Send the given packet to all players watching the chunk, that the given BlockEntity is within.
    void
    sendToDimension(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Send the given packet to all players within the given dimension.
    void
    Send the given packet to all server operators.
    void
    sendToPlayer(@Nullable net.minecraft.server.level.ServerPlayer player)
    Send the given packet to the specified player.
    net.minecraft.network.protocol.Packet<?>
    Wrap this packet into a vanilla Packet.

    Methods inherited from class codechicken.lib.packet.StreamPacket

    type

    Methods inherited from class net.minecraft.network.RegistryFriendlyByteBuf

    decorator, decorator, getConnectionType, registryAccess

    Methods inherited from class net.minecraft.network.FriendlyByteBuf

    alloc, array, arrayOffset, asReadOnly, bytesBefore, bytesBefore, bytesBefore, capacity, capacity, clear, compareTo, copy, copy, discardReadBytes, discardSomeReadBytes, duplicate, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getByte, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getInt, getIntLE, getLong, getLongLE, getMedium, getMediumLE, getShort, getShortLE, getSource, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMedium, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, hasArray, hashCode, hasMemoryAddress, indexOf, internalNioBuffer, isContiguous, isDirect, isReadable, isReadable, isReadOnly, isWritable, isWritable, limitValue, markReaderIndex, markWriterIndex, maxCapacity, maxFastWritableBytes, maxWritableBytes, memoryAddress, nioBuffer, nioBuffer, nioBufferCount, nioBuffers, nioBuffers, order, order, readableBytes, readBitSet, readBlockHitResult, readBlockPos, readBlockPos, readBoolean, readById, readByte, readByteArray, readByteArray, readByteArray, readByteArray, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readCharSequence, readChunkPos, readChunkPos, readCollection, readContainerId, readContainerId, readDouble, readEither, readEnum, readEnumSet, readerIndex, readerIndex, readFixedBitSet, readFixedSizeLongArray, readFixedSizeLongArray, readFloat, readGlobalPos, readIdentifier, readInstant, readInt, readIntIdList, readIntLE, readLenientJsonWithCodec, readList, readLong, readLongArray, readLongArray, readLongLE, readLpVec3, readMap, readMap, readMedium, readMediumLE, readNbt, readNbt, readNbt, readNbt, readNullable, readNullable, readOptional, readPublicKey, readQuaternion, readQuaternion, readRegistryKey, readResourceKey, readRetainedSlice, readShort, readShortLE, readSlice, readString, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, readUtf, readUtf, readUUID, readUUID, readVarInt, readVarIntArray, readVarIntArray, readVarLong, readVec3, readVec3, readVector3f, readVector3f, readWithCodec, readWithCodecTrusted, readWithCount, refCnt, release, release, resetReaderIndex, resetWriterIndex, retain, retain, retainedDuplicate, retainedSlice, retainedSlice, setBoolean, setByte, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setInt, setIntLE, setLong, setLongLE, setMedium, setMediumLE, setShort, setShortLE, setZero, skipBytes, slice, slice, toString, toString, toString, touch, touch, unwrap, writableBytes, writeBitSet, writeBlockHitResult, writeBlockPos, writeBlockPos, writeBoolean, writeById, writeByte, writeByteArray, writeByteArray, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeCharSequence, writeChunkPos, writeChunkPos, writeCollection, writeContainerId, writeContainerId, writeDouble, writeEither, writeEnum, writeEnumSet, writeFixedBitSet, writeFixedSizeLongArray, writeFixedSizeLongArray, writeFloat, writeGlobalPos, writeIdentifier, writeInstant, writeInt, writeIntIdList, writeIntLE, writeJsonWithCodec, writeLong, writeLongArray, writeLongArray, writeLongLE, writeLpVec3, writeMap, writeMedium, writeMediumLE, writeNbt, writeNbt, writeNullable, writeNullable, writeOptional, writePublicKey, writeQuaternion, writeQuaternion, writeResourceKey, writerIndex, writerIndex, writeShort, writeShortLE, writeUtf, writeUtf, writeUUID, writeUUID, writeVarInt, writeVarIntArray, writeVarLong, writeVec3, writeVec3, writeVector3f, writeVector3f, writeWithCodec, writeZero

    Methods inherited from class io.netty.buffer.ByteBuf

    asByteBuf, getDoubleLE, getFloatLE, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface codechicken.lib.packet.CCRegistryFriendlyByteBufExtension

    cc$readWithRegistryCodec, cc$writeWithRegistryCodec

    Methods inherited from interface net.minecraft.network.protocol.common.custom.CustomPacketPayload

    toVanillaClientbound, toVanillaServerbound

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IFriendlyByteBufExtension

    readArray, readMap, writeArray, writeByte, writeMap, writeObjectCollection
  • Method Details

    • toVanilla

      public net.minecraft.network.protocol.Packet<?> toVanilla()
      Wrap this packet into a vanilla Packet.
      Returns:
      The vanilla packet.
    • sendToPlayer

      public void sendToPlayer(@Nullable @Nullable net.minecraft.server.level.ServerPlayer player)
      Send the given packet to the specified player. If the specified player is null, sends the packet to all connected clients.
      Parameters:
      player - The receiver. null for all players.
    • sendToAllPlayers

      public void sendToAllPlayers()
      Sends the given packet to all connected clients.
    • sendToAllAround

      public void sendToAllAround(net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.

      For blocks, it is advised to instead use one of the sendToChunk(net.minecraft.world.level.block.entity.BlockEntity) methods.

      Parameters:
      pos - The origin point to send around.
      range - The range in which to send.
      dim - The dimension to send to.
    • sendToAllAround

      public void sendToAllAround(double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Sends the given packet to all players in the specified dimension, within the specified radius, around the specified origin.

      For blocks, it is advised to instead use one of the sendToChunk(net.minecraft.world.level.block.entity.BlockEntity) methods.

      Parameters:
      x - The X origin point to send around.
      y - The Y origin point to send around.
      z - The Z origin point to send around.
      range - The range in which to send.
      dim - The dimension to send to.
    • sendToDimension

      public void sendToDimension(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Send the given packet to all players within the given dimension.
      Parameters:
      dim - The dimension to send to.
    • sendToChunk

      public void sendToChunk(net.minecraft.world.level.block.entity.BlockEntity tile)
      Send the given packet to all players watching the chunk, that the given BlockEntity is within.
      Parameters:
      tile - The BlockEntity of the watched chunk to send to.
    • sendToChunk

      public void sendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos)
      Send the given packet to all players watching the chunk specified by the given BlockPos in the specified dimension.
      Parameters:
      level - The level containing the chunk to send to.
      pos - The BlockPos specifying the chunk to send to.
    • sendToChunk

      public void sendToChunk(net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ)
      Send the given packet to all players watching the specified chunk in the specified dimension.
      Parameters:
      level - The level containing the chunk to send to.
      chunkX - The chunk X coordinate to send to.
      chunkZ - The chunk Z coordinate to send to.
    • sendToChunk

      public void sendToChunk(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos)
      Send the given packet to all players watching the specified chunk in the specified dimension.
      Parameters:
      level - The level containing the chunk to send to.
      pos - The ChunkPos to send to.
    • sendToOps

      public void sendToOps()
      Send the given packet to all server operators.