Class Channel<MSG>

java.lang.Object
net.minecraftforge.network.Channel<MSG>
Direct Known Subclasses:
EventNetworkChannel, PayloadChannel, SimpleChannel

public abstract class Channel<MSG> extends Object
  • Field Details

    • LOGGER

      private static final org.apache.logging.log4j.Logger LOGGER
    • MARKER

      private static final org.apache.logging.log4j.Marker MARKER
    • instance

      protected final NetworkInstance instance
  • Constructor Details

  • Method Details

    • getName

      public ResourceLocation getName()
    • getName

      ResourceLocation getName(MSG packet)
      Retrieves the channel name to use for the specified packet This typically is the main channel's name, but in some cases you want to specify a custom one. If your channel has children
    • getProtocolVersion

      public int getProtocolVersion()
    • isRemotePresent

      public boolean isRemotePresent(Connection connection)
      Returns true if the channel is present in the given connection.
    • encode

      public abstract void encode(FriendlyByteBuf out, MSG message)
    • toVanillaPacket

      protected Packet<?> toVanillaPacket(Connection connection, MSG message)
    • send

      public void send(MSG msg, Connection connection)
    • send

      public void send(MSG msg, PacketDistributor.PacketTarget target)
      Send a message to the PacketDistributor.PacketTarget from a PacketDistributor instance.
           channel.send(message, PacketDistributor.PLAYER.with(()->player))
       
      Type Parameters:
      MSG - The type of the message
      Parameters:
      target - The curried target from a PacketDistributor
      message - The message to send
    • reply

      public void reply(MSG msg, CustomPayloadEvent.Context context)
    • validate

      protected void validate(Object id, Connection con, NetworkProtocol<?> protocol, PacketFlow direction, boolean sending)