Class ActiveMinecraftConnection

Direct Known Subclasses:
ActiveClientConnection, ActiveServerConnection

public abstract class ActiveMinecraftConnection extends BufferedConnection
A connection to the other side - this is either an ActiveClientConnection or an ActiveServerConnection.
  • Field Details

    • PACKET_ID

      public static final net.minecraft.util.Identifier PACKET_ID
    • ctx

      @Deprecated public final net.fabricmc.fabric.api.network.PacketContext 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 public net.fabricmc.fabric.api.network.PacketContext getMinecraftContext()
      Deprecated.
      Specified by:
      getMinecraftContext in class ActiveConnection
      Returns:
      The Fabric API PacketContext for this connection. Throws an error if this is not a ActiveMinecraftConnection. (Although mods will *never* need to worry about that unless they create their own netty layer for a completely different connection).
    • getNetSide

      public abstract EnumNetSide getNetSide()
      Overrides:
      getNetSide in class ActiveConnection
      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. (And EnumNetSide.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 class ActiveConnection
      Returns:
      The Minecraft PlayerEntity for this connection. Throws an error if this is not a ActiveMinecraftConnection.
    • sendRawData0

      public final void sendRawData0(NetByteBuf data)
      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 class BufferedConnection
    • 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 class BufferedConnection
    • toNormalPacket

      protected abstract net.minecraft.network.Packet<?> toNormalPacket(NetByteBuf data)
    • toCompactPacket

      protected abstract net.minecraft.network.Packet<?> toCompactPacket(int receiverId, NetByteBuf data)
    • sendPacket

      protected abstract void sendPacket(net.minecraft.network.Packet<?> packet)