Package me.tamkungz.nilkit.helper
Class PacketHelper
java.lang.Object
me.tamkungz.nilkit.helper.PacketHelper
PacketHelper — utility for creating and sending Packet250CustomPayload
without repeatedly hardcoding logic.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectbuildPacket250(SimpleRemap remap, String channel, byte[] payload) Creates a Packet250CustomPayload instance.static StringgetChannel(Object pkt250, SimpleRemap remap) Extracts the channel name from a Packet250 instance.static byte[]getData(Object pkt250, SimpleRemap remap) Extracts payload bytes from a Packet250 instance.static booleanisPacket250ForChannel(Object obj, String channel, SimpleRemap remap) Checks whether the object is a Packet250 for the given channel.static booleansendPacketBestEffort(Object mc, Object clientPlayer, Object pkt, SimpleRemap remap) Sends a packet using best-effort strategy.
-
Method Details
-
buildPacket250
Creates a Packet250CustomPayload instance. Tries (String, byte[]) constructor first, falls back to no-arg constructor + field assignment.- Parameters:
remap- SimpleRemap for the current versionchannel- channel name (e.g. "LYFE|Feed")payload- payload bytes- Returns:
- packet instance, or null if class cannot be found
-
sendPacketBestEffort
public static boolean sendPacketBestEffort(Object mc, Object clientPlayer, Object pkt, SimpleRemap remap) Sends a packet using best-effort strategy. Scans multiple possible paths (NetClientHandler, player fields, etc.).- Returns:
- true if sending succeeds
-
getChannel
Extracts the channel name from a Packet250 instance. -
getData
Extracts payload bytes from a Packet250 instance. -
isPacket250ForChannel
Checks whether the object is a Packet250 for the given channel.
-