From 99d976fb59442af4fbddcd170f306a21b475d946 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sat, 18 Jan 2025 14:36:56 -0600 Subject: [PATCH 1/4] Uncharted: At wit's end - Need to publish un-remapped sources for forge/mojmap based projects --- .../dev/engine_room/gradle/jarset/JarTaskSet.kt | 12 ++++++++++-- common/build.gradle.kts | 4 ++-- fabric/build.gradle.kts | 4 ++-- forge/build.gradle.kts | 4 ++-- vanillinFabric/build.gradle.kts | 2 +- vanillinForge/build.gradle.kts | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt index da7fa4e1b..69cf75170 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt @@ -30,11 +30,19 @@ class JarTaskSet( val remapSources: TaskProvider ) { - fun publish(artifactId: String) { + fun publishWithRawSources(artifactId: String) { + publish(artifactId, sources) + } + + fun publishWithRemappedSources(artifactId: String) { + publish(artifactId, remapSources) + } + + private fun publish(artifactId: String, sourceJar: TaskProvider) { project.the().publications { register("${name}RemapMaven") { artifact(remapJar) - artifact(remapSources) + artifact(sourceJar) artifact(javadocJar) this.artifactId = artifactId } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 4efe08229..f90803543 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -58,7 +58,7 @@ jarSets { // For publishing. create("api", api, lib).apply { addToAssemble() - publish("flywheel-common-intermediary-api-${property("artifact_minecraft_version")}") + publishWithRemappedSources("flywheel-common-intermediary-api-${property("artifact_minecraft_version")}") configureJar { manifest { @@ -75,7 +75,7 @@ jarSets { targetNamespace = "named" } - publish("flywheel-common-mojmap-api-${property("artifact_minecraft_version")}") + publishWithRawSources("flywheel-common-mojmap-api-${property("artifact_minecraft_version")}") } } } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index e9edf9108..20fd36821 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -67,12 +67,12 @@ platform { } jarSets { - mainSet.publish("flywheel-fabric-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRemappedSources("flywheel-fabric-${project.property("artifact_minecraft_version")}") mainSet.outgoing("flywheel") create("api", api, lib).apply { addToAssemble() - publish("flywheel-fabric-api-${project.property("artifact_minecraft_version")}") + publishWithRemappedSources("flywheel-fabric-api-${project.property("artifact_minecraft_version")}") configureJar { manifest { diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index fdd825e1e..fe113bfa3 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -65,12 +65,12 @@ platform { } jarSets { - mainSet.publish("flywheel-forge-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRawSources("flywheel-forge-${project.property("artifact_minecraft_version")}") mainSet.outgoing("flywheel") create("api", api, lib).apply { addToAssemble() - publish("flywheel-forge-api-${project.property("artifact_minecraft_version")}") + publishWithRawSources("flywheel-forge-api-${project.property("artifact_minecraft_version")}") configureJar { manifest { diff --git a/vanillinFabric/build.gradle.kts b/vanillinFabric/build.gradle.kts index 455da11d1..2e036033b 100644 --- a/vanillinFabric/build.gradle.kts +++ b/vanillinFabric/build.gradle.kts @@ -27,7 +27,7 @@ transitiveSourceSets { } jarSets { - mainSet.publish("vanillin-fabric-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRemappedSources("vanillin-fabric-${project.property("artifact_minecraft_version")}") } defaultPackageInfos { diff --git a/vanillinForge/build.gradle.kts b/vanillinForge/build.gradle.kts index b7f1a8170..4941a5106 100644 --- a/vanillinForge/build.gradle.kts +++ b/vanillinForge/build.gradle.kts @@ -27,7 +27,7 @@ transitiveSourceSets { } jarSets { - mainSet.publish("vanillin-forge-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRawSources("vanillin-forge-${project.property("artifact_minecraft_version")}") } defaultPackageInfos { From 10d3923bf558c902199d9cbb4f34f3cc6376d9f2 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sat, 18 Jan 2025 15:00:33 -0600 Subject: [PATCH 2/4] Tragedy of the commons - Publish common vanillin artifacts - Extend JarTaskSet publish to accept an action --- .../engine_room/gradle/jarset/JarTaskSet.kt | 26 +++++++------ common/build.gradle.kts | 37 ++++++++++++++++++- fabric/build.gradle.kts | 8 +++- forge/build.gradle.kts | 8 +++- vanillinFabric/build.gradle.kts | 4 +- vanillinForge/build.gradle.kts | 9 ++--- 6 files changed, 67 insertions(+), 25 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt b/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt index 69cf75170..c2a079da1 100644 --- a/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt +++ b/buildSrc/src/main/kotlin/dev/engine_room/gradle/jarset/JarTaskSet.kt @@ -4,6 +4,7 @@ import net.fabricmc.loom.task.AbstractRemapJarTask import net.fabricmc.loom.task.RemapJarTask import net.fabricmc.loom.task.RemapSourcesJarTask import org.gradle.api.Action +import org.gradle.api.NamedDomainObjectProvider import org.gradle.api.Project import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.publish.PublishingExtension @@ -30,22 +31,23 @@ class JarTaskSet( val remapSources: TaskProvider ) { - fun publishWithRawSources(artifactId: String) { - publish(artifactId, sources) + fun publishWithRawSources(action: Action): NamedDomainObjectProvider { + return publish(sources, action) } - fun publishWithRemappedSources(artifactId: String) { - publish(artifactId, remapSources) + fun publishWithRemappedSources(action: Action): NamedDomainObjectProvider { + return publish(remapSources, action) } - private fun publish(artifactId: String, sourceJar: TaskProvider) { - project.the().publications { - register("${name}RemapMaven") { - artifact(remapJar) - artifact(sourceJar) - artifact(javadocJar) - this.artifactId = artifactId - } + private fun publish( + sourceJar: TaskProvider, + action: Action + ): NamedDomainObjectProvider { + return project.the().publications.register("${name}RemapMaven") { + artifact(remapJar) + artifact(sourceJar) + artifact(javadocJar) + action.execute(this) } } diff --git a/common/build.gradle.kts b/common/build.gradle.kts index f90803543..e0baa3e4c 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -58,7 +58,9 @@ jarSets { // For publishing. create("api", api, lib).apply { addToAssemble() - publishWithRemappedSources("flywheel-common-intermediary-api-${property("artifact_minecraft_version")}") + publishWithRemappedSources { + artifactId = "flywheel-common-intermediary-api-${property("artifact_minecraft_version")}" + } configureJar { manifest { @@ -75,7 +77,38 @@ jarSets { targetNamespace = "named" } - publishWithRawSources("flywheel-common-mojmap-api-${property("artifact_minecraft_version")}") + publishWithRawSources { + artifactId = "flywheel-common-mojmap-api-${property("artifact_minecraft_version")}" + } + } + } + + create("vanillin", vanillin).apply { + addToAssemble() + publishWithRemappedSources { + artifactId = "vanillin-common-intermediary-${property("artifact_minecraft_version")}" + groupId = property("vanillin_group") as String + } + + configureJar { + manifest { + attributes("Fabric-Loom-Remap" to "true") + } + } + + // Don't publish the un-remapped jars because they don't have the correct manifest populated by Loom. + forkRemap("vanillinMojmap").apply { + addToAssemble() + configureRemap { + // "named" == mojmap + // We're probably remapping from named to named so Loom should noop this. + targetNamespace = "named" + } + + publishWithRawSources { + artifactId = "vanillin-common-mojmap-${property("artifact_minecraft_version")}" + groupId = property("vanillin_group") as String + } } } } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 20fd36821..e3a02f98d 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -67,12 +67,16 @@ platform { } jarSets { - mainSet.publishWithRemappedSources("flywheel-fabric-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRemappedSources { + artifactId = "flywheel-fabric-${project.property("artifact_minecraft_version")}" + } mainSet.outgoing("flywheel") create("api", api, lib).apply { addToAssemble() - publishWithRemappedSources("flywheel-fabric-api-${project.property("artifact_minecraft_version")}") + publishWithRemappedSources { + artifactId = "flywheel-fabric-api-${project.property("artifact_minecraft_version")}" + } configureJar { manifest { diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index fe113bfa3..694d7fd08 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -65,12 +65,16 @@ platform { } jarSets { - mainSet.publishWithRawSources("flywheel-forge-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRawSources { + artifactId = "flywheel-forge-${project.property("artifact_minecraft_version")}" + } mainSet.outgoing("flywheel") create("api", api, lib).apply { addToAssemble() - publishWithRawSources("flywheel-forge-api-${project.property("artifact_minecraft_version")}") + publishWithRawSources { + artifactId = "flywheel-forge-api-${project.property("artifact_minecraft_version")}" + } configureJar { manifest { diff --git a/vanillinFabric/build.gradle.kts b/vanillinFabric/build.gradle.kts index 2e036033b..3b2c08647 100644 --- a/vanillinFabric/build.gradle.kts +++ b/vanillinFabric/build.gradle.kts @@ -27,7 +27,9 @@ transitiveSourceSets { } jarSets { - mainSet.publishWithRemappedSources("vanillin-fabric-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRemappedSources { + artifactId = "vanillin-fabric-${project.property("artifact_minecraft_version")}" + } } defaultPackageInfos { diff --git a/vanillinForge/build.gradle.kts b/vanillinForge/build.gradle.kts index 4941a5106..12df3ba6a 100644 --- a/vanillinForge/build.gradle.kts +++ b/vanillinForge/build.gradle.kts @@ -27,7 +27,9 @@ transitiveSourceSets { } jarSets { - mainSet.publishWithRawSources("vanillin-forge-${project.property("artifact_minecraft_version")}") + mainSet.publishWithRawSources { + artifactId = "vanillin-forge-${project.property("artifact_minecraft_version")}" + } } defaultPackageInfos { @@ -40,11 +42,6 @@ loom { add(main, "vanillin.refmap.json") } - forge { -// mixinConfig("flywheel.backend.mixins.json") -// mixinConfig("flywheel.impl.mixins.json") - } - runs { configureEach { property("forge.logging.markers", "") From 809a0eb61647bf79e7cb3d6fc6d67a52dc68cf8c Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sun, 19 Jan 2025 11:25:21 -0600 Subject: [PATCH 3/4] Get JOML'd - Add more rotate methods to Affine and Rotate - Add optimized implementations in TransformedInstance --- .../lib/instance/TransformedInstance.java | 84 +++++++++++++++++-- .../flywheel/lib/transform/Affine.java | 65 ++++++++++++-- .../flywheel/lib/transform/Rotate.java | 57 ++++++------- 3 files changed, 161 insertions(+), 45 deletions(-) diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/TransformedInstance.java b/common/src/lib/java/dev/engine_room/flywheel/lib/instance/TransformedInstance.java index 8bab28975..ffab518eb 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/TransformedInstance.java +++ b/common/src/lib/java/dev/engine_room/flywheel/lib/instance/TransformedInstance.java @@ -1,5 +1,6 @@ package dev.engine_room.flywheel.lib.instance; +import org.joml.AxisAngle4f; import org.joml.Matrix4f; import org.joml.Matrix4fc; import org.joml.Quaternionfc; @@ -9,6 +10,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import dev.engine_room.flywheel.api.instance.InstanceHandle; import dev.engine_room.flywheel.api.instance.InstanceType; import dev.engine_room.flywheel.lib.transform.Affine; +import net.minecraft.core.Direction; public class TransformedInstance extends ColoredLitInstance implements Affine { public final Matrix4f pose = new Matrix4f(); @@ -17,12 +19,6 @@ public class TransformedInstance extends ColoredLitInstance implements Affine> extends Translate, Rotate, Scale { default Self rotateAround(Quaternionfc quaternion, float x, float y, float z) { @@ -15,19 +16,18 @@ public interface Affine> extends Translate, Rota } default Self rotateAround(Quaternionfc quaternion, Vector3fc vec) { - return translate(vec.x(), vec.y(), vec.z()).rotate(quaternion) - .translateBack(vec.x(), vec.y(), vec.z()); + return rotateAround(quaternion, vec.x(), vec.y(), vec.z()); } default Self rotateCentered(Quaternionfc q) { return rotateAround(q, CENTER, CENTER, CENTER); } - default Self rotateCentered(float radians, Vector3fc axis) { + default Self rotateCentered(float radians, float axisX, float axisY, float axisZ) { if (radians == 0) { return self(); } - return rotateCentered(new Quaternionf().setAngleAxis(radians, axis.x(), axis.y(), axis.z())); + return rotateCentered(new Quaternionf().setAngleAxis(radians, axisX, axisY, axisZ)); } default Self rotateCentered(float radians, Axis axis) { @@ -37,10 +37,59 @@ public interface Affine> extends Translate, Rota return rotateCentered(axis.rotation(radians)); } + default Self rotateCentered(float radians, Vector3fc axis) { + return rotateCentered(radians, axis.x(), axis.y(), axis.z()); + } + + default Self rotateCentered(float radians, Direction.Axis axis) { + return rotateCentered(radians, Direction.fromAxisAndDirection(axis, Direction.AxisDirection.POSITIVE)); + } + default Self rotateCentered(float radians, Direction axis) { - if (radians == 0) { - return self(); - } - return rotateCentered(radians, axis.step()); + return rotateCentered(radians, axis.getStepX(), axis.getStepY(), axis.getStepZ()); + } + + default Self rotateCenteredDegrees(float degrees, float axisX, float axisY, float axisZ) { + return rotateCentered(Mth.DEG_TO_RAD * degrees, axisX, axisY, axisZ); + } + + default Self rotateCenteredDegrees(float degrees, Axis axis) { + return rotateCentered(Mth.DEG_TO_RAD * degrees, axis); + } + + default Self rotateCenteredDegrees(float degrees, Vector3fc axis) { + return rotateCentered(Mth.DEG_TO_RAD * degrees, axis); + } + + default Self rotateCenteredDegrees(float degrees, Direction axis) { + return rotateCentered(Mth.DEG_TO_RAD * degrees, axis); + } + + default Self rotateCenteredDegrees(float degrees, Direction.Axis axis) { + return rotateCentered(Mth.DEG_TO_RAD * degrees, axis); + } + + default Self rotateXCentered(float radians) { + return rotateCentered(radians, Axis.XP); + } + + default Self rotateYCentered(float radians) { + return rotateCentered(radians, Axis.YP); + } + + default Self rotateZCentered(float radians) { + return rotateCentered(radians, Axis.ZP); + } + + default Self rotateXCenteredDegrees(float degrees) { + return rotateXCentered(Mth.DEG_TO_RAD * degrees); + } + + default Self rotateYCenteredDegrees(float degrees) { + return rotateYCentered(Mth.DEG_TO_RAD * degrees); + } + + default Self rotateZCenteredDegrees(float degrees) { + return rotateZCentered(Mth.DEG_TO_RAD * degrees); } } diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/transform/Rotate.java b/common/src/lib/java/dev/engine_room/flywheel/lib/transform/Rotate.java index 8684abd46..56b8b7f6e 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/transform/Rotate.java +++ b/common/src/lib/java/dev/engine_room/flywheel/lib/transform/Rotate.java @@ -8,6 +8,7 @@ import org.joml.Vector3fc; import com.mojang.math.Axis; import net.minecraft.core.Direction; +import net.minecraft.util.Mth; public interface Rotate> { Self rotate(Quaternionfc quaternion); @@ -16,11 +17,12 @@ public interface Rotate> { return rotate(new Quaternionf(axisAngle)); } - default Self rotate(float radians, Vector3fc axis) { + default Self rotate(float radians, float axisX, float axisY, float axisZ) { if (radians == 0) { return self(); } - return rotate(new Quaternionf().setAngleAxis(radians, axis.x(), axis.y(), axis.z())); + return rotate(new Quaternionf().setAngleAxis(radians, axisX, axisY, axisZ)); + } default Self rotate(float radians, Axis axis) { @@ -30,47 +32,36 @@ public interface Rotate> { return rotate(axis.rotation(radians)); } + default Self rotate(float radians, Vector3fc axis) { + return rotate(radians, axis.x(), axis.y(), axis.z()); + } + default Self rotate(float radians, Direction axis) { - if (radians == 0) { - return self(); - } - return rotate(radians, axis.step()); + return rotate(radians, axis.getStepX(), axis.getStepY(), axis.getStepZ()); } default Self rotate(float radians, Direction.Axis axis) { - return switch (axis) { - case X -> rotateX(radians); - case Y -> rotateY(radians); - case Z -> rotateZ(radians); - }; + return rotate(radians, Direction.fromAxisAndDirection(axis, Direction.AxisDirection.POSITIVE)); } - default Self rotateDegrees(float degrees, Vector3fc axis) { - if (degrees == 0) { - return self(); - } - return rotate((float) Math.toRadians(degrees), axis); + default Self rotateDegrees(float degrees, float axisX, float axisY, float axisZ) { + return rotate(Mth.DEG_TO_RAD * degrees, axisX, axisY, axisZ); } default Self rotateDegrees(float degrees, Axis axis) { - if (degrees == 0) { - return self(); - } - return rotate(axis.rotationDegrees(degrees)); + return rotate(Mth.DEG_TO_RAD * degrees, axis); + } + + default Self rotateDegrees(float degrees, Vector3fc axis) { + return rotate(Mth.DEG_TO_RAD * degrees, axis); } default Self rotateDegrees(float degrees, Direction axis) { - if (degrees == 0) { - return self(); - } - return rotate((float) Math.toRadians(degrees), axis); + return rotate(Mth.DEG_TO_RAD * degrees, axis); } default Self rotateDegrees(float degrees, Direction.Axis axis) { - if (degrees == 0) { - return self(); - } - return rotate((float) Math.toRadians(degrees), axis); + return rotate(Mth.DEG_TO_RAD * degrees, axis); } default Self rotateX(float radians) { @@ -86,15 +77,15 @@ public interface Rotate> { } default Self rotateXDegrees(float degrees) { - return rotateDegrees(degrees, Axis.XP); + return rotateX(Mth.DEG_TO_RAD * degrees); } default Self rotateYDegrees(float degrees) { - return rotateDegrees(degrees, Axis.YP); + return rotateY(Mth.DEG_TO_RAD * degrees); } default Self rotateZDegrees(float degrees) { - return rotateDegrees(degrees, Axis.ZP); + return rotateZ(Mth.DEG_TO_RAD * degrees); } default Self rotateToFace(Direction facing) { @@ -108,6 +99,10 @@ public interface Rotate> { }; } + default Self rotateTo(Vector3fc from, Vector3fc to) { + return rotate(new Quaternionf().rotateTo(from, to)); + } + @SuppressWarnings("unchecked") default Self self() { return (Self) this; From 5472f1a8f9a9a8a0e22384585ec4fb13b0300753 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Tue, 21 Jan 2025 17:23:56 -0600 Subject: [PATCH 4/4] Add foojay resolver --- settings.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/settings.gradle.kts b/settings.gradle.kts index 3f8bd243d..8fe063530 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,6 +13,10 @@ pluginManagement { } } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version("0.9.0") +} + rootProject.name = "Flywheel" include("common")