Record Class ServerStatusPing
{
"fmlNetworkVersion" : FMLNETVERSION,
"channels": [
{
"res": "fml:handshake",
"version": "1.2.3.4",
"required": true
}
],
"mods": [
{
"modid": "modid",
"modmarker": "{@literal <somestring>}"
}
]
}
Due to size of the ping packet (32767 UTF-16 code points of JSON data) this could exceed this limit and cause issues. To work around this, a truncation mechanism was introduced, to heuristically truncate the size of the data, at the expense of making the compatibility info on the server screen inaccurate.
Modern versions will send binary data, which is encoded in a custom format optimized for UTF-16 code point count.
See encodeOptimized(ByteBuf)
and decodeOptimized(String)
.
Essentially 15 bits of binary data are encoded into every UTF-16 code point. The resulting string is then stored in
the "d" property of the resulting JSON.
The "channels" and "mods" properties are retained for backwards compatibility, but left empty. A client that cannot read the old format would not be able to connect anyways, but the properties must exist to not cause exceptions.
{
"fmlNetworkVersion": FMLNETVERSION,
"channels": [],
"mods": [],
"d": "<binary data>"
}
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
static final record
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final com.mojang.serialization.Codec
<io.netty.buffer.ByteBuf> private final Map
<ResourceLocation, ServerStatusPing.ChannelData> The field for thechannels
record component.static final com.mojang.serialization.Codec
<ServerStatusPing> private final int
The field for thefmlNetworkVer
record component.The field for themods
record component.private final boolean
The field for thetruncated
record component.private static final int
-
Constructor Summary
ConstructorDescriptionServerStatusPing
(Map<ResourceLocation, ServerStatusPing.ChannelData> channels, Map<String, String> mods, int fmlNetworkVer, boolean truncated) Creates an instance of aServerStatusPing
record class. -
Method Summary
Modifier and TypeMethodDescriptionchannels()
Returns the value of thechannels
record component.private static io.netty.buffer.ByteBuf
Decode binary data encoded byencodeOptimized(io.netty.buffer.ByteBuf)
private static ServerStatusPing
deserializeOptimized
(int fmlNetworkVersion, io.netty.buffer.ByteBuf bbuf) private static String
encodeOptimized
(io.netty.buffer.ByteBuf buf) Encode given ByteBuf to a String.boolean
Indicates whether some other object is "equal to" this one.int
Returns the value of thefmlNetworkVer
record component.getChannelsForMod
(String modId) int
int
hashCode()
Returns a hash code value for this object.boolean
mods()
Returns the value of themods
record component.io.netty.buffer.ByteBuf
toBuf()
final String
toString()
Returns a string representation of this record class.boolean
Returns the value of thetruncated
record component.
-
Field Details
-
channels
The field for thechannels
record component. -
mods
The field for themods
record component. -
fmlNetworkVer
private final int fmlNetworkVerThe field for thefmlNetworkVer
record component. -
truncated
private final boolean truncatedThe field for thetruncated
record component. -
BYTE_BUF_CODEC
private static final com.mojang.serialization.Codec<io.netty.buffer.ByteBuf> BYTE_BUF_CODEC -
CODEC
-
VERSION_FLAG_IGNORESERVERONLY
private static final int VERSION_FLAG_IGNORESERVERONLY- See Also:
-
-
Constructor Details
-
ServerStatusPing
public ServerStatusPing() -
ServerStatusPing
public ServerStatusPing(Map<ResourceLocation, ServerStatusPing.ChannelData> channels, Map<String, String> mods, int fmlNetworkVer, boolean truncated) Creates an instance of aServerStatusPing
record class.- Parameters:
channels
- the value for thechannels
record componentmods
- the value for themods
record componentfmlNetworkVer
- the value for thefmlNetworkVer
record componenttruncated
- the value for thetruncated
record component
-
-
Method Details
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
getChannelsForMod
private List<Map.Entry<ResourceLocation,ServerStatusPing.ChannelData>> getChannelsForMod(String modId) -
getNonModChannels
-
toBuf
public io.netty.buffer.ByteBuf toBuf() -
deserializeOptimized
private static ServerStatusPing deserializeOptimized(int fmlNetworkVersion, io.netty.buffer.ByteBuf bbuf) -
encodeOptimized
Encode given ByteBuf to a String. This is optimized for UTF-16 Code-Point count. Supports at most 2^30 bytes in length -
decodeOptimized
Decode binary data encoded byencodeOptimized(io.netty.buffer.ByteBuf)
-
getRemoteChannels
-
getRemoteModData
-
getFMLNetworkVersion
public int getFMLNetworkVersion() -
isTruncated
public boolean isTruncated() -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
channels
Returns the value of thechannels
record component.- Returns:
- the value of the
channels
record component
-
mods
Returns the value of themods
record component.- Returns:
- the value of the
mods
record component
-
fmlNetworkVer
public int fmlNetworkVer()Returns the value of thefmlNetworkVer
record component.- Returns:
- the value of the
fmlNetworkVer
record component
-
truncated
public boolean truncated()Returns the value of thetruncated
record component.- Returns:
- the value of the
truncated
record component
-