public class SimpleChannel
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SimpleChannel.MessageBuilder<MSG> |
Constructor and Description |
---|
SimpleChannel(net.minecraftforge.fml.network.NetworkInstance instance) |
SimpleChannel(net.minecraftforge.fml.network.NetworkInstance instance,
java.util.function.Consumer<net.minecraftforge.fml.network.NetworkEvent.ChannelRegistrationChangeEvent> registryChangeNotify) |
Modifier and Type | Method and Description |
---|---|
<MSG> int |
encodeMessage(MSG message,
net.minecraft.network.PacketBuffer target) |
boolean |
isRemotePresent(net.minecraft.network.NetworkManager manager)
Returns true if the channel is present in the given connection.
|
<M> SimpleChannel.MessageBuilder<M> |
messageBuilder(java.lang.Class<M> type,
int id)
Build a new MessageBuilder.
|
<M> SimpleChannel.MessageBuilder<M> |
messageBuilder(java.lang.Class<M> type,
int id,
net.minecraftforge.fml.network.NetworkDirection direction)
Build a new MessageBuilder.
|
<MSG> com.pixelmonmod.pixelmon.network.IndexedMessageCodec.MessageHandler<MSG> |
registerMessage(int index,
java.lang.Class<MSG> messageType,
java.util.function.BiConsumer<MSG,net.minecraft.network.PacketBuffer> encoder,
java.util.function.Function<net.minecraft.network.PacketBuffer,MSG> decoder,
java.util.function.BiConsumer<MSG,java.util.function.Supplier<net.minecraftforge.fml.network.NetworkEvent.Context>> messageConsumer) |
<MSG> com.pixelmonmod.pixelmon.network.IndexedMessageCodec.MessageHandler<MSG> |
registerMessage(int index,
java.lang.Class<MSG> messageType,
java.util.function.BiConsumer<MSG,net.minecraft.network.PacketBuffer> encoder,
java.util.function.Function<net.minecraft.network.PacketBuffer,MSG> decoder,
java.util.function.BiConsumer<MSG,java.util.function.Supplier<net.minecraftforge.fml.network.NetworkEvent.Context>> messageConsumer,
java.util.Optional<net.minecraftforge.fml.network.NetworkDirection> networkDirection) |
<MSG> void |
reply(MSG msgToReply,
net.minecraftforge.fml.network.NetworkEvent.Context context) |
<MSG> void |
send(net.minecraftforge.fml.network.PacketDistributor.PacketTarget target,
MSG message)
Send a message to the
PacketDistributor.PacketTarget from a PacketDistributor instance. |
<MSG> void |
sendTo(MSG message,
net.minecraft.network.NetworkManager manager,
net.minecraftforge.fml.network.NetworkDirection direction) |
<MSG> void |
sendToServer(MSG message) |
<MSG> net.minecraft.network.IPacket<?> |
toVanillaPacket(MSG message,
net.minecraftforge.fml.network.NetworkDirection direction) |
public SimpleChannel(net.minecraftforge.fml.network.NetworkInstance instance)
public SimpleChannel(net.minecraftforge.fml.network.NetworkInstance instance, java.util.function.Consumer<net.minecraftforge.fml.network.NetworkEvent.ChannelRegistrationChangeEvent> registryChangeNotify)
public <MSG> int encodeMessage(MSG message, net.minecraft.network.PacketBuffer target)
public <MSG> com.pixelmonmod.pixelmon.network.IndexedMessageCodec.MessageHandler<MSG> registerMessage(int index, java.lang.Class<MSG> messageType, java.util.function.BiConsumer<MSG,net.minecraft.network.PacketBuffer> encoder, java.util.function.Function<net.minecraft.network.PacketBuffer,MSG> decoder, java.util.function.BiConsumer<MSG,java.util.function.Supplier<net.minecraftforge.fml.network.NetworkEvent.Context>> messageConsumer)
public <MSG> com.pixelmonmod.pixelmon.network.IndexedMessageCodec.MessageHandler<MSG> registerMessage(int index, java.lang.Class<MSG> messageType, java.util.function.BiConsumer<MSG,net.minecraft.network.PacketBuffer> encoder, java.util.function.Function<net.minecraft.network.PacketBuffer,MSG> decoder, java.util.function.BiConsumer<MSG,java.util.function.Supplier<net.minecraftforge.fml.network.NetworkEvent.Context>> messageConsumer, java.util.Optional<net.minecraftforge.fml.network.NetworkDirection> networkDirection)
public <MSG> void sendToServer(MSG message)
public <MSG> void sendTo(MSG message, net.minecraft.network.NetworkManager manager, net.minecraftforge.fml.network.NetworkDirection direction)
public <MSG> void send(net.minecraftforge.fml.network.PacketDistributor.PacketTarget target, MSG message)
PacketDistributor.PacketTarget
from a PacketDistributor
instance.
channel.send(PacketDistributor.PLAYER.with(()->player), message)
MSG
- The type of the messagetarget
- The curried target from a PacketDistributormessage
- The message to sendpublic <MSG> net.minecraft.network.IPacket<?> toVanillaPacket(MSG message, net.minecraftforge.fml.network.NetworkDirection direction)
public <MSG> void reply(MSG msgToReply, net.minecraftforge.fml.network.NetworkEvent.Context context)
public boolean isRemotePresent(net.minecraft.network.NetworkManager manager)
public <M> SimpleChannel.MessageBuilder<M> messageBuilder(java.lang.Class<M> type, int id)
IntSupplier
if it is a login
packet.M
- Type of typetype
- Type of messageid
- id in the indexed codecpublic <M> SimpleChannel.MessageBuilder<M> messageBuilder(java.lang.Class<M> type, int id, net.minecraftforge.fml.network.NetworkDirection direction)
IntSupplier
if it is a login
packet.M
- Type of typetype
- Type of messageid
- id in the indexed codecdirection
- a network direction which will be asserted before any processing of this message occurs. Use to
enforce strict sided handling to prevent spoofing.