aboutsummaryrefslogtreecommitdiff
path: root/fabric/src/main/java
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-03-28 23:02:31 +0800
committershedaniel <daniel@shedaniel.me>2021-03-28 23:02:31 +0800
commit9402858f8f6f4ddee96fbaf171de7f0cfd770d5b (patch)
tree3e45f4ae1946c6ad41b27f0026fe7cb7ef2cc191 /fabric/src/main/java
parent939d940c178637748f0c393e1209647479fdd8f3 (diff)
downloadRoughlyEnoughItems-9402858f8f6f4ddee96fbaf171de7f0cfd770d5b.tar.gz
RoughlyEnoughItems-9402858f8f6f4ddee96fbaf171de7f0cfd770d5b.tar.bz2
RoughlyEnoughItems-9402858f8f6f4ddee96fbaf171de7f0cfd770d5b.zip
Porperly save JEI compatibility settings
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'fabric/src/main/java')
-rw-r--r--fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java
new file mode 100644
index 000000000..3e06c8898
--- /dev/null
+++ b/fabric/src/main/java/me/shedaniel/rei/fabric/RoughlyEnoughItemsInitializerImpl.java
@@ -0,0 +1,72 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.fabric;
+
+import com.google.common.collect.ImmutableSet;
+import me.shedaniel.rei.RoughlyEnoughItemsState;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.loader.api.FabricLoader;
+import net.fabricmc.loader.api.SemanticVersion;
+import net.fabricmc.loader.api.VersionParsingException;
+
+public class RoughlyEnoughItemsInitializerImpl {
+ public static boolean isClient() {
+ return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
+ }
+
+ public static void checkMods() {
+ ImmutableSet<String> requiredModules = isClient() ?
+ ImmutableSet.<String>builder()
+ .add("fabric-api-base")
+ .add("fabric-resource-loader-v0")
+ .add("fabric-networking-v0")
+ .add("fabric-lifecycle-events-v1")
+ .add("fabric-rendering-fluids-v1")
+ .build() :
+ ImmutableSet.<String>builder()
+ .add("fabric-api-base")
+ .add("fabric-resource-loader-v0")
+ .add("fabric-networking-v0")
+ .add("fabric-lifecycle-events-v1")
+ .build();
+ for (String module : requiredModules) {
+ boolean moduleLoaded = FabricLoader.getInstance().isModLoaded(module);
+ if (!moduleLoaded) {
+ RoughlyEnoughItemsState.error("Fabric API is not installed!", "https://www.curseforge.com/minecraft/mc-mods/fabric-api/files/all");
+ break;
+ }
+ }
+ if (isClient()) {
+ try {
+ if (!FabricLoader.getInstance().isModLoaded("cloth-config2")) {
+ RoughlyEnoughItemsState.error("Cloth Config is not installed!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all");
+ } else if (SemanticVersion.parse(FabricLoader.getInstance().getModContainer("cloth-config2").get().getMetadata().getVersion().getFriendlyString()).compareTo(SemanticVersion.parse("4.10.9")) < 0) {
+ RoughlyEnoughItemsState.error("Your Cloth Config version is too old!", "https://www.curseforge.com/minecraft/mc-mods/cloth-config/files/all");
+ }
+ } catch (VersionParsingException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}