Package alexiil.mc.lib.net.impl
Class ActiveMinecraftConnection
java.lang.Object
alexiil.mc.lib.net.ActiveConnection
alexiil.mc.lib.net.BufferedConnection
alexiil.mc.lib.net.impl.ActiveMinecraftConnection
- Direct Known Subclasses:
ActiveClientConnection
,ActiveServerConnection
A connection to the other side - this is either an
ActiveClientConnection
or an
ActiveServerConnection
.-
Field Summary
Modifier and TypeFieldDescriptionnet.fabricmc.fabric.api.network.PacketContext
Deprecated.static net.minecraft.util.Identifier
Fields inherited from class alexiil.mc.lib.net.BufferedConnection
ENABLE_QUEUE
-
Constructor Summary
ConstructorDescriptionActiveMinecraftConnection(net.fabricmc.fabric.api.network.PacketContext ctx)
-
Method Summary
Modifier and TypeMethodDescriptionnet.fabricmc.fabric.api.network.PacketContext
Deprecated.abstract EnumNetSide
abstract net.minecraft.entity.player.PlayerEntity
protected abstract void
sendPacket(net.minecraft.network.Packet<?> packet)
void
sendRawData0(NetByteBuf data)
Sends some raw data.void
tick()
Ticks this connection, flushing all queued data that needs to be sent immediately.protected abstract net.minecraft.network.Packet<?>
toCompactPacket(int receiverId, NetByteBuf data)
protected abstract net.minecraft.network.Packet<?>
toNormalPacket(NetByteBuf data)
Methods inherited from class alexiil.mc.lib.net.BufferedConnection
hasPackets, maximumPacketSize, onReceiveRawData, sendPacket, sendTickPacket, setMaxBandwidth
Methods inherited from class alexiil.mc.lib.net.ActiveConnection
postConstruct
-
Field Details
-
PACKET_ID
public static final net.minecraft.util.Identifier PACKET_ID -
ctx
Deprecated.Replaced by the specific methods (getPlayer()
,getNetSide()
, and )
-
-
Constructor Details
-
ActiveMinecraftConnection
public ActiveMinecraftConnection(net.fabricmc.fabric.api.network.PacketContext ctx)
-
-
Method Details
-
getMinecraftContext
Deprecated.- Specified by:
getMinecraftContext
in classActiveConnection
- 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
- Overrides:
getNetSide
in classActiveConnection
- Returns:
- The "side" of this connection. This will be
EnumNetSide.CLIENT
both when writing client to server packets, and when reading packets sent from the server. (AndEnumNetSide.SERVER
both when writing server to client packets, and when reading client to server packets).
-
getPlayer
public abstract net.minecraft.entity.player.PlayerEntity getPlayer()- Overrides:
getPlayer
in classActiveConnection
- Returns:
- The Minecraft
PlayerEntity
for this connection. Throws an error if this is not aActiveMinecraftConnection
.
-
sendRawData0
Description copied from class:BufferedConnection
Sends some raw data. It might contain multiple packets, half packets, or even less. Either way the implementation should just directly send the data on to the other side, and ensure it arrives in-order.- Specified by:
sendRawData0
in classBufferedConnection
-
tick
public void tick()Description copied from class:BufferedConnection
Ticks this connection, flushing all queued data that needs to be sent immediately.- Overrides:
tick
in classBufferedConnection
-
toNormalPacket
-
toCompactPacket
protected abstract net.minecraft.network.Packet<?> toCompactPacket(int receiverId, NetByteBuf data) -
sendPacket
protected abstract void sendPacket(net.minecraft.network.Packet<?> packet)
-