Package org.moddingx.libx.network
Class NetworkX
java.lang.Object
org.moddingx.libx.network.NetworkX
A class implementing network logic. You can use the
register
methods
in you constructor to register network packets.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canSend
(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type) Checks whether a packet of a given type can currently be sent.boolean
canSend
(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type) Checks whether a packet of a given type can currently be sent to the given player.protected abstract String
Gets the network version for this network.protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidregister
(PacketHandler<T> handler) Registers a new packet handler to the system.protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
voidregisterOptional
(PacketHandler<T> handler) Registers a new optional packet handler to the system.
-
Constructor Details
-
NetworkX
-
-
Method Details
-
getVersion
Gets the network version for this network. -
register
protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void register(PacketHandler<T> handler) Registers a new packet handler to the system. This should be called in the constructor. -
registerOptional
protected final <T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> void registerOptional(PacketHandler<T> handler) Registers a new optional packet handler to the system. An optional packet handler is not required to be present on the remote side for the connection negotiation to be successful. This should be called in the constructor. -
canSend
public boolean canSend(net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type) Checks whether a packet of a given type can currently be sent. On the physical client this checks that the current connection supports the given packet type. On a dedicated server, this always returnstrue
. -
canSend
public boolean canSend(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<?> type) Checks whether a packet of a given type can currently be sent to the given player. This check that the given players connection supports the given packet type.
-