diff --git a/build.gradle b/build.gradle index 9d3e012b4..5617c8b4a 100644 --- a/build.gradle +++ b/build.gradle @@ -115,12 +115,25 @@ subprojects { p -> // Toml implementation("com.electronwill.night-config:toml:${rootProject.toml_version}") - if (p != project(":forge")) { + if (p != project(":forge") && p != project(":fabric")) { // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies // Do NOT use other classes from fabric loader unless working with fabric modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" } + if (p == project(":fabric")) { + // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies + // Do NOT use other classes from fabric loader unless working with fabric + if (rootProject.use_quilt_rather_than_fabric == "true") { + // Quilt loader + modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" + modImplementation "org.quiltmc:quilt-json5:1.0.0" // Needed for quilt loader but for some reason it dosnt come with it + } else { + // Fabric loader + modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + } + } + if (p != project(":core")) { common(project(":core")) { transitive false } shadowMe(project(":core")) { transitive false } @@ -180,6 +193,12 @@ allprojects { p -> } } + // Required for Quilt + maven { + name 'Quilt' + url 'https://maven.quiltmc.org/repository/release' + } + // These 2 are for importing mods that arnt on CursedForge, Modrinth, GitHub, GitLab or anywhere opensource flatDir { dirs "${rootDir}/mods/fabric" diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java index 941face86..883263d9b 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/minecraft/MinecraftClientWrapper.java @@ -59,6 +59,7 @@ import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LightLayer; import net.minecraft.world.level.dimension.DimensionType; import org.jetbrains.annotations.Nullable; @@ -326,6 +327,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper return mc.getCurrentServer() != null; } + @Override + public int getPlayerSkylight() { + if (mc.level == null) return -1; + if (mc.player == null) return -1; + if (mc.player.blockPosition() == null) return -1; + return mc.level.getBrightness(LightLayer.SKY, mc.player.blockPosition()); + } + public ServerData getCurrentServer() { return mc.getCurrentServer(); diff --git a/core b/core index 6ad6ecc73..83a2fa86d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 6ad6ecc7312275eeb11b48ae8d1a118e4a366de5 +Subproject commit 83a2fa86d9ee7a0146b748d7b93265a5c4770ff6 diff --git a/fabric/src/main/java/com/seibel/lod/fabric/Main.java b/fabric/src/main/java/com/seibel/lod/fabric/Main.java index 7a92a5d73..55c7659fd 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/Main.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/Main.java @@ -53,9 +53,11 @@ public class Main // Once it works on servers change the implement to ModInitializer and in fabric.mod.json it should be "environment": "*" public static ClientProxy client_proxy; + public static boolean isQuilt; // This loads the mod after minecraft loads which doesn't causes a lot of issues public static void init() { + scuffedQuiltChecker(); LodCommonMain.initConfig(); LodCommonMain.startup(null, false, new NetworkHandler()); FabricDependencySetup.createInitialBindings(); @@ -85,4 +87,13 @@ public class Main FabricDependencySetup.finishBinding(); ApiShared.LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); } + + public static void scuffedQuiltChecker() { + try { + Class.forName("org.quiltmc.loader.api.QuiltLoader"); + isQuilt = true; + } catch (ClassNotFoundException e) { + isQuilt = false; + } + } } diff --git a/fabric/src/main/java/com/seibel/lod/fabric/quilt/QuiltUtils.java b/fabric/src/main/java/com/seibel/lod/fabric/quilt/QuiltUtils.java new file mode 100644 index 000000000..e7380012d --- /dev/null +++ b/fabric/src/main/java/com/seibel/lod/fabric/quilt/QuiltUtils.java @@ -0,0 +1,14 @@ +package com.seibel.lod.fabric.quilt; + +/** + * Used to call classes that are in Quilt + * @author Ran + */ +public class QuiltUtils { + public static boolean isModLoaded(String modId) { + try { + return (boolean) Class.forName("org.quiltmc.loader.api.QuiltLoader").getDeclaredMethod("isModLoaded", String.class).invoke(null, modId); + } catch (Exception ignored) { } + return false; + } +} diff --git a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/ModChecker.java b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/ModChecker.java index 6540ebc38..461f57051 100644 --- a/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/ModChecker.java +++ b/fabric/src/main/java/com/seibel/lod/fabric/wrappers/modAccessor/ModChecker.java @@ -20,6 +20,8 @@ package com.seibel.lod.fabric.wrappers.modAccessor; import com.seibel.lod.core.wrapperInterfaces.modAccessor.IModChecker; +import com.seibel.lod.fabric.Main; +import com.seibel.lod.fabric.quilt.QuiltUtils; import net.fabricmc.loader.api.FabricLoader; public class ModChecker implements IModChecker { @@ -27,6 +29,10 @@ public class ModChecker implements IModChecker { @Override public boolean isModLoaded(String modid) { - return FabricLoader.getInstance().isModLoaded(modid); + if (Main.isQuilt) { + return QuiltUtils.isModLoaded(modid); + } else { + return FabricLoader.getInstance().isModLoaded(modid); + } } }