No need to get spicy

- Move common vanillin stuffs to a "vanillin" sourceset
- Add vanillinForge and vanillinFabric subprojects
- Mostly do gradling from scratch
- Export remap jars from platform projects to `include` in vanillin
  projects
This commit is contained in:
Jozufozu 2025-01-12 13:02:50 -08:00
parent b379be57ae
commit 6bea04ffee
25 changed files with 322 additions and 17 deletions

View file

@ -23,11 +23,11 @@ import org.gradle.language.jvm.tasks.ProcessResources
class JarTaskSet( class JarTaskSet(
private val project: Project, private val project: Project,
private val name: String, private val name: String,
private val jar: TaskProvider<Jar>, val jar: TaskProvider<Jar>,
private val sources: TaskProvider<Jar>, val sources: TaskProvider<Jar>,
private val javadocJar: TaskProvider<Jar>, val javadocJar: TaskProvider<Jar>,
private val remapJar: TaskProvider<RemapJarTask>, val remapJar: TaskProvider<RemapJarTask>,
private val remapSources: TaskProvider<RemapSourcesJarTask> val remapSources: TaskProvider<RemapSourcesJarTask>
) { ) {
fun publish(artifactId: String) { fun publish(artifactId: String) {

View file

@ -23,7 +23,7 @@ open class PlatformExtension(val project: Project) {
var apiArtifactId: String = "flywheel-${project.name}-api-${project.property("artifact_minecraft_version")}" var apiArtifactId: String = "flywheel-${project.name}-api-${project.property("artifact_minecraft_version")}"
private val commonSourceSets: SourceSetContainer by lazy { commonProject.the<SourceSetContainer>() } val commonSourceSets: SourceSetContainer by lazy { commonProject.the<SourceSetContainer>() }
fun setupLoomMod(vararg sourceSets: SourceSet) { fun setupLoomMod(vararg sourceSets: SourceSet) {
project.the<LoomGradleExtensionAPI>().mods.maybeCreate("main").apply { project.the<LoomGradleExtensionAPI>().mods.maybeCreate("main").apply {

View file

@ -181,5 +181,11 @@ val processResourcesExpandProperties = listOf(
"minecraft_maven_version_range", "minecraft_maven_version_range",
"fabric_api_version_range", "fabric_api_version_range",
"forge_version_range", "forge_version_range",
"vanillin_id",
"vanillin_name",
"vanillin_version",
"vanillin_description",
"flywheel_maven_version_range",
"flywheel_semver_version_range",
) )

View file

@ -11,6 +11,7 @@ val lib = sourceSets.create("lib")
val backend = sourceSets.create("backend") val backend = sourceSets.create("backend")
val stubs = sourceSets.create("stubs") val stubs = sourceSets.create("stubs")
val main = sourceSets.getByName("main") val main = sourceSets.getByName("main")
val vanillin = sourceSets.create("vanillin")
transitiveSourceSets { transitiveSourceSets {
compileClasspath = main.compileClasspath compileClasspath = main.compileClasspath
@ -35,10 +36,14 @@ transitiveSourceSets {
sourceSet(sourceSets.getByName("test")) { sourceSet(sourceSets.getByName("test")) {
implementation(api, lib, backend) implementation(api, lib, backend)
} }
sourceSet(vanillin) {
rootCompile()
compile(api, lib)
}
} }
defaultPackageInfos { defaultPackageInfos {
sources(api, lib, backend, main) sources(api, lib, backend, main, vanillin)
} }
jarSets { jarSets {
@ -48,6 +53,7 @@ jarSets {
outgoing("commonBackend", backend) outgoing("commonBackend", backend)
outgoing("commonStubs", stubs) outgoing("commonStubs", stubs)
outgoing("commonImpl", main) outgoing("commonImpl", main)
outgoing("commonVanillin", vanillin)
// For publishing. // For publishing.
create("api", api, lib).apply { create("api", api, lib).apply {

View file

@ -6,7 +6,6 @@ import org.slf4j.LoggerFactory;
import dev.engine_room.flywheel.api.Flywheel; import dev.engine_room.flywheel.api.Flywheel;
import dev.engine_room.flywheel.backend.FlwBackend; import dev.engine_room.flywheel.backend.FlwBackend;
import dev.engine_room.flywheel.impl.registry.IdRegistryImpl; import dev.engine_room.flywheel.impl.registry.IdRegistryImpl;
import dev.engine_room.flywheel.vanilla.VanillaVisuals;
public final class FlwImpl { public final class FlwImpl {
public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID); public static final Logger LOGGER = LoggerFactory.getLogger(Flywheel.ID);
@ -23,9 +22,6 @@ public final class FlwImpl {
// backend // backend
FlwBackend.init(FlwConfig.INSTANCE.backendConfig()); FlwBackend.init(FlwConfig.INSTANCE.backendConfig());
// vanilla
VanillaVisuals.init();
} }
public static void freezeRegistries() { public static void freezeRegistries() {

View file

@ -0,0 +1,5 @@
package dev.engine_room.vanillin;
public class Vanillin {
public static final String ID = "vanillin";
}

View file

@ -1,4 +1,4 @@
package dev.engine_room.flywheel.vanilla; package dev.engine_room.vanillin.visuals;
import java.util.function.Consumer; import java.util.function.Consumer;

View file

@ -1,4 +1,4 @@
package dev.engine_room.flywheel.vanilla; package dev.engine_room.vanillin.visuals;
import java.util.Calendar; import java.util.Calendar;
import java.util.EnumMap; import java.util.EnumMap;

View file

@ -1,4 +1,4 @@
package dev.engine_room.flywheel.vanilla; package dev.engine_room.vanillin.visuals;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f; import org.joml.Matrix4f;

View file

@ -1,4 +1,4 @@
package dev.engine_room.flywheel.vanilla; package dev.engine_room.vanillin.visuals;
import java.util.Set; import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;

View file

@ -1,4 +1,4 @@
package dev.engine_room.flywheel.vanilla; package dev.engine_room.vanillin.visuals;
import org.joml.Matrix4f; import org.joml.Matrix4f;

View file

@ -1,4 +1,4 @@
package dev.engine_room.flywheel.vanilla; package dev.engine_room.vanillin.visuals;
import static dev.engine_room.flywheel.lib.visualization.SimpleBlockEntityVisualizer.builder; import static dev.engine_room.flywheel.lib.visualization.SimpleBlockEntityVisualizer.builder;
import static dev.engine_room.flywheel.lib.visualization.SimpleEntityVisualizer.builder; import static dev.engine_room.flywheel.lib.visualization.SimpleEntityVisualizer.builder;

View file

@ -66,6 +66,13 @@ jarSets {
} }
} }
val config = project.configurations.register("flywheelFabric") {
isCanBeConsumed = true
isCanBeResolved = false
}
project.artifacts.add(config.name, jarSets.mainSet.remapJar)
defaultPackageInfos { defaultPackageInfos {
sources(api, lib, backend, main) sources(api, lib, backend, main)
} }

View file

@ -64,6 +64,13 @@ jarSets {
} }
} }
val config = project.configurations.register("flywheelForge") {
isCanBeConsumed = true
isCanBeResolved = false
}
project.artifacts.add(config.name, jarSets.mainSet.remapJar)
defaultPackageInfos { defaultPackageInfos {
sources(api, lib, backend, main) sources(api, lib, backend, main)
} }

View file

@ -10,6 +10,12 @@ mod_license = MIT
mod_sources = https://github.com/Engine-Room/Flywheel mod_sources = https://github.com/Engine-Room/Flywheel
mod_issues = https://github.com/Engine-Room/Flywheel/issues mod_issues = https://github.com/Engine-Room/Flywheel/issues
mod_homepage = https://github.com/Engine-Room/Flywheel mod_homepage = https://github.com/Engine-Room/Flywheel
vanillin_id=vanillin
vanillin_name=Vanillin
vanillin_version=1.0.0-beta
vanillin_description=Instanced rendering for entities and block entities via Flywheel.
flywheel_maven_version_range=[1.0.0-beta,2.0)
flywheel_semver_version_range=>=1.0.0-beta <2.0.0
# Mod dependency declarations # Mod dependency declarations
minecraft_semver_version_range = >=1.20.1 <1.20.2 minecraft_semver_version_range = >=1.20.1 <1.20.2

View file

@ -18,3 +18,5 @@ rootProject.name = "Flywheel"
include("common") include("common")
include("fabric") include("fabric")
include("forge") include("forge")
include("vanillinForge")
include("vanillinFabric")

View file

@ -0,0 +1,75 @@
import dev.engine_room.gradle.jarset.JarTaskSet
import org.gradle.jvm.tasks.Jar
plugins {
idea
java
`maven-publish`
id("dev.architectury.loom")
id("flywheel.subproject")
id("flywheel.platform")
}
group = "dev.engine_room.vanillin"
val main = sourceSets.getByName("main")
platform {
modArtifactId = "vanillin-fabric-${project.property("artifact_minecraft_version")}"
commonProject = project(":common")
setupLoomRuns()
}
listOf("api", "lib")
.map { project(":fabric").sourceSets.named(it).get() }
.forEach { main.compileClasspath += it.output }
val commonSourceSet = platform.commonSourceSets.named("vanillin").get()
tasks.named<Javadoc>("javadoc").configure {
source(commonSourceSet.allJava)
JarTaskSet.excludeDuplicatePackageInfos(this)
}
tasks.named<Jar>("sourcesJar").configure {
from(commonSourceSet.allJava)
JarTaskSet.excludeDuplicatePackageInfos(this)
}
tasks.withType<JavaCompile>().configureEach {
JarTaskSet.excludeDuplicatePackageInfos(this)
}
tasks.named<JavaCompile>(main.compileJavaTaskName).configure {
source(commonSourceSet.allJava)
}
tasks.named<ProcessResources>(main.processResourcesTaskName).configure {
from(commonSourceSet.resources)
}
jarSets {
mainSet.publish(platform.modArtifactId)
}
defaultPackageInfos {
sources(main)
}
loom {
mixin {
useLegacyMixinAp = true
add(main, "vanillin.refmap.json")
}
}
dependencies {
modImplementation("net.fabricmc:fabric-loader:${property("fabric_loader_version")}")
modApi("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}")
modCompileOnly("maven.modrinth:sodium:${property("sodium_version")}")
compileOnly(project(path = ":common", configuration = "commonVanillin"))
include(project(path = ":fabric", configuration = "flywheelFabric"))
modRuntimeOnly(project(path = ":fabric", configuration = "flywheelFabric"))
}

View file

@ -0,0 +1 @@
loom.platform=fabric

View file

@ -0,0 +1,11 @@
package dev.engine_room.vanillin;
import dev.engine_room.vanillin.visuals.VanillaVisuals;
import net.fabricmc.api.ClientModInitializer;
public class VanillinFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
VanillaVisuals.init();
}
}

View file

@ -0,0 +1,34 @@
{
"schemaVersion" : 1,
"id" : "${vanillin_id}",
"version" : "${vanillin_version}",
"name" : "${vanillin_name}",
"description" : "${vanillin_description}",
"authors" : [
"Jozufozu",
"PepperCode1"
],
"contact" : {
"homepage" : "${mod_homepage}",
"sources" : "${mod_sources}",
"issues" : "${mod_issues}"
},
"license" : "${mod_license}",
"icon" : "logo.png",
"environment" : "client",
"entrypoints" : {
"client" : [
"dev.engine_room.vanillin.VanillinFabric"
]
},
"mixins" : [
],
"depends" : {
"minecraft" : "${minecraft_semver_version_range}",
"fabricloader" : ">=0.15.0",
"fabric-api" : "${fabric_api_version_range}",
"${mod_id}" : "${flywheel_semver_version_range}"
},
"breaks" : {
}
}

View file

@ -0,0 +1,86 @@
import dev.engine_room.gradle.jarset.JarTaskSet
import org.gradle.jvm.tasks.Jar
plugins {
idea
java
`maven-publish`
id("dev.architectury.loom")
id("flywheel.subproject")
id("flywheel.platform")
}
group = "dev.engine_room.vanillin"
val main = sourceSets.getByName("main")
platform {
modArtifactId = "vanillin-forge-${project.property("artifact_minecraft_version")}"
commonProject = project(":common")
setupLoomRuns()
}
listOf("api", "lib")
.map { project(":forge").sourceSets.named(it).get() }
.forEach { main.compileClasspath += it.output }
val commonSourceSet = platform.commonSourceSets.named("vanillin").get()
tasks.named<Javadoc>("javadoc").configure {
source(commonSourceSet.allJava)
JarTaskSet.excludeDuplicatePackageInfos(this)
}
tasks.named<Jar>("sourcesJar").configure {
from(commonSourceSet.allJava)
JarTaskSet.excludeDuplicatePackageInfos(this)
}
tasks.withType<JavaCompile>().configureEach {
JarTaskSet.excludeDuplicatePackageInfos(this)
}
tasks.named<JavaCompile>(main.compileJavaTaskName).configure {
source(commonSourceSet.allJava)
}
tasks.named<ProcessResources>(main.processResourcesTaskName).configure {
from(commonSourceSet.resources)
}
jarSets {
mainSet.publish(platform.modArtifactId)
}
defaultPackageInfos {
sources(main)
}
loom {
mixin {
useLegacyMixinAp = true
add(main, "vanillin.refmap.json")
}
forge {
// mixinConfig("flywheel.backend.mixins.json")
// mixinConfig("flywheel.impl.mixins.json")
}
runs {
configureEach {
property("forge.logging.markers", "")
property("forge.logging.console.level", "debug")
}
}
}
dependencies {
forge("net.minecraftforge:forge:${property("minecraft_version")}-${property("forge_version")}")
modCompileOnly("maven.modrinth:embeddium:${property("embeddium_version")}")
compileOnly(project(path = ":common", configuration = "commonVanillin"))
include(project(path = ":forge", configuration = "flywheelForge"))
modRuntimeOnly(project(path = ":forge", configuration = "flywheelForge"))
}

View file

@ -0,0 +1 @@
loom.platform=forge

View file

@ -0,0 +1,23 @@
package dev.engine_room.vanillin;
import dev.engine_room.vanillin.visuals.VanillaVisuals;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Mod(Vanillin.ID)
public class VanillinForge {
public VanillinForge() {
IEventBus forgeEventBus = MinecraftForge.EVENT_BUS;
IEventBus modEventBus = FMLJavaModLoadingContext.get()
.getModEventBus();
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> clientInit(forgeEventBus, modEventBus));
}
private static void clientInit(IEventBus forgeEventBus, IEventBus modEventBus) {
VanillaVisuals.init();
}
}

View file

@ -0,0 +1,33 @@
modLoader = "javafml"
# The loader version doesn't matter. Modify the Forge and/or Minecraft version ranges instead.
loaderVersion = "[0,)"
license = "${mod_license}"
issueTrackerURL = "${mod_issues}"
[[mods]]
modId = "${vanillin_id}"
version = "${vanillin_version}"
displayName = "${vanillin_name}"
description = "${vanillin_description}"
logoFile = "logo.png"
authors = "Jozufozu, PepperCode1"
displayURL = "${mod_homepage}"
displayTest = "IGNORE_ALL_VERSION"
[[dependencies.${ vanillin_id }]]
modId = "minecraft"
mandatory = true
versionRange = "${minecraft_maven_version_range}"
side = "CLIENT"
[[dependencies.${ vanillin_id }]]
modId = "forge"
mandatory = true
versionRange = "${forge_version_range}"
side = "CLIENT"
[[dependencies.${ vanillin_id }]]
modId = "${mod_id}"
mandatory = true
versionRange = "${flywheel_maven_version_range}"
side = "CLIENT"

View file

@ -0,0 +1,6 @@
{
"pack": {
"description": "${mod_name} resources",
"pack_format": 15
}
}