SendPacket
com.jsmacrosce.jsmacros.client.api.event.impl.EventSendPacket
Fires synchronously at the client's packet-send path, including for non-gameplay packets.
A joined listener can cancel sending or replace the packet with setPacket(...);
assigning null drops it. A joined script listener runs on a worker thread while the sending thread waits until the script releases the packet, so keep it short; pass false to observe asynchronously without blocking or changing the packet. A buffer from getPacketBuffer() is independent, so apply edits by decoding it and assigning the result to setPacket(...). Use a filterer to limit which packets invoke a listener.
Filterer: FiltererSendPacket. Create it with JsMacros.createEventFilterer("SendPacket") and pass it to the filterer overload of JsMacros.on.
Constructors
new EventSendPacket
setPacket(...) is later called.Parameters:
packet: the non-null outgoing packet to store
Fields
packet
null drops it. Buffer edits do not alter this field unless the decoded packet is assigned here.Deprecated: Removal in 3.0.0: Use getPacket() and setPacket(Packet) instead.
type
Methods
canGetPacketBuffer
false when the current packet is null. This does not guarantee that encoding its contents will succeed; bundles are unsupported.getPacket
getPacketBuffer
setPacket(...). Unsupported packets, including bundles, cause an IllegalArgumentException; canGetPacketBuffer() checks codec availability but does not guarantee encoding succeeds.replacePacket
setPacket(...). It first tries an exact runtime-argument-type match, then constructors with the same argument count, coercing numeric arguments to parameter types.Parameters:
args: the arguments to pass to the packet's constructor