Class NetworkX

java.lang.Object
org.moddingx.libx.network.NetworkX

public abstract class NetworkX extends Object
A class implementing network logic. You can use the register methods in you constructor to register network packets.
  • Constructor Summary Link icon

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    boolean
    canSend(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type)
    Checks whether a packet of a given type can currently be sent.
    boolean
    canSend(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type)
    Checks whether a packet of a given type can currently be sent to the given player.
    protected abstract String
    Gets the network version for this network.
    protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    register(PacketHandler<T> handler)
    Registers a new packet handler to the system.
    protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
    void
    Registers a new optional packet handler to the system.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • NetworkX Link icon

      protected NetworkX(ModX mod)
  • Method Details Link icon

    • getVersion Link icon

      protected abstract String getVersion()
      Gets the network version for this network.
    • register Link icon

      protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void register(PacketHandler<T> handler)
      Registers a new packet handler to the system. This should be called in the constructor.
    • registerOptional Link icon

      protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerOptional(PacketHandler<T> handler)
      Registers a new optional packet handler to the system. An optional packet handler is not required to be present on the remote side for the connection negotiation to be successful. This should be called in the constructor.
    • canSend Link icon

      public boolean canSend(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type)
      Checks whether a packet of a given type can currently be sent. On the physical client this checks that the current connection supports the given packet type. On a dedicated server, this always returns true.
    • canSend Link icon

      public boolean canSend(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type)
      Checks whether a packet of a given type can currently be sent to the given player. This check that the given players connection supports the given packet type.