Package alexiil.mc.lib.net
Class ActiveConnection
java.lang.Object
alexiil.mc.lib.net.ActiveConnection
- Direct Known Subclasses:
BufferedConnection
An active game connection to a single receiver (and with a single sender).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract net.fabricmc.fabric.api.network.PacketContext
Deprecated.net.minecraft.entity.player.PlayerEntity
void
onReceiveRawData(NetByteBuf data)
void
protected abstract void
sendPacket(NetByteBuf data, int packetId, NetIdBase netId, int priority)
-
Constructor Details
-
ActiveConnection
-
-
Method Details
-
postConstruct
public final void postConstruct() -
getMinecraftContext
Deprecated.Replaced by the specific methodsgetPlayer()
andgetNetSide()
.- Returns:
- The Fabric API
PacketContext
for this connection. Throws an error if this is not aActiveMinecraftConnection
. (Although mods will *never* need to worry about that unless they create their own netty layer for a completely different connection).
-
getNetSide
- Returns:
- The "side" of this connection. If this is an
ActiveMinecraftConnection
then this will be CLIENT both when writing client to server packets, and when reading packets sent from the server. (And SERVER both when writing server to client packets, and when reading client to server packets). Other connection types might throw an exception if they reuse LNS for a non-standard minecraft connection.
-
getPlayer
public net.minecraft.entity.player.PlayerEntity getPlayer()- Returns:
- The Minecraft
PlayerEntity
for this connection. Throws an error if this is not aActiveMinecraftConnection
.
-
sendPacket
protected abstract void sendPacket(NetByteBuf data, int packetId, @Nullable NetIdBase netId, int priority)- Parameters:
packetId
- The packet ID that has been written out to the first int of the given buffer.netId
- TheNetIdBase
that is being written out. Will be null if the packet ID is one of the internal packets.priority
- The priority for the packet. Will be either 0 or a negative number.
-
onReceiveRawData
- Throws:
InvalidInputDataException
-
getPlayer()
andgetNetSide()
.