Remove game registry comparsion from list ping

Signed-off-by: JoJoDeveloping <jojohostert@gmail.com>
This commit is contained in:
JoJoDeveloping 2019-03-25 22:22:29 +01:00
parent 4764136d47
commit 7e4101b3ad
No known key found for this signature in database
GPG key ID: 124FAA37C4711CBF
3 changed files with 2 additions and 35 deletions

View file

@ -74,18 +74,12 @@ public class ClientHooks
{
if(packet.getForgeData() != null){
int numberOfMods = packet.getForgeData().getNumberOfMods();
MapDifference<ResourceLocation, Integer> difference = Maps.difference(packet.getForgeData().getRegistryHashes(), RegistryManager.ACTIVE.computeRegistryHashes());
int fmlver = packet.getForgeData().getFMLNetworkVersion();
boolean b = NetworkRegistry.checkListPingCompatibilityForClient(packet.getForgeData().getPresentMods())
&& difference.areEqual()
&& fmlver == FMLNetworkConstants.FMLNETVERSION;
LOGGER.debug(CLIENTHOOKS, "Received FML ping data from server at {}: FMLNETVER={}, {} mods, channels: [{}] - compatible: {}", target.serverIP, fmlver, numberOfMods, packet.getForgeData().getPresentMods().entrySet(), b);
difference.entriesDiffering().forEach((k,vd)-> LOGGER.debug(CLIENTHOOKS, "Registry {}: Local: {}, Remote: {}", k, vd.rightValue(), vd.leftValue()));
difference.entriesOnlyOnLeft().forEach((k,vd)-> LOGGER.debug(CLIENTHOOKS, "Registry {} is only on server with hash {}", k, vd));
difference.entriesOnlyOnRight().forEach((k,vd)-> LOGGER.debug(CLIENTHOOKS, "Registry {} is missing on server with hash {}", k, vd));
difference.entriesInCommon().forEach((k,vd)-> LOGGER.debug(CLIENTHOOKS, "Registry {} is equal, hash={}", k, vd));
String extraReason = null;
if(fmlver<FMLNetworkConstants.FMLNETVERSION)

View file

@ -35,19 +35,16 @@ public class FMLStatusPing {
private Map<ResourceLocation, Pair<String, Boolean>> channelVersions;
private int numberOfMods;
private int fmlNetworkVer;
private Map<ResourceLocation, Integer> registrySnapshots;
public FMLStatusPing(){
this.channelVersions = NetworkRegistry.buildChannelVersionsForListPing();
this.numberOfMods = ModList.get().size();
this.registrySnapshots = RegistryManager.ACTIVE.computeRegistryHashes();
this.fmlNetworkVer = FMLNetworkConstants.FMLNETVERSION;
}
private FMLStatusPing(Map<ResourceLocation, Pair<String, Boolean>> deserialized, Map<ResourceLocation, Integer> registryHashes, int nom, int fmlNetVer){
private FMLStatusPing(Map<ResourceLocation, Pair<String, Boolean>> deserialized, int nom, int fmlNetVer){
this.channelVersions = ImmutableMap.copyOf(deserialized);
this.numberOfMods = nom;
this.registrySnapshots = registryHashes;
this.fmlNetworkVer = fmlNetVer;
}
@ -64,14 +61,7 @@ public class FMLStatusPing {
Boolean canBeAbsent = JsonUtils.getBoolean(jo, "mayBeAbsent");
versions.put(name, Pair.of(version, canBeAbsent));
}
JsonArray reghashes = JsonUtils.getJsonArray(forgeData, "registryKeys");
Map<ResourceLocation, Integer> registyData = Maps.newHashMap();
for(JsonElement el : reghashes){
JsonObject jo = el.getAsJsonObject();
ResourceLocation name = new ResourceLocation(JsonUtils.getString(jo, "namespace"), JsonUtils.getString(jo, "path"));
registyData.put(name, JsonUtils.getInt(jo, "hash"));
}
return new FMLStatusPing(versions, registyData, JsonUtils.getInt(forgeData, "numberOfMods"), JsonUtils.getInt(forgeData, "fmlNetworkVersion"));
return new FMLStatusPing(versions, JsonUtils.getInt(forgeData, "numberOfMods"), JsonUtils.getInt(forgeData, "fmlNetworkVersion"));
}catch (Exception c){
return null;
}
@ -89,15 +79,6 @@ public class FMLStatusPing {
return mi;
}).forEach(mods::add);
obj.add("mods", mods);
JsonArray regdata = new JsonArray();
forgeData.registrySnapshots.entrySet().stream().map(p -> {
JsonObject mi = new JsonObject();
mi.addProperty("namespace", p.getKey().getNamespace());
mi.addProperty("path", p.getKey().getPath());
mi.addProperty("hash", p.getValue());
return mi;
}).forEach(regdata::add);
obj.add("registryKeys", regdata);
obj.addProperty("numberOfMods", forgeData.numberOfMods);
obj.addProperty("fmlNetworkVersion", forgeData.fmlNetworkVer);
return obj;
@ -112,10 +93,6 @@ public class FMLStatusPing {
return numberOfMods;
}
public Map<ResourceLocation, Integer> getRegistryHashes(){
return registrySnapshots;
}
public int getFMLNetworkVersion(){
return fmlNetworkVer;
}

View file

@ -159,8 +159,4 @@ public class RegistryManager
{
return new ArrayList<>(ACTIVE.registries.keySet());
}
public Map<ResourceLocation, Integer> computeRegistryHashes() {
return this.registries.entrySet().stream().map(p -> Pair.of(p.getKey(), p.getValue().getKeys().hashCode())).collect(Collectors.toMap(Pair::getLeft, Pair::getRight));
}
}