Record Class ConnectionData.ModMismatchData

java.lang.Object
java.lang.Record
net.minecraftforge.network.ConnectionData.ModMismatchData
Record Components:
mismatchedModData - The data of the mismatched or missing mods/channels, consisting of the mod or channel id and the version of the respective mod. If the mod version is absent, the entry is assumed to be missing on either side. If it is present, the entry gets treated as a mismatch.
presentModData - The data of the channels/mods from the side the mismatch data doesn't originate from, consisting of the mod or channel id and the name and version of the respective mod. This data is useful for a proper comparison against the mismatched channel data. The data is stored like this: [id -> [modName, modVersion]]
mismatchedDataFromServer - Whether the mismatched data originates from the server. Note, that the mismatched data origin does not tell us if the actual mismatch check happened on the client or the server.
Enclosing class:
ConnectionData

public static record ConnectionData.ModMismatchData(Map<ResourceLocation,String> mismatchedModData, Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<String,String>> presentModData, boolean mismatchedDataFromServer) extends Record
A class for holding the mod mismatch data of a failed handshake. Contains a list of mismatched channels, the channels present on the side the handshake failed on, the mods with mismatching registries (if available) and the information of whether the mismatching data's origin is the server.
  • Field Details

  • Constructor Details

  • Method Details

    • channel

      public static ConnectionData.ModMismatchData channel(Map<ResourceLocation,String> mismatchedChannels, ConnectionData connectionData, boolean mismatchedDataFromServer)
      Creates a ModMismatchData instance from given channel mismatch data, which is processed side-aware depending on the value of mismatchedDataFromServer
      Parameters:
      mismatchedChannels - The list of channels that were listed as mismatches, either because they are missing on one side or because their versions mismatched
      connectionData - The connection data instance responsible for collecting the server mod data.
      mismatchedDataFromServer - Whether the mismatched data originates from the server.
    • registry

      public static ConnectionData.ModMismatchData registry(com.google.common.collect.Multimap<ResourceLocation,ResourceLocation> mismatchedRegistryData, ConnectionData connectionData)
      Creates a ModMismatchData instance from given mismatched registry entries. In this case, the mismatched data is always treated as originating from the client because registry entries missing on the server never cause the handshake to fail.
      Parameters:
      mismatchedRegistryData - The list of mismatched registries and the associated mismatched registry entries. The data is stored like this: "registryNamespace:registryPath" -> "entryNamespace:entryPath"
      connectionData - The connection data instance responsible for collecting the server mod data.
    • containsMismatches

      public boolean containsMismatches()
      Returns:
      true if this ModMismatchData instance contains channel or registry mismatches
    • enhanceWithModVersion

      private static Map<ResourceLocation,String> enhanceWithModVersion(Map<ResourceLocation,String> mismatchedChannels, ConnectionData connectionData, boolean mismatchedDataFromServer)
      Enhances a map of mismatched channels with the corresponding mod version.
      Parameters:
      mismatchedChannels - The original mismatched channel list, containing the id and version of the mismatched channel.
      connectionData - The connection data instance responsible for collecting the server mod data.
      mismatchedDataFromServer - Whether the mismatched data originates from the server. The given mismatched channel list gets processed side-aware depending on the value of this parameter.
      Returns:
      A map containing the id of the channel and the version of the corresponding mod, or NetworkRegistry.ABSENT if the channel is missing.
    • getPresentChannelData

      private static Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<String,String>> getPresentChannelData(Set<ResourceLocation> mismatchedChannelsFilter, ConnectionData connectionData, boolean mismatchedDataFromServer)
      Queries the channel data from the side the mismatched data isn't from, in order to provide a map of all the present channels for a proper comparison against the mismatched channel data.
      Parameters:
      mismatchedChannelsFilter - A filter that gets used in order to only query the data of mismatched mods, because that's the only one we need for a proper comparison between mismatched and present mods.
      connectionData - The connection data instance responsible for collecting the server mod data.
      mismatchedDataFromServer - Whether the mismatched data originates from the server. The data gets queried from the side that the mismatch data does not originate from.
      Returns:
      The data of all relevant present channels, containing the channel id and the name and version of the corresponding mod.
    • getPresentModDataFromChannel

      private static org.apache.commons.lang3.tuple.Pair<ResourceLocation,org.apache.commons.lang3.tuple.Pair<String,String>> getPresentModDataFromChannel(ResourceLocation channel, ConnectionData connectionData, boolean mismatchedDataFromServer)
      Queries the mod data from a given channel id from the side the mismatched data isn't from.
      Parameters:
      channel - The id of the channel the mod data should be queried for.
      connectionData - The connection data instance responsible for collecting the server mod data.
      mismatchedDataFromServer - Whether the mismatched data originates from the server. The data gets queried from the side that the mismatch data does not originate from.
      Returns:
      The mod data corresponding to the channel id, containing the channel id and the name and version of the corresponding mod.
    • getServerSidePresentModData

      private static Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<String,String>> getServerSidePresentModData(Set<ResourceLocation> mismatchedModsFilter, ConnectionData connectionData)
      Queries the mod data from the server side. Useful in case of a registry mismatch, which always gets detected on the client.
      Parameters:
      mismatchedModsFilter - A filter that gets used in order to only query the data of mismatched mods, because that's the only one we need for a proper comparison between mismatched and present mods.
      connectionData - The connection data instance responsible for collecting the server mod data.
      Returns:
      The mod data from the server, containing the channel id and the name and version of the corresponding mod.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • mismatchedModData

      public Map<ResourceLocation,String> mismatchedModData()
      Returns the value of the mismatchedModData record component.
      Returns:
      the value of the mismatchedModData record component
    • presentModData

      public Map<ResourceLocation,org.apache.commons.lang3.tuple.Pair<String,String>> presentModData()
      Returns the value of the presentModData record component.
      Returns:
      the value of the presentModData record component
    • mismatchedDataFromServer

      public boolean mismatchedDataFromServer()
      Returns the value of the mismatchedDataFromServer record component.
      Returns:
      the value of the mismatchedDataFromServer record component