diff --git a/src/main/java/net/neoforged/neoforge/network/configuration/CheckExtensibleEnums.java b/src/main/java/net/neoforged/neoforge/network/configuration/CheckExtensibleEnums.java index 9d493a3ef5..a62200e369 100644 --- a/src/main/java/net/neoforged/neoforge/network/configuration/CheckExtensibleEnums.java +++ b/src/main/java/net/neoforged/neoforge/network/configuration/CheckExtensibleEnums.java @@ -75,33 +75,33 @@ public static void handleClientboundPayload(ExtensibleEnumDataPayload payload, I Map localEnumEntries = getEnumEntries(); Map remoteEnumEntries = payload.enumEntries(); - Set keyDiff = Sets.symmetricDifference(localEnumEntries.keySet(), remoteEnumEntries.keySet()); - if (!keyDiff.isEmpty()) { - context.disconnect(Component.translatable("neoforge.network.extensible_enums.enum_set_mismatch")); - return; - } - Map mismatched = new HashMap<>(); - for (EnumEntry localEntry : localEnumEntries.values()) { - EnumEntry remoteEntry = remoteEnumEntries.get(localEntry.className); - if (!localEntry.isExtended() && !remoteEntry.isExtended()) { + for (String className : Sets.union(localEnumEntries.keySet(), remoteEnumEntries.keySet())) { + EnumEntry localEntry = localEnumEntries.get(className); + EnumEntry remoteEntry = remoteEnumEntries.get(className); + if ((localEntry == null && remoteEntry.isExtended()) || (remoteEntry == null && localEntry.isExtended())) { + mismatched.put(className, Mismatch.EXTENSIBILITY); + continue; + } + + if ((localEntry == null || !localEntry.isExtended()) && (remoteEntry == null || !remoteEntry.isExtended())) { continue; } if (localEntry.networkCheck != remoteEntry.networkCheck) { - mismatched.put(localEntry.className, Mismatch.NETWORK_CHECK); + mismatched.put(className, Mismatch.NETWORK_CHECK); continue; } if (localEntry.isExtended() != remoteEntry.isExtended()) { - mismatched.put(localEntry.className, Mismatch.EXTENSION); + mismatched.put(className, Mismatch.EXTENSION); continue; } ExtensionData localData = localEntry.data.orElseThrow(); ExtensionData remoteData = remoteEntry.data.orElseThrow(); if (localData.vanillaCount != remoteData.vanillaCount || localData.totalCount != remoteData.totalCount) { - mismatched.put(localEntry.className, Mismatch.ENTRY_COUNT); + mismatched.put(className, Mismatch.ENTRY_COUNT); continue; } @@ -109,7 +109,7 @@ public static void handleClientboundPayload(ExtensibleEnumDataPayload payload, I List remoteValues = remoteData.entries; for (int i = 0; i < localData.totalCount - localData.vanillaCount; i++) { if (!localValues.get(i).equals(remoteValues.get(i))) { - mismatched.put(localEntry.className, Mismatch.ENTRY_MISMATCH); + mismatched.put(className, Mismatch.ENTRY_MISMATCH); break; } } @@ -122,6 +122,13 @@ public static void handleClientboundPayload(ExtensibleEnumDataPayload payload, I String enumClass = entry.getKey(); message.append("\n").append(enumClass).append(": "); switch (entry.getValue()) { + case EXTENSIBILITY -> { + if (remoteEnumEntries.containsKey(enumClass)) { + message.append("Enum is extensible on the server but not on the client"); + } else { + message.append("Enum is extensible on the client but not on the server"); + } + } case NETWORK_CHECK -> message.append("Mismatched NetworkCheck (server: ") .append(remoteEnumEntries.get(enumClass).networkCheck) .append(", client: ") @@ -258,6 +265,7 @@ public record ExtensionData(int vanillaCount, int totalCount, List entri } private enum Mismatch { + EXTENSIBILITY, NETWORK_CHECK, EXTENSION, ENTRY_COUNT, diff --git a/src/main/resources/assets/neoforge/lang/en_us.json b/src/main/resources/assets/neoforge/lang/en_us.json index b61eef8d39..d0f85277ce 100644 --- a/src/main/resources/assets/neoforge/lang/en_us.json +++ b/src/main/resources/assets/neoforge/lang/en_us.json @@ -264,7 +264,6 @@ "neoforge.network.data_maps.missing_their": "Cannot connect to server as it has mandatory registry data maps not present on the client: %s", "neoforge.network.extensible_enums.no_vanilla_server": "This client does not support vanilla servers as it has extended enums used in serverbound networking", - "neoforge.network.extensible_enums.enum_set_mismatch": "The set of extensible enums on the client and server do not match. Make sure you are using the same NeoForge version as the server", "neoforge.network.extensible_enums.enum_entry_mismatch": "The set of values added to extensible enums on the client and server do not match. Make sure you are using the same mod and NeoForge versions as the server. See the log for more details", "neoforge.attribute.debug.base": "[Entity: %s | Item: %s]",