Record Class IExtensionPoint.DisplayTest

java.lang.Object
java.lang.Record
net.minecraftforge.fml.IExtensionPoint.DisplayTest
All Implemented Interfaces:
IExtensionPoint<IExtensionPoint.DisplayTest>
Enclosing interface:
IExtensionPoint<T extends Record>

public static record IExtensionPoint.DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String,Boolean> remoteVersionTest) extends Record implements IExtensionPoint<IExtensionPoint.DisplayTest>
Compatibility display test for the mod. Used for displaying compatibility with remote servers with the same mod, and on disk saves. The supplier provides my "local" version for sending across the impl or writing to disk The predicate tests the version from a remote instance or save for acceptability (Boolean is true for impl, false for local save) and returns true if the version is compatible.

Return net.minecraftforge.network.NetworkConstants#IGNORESERVERONLY in the supplier, if you wish to be ignored as a server side only mod.

Return true in the predicate for all values of the input string (when impl boolean is true) if you are client side, and don't care about matching any potential server version.

Examples: A server only mod


     registerExtensionPoint(DisplayTest.class, ()->new DisplayTest(
      ()->NetworkConstants.IGNORESERVERONLY, // ignore me, I'm a server only mod
      (s,b)->true // i accept anything from the server or the save, if I'm asked
     )
 

Examples: A client only mod


     registerExtensionPoint(DisplayTest.class, ()->new DisplayTest(
      ()->"anything. i don't care", // if i'm actually on the server, this string is sent but i'm a client only mod, so it won't be
      (remoteversionstring,networkbool)->networkbool // i accept anything from the server, by returning true if it's asking about the server
     )
 
  • Field Details

    • suppliedVersion

      private final Supplier<String> suppliedVersion
      The field for the suppliedVersion record component.
    • remoteVersionTest

      private final BiPredicate<String,Boolean> remoteVersionTest
      The field for the remoteVersionTest record component.
  • Constructor Details

    • DisplayTest

      public DisplayTest(Supplier<String> suppliedVersion, BiPredicate<String,Boolean> remoteVersionTest)
      Creates an instance of a DisplayTest record class.
      Parameters:
      suppliedVersion - the value for the suppliedVersion record component
      remoteVersionTest - the value for the remoteVersionTest record component
  • Method Details

    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • suppliedVersion

      public Supplier<String> suppliedVersion()
      Returns the value of the suppliedVersion record component.
      Returns:
      the value of the suppliedVersion record component
    • remoteVersionTest

      public BiPredicate<String,Boolean> remoteVersionTest()
      Returns the value of the remoteVersionTest record component.
      Returns:
      the value of the remoteVersionTest record component