Package codechicken.lib.packet
Class PacketSender
java.lang.Object
codechicken.lib.packet.PacketSender
Created by covers1624 on 17/9/24.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidsendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Overload ofsendToAllAround(Packet, double, double, double, double, ResourceKey)first wrappingpayloadto a client bound packet.static voidsendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Overload ofsendToAllAround(Packet, BlockPos, double, ResourceKey)first wrappingpayloadto a client bound packet.static voidsendToAllAround(net.minecraft.network.protocol.Packet<?> packet, 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.static voidsendToAllAround(net.minecraft.network.protocol.Packet<?> packet, 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.static voidsendToAllPlayers(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Overload ofsendToAllPlayers(Packet)first wrappingpayloadto a client bound packet.static voidsendToAllPlayers(net.minecraft.network.protocol.Packet<?> packet) Sends the given packet to all connected clients.static voidsendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ) Overload ofsendToChunk(Packet, ServerLevel, int, int)first wrappingpayloadto a client bound packet.static voidsendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Overload ofsendToChunk(Packet, ServerLevel, BlockPos)first wrappingpayloadto a client bound packet.static voidsendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) Overload ofsendToChunk(Packet, ServerLevel, ChunkPos)first wrappingpayloadto a client bound packet.static voidsendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.world.level.block.entity.BlockEntity tile) Overload ofsendToChunk(Packet, BlockEntity)first wrappingpayloadto a client bound packet.static voidsendToChunk(net.minecraft.network.protocol.Packet<?> packet, 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.static voidsendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Send the given packet to all players watching the chunk specified by the givenBlockPosin the specified dimension.static voidsendToChunk(net.minecraft.network.protocol.Packet<?> packet, 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.static voidsendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.world.level.block.entity.BlockEntity tile) Send the given packet to all players watching the chunk, that the givenBlockEntityis within.static voidsendToDimension(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Overload ofsendToDimension(Packet, ResourceKey)first wrappingpayloadto a client bound packet.static voidsendToDimension(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Send the given packet to all players within the given dimension.static voidsendToOps(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Overload ofsendToOps(Packet)first wrappingpayloadto a client bound packet.static voidsendToOps(net.minecraft.network.protocol.Packet<?> packet) Send the given packet to all server operators.static voidsendToPlayer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, @Nullable net.minecraft.server.level.ServerPlayer player) Overload ofsendToPlayer(Packet, ServerPlayer)first wrappingpayloadto a client bound packet.static voidsendToPlayer(net.minecraft.network.protocol.Packet<?> packet, @Nullable net.minecraft.server.level.ServerPlayer player) Send the given packet to the specified player.static voidsendToServer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Overload ofsendToServer(Packet)first wrappingpayloadto a server bound packet.static voidsendToServer(net.minecraft.network.protocol.Packet<?> packet) Send the given packet to the server.static net.minecraft.network.protocol.Packet<?> toClientPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Create a client bound packet for the given custom payload.static net.minecraft.network.protocol.Packet<?> toServerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Create a server bound packet for the given custom payload.
-
Constructor Details
-
PacketSender
public PacketSender()
-
-
Method Details
-
toClientPacket
public static net.minecraft.network.protocol.Packet<?> toClientPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Create a client bound packet for the given custom payload.- Parameters:
payload- The payload.- Returns:
- The packet.
-
sendToPlayer
public static void sendToPlayer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, @Nullable @Nullable net.minecraft.server.level.ServerPlayer player) Overload ofsendToPlayer(Packet, ServerPlayer)first wrappingpayloadto a client bound packet. -
sendToPlayer
public static void sendToPlayer(net.minecraft.network.protocol.Packet<?> packet, @Nullable @Nullable net.minecraft.server.level.ServerPlayer player) Send the given packet to the specified player. If the specified player isnull, sends the packet to all connected clients.- Parameters:
packet- The packet to send.player- The receiver.nullfor all players.
-
sendToAllPlayers
public static void sendToAllPlayers(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Overload ofsendToAllPlayers(Packet)first wrappingpayloadto a client bound packet. -
sendToAllPlayers
public static void sendToAllPlayers(net.minecraft.network.protocol.Packet<?> packet) Sends the given packet to all connected clients.- Parameters:
packet- The packet to send.
-
sendToAllAround
public static void sendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.core.BlockPos pos, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Overload ofsendToAllAround(Packet, BlockPos, double, ResourceKey)first wrappingpayloadto a client bound packet. -
sendToAllAround
public static void sendToAllAround(net.minecraft.network.protocol.Packet<?> packet, 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.network.protocol.common.custom.CustomPacketPayload, net.minecraft.world.level.block.entity.BlockEntity)methods.- Parameters:
packet- The packet to send.pos- The origin point to send around.range- The range in which to send.dim- The dimension to send to.
-
sendToAllAround
public static void sendToAllAround(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, double x, double y, double z, double range, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Overload ofsendToAllAround(Packet, double, double, double, double, ResourceKey)first wrappingpayloadto a client bound packet. -
sendToAllAround
public static void sendToAllAround(net.minecraft.network.protocol.Packet<?> packet, 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.network.protocol.common.custom.CustomPacketPayload, net.minecraft.world.level.block.entity.BlockEntity)methods.- Parameters:
packet- The packet to send.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 static void sendToDimension(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Overload ofsendToDimension(Packet, ResourceKey)first wrappingpayloadto a client bound packet. -
sendToDimension
public static void sendToDimension(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) Send the given packet to all players within the given dimension.- Parameters:
packet- The packet to send.dim- The dimension to send to.
-
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.world.level.block.entity.BlockEntity tile) Overload ofsendToChunk(Packet, BlockEntity)first wrappingpayloadto a client bound packet. -
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.world.level.block.entity.BlockEntity tile) Send the given packet to all players watching the chunk, that the givenBlockEntityis within.- Parameters:
packet- The packet to send.tile- TheBlockEntityof the watched chunk to send to.
-
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Overload ofsendToChunk(Packet, ServerLevel, BlockPos)first wrappingpayloadto a client bound packet. -
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Send the given packet to all players watching the chunk specified by the givenBlockPosin the specified dimension.- Parameters:
packet- The packet to send.level- The level containing the chunk to send to.pos- TheBlockPosspecifying the chunk to send to.
-
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, int chunkX, int chunkZ) Overload ofsendToChunk(Packet, ServerLevel, int, int)first wrappingpayloadto a client bound packet. -
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, 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:
packet- The packet to send.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 static void sendToChunk(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) Overload ofsendToChunk(Packet, ServerLevel, ChunkPos)first wrappingpayloadto a client bound packet. -
sendToChunk
public static void sendToChunk(net.minecraft.network.protocol.Packet<?> packet, 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:
packet- The packet to send.level- The level containing the chunk to send to.pos- TheChunkPosto send to.
-
sendToOps
public static void sendToOps(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Overload ofsendToOps(Packet)first wrappingpayloadto a client bound packet. -
sendToOps
public static void sendToOps(net.minecraft.network.protocol.Packet<?> packet) Send the given packet to all server operators.- Parameters:
packet- The packet to send.
-
toServerPacket
public static net.minecraft.network.protocol.Packet<?> toServerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Create a server bound packet for the given custom payload.- Parameters:
payload- The payload.- Returns:
- The packet.
-
sendToServer
public static void sendToServer(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Overload ofsendToServer(Packet)first wrappingpayloadto a server bound packet. -
sendToServer
public static void sendToServer(net.minecraft.network.protocol.Packet<?> packet) Send the given packet to the server.- Parameters:
packet- The packet to send.
-