Class ForgeNetworkHandler
java.lang.Object
commonnetwork.networking.PacketRegistrationHandler
commonnetwork.networking.ForgeNetworkHandler
- All Implemented Interfaces:
NetworkHandler, PacketRegistrar
-
Field Summary
Fields inherited from class PacketRegistrationHandler
side -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
@Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacketgetRawClientboundPacket(T packet) Generates a ClientboundCustomPayloadPacket<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
@Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacketgetRawServerboundPacket(T packet) Generates a ServerboundCustomPayloadPacketprotected <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidonRegister(PacketContainer<T> container) Loader-specific wiring for a freshly-registered packet.<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidsend(T packet, net.minecraft.network.Connection connection) Sends the packet to the connection.<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidsendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck) Sends the packet to the client player.<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidsendToServer(T packet, boolean ignoreCheck) Sends the packet to the server.Methods inherited from class PacketRegistrationHandler
getPacketContainer, getSide, registerConfigurationPacket, registerPacket, requireContainer, supportsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface NetworkHandler
sendToAllClients, sendToAllClients, sendToClient, sendToClients, sendToClients, sendToClientsInLevel, sendToClientsInLevel, sendToClientsInRange, sendToClientsInRange, sendToClientsLoadingChunk, sendToClientsLoadingChunk, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToClientsLoadingPos, sendToServer
-
Constructor Details
-
ForgeNetworkHandler
-
-
Method Details
-
onRegister
protected <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void onRegister(PacketContainer<T> container) Description copied from class:PacketRegistrationHandlerLoader-specific wiring for a freshly-registered packet. May be a no-op if the loader defers registration to its own lifecycle event.- Specified by:
onRegisterin classPacketRegistrationHandler
-
sendToServer
public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToServer(T packet, boolean ignoreCheck) Description copied from interface:NetworkHandlerSends the packet to the server. Can ignore the check if the server has the packet registered. Likely use case for this is talking to bukkit/spigot/paper servers.- Type Parameters:
T- - The packet type- Parameters:
packet- - the packetignoreCheck- - ignore the check if the server has the packet registered.
-
sendToClient
public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void sendToClient(T packet, net.minecraft.server.level.ServerPlayer player, boolean ignoreCheck) Description copied from interface:NetworkHandlerSends the packet to the client player.- Type Parameters:
T- - The packet type- Parameters:
packet- - the packetplayer- - the playerignoreCheck- - ignore the check if the client has the packet registered.
-
send
public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void send(T packet, net.minecraft.network.Connection connection) Description copied from interface:NetworkHandlerSends the packet to the connection.- Type Parameters:
T- - The packet type- Parameters:
packet- - the packetconnection- - the connection
-
getRawClientboundPacket
@Nullable public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket getRawClientboundPacket(T packet) Description copied from interface:NetworkHandlerGenerates a ClientboundCustomPayloadPacket- Specified by:
getRawClientboundPacketin interfaceNetworkHandler- Overrides:
getRawClientboundPacketin classPacketRegistrationHandler- Type Parameters:
T- - The packet type- Parameters:
packet- - the packet- Returns:
- The packet wrapped into a ClientboundCustomPayloadPacket
-
getRawServerboundPacket
@Nullable public <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> @Nullable net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket getRawServerboundPacket(T packet) Description copied from interface:NetworkHandlerGenerates a ServerboundCustomPayloadPacket- Specified by:
getRawServerboundPacketin interfaceNetworkHandler- Overrides:
getRawServerboundPacketin classPacketRegistrationHandler- Type Parameters:
T- - The packet type- Parameters:
packet- - the packet- Returns:
- The packet wrapped into a ServerboundCustomPayloadPacket
-