Class ActiveConnection

java.lang.Object
alexiil.mc.lib.net.ActiveConnection
Direct Known Subclasses:
BufferedConnection

public abstract class ActiveConnection extends Object
An active game connection to a single receiver (and with a single sender).
  • Constructor Details

    • ActiveConnection

      public ActiveConnection(ParentNetId rootId)
  • Method Details

    • isDebuggingConnection

      protected boolean isDebuggingConnection()
    • postConstruct

      public final void postConstruct()
    • getNetSide

      public EnumNetSide 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 a ActiveMinecraftConnection.
    • 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 - The NetIdBase 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

      public void onReceiveRawData(NetByteBuf data) throws InvalidInputDataException
      Throws:
      InvalidInputDataException
    • allocBuffer

      public NetByteBuf allocBuffer()
    • allocBuffer

      public NetByteBuf allocBuffer(int initialCapacity)