Skip to content

Commit

Permalink
First port to MC 21
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Jun 14, 2024
1 parent 3d81108 commit 21174d2
Show file tree
Hide file tree
Showing 85 changed files with 318 additions and 483 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("org.jetbrains.gradle.plugin.idea-ext") version ("1.1.7")

// alias(neoforged.plugins.common)
alias(neoforged.plugins.userdev).apply(false)
alias(neoforged.plugins.moddev).apply(false)
}

subprojects {
Expand Down
6 changes: 3 additions & 3 deletions core-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ val versionMain: String = System.getenv("VERSION") ?: "0.0.0"
plugins {
id("java-library")
id("maven-publish")
alias(neoforged.plugins.userdev)
alias(neoforged.plugins.moddev)
}

sourceSets {
Expand All @@ -29,8 +29,8 @@ java {
withJavadocJar()
}

dependencies {
api(neoforged.neoforge)
neoForge {
version = neoforged.versions.neoforge
}

tasks.withType<JavaCompile> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package dev.compactmods.machines.api;

import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.registries.DeferredRegister;

public interface CompactMachinesApi {
String MOD_ID = "compactmachines";

static ResourceLocation modRL(String path) {
return new ResourceLocation(MOD_ID, path);
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
}
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ minecraft_version_range=[1.20.6]
neo_version_range=[20.6,20.7)
loader_version_range=[1,)

org.gradle.configuration-cache=true

neogradle.subsystems.conventions.runs.enabled=false
neogradle.subsystems.conventions.runs.create-default-run-per-type=false

Expand Down
64 changes: 18 additions & 46 deletions neoforge-datagen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,49 @@ plugins {
id("eclipse")
id("idea")
id("maven-publish")
alias(neoforged.plugins.userdev)
alias(neoforged.plugins.moddev)
}

val mod_id: String by extra
val modId: String = rootProject.property("mod_id") as String
val mainProject: Project = project(":neoforge-main")
evaluationDependsOn(mainProject.path)

val coreApi = project(":core-api")
val roomApi = project(":room-api")

val coreProjects = listOf(coreApi, roomApi)

coreProjects.forEach {
project.evaluationDependsOn(it.path)
}

base {
group = "dev.compactmods.compactmachines"
archivesName.set(mod_id)
}
project.evaluationDependsOn(coreApi.path)

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

minecraft {
modIdentifier.set(mod_id)
}

runs {
// applies to all the run configs below
configureEach {
systemProperty("forge.logging.markers", "") // 'SCAN,REGISTRIES,REGISTRYDUMP'

// Recommended logging level for the console
systemProperty("forge.logging.console.level", "debug")
neoForge {
version = neoforged.versions.neoforge

modSource(project.sourceSets.main.get())
modSource(mainProject.sourceSets.main.get())

coreProjects.forEach { modSource(it.sourceSets.main.get()) }
this.mods.create(modId) {
modSourceSets.add(sourceSets.main)
this.dependency(coreApi)
this.dependency(mainProject)
}

create("data") {
dataGenerator(true)
this.runs {
create("data") {
data()

programArguments("--mod", "compactmachines")
programArguments("--all")
programArguments("--output", mainProject.file("src/generated/resources").absolutePath)
programArguments("--existing", mainProject.file("src/main/resources").absolutePath)
programArguments.addAll("--mod", modId)
programArguments.addAll("--all")
programArguments.addAll("--output", mainProject.file("src/generated/resources").absolutePath)
programArguments.addAll("--existing", mainProject.file("src/main/resources").absolutePath)
}
}
}

repositories {
mavenLocal()

maven("https://maven.pkg.github.com/compactmods/compactmachines-core") {
name = "Github PKG Core"
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.token") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
implementation(neoforged.neoforge)
compileOnly(coreApi)
compileOnly(mainProject)
coreProjects.forEach {
compileOnly(it)
}
}

tasks.compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ protected void addTranslations() {
// add(MachineRoomUpgrades.WORKBENCH_BLOCK.get(), "Workbench");
add("entity.minecraft.villager.compactmachines.tinkerer", "Spatial Tinkerer");

add(RoomExitKeyMapping.CATEGORY, "Compact Machines");
add(RoomExitKeyMapping.NAME, "Quick-Exit Compact Machine");
add(RoomExitKeyMapping.I18n.CATEGORY, "Compact Machines");
add(RoomExitKeyMapping.I18n.NAME, "Quick-Exit Compact Machine");

addJade();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.compactmods.machines.data.functions.CopyRoomBindingFunction;
import dev.compactmods.machines.machine.Machines;
import dev.compactmods.machines.room.Rooms;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.level.block.Block;
Expand All @@ -17,8 +18,8 @@

public class BlockLootGenerator extends BlockLootSubProvider {

public BlockLootGenerator() {
super(Collections.emptySet(), FeatureFlags.REGISTRY.allFlags());
public BlockLootGenerator(HolderLookup.Provider holderLookup) {
super(Collections.emptySet(), FeatureFlags.REGISTRY.allFlags(), holderLookup);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ protected void addTags(HolderLookup.Provider provider) {
private void shrinkingDevices(PersonalShrinkingDevice psd) {
final var cmShrinkTag = tag(PSDTags.ITEM);
cmShrinkTag.add(psd);
cmShrinkTag.addOptional(new ResourceLocation("shrink", "shrinking_device"));
cmShrinkTag.addOptional(ResourceLocation.fromNamespaceAndPath("shrink", "shrinking_device"));
}

private void curiosTags(PersonalShrinkingDevice psd) {
final var curiosPsdTag = tag(TagKey.create(CMRegistries.ITEMS.getRegistryKey(), new ResourceLocation("curios", "psd")));
final var curiosPsdTag = tag(TagKey.create(CMRegistries.ITEMS.getRegistryKey(), ResourceLocation.fromNamespaceAndPath("curios", "psd")));
curiosPsdTag.add(psd);
}

Expand Down
132 changes: 62 additions & 70 deletions neoforge-main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@ val modId: String = property("mod_id") as String
val isRelease: Boolean = (System.getenv("RELEASE") ?: "false").equals("true", true)

val coreApi = project(":core-api")
val roomApi = project(":room-api")

val coreProjects = listOf(coreApi, roomApi)

plugins {
java
id("idea")
id("eclipse")
id("maven-publish")
id("org.ajoberstar.grgit") version("5.2.1")
alias(neoforged.plugins.userdev)
id("org.ajoberstar.grgit") version ("5.2.1")
alias(neoforged.plugins.moddev)
}

coreProjects.forEach {
project.evaluationDependsOn(it.path)
}
project.evaluationDependsOn(coreApi.path)

base {
archivesName.set(modId)
Expand All @@ -40,7 +35,7 @@ java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

jarJar.enable()
//jarJar.enable()

sourceSets.main {
java {
Expand All @@ -63,55 +58,56 @@ sourceSets.test {
}
}

minecraft {
modIdentifier.set(modId)
accessTransformers.file(project.file("src/main/resources/META-INF/accesstransformer.cfg"))
}
neoForge {
version = neoforged.versions.neoforge
accessTransformers.add("src/main/resources/META-INF/accesstransformer.cfg")

runs {
// applies to all the run configs below
configureEach {
systemProperty("forge.logging.markers", "") // 'SCAN,REGISTRIES,REGISTRYDUMP'
this.mods.create(modId) {
modSourceSets.add(sourceSets.main)
//modSourceSets.add(coreApi.sourceSets.main.get())
this.dependency(coreApi)
}

// Recommended logging level for the console
systemProperty("forge.logging.console.level", "debug")
runs {
// applies to all the run configs below
configureEach {
systemProperty("forge.logging.markers", "") // 'SCAN,REGISTRIES,REGISTRYDUMP'

dependencies {
runtime("dev.compactmods:feather:${libraries.versions.feather.get()}")
runtime("com.aventrix.jnanoid:jnanoid:2.0.0")
}
// Recommended logging level for the console
systemProperty("forge.logging.console.level", "debug")

if(!System.getenv().containsKey("CI")) {
// JetBrains Runtime Hotswap
// jvmArgument("-XX:+AllowEnhancedClassRedefinition")
}
if (!System.getenv().containsKey("CI")) {
// JetBrains Runtime Hotswap
// jvmArgument("-XX:+AllowEnhancedClassRedefinition")
}

modSource(sourceSets.main.get())
coreProjects.forEach {
modSource(it.sourceSets.main.get())
additionalRuntimeClasspath.add("dev.compactmods:feather:${libraries.versions.feather.get()}")
additionalRuntimeClasspath.add("com.aventrix.jnanoid:jnanoid:2.0.0")
}
}

create("client") {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty("forge.enabledGameTestNamespaces", modId)
create("client") {
client()

programArguments("--username", "Nano")
programArguments("--width", "1920")
programArguments("--height", "1080")
}
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty("forge.enabledGameTestNamespaces", modId)

create("server") {
systemProperty("forge.enabledGameTestNamespaces", modId)
environmentVariables("CM_TEST_RESOURCES", project.file("src/test/resources").path)
programArguments("nogui")
modSource(project.sourceSets.test.get())
}
programArguments.addAll("--username", "Nano")
programArguments.addAll("--width", "1920")
programArguments.addAll("--height", "1080")
}

create("gameTestServer") {
systemProperty("forge.enabledGameTestNamespaces", modId)
environmentVariable("CM_TEST_RESOURCES", file("src/test/resources").path)
modSource(project.sourceSets.test.get())
// create("server") {
// systemProperty("forge.enabledGameTestNamespaces", modId)
// environmentVariables("CM_TEST_RESOURCES", project.file("src/test/resources").path)
// programArguments("nogui")
// modSource(project.sourceSets.test.get())
// }
//
// create("gameTestServer") {
// systemProperty("forge.enabledGameTestNamespaces", modId)
// environmentVariable("CM_TEST_RESOURCES", file("src/test/resources").path)
// modSource(project.sourceSets.test.get())
// }
}
}

Expand Down Expand Up @@ -152,23 +148,19 @@ repositories {
dependencies {
// Core Projects and Libraries
this {
implementation(neoforged.neoforge)
testImplementation(neoforged.testframework)
implementation(libraries.jnanoid)
compileOnly(libraries.jnanoid)
jarJar(libraries.jnanoid)

listOf(coreApi, roomApi).forEach {
compileOnly(it)
testCompileOnly(it)
}
compileOnly(coreApi)
testCompileOnly(coreApi)

implementation(libraries.feather)
compileOnly(libraries.feather)
jarJar(libraries.feather) { isTransitive = false }
}

// Mods
compileOnly(mods.bundles.jei)
compileOnly(mods.jade)
// compileOnly(mods.bundles.jei)
// compileOnly(mods.jade)
}

tasks.withType<ProcessResources> {
Expand All @@ -192,7 +184,8 @@ tasks.withType<Jar> {

manifest {
val now = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date())
attributes(mapOf(
attributes(
mapOf(
"Specification-Title" to "Compact Machines",
"Specification-Vendor" to "CompactMods",
"Specification-Version" to "2",
Expand All @@ -204,25 +197,24 @@ tasks.withType<Jar> {
"NeoForge-Version" to neoforged.versions.neoforge.get(),
"Main-Commit" to mainGit.head().id,
"Core-Commit" to coreGit.head().id
))
)
)
}
}

tasks.jar {
archiveClassifier.set("slim")
from(sourceSets.main.get().output)
coreProjects.forEach {
from (it.sourceSets.main.get().output)
}
from(coreApi.sourceSets.main.get().output)
}

tasks.jarJar {
archiveClassifier.set("")
from(sourceSets.main.get().output)
coreProjects.forEach {
from (it.sourceSets.main.get().output)
}
}
//tasks.jarJar {
// archiveClassifier.set("")
// from(sourceSets.main.get().output)
// coreProjects.forEach {
// from (it.sourceSets.main.get().output)
// }
//}

val PACKAGES_URL = System.getenv("GH_PKG_URL") ?: "https://maven.pkg.github.com/compactmods/compactmachines"
publishing {
Expand Down
Loading

0 comments on commit 21174d2

Please sign in to comment.