Record Class IExtensionPoint.DisplayTest
- All Implemented Interfaces:
IExtensionPoint<IExtensionPoint.DisplayTest>
- Enclosing interface:
- IExtensionPoint<T extends Record>
The Supplier
provides the local compatibility version, which is sent from the server to the client
for multiplayer connections or stored to disk for the world save. The BiPredicate
accepts the remote
compatibility version and a boolean indicating whether the remote version is from the server or a world save,
where true
means it is from the server and false
means it is from the world save. The return
value of the predicate determines whether the remote version is "compatible" for the purposes of the display test.
The local compatibility version may be of the value IGNORESERVERONLY
,
in which case clients will ignore the mod's presence if it is present on the server but not on the client.
However, the remote version test predicate must still accept this value as a remote version in order to display
as compatible if the mod is present on the client.
The compatibility display test does not necessarily indicate the success or failure of an actual connection attempt. Factors such as display test extension misconfiguration, truncation of ping data, difference of registry data or network channels between server and client, and others may cause the result of the compatibility test to not reflect the actual likelihood of a connection successfully being established between the server and the client.
An example declaration of a display test extension registration for a regular mod (requires to be present on server and client) is as follows:
String compatibilityVersion = "1"; // Could be linked with a network channel version or mod version
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(
() -> compatibilityVersion,
(remoteVersion, isFromServer) -> remoteVersion.equals(compatibilityVersion)
)
);
An example declaration of a display test extension registration for a server-side-only mod (does not require to be present on the client) is as follows:
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(
// Ignore this mod if not present on the client
() -> NetworkConstants.IGNORESERVERONLY,
// If present on the client, accept any version if from a server
(remoteVersion, isFromServer) -> isFromServer
)
);
An example declaration of a display test extension registration for a client-side-only mod (does not require to be present on the server) is as follows:
ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class,
() -> new IExtensionPoint.DisplayTest(
// Send any version from server to client, since we will be accepting any version as well
() -> "dQw4w9WgXcQ",
// Accept any version on the client, from server or from save
(remoteVersion, isFromServer) -> true
)
);
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraftforge.fml.IExtensionPoint
IExtensionPoint.DisplayTest
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Supplier<IExtensionPoint.DisplayTest>
Ignores all information and provides no informationstatic final Supplier<IExtensionPoint.DisplayTest>
Ignores any version information coming from the server - use for server only modsstatic final String
private final BiPredicate<String,
Boolean> The field for theremoteVersionTest
record component.The field for thesuppliedVersion
record component. -
Constructor Summary
ConstructorDescriptionDisplayTest
(String version, BiPredicate<String, Boolean> remoteVersionTest) An optional alternative toDisplayTest(Supplier, BiPredicate)
which accepts a constant version string instead of aSupplier
.DisplayTest
(Supplier<String> suppliedVersion, BiPredicate<String, Boolean> remoteVersionTest) Creates an instance of aDisplayTest
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.Returns the value of theremoteVersionTest
record component.Returns the value of thesuppliedVersion
record component.final String
toString()
Returns a string representation of this record class.
-
Field Details
-
suppliedVersion
The field for thesuppliedVersion
record component. -
remoteVersionTest
The field for theremoteVersionTest
record component. -
IGNORESERVERONLY
- See Also:
-
IGNORE_SERVER_VERSION
Ignores any version information coming from the server - use for server only mods -
IGNORE_ALL_VERSION
Ignores all information and provides no informationNote: If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN), consider setting
clientSideOnly=true
in the root of your mods.toml.
-
-
Constructor Details
-
DisplayTest
An optional alternative toDisplayTest(Supplier, BiPredicate)
which accepts a constant version string instead of aSupplier
.Internally, the provided version string is wrapped in a Supplier for you.
-
DisplayTest
Creates an instance of aDisplayTest
record class.- Parameters:
suppliedVersion
- the value for thesuppliedVersion
record componentremoteVersionTest
- the value for theremoteVersionTest
record component
-
-
Method Details
-
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. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
suppliedVersion
Returns the value of thesuppliedVersion
record component.- Returns:
- the value of the
suppliedVersion
record component
-
remoteVersionTest
Returns the value of theremoteVersionTest
record component.- Returns:
- the value of the
remoteVersionTest
record component
-