mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-15 10:45:35 +01:00
Simplify and improve version sanity checks
Adds a check for the ProtocolTranslator#NATIVE_VERSION field
This commit is contained in:
parent
a0baba5661
commit
330412618a
@ -20,7 +20,7 @@
|
||||
package de.florianmichael.viafabricplus.fixes.data;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.protocol.version.VersionType;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.GameVersion;
|
||||
import net.minecraft.SaveVersion;
|
||||
import net.minecraft.SharedConstants;
|
||||
@ -83,17 +83,10 @@ public class ResourcePackHeaderDiff {
|
||||
registerVersion(ProtocolVersion.v1_7_2, 1, "1.7.5");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the registry is outdated.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static void checkOutdated() {
|
||||
for (ProtocolVersion version : ProtocolVersion.getProtocols()) {
|
||||
if (version.isSnapshot()) continue;
|
||||
if (version.getVersionType() != VersionType.RELEASE) continue;
|
||||
if (!GAME_VERSION_DIFF.containsKey(version)) {
|
||||
throw new RuntimeException("The version " + version + " has no pack format registered");
|
||||
}
|
||||
if (!GAME_VERSION_DIFF.containsKey(ProtocolTranslator.NATIVE_VERSION)) {
|
||||
throw new RuntimeException("The native client version is not registered in the resource pack header diff!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ import io.netty.channel.Channel;
|
||||
import io.netty.util.AttributeKey;
|
||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
@ -315,6 +316,9 @@ public class ProtocolTranslator {
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public static CompletableFuture<Void> init(final File directory) {
|
||||
if (SharedConstants.getProtocolVersion() != NATIVE_VERSION.getOriginalVersion()) {
|
||||
throw new IllegalStateException("Native version is not the same as the current version");
|
||||
}
|
||||
patchConfigs(new File(directory, "ViaLoader"));
|
||||
|
||||
// Register command callback for /viafabricplus
|
||||
|
Loading…
Reference in New Issue
Block a user