Class AbstractChanneledNetworkAddon<H>
java.lang.Object
net.fabricmc.fabric.impl.networking.AbstractNetworkAddon<H>
net.fabricmc.fabric.impl.networking.AbstractChanneledNetworkAddon<H>
- Type Parameters:
H- the channel handler type
- All Implemented Interfaces:
PacketSender, CommonPacketHandler
- Direct Known Subclasses:
ClientConfigurationNetworkAddon, ClientPlayNetworkAddon, ServerConfigurationNetworkAddon, ServerPlayNetworkAddon
public abstract class AbstractChanneledNetworkAddon<H>
extends AbstractNetworkAddon<H>
implements PacketSender, CommonPacketHandler
A network addon which is aware of the channels the other side may receive.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected final net.minecraft.network.Connectionprotected final GlobalReceiverRegistry<H> protected final Set<net.minecraft.resources.Identifier> Fields inherited from class AbstractNetworkAddon
logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractChanneledNetworkAddon(GlobalReceiverRegistry<H> receiver, net.minecraft.network.Connection connection, String description) -
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable RegistrationPayloadcreateRegistrationPayload(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<RegistrationPayload> type, Collection<net.minecraft.resources.Identifier> channels) voiddisconnect(net.minecraft.network.chat.Component disconnectReason) Disconnects the player.intSet<net.minecraft.resources.Identifier> booleanhandle(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) protected abstract voidinvokeRegisterEvent(List<net.minecraft.resources.Identifier> ids) protected abstract voidinvokeUnregisterEvent(List<net.minecraft.resources.Identifier> ids) protected abstract booleanvoidvoidonCommonVersionPacket(int negotiatedVersion) protected abstract voidprotected voidreceiveRegistration(boolean register, RegistrationPayload payload) protected voidregisterPendingChannels(ChannelInfoHolder holder, net.minecraft.network.ConnectionProtocol state) protected abstract voidSchedules a task to run on the main thread.protected voidvoidsendPacket(net.minecraft.network.protocol.Packet<?> packet, io.netty.channel.ChannelFutureListener callback) Sends a packet.Methods inherited from class AbstractNetworkAddon
endSession, getHandler, getReceivableChannels, handleDisconnect, handleRegistration, handleUnregistration, invokeDisconnectEvent, invokeInitEvent, isReservedChannel, lateInit, registerChannel, registerChannels, unregisterChannelMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface PacketSender
createPacket, sendPacket, sendPacket, sendPacket
-
Field Details
-
connection
protected final net.minecraft.network.Connection connection -
receiver
-
sendableChannels
-
commonVersion
protected int commonVersion
-
-
Constructor Details
-
AbstractChanneledNetworkAddon
protected AbstractChanneledNetworkAddon(GlobalReceiverRegistry<H> receiver, net.minecraft.network.Connection connection, String description)
-
-
Method Details
-
registerPendingChannels
protected void registerPendingChannels(ChannelInfoHolder holder, net.minecraft.network.ConnectionProtocol state) -
handle
public boolean handle(net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) -
isOnReceiveThread
protected abstract boolean isOnReceiveThread() -
receive
protected abstract void receive(H handler, net.minecraft.network.protocol.common.custom.CustomPacketPayload payload) -
sendInitialChannelRegistrationPacket
protected void sendInitialChannelRegistrationPacket() -
createRegistrationPayload
protected @Nullable RegistrationPayload createRegistrationPayload(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<RegistrationPayload> type, Collection<net.minecraft.resources.Identifier> channels) -
receiveRegistration
-
sendPacket
public void sendPacket(net.minecraft.network.protocol.Packet<?> packet, io.netty.channel.ChannelFutureListener callback) Description copied from interface:PacketSenderSends a packet.- Specified by:
sendPacketin interfacePacketSender- Parameters:
packet- the packetcallback- an optional callback to execute after the packet is sent, may benull.
-
disconnect
public void disconnect(net.minecraft.network.chat.Component disconnectReason) Description copied from interface:PacketSenderDisconnects the player.- Specified by:
disconnectin interfacePacketSender- Parameters:
disconnectReason- the reason for disconnection
-
schedule
Schedules a task to run on the main thread. -
invokeRegisterEvent
-
invokeUnregisterEvent
-
getSendableChannels
-
onCommonVersionPacket
public void onCommonVersionPacket(int negotiatedVersion) - Specified by:
onCommonVersionPacketin interfaceCommonPacketHandler
-
onCommonRegisterPacket
- Specified by:
onCommonRegisterPacketin interfaceCommonPacketHandler
-
createRegisterPayload
- Specified by:
createRegisterPayloadin interfaceCommonPacketHandler
-
getNegotiatedVersion
public int getNegotiatedVersion()- Specified by:
getNegotiatedVersionin interfaceCommonPacketHandler
-