Package foundry.veil.api.network.handler
Interface PacketContext
- All Known Subinterfaces:
ClientPacketContext,ServerPacketContext
public interface PacketContext
Common context for packet handling.
-
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.protocol.Packet<?> createPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Creates a packet from a packet payload.voiddisconnect(net.minecraft.network.chat.Component disconnectReason) Disconnects the player.default @Nullable net.minecraft.world.level.Levellevel()@Nullable net.minecraft.world.entity.player.Playerplayer()default voidsendPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Sends a packet to the other side.default voidsendPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, @Nullable net.minecraft.network.PacketSendListener callback) Sends a packet to the other side.default voidsendPacket(net.minecraft.network.protocol.Packet<?> packet) Sends a packet.voidsendPacket(net.minecraft.network.protocol.Packet<?> packet, @Nullable net.minecraft.network.PacketSendListener callback) Sends a packet.
-
Method Details
-
player
@Nullable @Nullable net.minecraft.world.entity.player.Player player()- Returns:
- The player that received the payload
-
level
@Nullable default @Nullable net.minecraft.world.level.Level level()- Returns:
- The level the context player is on
-
createPacket
net.minecraft.network.protocol.Packet<?> createPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Creates a packet from a packet payload.- Parameters:
payload- the packet payload
-
sendPacket
default void sendPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) Sends a packet to the other side.- Parameters:
payload- the payload to create a packet from
-
sendPacket
default void sendPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload, @Nullable @Nullable net.minecraft.network.PacketSendListener callback) Sends a packet to the other side.- Parameters:
payload- the payload to create a packet fromcallback- an optional callback to execute after the packet is sent, may benull.
-
sendPacket
default void sendPacket(net.minecraft.network.protocol.Packet<?> packet) Sends a packet.- Parameters:
packet- the payload
-
sendPacket
void sendPacket(net.minecraft.network.protocol.Packet<?> packet, @Nullable @Nullable net.minecraft.network.PacketSendListener callback) Sends a packet.- Parameters:
packet- the payloadcallback- an optional callback to execute after the packet is sent, may benull.
-
disconnect
void disconnect(net.minecraft.network.chat.Component disconnectReason) Disconnects the player.- Parameters:
disconnectReason- the reason for disconnection
-