记录类 IExtensionPoint.DisplayTest
- 所有已实现的接口:
IExtensionPoint<IExtensionPoint.DisplayTest>
- 封闭接口:
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
)
);
- 另请参阅:
-
嵌套类概要
从接口继承的嵌套类/接口 net.minecraftforge.fml.IExtensionPoint
IExtensionPoint.DisplayTest
-
字段概要
字段修饰符和类型字段说明static 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> remoteVersionTest
记录组件的字段。suppliedVersion
记录组件的字段。 -
构造器概要
构造器构造器说明DisplayTest
(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) 创建DisplayTest
记录类的实例。 -
方法概要
-
字段详细资料
-
suppliedVersion
suppliedVersion
记录组件的字段。 -
remoteVersionTest
remoteVersionTest
记录组件的字段。 -
IGNORESERVERONLY
- 另请参阅:
-
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.
-
-
构造器详细资料
-
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
创建DisplayTest
记录类的实例。- 参数:
suppliedVersion
-suppliedVersion
记录组件的值remoteVersionTest
-remoteVersionTest
记录组件的值
-
-
方法详细资料
-
toString
返回此记录类的字符串表示形式。此表示形式包含类的名称,后跟每个记录组件的名称和值。 -
hashCode
public final int hashCode()返回此对象的哈希代码值。此值派生自每个记录组件的哈希代码。 -
equals
指示某个其他对象是否“等于”此对象。如果两个对象属于同一个类,而且所有记录组件都相等,则这两个对象相等。 此记录类中的所有组件都使用Objects::equals(Object,Object)
进行比较。 -
suppliedVersion
返回suppliedVersion
记录组件的值。- 返回:
suppliedVersion
记录组件的值
-
remoteVersionTest
返回remoteVersionTest
记录组件的值。- 返回:
remoteVersionTest
记录组件的值
-