Files
ForgeMultipart/src/main/scala/codechicken/multipart/IScheduledPacketPart.java
T
Algent 40bb1b71b7 refactor: port PacketScheduler to Java
IScheduledPacketPart is descriptor-identical and schedulePacket is unchanged.
TScheduledPacketPart.read stays abstract: TMultiPart declares read, so a
default would be shadowed and a part would silently read a description instead
of a mask. The dispatch that lived in the $class helper is now the interface
static readMask, with the one-line forwarder documented on read.

writeScheduled and readScheduled became defaults. TMultiPart declares neither,
and empty bodies are what mixing the Scala trait in already gave a Scala
implementor -- only Java implementors ever had to write them out.

sendScheduled is public because the reference's private[multipart] reaches the
handler package and Java has no equivalent scope. An unsupported mask width now
throws IllegalArgumentException rather than scala.MatchError; both are
RuntimeException and the map is still left uncleared on that path, as before.

Dropped PacketScheduler$, TScheduledPacketPart$class and two closure classes,
none referenced in bytecode or by reflective name.

118 plain-JVM tests and 18 Forge server tests pass.
2026-08-15 17:04:41 +02:00

23 lines
722 B
Java

package codechicken.multipart;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
/** Callback interface for PacketScheduler. */
public interface IScheduledPacketPart {
/** Write scheduled data to the packet, mask is the cumulative mask from calls to schedulePacket. */
void writeScheduled(long mask, MCDataOutput packet);
/**
* Returns the width (in bytes) of the data type required to hold all valid mask bits. Valid values are 1, 2, 4 and
* 8.
*/
int maskWidth();
/**
* Read data matching mask. Establishes a method for subclasses to override. This should be called from read.
*/
void readScheduled(long mask, MCDataInput packet);
}