Class Network

java.lang.Object
commonnetwork.api.Network

public class Network extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the Network handler for use to send packets.
    static <T> PacketRegistrar
    registerConfigurationPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler)
    Packet Registration
    static <T> PacketRegistrar
    registerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler)
    Packet Registration
    static <T> PacketRegistrar
    registerPacket(net.minecraft.resources.ResourceLocation packetIdentifier, Class<T> packetClass, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, Consumer<PacketContext<T>> handler)
    Deprecated, for removal: This API element is subject to removal in a future version.
    this method will eventually be removed, please migrate to the method supplying your own encoding/decoding codec.

    Methods inherited from class java.lang.Object

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

    • Network

      public Network()
  • Method Details

    • registerPacket

      @Deprecated(forRemoval=true) public static <T> PacketRegistrar registerPacket(net.minecraft.resources.ResourceLocation packetIdentifier, Class<T> packetClass, BiConsumer<T,net.minecraft.network.FriendlyByteBuf> encoder, Function<net.minecraft.network.FriendlyByteBuf,T> decoder, Consumer<PacketContext<T>> handler)
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method will eventually be removed, please migrate to the method supplying your own encoding/decoding codec. Likely in 1.21.2 or 1.22.
      Packet Registration
      Type Parameters:
      T - - The type
      Parameters:
      packetIdentifier - - The unique ResourceLocation packet id.
      packetClass - - The class of the packet.
      encoder - - The encoder method.
      decoder - - The decoder method.
      handler - - The handler method.
      Returns:
      The registrar for chaining registrations.
    • registerPacket

      public static <T> PacketRegistrar registerPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler)
      Packet Registration
      Type Parameters:
      T - - The class type
      Parameters:
      type - - The packet type.
      packetClass - - The class of the packet.
      codec - - The StreamCodec.
      handler - - The handler method.
      Returns:
      The registrar for chaining registrations.
    • registerConfigurationPacket

      public static <T> PacketRegistrar registerConfigurationPacket(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type, Class<T> packetClass, net.minecraft.network.codec.StreamCodec<? extends net.minecraft.network.FriendlyByteBuf,T> codec, Consumer<PacketContext<T>> handler)
      Packet Registration
      Type Parameters:
      T - - The class type
      Parameters:
      type - - The packet type.
      packetClass - - The class of the packet.
      codec - - The StreamCodec.
      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