Package foundry.veil.api.network
Interface VeilPacketManager
public interface VeilPacketManager
Manages packet registration and sending.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Factory class forregistration providers
.static interface
VeilPacketManager.PacketHandler<T extends PacketContext,
P extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> Handles packets from the client/server.static interface
Sends packets to players and automatically bundles payloads together. -
Field Summary
Modifier and TypeFieldDescriptionstatic final VeilPacketManager.Factory
The singleton instance of theVeilPacketManager.Factory
. -
Method Summary
Modifier and TypeMethodDescriptionstatic VeilPacketManager.PacketSink
all
(net.minecraft.server.MinecraftServer server) Sends packets to all players in the server.static VeilPacketManager.PacketSink
around
(@Nullable net.minecraft.server.level.ServerPlayer excluded, net.minecraft.server.level.ServerLevel level, double x, double y, double z, double radius) Sends packets to all players in the area covered by the specified radius, around the specified coordinates, in the specified dimension, excluding the specified excluded player if present.static VeilPacketManager
Creates aVeilPacketManager
.static VeilPacketManager.PacketSink
level
(net.minecraft.server.level.ServerLevel level) Sends packets to all players in the specified level.static VeilPacketManager.PacketSink
player
(net.minecraft.server.level.ServerPlayer player) <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidregisterClientbound
(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> codec, VeilPacketManager.PacketHandler<ClientPacketContext, T> handler) Registers a new packet from the client to the server.<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidregisterServerbound
(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> codec, VeilPacketManager.PacketHandler<ServerPacketContext, T> handler) Registers a new packet from the server to the client.static VeilPacketManager.PacketSink
server()
static VeilPacketManager.PacketSink
tracking
(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Sends packets to all players tracking the chunk at the specified position in the specified levelstatic VeilPacketManager.PacketSink
tracking
(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos min, net.minecraft.core.BlockPos max) Sends packets to all players tracking the chunks at the specified positions in the specified levelstatic VeilPacketManager.PacketSink
tracking
(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) Sends packets to all players tracking the chunk at the specified position in the specified levelstatic VeilPacketManager.PacketSink
tracking
(net.minecraft.world.entity.Entity entity) Sends packets to all players tracking the specified entity, excluding the entity.static VeilPacketManager.PacketSink
tracking
(net.minecraft.world.level.block.entity.BlockEntity blockEntity) Sends packets to all players tracking the specified block entity.static VeilPacketManager.PacketSink
trackingAndSelf
(net.minecraft.world.entity.Entity entity) Sends packets to all players tracking the specified entity, including the entity.
-
Field Details
-
FACTORY
The singleton instance of theVeilPacketManager.Factory
. This is different on each loader.
-
-
Method Details
-
create
Creates aVeilPacketManager
.- Parameters:
modId
- The id of the mod creating the channelversion
- The NeoForge channel version- Returns:
- The packet manager
-
registerClientbound
<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerClientbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> codec, VeilPacketManager.PacketHandler<ClientPacketContext, T> handler) Registers a new packet from the client to the server.- Type Parameters:
T
- The type of packet to register- Parameters:
id
- The id of the packetcodec
- The codec for encoding and decoding the packethandler
- The handler method for the packet on the client
-
registerServerbound
<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerServerbound(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T> id, net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> codec, VeilPacketManager.PacketHandler<ServerPacketContext, T> handler) Registers a new packet from the server to the client.- Type Parameters:
T
- The type of packet to register- Parameters:
id
- The id of the packetcodec
- The codec for encoding and decoding the packethandler
- The handler method for the packet on the server
-
server
- Returns:
- A sink to send packets to the server
-
player
- Returns:
- A sink to send packets to the specified player
-
level
Sends packets to all players in the specified level.- Parameters:
level
- The level to send the packet to- Returns:
- A sink to send packets to all players in the dimension
-
around
static VeilPacketManager.PacketSink around(@Nullable @Nullable net.minecraft.server.level.ServerPlayer excluded, net.minecraft.server.level.ServerLevel level, double x, double y, double z, double radius) Sends packets to all players in the area covered by the specified radius, around the specified coordinates, in the specified dimension, excluding the specified excluded player if present.- Parameters:
excluded
- The player to exclude when sending the packet ornull
to send to all playerslevel
- the level to send the packet aroundx
- the X positiony
- the Y positionz
- the Z positionradius
- the maximum distance from the position in blocks- Returns:
- A sink to send packets to all players in the area
-
all
Sends packets to all players in the server.- Parameters:
server
- The server instance- Returns:
- A sink to send packets to all players
-
tracking
Sends packets to all players tracking the specified entity, excluding the entity.- Parameters:
entity
- The entity to send tracking packets to- Returns:
- A sink to send packets to all players tracking the entity
- Throws:
IllegalArgumentException
- if the entity is not in a server world
-
trackingAndSelf
Sends packets to all players tracking the specified entity, including the entity.- Parameters:
entity
- The entity to send tracking packets to- Returns:
- A sink to send packets to all players tracking the entity and the entity
- Throws:
IllegalArgumentException
- if the entity is not in a server world
-
tracking
static VeilPacketManager.PacketSink tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.world.level.ChunkPos pos) Sends packets to all players tracking the chunk at the specified position in the specified level- Parameters:
level
- The level to send the packet topos
- The chunk to send to- Returns:
- A sink to send packets to all players tracking that chunk
-
tracking
static VeilPacketManager.PacketSink tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos pos) Sends packets to all players tracking the chunk at the specified position in the specified level- Parameters:
level
- The level to send the packet topos
- The position to send to- Returns:
- A sink to send packets to all players tracking that chunk
-
tracking
static VeilPacketManager.PacketSink tracking(net.minecraft.server.level.ServerLevel level, net.minecraft.core.BlockPos min, net.minecraft.core.BlockPos max) Sends packets to all players tracking the chunks at the specified positions in the specified level- Parameters:
level
- The level to send the packet tomin
- The minimum position to send tomax
- The maximum position to send to- Returns:
- A sink to send packets to all players tracking that chunk
-
tracking
static VeilPacketManager.PacketSink tracking(net.minecraft.world.level.block.entity.BlockEntity blockEntity) Sends packets to all players tracking the specified block entity.- Parameters:
blockEntity
- The block entity to send the packet to- Returns:
- A sink to send packets to all players tracking that block entity
- Throws:
IllegalArgumentException
- if the block entity is not in a server level
-