Class NetIdBase

Direct Known Subclasses:
NetIdSeparate, NetIdTyped

public abstract class NetIdBase extends TreeNetIdBase
A leaf node that will send and receive messages.
  • Field Details

    • MAXIMUM_PRIORITY

      public static final int MAXIMUM_PRIORITY
      This priority indicates that this should never be dropped on the sending side. This is the equivalent priority to minecraft's own packets. Generally this should be used for user interaction or other very important packets that must not be delayed or dropped.
      See Also:
      Constant Field Values
    • DEFAULT_FLAGS

      public static final int DEFAULT_FLAGS
      See Also:
      Constant Field Values
  • Method Details

    • setTinySize

      public final void setTinySize()
      Changes the size flags of this net ID to indicate that it should use a single byte for the packet's total length (including the header). In other words the maximum packet length is 256 bytes, and the minimum is 1 byte. Has no effect if the packet's length is not fixed.

      Generally you should call withTinySize() rather than this, as it returns itself rather than nothing.

      See Also:
      setNormalSize(), setLargeSize()
    • withTinySize

      public abstract NetIdBase withTinySize()
      Changes the size flags of this net ID to indicate that it should use a single byte for the packet's total length (including the header). In other words the maximum packet length is 256 bytes, and the minimum is 1 byte. Has no effect if the packet's length is not fixed.

      This method should be preferred over setTinySize() because it returns itself.

      See Also:
      withNormalSize(), withLargeSize()
    • setNormalSize

      public final void setNormalSize()
      Changes the size flags of this net ID to indicate that it should use two bytes for the packet's total length (including the header). In other words the maximum packet length is 65,536 bytes, and the minimum is 1 byte. Has no effect if the packet's length is not fixed.

      Generally you should call withNormalSize() rather than this, as it returns itself rather than nothing.

      See Also:
      setTinySize(), setLargeSize()
    • withNormalSize

      public abstract NetIdBase withNormalSize()
      Changes the size flags of this net ID to indicate that it should use two bytes for the packet's total length (including the header). In other words the maximum packet length is 65,536 bytes, and the minimum is 1 byte. Has no effect if the packet's length is not fixed.

      This method should be preferred over setNormalSize() because it returns itself.

      See Also:
      withTinySize(), withLargeSize()
    • setLargeSize

      public final void setLargeSize()
      Changes the size flags of this net ID to indicate that it should use three bytes for the packet's total length (including the header). In other words the maximum packet length is 16,777,216 bytes, and the minimum is 1 byte. Has no effect if the packet's length is not fixed.

      Generally you should call withLargeSize() rather than this, as it returns itself rather than nothing.

      See Also:
      setTinySize(), setNormalSize()
    • withLargeSize

      public abstract NetIdBase withLargeSize()
      Changes the size flags of this net ID to indicate that it should use three bytes for the packet's total length (including the header). In other words the maximum packet length is 16,777,216 bytes, and the minimum is 1 byte. Has no effect if the packet's length is not fixed.

      Unlike all of the other flag modification methods this may be called at any time, in particular before and after sending this.

      This method should be preferred over setLargeSize() because it returns itself.

      See Also:
      withTinySize(), withNormalSize()
    • notBuffered

      public final void notBuffered()
      Changes the flags for this packet to indicate that it should never be buffered by a BufferedConnection. This means that it will arrive on the other end of the connection before other packets that don't have this flag set. Sending a lot of these "queue-skipping packets" will generally have a large impact on performance.

      Unlike all of the other flag modification methods this may be called at any time, in particular before and after sending this.

      Generally you should call withoutBuffering() rather than this, as it returns itself rather than nothing.

    • buffered

      public final void buffered()
      The inverse of notBuffered(). (This is the default state).

      Unlike all of the other flag modification methods this may be called at any time, in particular before and after sending this.

    • setBuffered

      public final void setBuffered(boolean isBuffered)
      Parameters:
      isBuffered - If true then this calls buffered(), otherwise this calls notBuffered().
    • withoutBuffering

      public abstract NetIdBase withoutBuffering()
      Changes the flags for this packet to indicate that it should never be buffered by a BufferedConnection. This means that it will arrive on the other end of the connection before other packets that don't have this flag set. Sending a lot of these "queue-skipping packets" will generally have a large impact on performance.

      Unlike all of the other flag modification methods this may be called at any time, in particular before and after sending this.

      This method should be preferred over notBuffered() because it returns itself.

      Returns:
      This.
    • _toClientOnly

      protected final void _toClientOnly()
    • _toServerOnly

      protected final void _toServerOnly()
    • _toEitherSide

      protected final void _toEitherSide()
    • toClientOnly

      public abstract NetIdBase toClientOnly()
      Changes the flags for this packet to indicate that it should only be sent from the server to the client. This will make sending this packet from the client throw an unchecked exception, and make the server refuse to bind this packet to an integer ID for receiving.
      See Also:
      toServerOnly()
    • toServerOnly

      public abstract NetIdBase toServerOnly()
      Changes the flags for this packet to indicate that it should only be sent from the client to the server. This will make sending this packet from the server throw an unchecked exception, and make the client refuse to bind this packet to an integer ID for receiving.
      See Also:
      toClientOnly()
    • toEitherSide

      public abstract NetIdBase toEitherSide()
      This clears the toClientOnly() and toServerOnly() flag states, and will make sending packets not throw exceptions.

      This is the default state for every NetIdBase.

    • setMaximumDropDelay

      public void setMaximumDropDelay(int dropDelay)
      Sets the maximum time that this packet may be held before dropping it. This value is only used if the connection tries to send too much data in a single tick. Negative values are not allowed. This indicates an absolute number of connection ticks (for normal minecraft connections this is every server or client tick).
    • changeFlag

      protected final void changeFlag(int newFlags)