Class SimpleChannel

java.lang.Object
net.minecraftforge.network.Channel<Object>
net.minecraftforge.network.SimpleChannel

public class SimpleChannel extends Channel<Object>
  • Field Details

    • LOGGER

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

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

      private int lastIndex
    • byId

      private it.unimi.dsi.fastutil.ints.Int2ObjectMap<SimpleChannel.Message<?>> byId
    • byType

      private it.unimi.dsi.fastutil.objects.Object2ObjectMap<Class<?>,SimpleChannel.Message<?>> byType
  • Constructor Details

  • Method Details

    • messageBuilder

      public <M> SimpleChannel.MessageBuilder<M> messageBuilder(Class<M> type)
      Build a new MessageBuilder, using the next available discriminator.
      Type Parameters:
      M - Type of type
      Parameters:
      type - Type of message
    • messageBuilder

      public <M> SimpleChannel.MessageBuilder<M> messageBuilder(Class<M> type, int discriminator)
      Build a new MessageBuilder.
      Type Parameters:
      M - Type of type
      Parameters:
      type - Type of message
      discriminator - Manually configured discriminator, Must be a positive number.
    • messageBuilder

      public <M> SimpleChannel.MessageBuilder<M> messageBuilder(Class<M> type, NetworkDirection direction)
      Build a new MessageBuilder, using the next available discriminator.
      Type Parameters:
      M - Type of type
      Parameters:
      type - Type of message
      direction - a impl direction which will be asserted before any processing of this message occurs. Use to enforce strict sided handling to prevent spoofing.
    • messageBuilder

      public <M> SimpleChannel.MessageBuilder<M> messageBuilder(Class<M> type, int discriminator, NetworkDirection direction)
      Build a new MessageBuilder.
      Type Parameters:
      M - Type of type
      Parameters:
      type - Type of message
      discriminator - Manually configured discriminator, Must be a positive number.
      direction - a impl direction which will be asserted before any processing of this message occurs. Use to enforce strict sided handling to prevent spoofing.
    • nextIndex

      private int nextIndex()
    • networkEventListener

      private void networkEventListener(CustomPayloadEvent event)
    • decodeAndDispatch

      private static <MSG> void decodeAndDispatch(FriendlyByteBuf data, CustomPayloadEvent.Context ctx, SimpleChannel.Message<MSG> msg)
    • toBuffer

      public FriendlyByteBuf toBuffer(Object message)
      Specified by:
      toBuffer in class Channel<Object>