Class Network

java.lang.Object
commonnetwork.api.Network

public class Network extends Object
  • Constructor Details

    • Network

      public Network()
  • Method Details

    • registerPacket

      public static <T> PacketRegistrar registerPacket(net.minecraft.resources.ResourceLocation packetIdentifier, Class<T> messageType, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, Consumer<PacketContext<T>> handler)
      Packet Registration
      Type Parameters:
      T - - The type
      Parameters:
      packetIdentifier - - The unique ResourceLocation packet id.
      messageType - - The class of the packet.
      encoder - - The encoder method.
      decoder - - The decoder method.
      handler - - The handler method.
      Returns:
      The registrar for chaining registrations.
    • getNetworkHandler

      public static NetworkHandler getNetworkHandler()
      Gets the Network handler for use to send packets.
      Returns:
      - The network handler