From 0b281e58493ced6dcd9516905c9be8c9b464c158 Mon Sep 17 00:00:00 2001 From: comp500 Date: Mon, 10 Jun 2024 19:47:18 +0100 Subject: [PATCH] Initial port to 1.21 (builds, untested) --- build.gradle | 14 +++++++------- gradle.properties | 12 ++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- .../link/infra/indium/other/SpriteFinderCache.java | 8 ++++---- .../infra/indium/renderer/mesh/EncodingFormat.java | 3 +-- .../renderer/render/AbstractRenderContext.java | 14 ++++++-------- src/main/resources/fabric.mod.json | 2 +- src/main/resources/indium.mixins.json | 2 +- 8 files changed, 27 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index 1b13be5..3ed9804 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.1.+' + id 'fabric-loom' version '1.6.+' id 'maven-publish' id "com.github.breadmoirai.github-release" version "2.4.1" @@ -8,8 +8,8 @@ plugins { id "com.matthewprenger.cursegradle" version "1.4.0" } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 String getGitVersion(Project project) { if (grgit != null) { @@ -80,8 +80,8 @@ tasks.withType(JavaCompile).configureEach { // If Javadoc is generated, this must be specified in that task too. it.options.encoding = "UTF-8" - // Minecraft 1.18 upwards uses Java 17. - it.options.release = 17 + // Minecraft 1.20.5 upwards uses Java 21. + it.options.release = 21 } java { @@ -111,8 +111,8 @@ publishing { } // TODO: infer from fabric.mod.json?! -def supportedVersions = ["1.20.1", "1.20.3", "${project.minecraft_version}", "1.20.5", "1.20.6"] -def verName = "Indium ${project.mod_version} for Minecraft 1.20.x/Sodium ${project.sodium_version}" +def supportedVersions = ["${project.minecraft_version}"] +def verName = "Indium ${project.mod_version} for Minecraft 1.21.x/Sodium ${project.sodium_version}" // Check version is as expected if (System.getenv("EXPECTED_VERSION") !== null) { diff --git a/gradle.properties b/gradle.properties index 0a7e180..fa87880 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,18 +2,18 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.4 -yarn_mappings=1.20.4+build.3 -loader_version=0.15.3 +minecraft_version=1.21-rc1 +yarn_mappings=1.21-rc1+build.1 +loader_version=0.15.11 # Mod Properties -mod_version=1.0.31 +mod_version=1.0.30 maven_group=link.infra archives_base_name=indium # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.91.3+1.20.4 +fabric_version=0.100.0+1.21 sodium_version=0.5.8 -sodium_minecraft_version=1.20.4 +sodium_minecraft_version=1.20.5 # Publishing metadata curseforge_id=459496 source_url=https://github.com/comp500/Indium/ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb87..48c0a02 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/link/infra/indium/other/SpriteFinderCache.java b/src/main/java/link/infra/indium/other/SpriteFinderCache.java index 8ef4fc5..71e3d85 100644 --- a/src/main/java/link/infra/indium/other/SpriteFinderCache.java +++ b/src/main/java/link/infra/indium/other/SpriteFinderCache.java @@ -1,8 +1,5 @@ package link.infra.indium.other; -import java.util.Collection; -import java.util.List; - import net.fabricmc.fabric.api.renderer.v1.model.SpriteFinder; import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; @@ -12,6 +9,9 @@ import net.minecraft.screen.PlayerScreenHandler; import net.minecraft.util.Identifier; +import java.util.Collection; +import java.util.List; + /** * Cache SpriteFinders for maximum efficiency. * @@ -25,7 +25,7 @@ public static SpriteFinder forBlockAtlas() { } public static class ReloadListener implements SimpleSynchronousResourceReloadListener { - public static final Identifier ID = new Identifier("indium", "sprite_finder_cache"); + public static final Identifier ID = Identifier.of("indium", "sprite_finder_cache"); public static final List DEPENDENCIES = List.of(ResourceReloadListenerKeys.MODELS); public static final ReloadListener INSTANCE = new ReloadListener(); diff --git a/src/main/java/link/infra/indium/renderer/mesh/EncodingFormat.java b/src/main/java/link/infra/indium/renderer/mesh/EncodingFormat.java index 07625b7..255b440 100644 --- a/src/main/java/link/infra/indium/renderer/mesh/EncodingFormat.java +++ b/src/main/java/link/infra/indium/renderer/mesh/EncodingFormat.java @@ -17,7 +17,6 @@ package link.infra.indium.renderer.mesh; import com.google.common.base.Preconditions; - import link.infra.indium.renderer.helper.GeometryHelper; import link.infra.indium.renderer.material.RenderMaterialImpl; import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing; @@ -66,7 +65,7 @@ private EncodingFormat() { } VERTEX_V = VERTEX_U + 1; VERTEX_LIGHTMAP = HEADER_STRIDE + 6; VERTEX_NORMAL = HEADER_STRIDE + 7; - VERTEX_STRIDE = format.getVertexSizeInteger(); + VERTEX_STRIDE = format.getVertexSizeByte(); QUAD_STRIDE = VERTEX_STRIDE * 4; QUAD_STRIDE_BYTES = QUAD_STRIDE * 4; TOTAL_STRIDE = HEADER_STRIDE + QUAD_STRIDE; diff --git a/src/main/java/link/infra/indium/renderer/render/AbstractRenderContext.java b/src/main/java/link/infra/indium/renderer/render/AbstractRenderContext.java index ee083e7..770185b 100644 --- a/src/main/java/link/infra/indium/renderer/render/AbstractRenderContext.java +++ b/src/main/java/link/infra/indium/renderer/render/AbstractRenderContext.java @@ -16,13 +16,6 @@ package link.infra.indium.renderer.render; -import java.util.function.Consumer; - -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import org.joml.Vector3f; -import org.joml.Vector4f; - import it.unimi.dsi.fastutil.objects.ObjectArrayList; import link.infra.indium.other.SpriteFinderCache; import link.infra.indium.renderer.mesh.MutableQuadViewImpl; @@ -32,6 +25,12 @@ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.texture.Sprite; +import org.joml.Matrix3f; +import org.joml.Matrix4f; +import org.joml.Vector3f; +import org.joml.Vector4f; + +import java.util.function.Consumer; abstract class AbstractRenderContext implements RenderContext { private static final QuadTransform NO_TRANSFORM = q -> true; @@ -131,7 +130,6 @@ protected void bufferQuad(MutableQuadViewImpl quad, VertexConsumer vertexConsume } vertexConsumer.normal(normalVec.x(), normalVec.y(), normalVec.z()); - vertexConsumer.next(); } Sprite sprite = quad.cachedSprite(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 73d550c..475c926 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ ], "depends": { "fabricloader": ">=0.8.0", - "minecraft": "~1.20.1", + "minecraft": "~1.21.0", "sodium": "0.5.8", "fabric-renderer-api-v1": ">=3.2.0", "fabric-resource-loader-v0": ">=0.4.0" diff --git a/src/main/resources/indium.mixins.json b/src/main/resources/indium.mixins.json index 62a5a42..1e8c006 100644 --- a/src/main/resources/indium.mixins.json +++ b/src/main/resources/indium.mixins.json @@ -1,7 +1,7 @@ { "required": true, "package": "link.infra.indium.mixin", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", "client": [ "renderer.AccessAmbientOcclusionCalculator", "renderer.MixinBlockModelRenderer",