diff --git a/fabric/build.gradle b/fabric/build.gradle index 270ede33c..07598967c 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -72,19 +72,22 @@ dependencies { // runtimeOnly "javax.annotation:javax.annotation-api:1.3.2" // compileOnly "javax.annotation:javax.annotation-api:1.3.2" // modImplementation "javax.annotation:javax.annotation-api:1.3.2" - + // Fabric API addModJar(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) addModJar(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) - addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)) + if (buildVersionBefore(minecraft_version, "1.21.10")) + addModJar(fabricApi.module("fabric-resource-loader-v0", rootProject.fabric_api_version)) + else // > 1.21.10 + addModJar(fabricApi.module("fabric-resource-loader-v1", rootProject.fabric_api_version)) addModJar(fabricApi.module("fabric-events-interaction-v0", rootProject.fabric_api_version)) - addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) // TODO: Remove this as it is only needed in 1 line (FabricClientProxy) + addModJar(fabricApi.module("fabric-rendering-v1", rootProject.fabric_api_version)) addModJar(fabricApi.module("fabric-networking-api-v1", rootProject.fabric_api_version)) addModJar(fabricApi.module("fabric-entity-events-v1", rootProject.fabric_api_version)) - if (minecraft_version >= "1.19.2") - addModJar(fabricApi.module("fabric-command-api-v2", rootProject.fabric_api_version)) - else // < 1.19.2 + if (buildVersionBefore(minecraft_version, "1.19.2")) addModJar(fabricApi.module("fabric-command-api-v1", rootProject.fabric_api_version)) + else + addModJar(fabricApi.module("fabric-command-api-v2", rootProject.fabric_api_version)) // used by mod menu in MC 1.20.6+ addModJar(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) @@ -143,6 +146,40 @@ dependencies { } } +private static boolean buildVersionBefore(String minecraft_version, String compareVersion) +{ + int sortValue = sortSemanticVersionOldestToNewest(minecraft_version, compareVersion); + return sortValue == -1; +} +/** + * input format: "major.minor.patch" + * needed so we can sort versions with different length strings + * IE: 1.21.1 should come before 1.21.10 + */ +private static int sortSemanticVersionOldestToNewest(String version1, String version2) +{ + String[] parts1 = version1.split("\\."); + String[] parts2 = version2.split("\\."); + + int major1 = Integer.parseInt(parts1[0]); + int major2 = Integer.parseInt(parts2[0]); + if (major1 != major2) + { + return Integer.compare(major1, major2); + } + + int minor1 = Integer.parseInt(parts1[1]); + int minor2 = Integer.parseInt(parts2[1]); + if (minor1 != minor2) + { + return Integer.compare(minor1, minor2); + } + + int patch1 = Integer.parseInt(parts1[2]); + int patch2 = Integer.parseInt(parts2[2]); + return Integer.compare(patch1, patch2); +} + task deleteResources(type: Delete) { delete file("build/resources/main") diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java index fae958e27..483ba6dc0 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/FabricClientProxy.java @@ -290,7 +290,7 @@ public class FabricClientProxy implements AbstractModInitializer.IEventProxy #if MC_VER < MC_1_21_6 // rendered in MixinLevelRenderer #else - ClientApi.INSTANCE.renderDeferredLodsForShaders(ClientLevelWrapper.getWrapper(); + ClientApi.INSTANCE.renderDeferredLodsForShaders(); #endif this.clientApi.renderFadeTransparent(); diff --git a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java index 92f538ed5..7d117f97d 100644 --- a/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java +++ b/fabric/src/main/java/com/seibel/distanthorizons/fabric/mixins/client/MixinLevelRenderer.java @@ -30,6 +30,20 @@ import net.minecraft.client.renderer.RenderType; import com.mojang.blaze3d.vertex.PoseStack; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +#elif MC_VER < MC_1_21_10 +import com.mojang.blaze3d.buffers.GpuBufferSlice; +import com.mojang.blaze3d.framegraph.FrameGraphBuilder; +import com.mojang.blaze3d.resource.GraphicsResourceAllocator; +import net.minecraft.client.Camera; +import net.minecraft.client.DeltaTracker; +import net.minecraft.client.renderer.chunk.ChunkSectionsToRender; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.util.profiling.ProfilerFiller; +import org.joml.Matrix4f; +import org.joml.Matrix4fc; +import org.joml.Vector4f; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; #else import com.mojang.blaze3d.buffers.GpuBufferSlice; import com.mojang.blaze3d.framegraph.FrameGraphBuilder; @@ -164,7 +178,7 @@ public class MixinLevelRenderer - #if MC_VER < MC_1_21_6 + #if MC_VER < MC_1_21_10 // rendering handled via Fabric Api render event #else @Inject(at = @At("HEAD"), method = "prepareChunkRenders") diff --git a/versionProperties/1.21.10.properties b/versionProperties/1.21.10.properties index 239ae84be..02238be09 100644 --- a/versionProperties/1.21.10.properties +++ b/versionProperties/1.21.10.properties @@ -11,7 +11,7 @@ builds_for=fabric,neoforge netty_version=4.1.97.Final # Fabric loader -fabric_loader_version=0.17.2 +fabric_loader_version=0.17.3 fabric_api_version=0.135.0+1.21.10 modmenu_version=16.0.0-rc.1 starlight_version_fabric=