diff --git a/build.gradle.kts b/build.gradle.kts index 70eaac4..4886475 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,209 @@ plugins { - alias(libs.plugins.loom) apply false - alias(libs.plugins.moddev) apply false - alias(libs.plugins.mod.publish) apply false + alias(libs.plugins.loom) alias(libs.plugins.yumi.licenser) + alias(libs.plugins.mod.publish) + `maven-publish` +} + +val maven_group: String by properties +val mod_id: String by properties +val mod_version: String by properties +val friendly_minecraft_version: String by properties +val archives_base_name: String by properties + +base.archivesName.set(mod_id) +group = maven_group +version = "${mapModVersion(mod_version)}+${mapMinecraftVersion(friendly_minecraft_version)}" + +val maven_url = mapMavenUrl("https://maven.sylv.gay/") + +val localCompile = configurations.register("localCompile") { + isCanBeResolved = true + isCanBeConsumed = false +} + +configurations { + named("compileClasspath") { + extendsFrom(localCompile) + } +} + +repositories { + maven("https://maven.terraformersmc.com/") { + name = "TerraformersMC" + } + maven("https://maven.greenhouse.lgbt/releases") { + name = "Greenhouse Modding" + } + maven("https://maven.greenhouse.lgbt/snapshots/") { + name = "Greenhouse Modding (Snapshots)" + } + maven( "https://maven.sylv.gay/releases/") { + name = "BlameJared" + } + maven( "https://maven.blamejared.com/") { + name = "BlameJared" + } + maven("https://maven.shedaniel.me") { + name = "Shedaniel" + } + maven("https://maven.cassian.cc") { + name = "Cassian's Maven" + } + mavenCentral() + mavenLocal() +} + +dependencies { + minecraft(libs.minecraft) + + implementation(libs.fabric.loader) + implementation(libs.fabric.api) + + localRuntime(libs.mod.menu) + + // Required Dependencies + val apiAttribute = Attribute.of("lgbt.greenhouse.modding.api", String::class.java) + compileOnlyApi(libs.greenhouse.config) { + attributes { + attribute(apiAttribute, "") + } + } + runtimeOnly(libs.greenhouse.config) + include(libs.greenhouse.config) + + api(libs.greenhouse.config.extensions.gamerules) + include(libs.greenhouse.config.extensions.gamerules) + + localCompile(libs.jei.common.api) + localCompile(libs.jei.common) + localCompile(libs.jei.lib) + // Uncomment the below to test JEI. +// localRuntime(libs.jei.fabric) + + localCompile(libs.architectury) + localCompile(libs.rei.fabric) + // Uncomment the below to test REI. +// localRuntime(libs.rei.fabric) + + localRuntime(libs.rrv.fabric) +} + +publishMods { + changelog = rootProject.file("CHANGELOG.md").readText() + displayName = "v${mod_version} (Minecraft ${friendly_minecraft_version})" + version = "${mod_version}+${friendly_minecraft_version}" + type = STABLE + + modrinth { + + } +} + +publishing { + publications { + create("mavenJava") { + artifactId = base.archivesName.get() + from(components["java"]) + } + } + repositories { + maven { + name = "Sylv" + url = uri(maven_url) + credentials { + username = System.getenv("MAVEN_USERNAME") + password = System.getenv("MAVEN_PASSWORD") + } + authentication { + create("basic") + } + } + } +} + +// TODO: Split Sources. +loom { + mods { + register(mod_id) { + sourceSet(sourceSets["main"]) + } + } +} + +fabricApi { + configureDataGeneration { + client = true + createRunConfiguration = true + createSourceSet = true + } +} + +tasks { + withType().configureEach { + options.release = 25 + } + + named("jar") { + from(rootProject.file("LICENSE")) { + rename { "${it}_${project.name}" } + } + } + + val expandProps = mapOf( + "mod_version" to version, + "mod_name" to project.name, + "minecraft_version" to libs.versions.minecraft, + "group" to project.group, //Else we target the task's group. + "mod_id" to mod_id + ) + + val processResourcesTasks = + listOf("processResources", "processDatagenResources", "processTestmodResources", "processGametestResources") + + withType().matching { processResourcesTasks.contains(it.name) }.configureEach { + inputs.properties(expandProps) + filesMatching("fabric.mod.json") { + expand(expandProps) + } + exclude("\\.cache") + } +} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} + +license { + rule(rootProject.file("codeformat/LICENSE_HEADER")) + include("**/*.java") +} + +fun mapModVersion(modVersion: String): String { + if (System.getenv("RELEASE_TYPE") != "releases") { + return "${modVersion}+dev" + } + + return modVersion +} + +fun mapMinecraftVersion(minecraftVersion: String): String { + if (System.getenv("RELEASE_TYPE") != "releases") { + if (System.getenv("TANGLED_COMMIT_SHA") != null) { + val sha = "${System.getenv("TANGLED_COMMIT_SHA")}" + return "${minecraftVersion}+${sha}" + } else if (System.getenv("FORGEJO_SHA") != null) { + val sha = "${System.getenv("FORGEJO_SHA")}" + return "${minecraftVersion}+${sha}" + } + } + + return minecraftVersion +} + +fun mapMavenUrl(mavenUrl: String): String { + return mavenUrl + System.getenv("RELEASE_TYPE") } diff --git a/build_logic/build.gradle.kts b/build_logic/build.gradle.kts deleted file mode 100644 index 38e987e..0000000 --- a/build_logic/build.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - repositories { - maven("https://maven.fabricmc.net/") { - name = "Fabric" - } - } - maven("https://maven.neoforged.net/releases") { - name = "NeoForge" - } - gradlePluginPortal() -} - -dependencies { - implementation("net.fabricmc:fabric-loom:${libs.versions.loom.get()}") { - isTransitive = false - } - implementation("net.neoforged:moddev-gradle:${libs.versions.moddev.get()}") { - isTransitive = false - } - implementation("dev.yumi:yumi-gradle-licenser:${libs.versions.yumi.licenser.get()}") - - // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 - implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) -} diff --git a/build_logic/settings.gradle.kts b/build_logic/settings.gradle.kts deleted file mode 100644 index 45b8914..0000000 --- a/build_logic/settings.gradle.kts +++ /dev/null @@ -1,24 +0,0 @@ -dependencyResolutionManagement { - versionCatalogs { - create("libs") { - from(files("../gradle/libs.versions.toml")) - } - } -} - -pluginManagement { - repositories { - gradlePluginPortal() - mavenCentral() - maven("https://maven.neoforged.net/releases") { - name = "NeoForged" - } - maven("https://maven.fabricmc.net/") { - name = "Fabric" - } - } -} - -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/ModPlatform.kt b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/ModPlatform.kt deleted file mode 100644 index f78da85..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/ModPlatform.kt +++ /dev/null @@ -1,51 +0,0 @@ -package lgbt.greenhouse.menderman.gradle - -import org.gradle.kotlin.dsl.support.uppercaseFirstChar - -enum class ModPlatform(val platformName: String, val mcGradleConventionsName: String) { - XPLAT("xplat", "common"), - FABRIC("fabric", "fabric"), - NEOFORGE("neoforge", "neoforge"); - - fun isXplat(): Boolean { - return this == XPLAT - } - - fun mapConfigurationName(configurationName: String): String { - return platformName + configurationName.uppercaseFirstChar() - } - - fun mapModuleName(baseName: String): String { - if (!isXplat()) { - return "${baseName}_${platformName}" - } - return baseName - } - - fun remapModuleName(baseName: String, modPlatform: ModPlatform): String { - if (this.isXplat() && !modPlatform.isXplat()) { - return "${baseName}_${modPlatform.platformName}" - } - - if (!this.isXplat() && modPlatform.isXplat()) { - return baseName.substring(0, baseName.length - this.platformName.length - 1) - } - - return baseName.replace(this.platformName, modPlatform.platformName) - } - - companion object { - fun getProjectPlatformName(projectName: String): String { - return getProjectPlatform(projectName).platformName - } - - fun getProjectPlatform(projectName: String): ModPlatform { - for (modPlatform in entries) { - if (projectName == modPlatform.platformName) { - return modPlatform - } - } - return XPLAT - } - } -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/Properties.kt b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/Properties.kt index 583f931..e69de29 100644 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/Properties.kt +++ b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/Properties.kt @@ -1,56 +0,0 @@ -package lgbt.greenhouse.menderman.gradle - -object Properties { - val MOD_VERSION = mapModVersion("1.2.0") - val FRIENDLY_MINECRAFT_VERSION = mapMinecraftVersion("26.2.x") - const val JAVA_VERSION = 25 - - const val GROUP = "lgbt.greenhouse.menderman" - const val MOD_NAME = "Menderman" - const val MOD_ID = "menderman" - val ARCHIVES_BASE_NAME = MOD_ID.replace("_", "-") - const val MOD_AUTHOR = "Vulpixel" - val MOD_CONTRIBUTORS = listOf("ChrysanthCow", "Sylv ") - const val DESCRIPTION = "Minor repairing reworks for the anvil." - const val LICENSE = "MPL-2.0" - - val SUPPORTED_MINECRAFT_VERSIONS = listOf("26.2") - - const val FABRIC_LOADER_VERSION_RANGE = ">=0.19" - const val FABRIC_API_VERSION_RANGE = ">=0.149.1" - const val FABRIC_MINECRAFT_VERSION_RANGE = "~26.2" - - const val NEOFORGE_LOADER_VERSION_RANGE = "[11,)" - const val NEOFORGE_VERSION_RANGE = "[26.2.0.10,26.3)" - const val NEOFORGE_MINECRAFT_VERSION_RANGE = "[26.2,26.3)" - - const val CURSEFORGE_PAGE = "https://www.curseforge.com/minecraft/mc-mods/menderman" - const val CURSEFORGE_PROJECT_ID = "1384572" - const val MODRINTH_PAGE = "https://modrinth.com/project/menderman" - const val MODRINTH_PROJECT_ID = "C7Hovsc7" - - const val GIT_URL = "https://tangled.org" - const val GIT_REPO = "vulpixel.org/menderman" - const val GIT_COMMITISH = "26.3.x" - - val MAVEN_URL = mapMavenUrl("https://maven.sylv.gay/") -} - -fun mapModVersion(modVersion: String): String { - if (System.getenv("RELEASE_TYPE") != "releases") { - return "${modVersion}+dev" - } - return modVersion -} - -fun mapMinecraftVersion(minecraftVersion: String): String { - if (System.getenv("RELEASE_TYPE") != "releases" && System.getenv("TANGLED_COMMIT_SHA") != null) { - val sha = "${System.getenv("TANGLED_COMMIT_SHA")}" - return "${minecraftVersion}+${sha}" - } - return minecraftVersion -} - -fun mapMavenUrl(mavenUrl: String): String { - return mavenUrl + System.getenv("RELEASE_TYPE") -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/java.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/java.gradle.kts index 57df94f..e69de29 100644 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/java.gradle.kts +++ b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/java.gradle.kts @@ -1,125 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.base - -import lgbt.greenhouse.menderman.gradle.Properties -import org.gradle.accessors.dm.LibrariesForLibs - -plugins { - id("lgbt.greenhouse.menderman.gradle.base.root") - `java-library` -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() -val platformName = project.name -val platformAttribute = Attribute.of("lgbt.greenhouse.modding.platform", String::class.java) - -val greenhouseModdingApiAttribute = Attribute.of("lgbt.greenhouse.modding.api", String::class.java) - -sourceSets { - register("gametest") { - compileClasspath += sourceSets["main"].compileClasspath - runtimeClasspath += sourceSets["main"].runtimeClasspath - compileClasspath += sourceSets["main"].output - runtimeClasspath += sourceSets["main"].output - } -} - -configurations { - register("localCompile") { - isCanBeResolved = true - isCanBeConsumed = false - } - named("compileClasspath") { - extendsFrom(configurations["localCompile"]) - } - named("gametestCompileClasspath") { - extendsFrom(configurations["compileClasspath"]) - } - register("platformApi") { - isCanBeResolved = true - isCanBeConsumed = true - } -} - - -dependencies { - compileOnlyApi(libs.greenhouse.config) { - attributes { - attribute(greenhouseModdingApiAttribute, "") - } - } - compileOnlyApi(libs.greenhouse.config.extensions.gamerules) { - attributes { - attribute(greenhouseModdingApiAttribute, "") - } - } - "localCompile"(libs.jei.common.api) - "localCompile"(libs.jei.common) - "localCompile"(libs.jei.lib) -} - -java { - toolchain.languageVersion.set(JavaLanguageVersion.of(Properties.JAVA_VERSION)) - withSourcesJar() - withJavadocJar() -} - -tasks { - named("jar") { - from(rootProject.file("LICENSE")) { - rename { "${it}_${Properties.MOD_NAME}" } - } - archiveClassifier = platformName - } - named("javadocJar") { - from(rootProject.file("LICENSE")) { - rename { "${it}_${Properties.MOD_NAME}" } - } - archiveClassifier = "javadoc-$platformName" - } - named("sourcesJar") { - from(rootProject.file("LICENSE")) { - rename { "${it}_${Properties.MOD_NAME}" } - } - archiveClassifier = "sources-$platformName" - } - - val expandProps = mapOf( - "mod_version" to Properties.MOD_VERSION, - "group" to project.group, //Else we target the task's group. - "minecraft_version" to Properties.FRIENDLY_MINECRAFT_VERSION, - "fabric_minecraft_version_range" to Properties.FABRIC_MINECRAFT_VERSION_RANGE, - "fabric_loader_version" to libs.versions.fabric.loader.get(), - "fabric_loader_version_range" to Properties.FABRIC_LOADER_VERSION_RANGE, - "fabric_api_version" to libs.versions.fabric.api.get(), - "fabric_api_version_range" to Properties.FABRIC_API_VERSION_RANGE, - "mod_name" to Properties.MOD_NAME, - "mod_author" to Properties.MOD_AUTHOR, - "neoforge_mod_contributors" to Properties.MOD_CONTRIBUTORS.joinToString(), - "fabric_mod_contributors" to Properties.MOD_CONTRIBUTORS.joinToString("\",\n\t\t\""), - "mod_id" to Properties.MOD_ID, - "mod_license" to Properties.LICENSE, - "mod_description" to Properties.DESCRIPTION, - "neoforge_minecraft_version_range" to Properties.NEOFORGE_MINECRAFT_VERSION_RANGE, - "neoforge_loader_version_range" to Properties.NEOFORGE_LOADER_VERSION_RANGE, - "neoforge_version" to libs.versions.neoforge.get(), - "neoforge_version_range" to Properties.NEOFORGE_VERSION_RANGE, - "java_version" to Properties.JAVA_VERSION, - "curseforge_page" to Properties.CURSEFORGE_PAGE, - "modrinth_page" to Properties.MODRINTH_PAGE, - "sources" to "${Properties.GIT_URL}/${Properties.GIT_REPO}", - "config_version" to libs.versions.greenhouse.config.asProvider().get(), - "config_extensions_gamerules_version" to libs.versions.greenhouse.config.extensions.gamerules.get() - ) - - val processResourcesTasks = - listOf("processResources", "processDatagenResources", "processTestmodResources", "processGametestResources") - - withType().matching { processResourcesTasks.contains(it.name) }.configureEach { - inputs.properties(expandProps) - filesMatching(setOf("fabric.mod.json", "META-INF/neoforge.mods.toml", "META-INF/jarjar/metadata.json")) { - expand(expandProps) - } - exclude("\\.cache") - } -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/merge.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/merge.gradle.kts deleted file mode 100644 index 25a01e5..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/merge.gradle.kts +++ /dev/null @@ -1,439 +0,0 @@ -@file:Suppress("AvoidDuplicateDependencies", "DuplicatedCode") - -package lgbt.greenhouse.menderman.gradle.base - -import lgbt.greenhouse.menderman.gradle.ModPlatform -import lgbt.greenhouse.menderman.gradle.Properties -import org.gradle.accessors.dm.LibrariesForLibs -import org.gradle.api.internal.tasks.JvmConstants -import org.gradle.api.publish.internal.component.DefaultAdhocSoftwareComponent -import org.gradle.jvm.component.internal.DefaultJvmSoftwareComponent - -plugins { - id("lgbt.greenhouse.menderman.gradle.base.java") -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() - -val platform = ModPlatform.getProjectPlatform(project.name) - -val greenhouseModdingPlatformAttribute = Attribute.of("lgbt.greenhouse.modding.platform", String::class.java) -val greenhouseModdingApiAttribute = Attribute.of("lgbt.greenhouse.modding.api", String::class.java) -val mcGradleConventionsAttribute = Attribute.of("io.github.mcgradleconventions.loader", String::class.java) - -val hasApi = configurations.findByName("apiApiElements") != null - -configurations { - val xplatClasspath = setOf( - "compileClasspath", - "runtimeClasspath" - ) - named { string -> xplatClasspath.contains(string) }.configureEach { - attributes { - attribute(greenhouseModdingPlatformAttribute, "xplat") - attribute(mcGradleConventionsAttribute, "common") - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-xplat:${version}") - } - } - - createPlatformClasspaths(ModPlatform.FABRIC) - - createPlatformElements(ModPlatform.XPLAT) - createPlatformElements(ModPlatform.FABRIC) - - if (neoforgeInterfaceInjectionsFile().exists()) { - register("interfaceInjectionDataElements") { - isCanBeConsumed = true - isCanBeResolved = false - - attributes { - attribute( - Category.CATEGORY_ATTRIBUTE, - project.objects.named(Category.CATEGORY_ATTRIBUTE.getType(), "interfaceinjection") - ) - } - } - } -} - -dependencies { - "fabricCompileClasspath"(project(":fabric", "compileClasspath")) - - "xplatApiElements"(project(":xplat", "platformApi")) - "fabricApiElements"(project(":fabric", "platformApi")) - - if (hasApi) { - "xplatApiApiElements"(project(":xplat", "apiApiElements")) - "fabricApiApiElements"(project(":fabric", "apiApiElements")) - } -} - -val mergeJar = tasks.register("mergeJar") { - description = "Assembles a jar archive containing the classes of the 'main' feature from all submodules." - - archiveBaseName.set(Properties.ARCHIVES_BASE_NAME) - destinationDirectory.set(project.rootDir.resolve("build/libs")) - - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -val mergeJavadocJar = tasks.register("mergeJavadocJar") { - description = "Assembles a jar archive containing the main javadocs from all submodules." - - archiveBaseName.set(Properties.ARCHIVES_BASE_NAME) - archiveClassifier.set("javadoc") - destinationDirectory.set(project.rootDir.resolve("build/libs")) - - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -val mergeSourcesJar = tasks.register("mergeSourcesJar") { - description = "Assembles a jar archive containing the main javadocs from all sources." - - archiveBaseName.set(Properties.ARCHIVES_BASE_NAME) - archiveClassifier.set("sources") - destinationDirectory.set(project.rootDir.resolve("build/libs")) - - duplicatesStrategy = DuplicatesStrategy.EXCLUDE -} - -tasks.named("assemble") { - dependsOn( - mergeJar, - mergeJavadocJar, - mergeSourcesJar - ) -} - -afterEvaluate { - val apiElementsName = JvmConstants.API_ELEMENTS_CONFIGURATION_NAME - val runtimeElementsName = JvmConstants.RUNTIME_ELEMENTS_CONFIGURATION_NAME - val javadocElementsName = JvmConstants.JAVADOC_ELEMENTS_CONFIGURATION_NAME - val sourcesElementsName = JvmConstants.SOURCES_ELEMENTS_CONFIGURATION_NAME - - configurations[apiElementsName].artifacts.clear() - artifacts.add(apiElementsName, mergeJar.get().archiveFile) - - configurations[runtimeElementsName].artifacts.clear() - artifacts.add(runtimeElementsName, mergeJar.get().archiveFile) - - configurations[javadocElementsName].artifacts.clear() - artifacts.add(javadocElementsName, mergeJavadocJar.get().archiveFile) - - configurations[sourcesElementsName].artifacts.clear() - artifacts.add(sourcesElementsName, mergeSourcesJar.get().archiveFile) - - artifacts { - addApiArtifact(ModPlatform.XPLAT) - addApiArtifact(ModPlatform.FABRIC) - - add("xplatApiElements", jarFile("xplat", "")) { - classifier = "xplat" - } - add("xplatRuntimeElements", mergeJar.get().archiveFile) { - builtBy(mergeJar.get()) - } - add("xplatJavadocElements", jarFile("xplat", "javadoc")) { - classifier = "javadoc-xplat" - } - add("xplatSourcesElements", jarFile("xplat", "sources")) { - classifier = "sources-xplat" - } - - add("fabricApiElements", jarFile("fabric", "")) { - classifier = "fabric" - } - add("fabricRuntimeElements", mergeJar.get().archiveFile) { - builtBy(mergeJar.get()) - } - add("fabricJavadocElements", jarFile("fabric", "javadoc")) { - classifier = "javadoc-fabric" - } - add("fabricSourcesElements", jarFile("fabric", "sources")) { - classifier = "sources-fabric" - } - } - - @Suppress("UnstableApiUsage") - components { - named("java") { - addVariantsFromApiConfiguration(ModPlatform.XPLAT) - addVariantsFromApiConfiguration(ModPlatform.FABRIC) - - addVariantsFromConfiguration(configurations["fabricApiElements"]) { - mapToMavenScope("compile") - mapToOptional() - } - addVariantsFromConfiguration(configurations["xplatApiElements"]) { - mapToMavenScope("compile") - mapToOptional() - } - addVariantsFromConfiguration(configurations["fabricRuntimeElements"]) { - mapToMavenScope("runtime") - mapToOptional() - } - addVariantsFromConfiguration(configurations["xplatRuntimeElements"]) { - mapToMavenScope("runtime") - mapToOptional() - } - addVariantsFromConfiguration(configurations["fabricJavadocElements"]) { - mapToOptional() - } - addVariantsFromConfiguration(configurations["xplatJavadocElements"]) { - mapToOptional() - } - addVariantsFromConfiguration(configurations["fabricSourcesElements"]) { - mapToOptional() - } - addVariantsFromConfiguration(configurations["xplatSourcesElements"]) { - mapToOptional() - } - - if (neoforgeInterfaceInjectionsFile().exists()) { - addVariantsFromConfiguration(configurations["interfaceInjectionDataElements"]) { - mapToOptional() - if (configurationVariant.artifacts.isEmpty()) { - skip() - } - } - } - - withVariantsFromConfiguration(configurations[apiElementsName]) { - mapToOptional() - } - withVariantsFromConfiguration(configurations[runtimeElementsName]) { - mapToOptional() - } - withVariantsFromConfiguration(configurations[javadocElementsName]) { - mapToOptional() - } - withVariantsFromConfiguration(configurations[sourcesElementsName]) { - mapToOptional() - } - } - } -} - -fun ConfigurationContainer.createPlatformClasspaths(modPlatform: ModPlatform) { - val compileClasspathConfigurationName = JvmConstants.COMPILE_CLASSPATH_CONFIGURATION_NAME - register(modPlatform.mapConfigurationName(compileClasspathConfigurationName)) { - isCanBeConsumed = true - isCanBeResolved = false - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.LIBRARY)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_API)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute( - LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, - objects.named(LibraryElements::class, LibraryElements.CLASSES) - ) - attribute( - TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, - objects.named(TargetJvmEnvironment::class, TargetJvmEnvironment.STANDARD_JVM) - ) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, java.toolchain.languageVersion.get().asInt()) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } - - val runtimeClasspathConfigurationName = JvmConstants.RUNTIME_CLASSPATH_CONFIGURATION_NAME - register(modPlatform.mapConfigurationName(runtimeClasspathConfigurationName)) { - isCanBeConsumed = true - isCanBeResolved = false - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.LIBRARY)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_RUNTIME)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute( - LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, - objects.named(LibraryElements::class, LibraryElements.CLASSES) - ) - attribute( - TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, - objects.named(TargetJvmEnvironment::class, TargetJvmEnvironment.STANDARD_JVM) - ) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, java.toolchain.languageVersion.get().asInt()) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } -} - -fun ConfigurationContainer.createPlatformElements(modPlatform: ModPlatform) { - val apiElementsConfigurationName = JvmConstants.API_ELEMENTS_CONFIGURATION_NAME - val runtimeElementsConfigurationName = JvmConstants.RUNTIME_ELEMENTS_CONFIGURATION_NAME - val javadocElementsConfigurationName = JvmConstants.JAVADOC_ELEMENTS_CONFIGURATION_NAME - val sourcesElementsConfigurationName = JvmConstants.SOURCES_ELEMENTS_CONFIGURATION_NAME - - if (hasApi) { - register(modPlatform.mapConfigurationName("apiApiElements")) { - isCanBeConsumed = true - isCanBeResolved = false - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(greenhouseModdingApiAttribute, "") - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.LIBRARY)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_API)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements::class, LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, java.toolchain.languageVersion.get().asInt()) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } - } - - if (configurations.findByName(apiElementsConfigurationName) != null) { - register(modPlatform.mapConfigurationName(apiElementsConfigurationName)) { - isCanBeConsumed = true - isCanBeResolved = false - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.LIBRARY)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_API)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements::class, LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, java.toolchain.languageVersion.get().asInt()) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } - } - if (configurations.findByName(runtimeElementsConfigurationName) != null) { - register(modPlatform.mapConfigurationName(runtimeElementsConfigurationName)) { - isCanBeConsumed = false - isCanBeResolved = true - - extendsFrom(configurations.getByName("api")) - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.LIBRARY)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_RUNTIME)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements::class, LibraryElements.JAR)) - attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, java.toolchain.languageVersion.get().asInt()) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } - } - if (configurations.findByName(javadocElementsConfigurationName) != null) { - register(modPlatform.mapConfigurationName(javadocElementsConfigurationName)) { - isCanBeConsumed = false - isCanBeResolved = true - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.DOCUMENTATION)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_RUNTIME)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType::class, DocsType.JAVADOC)) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } - } - if (configurations.findByName(sourcesElementsConfigurationName) != null) { - register(modPlatform.mapConfigurationName(sourcesElementsConfigurationName)) { - isCanBeConsumed = false - isCanBeResolved = true - - attributes { - attribute(greenhouseModdingPlatformAttribute, modPlatform.platformName) - attribute(mcGradleConventionsAttribute, modPlatform.mcGradleConventionsName) - - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.DOCUMENTATION)) - attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class, Usage.JAVA_RUNTIME)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling::class, Bundling.EXTERNAL)) - attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType::class, DocsType.SOURCES)) - } - outgoing { - capabilities.clear() - capability("${group}:${Properties.ARCHIVES_BASE_NAME}-${modPlatform.platformName}:${version}") - } - } - } -} - -fun jarFile(projectName: String, classifier: String): File { - val finalClassifier: String = if (!classifier.isBlank()) "-${classifier}" else classifier - return rootProject.file("${projectName}/build/libs/${Properties.ARCHIVES_BASE_NAME}-${Properties.MOD_VERSION}+${Properties.FRIENDLY_MINECRAFT_VERSION}${finalClassifier}-${projectName}.jar") -} - -fun neoforgeInterfaceInjectionsFile(): File { - return rootProject.file("neoforge/interfaces.json") -} - -fun ArtifactHandler.addApiArtifact(modPlatform: ModPlatform) { - if (!hasApi) return - - val apiJar = jarFile(modPlatform.platformName, "api") - if (apiJar.exists()) { - add("${modPlatform.platformName}ApiApiElements", apiJar) { - classifier = "${modPlatform.platformName}-api" - } - } - - val xplatApiJar = jarFile("xplat", "api") - if (xplatApiJar.exists()) { - add("${modPlatform.platformName}ApiApiElements", xplatApiJar) { - classifier = "xplat-api" - } - } -} - -fun DefaultAdhocSoftwareComponent.addVariantsFromApiConfiguration(modPlatform: ModPlatform) { - if (!hasApi) - return - - addVariantsFromConfiguration(configurations[modPlatform.mapConfigurationName("apiApiElements")]) { - mapToMavenScope("compile") - mapToOptional() - if (configurationVariant.artifacts.isEmpty()) { - skip() - } - } - addVariantsFromConfiguration(configurations[modPlatform.mapConfigurationName(JvmConstants.JAVADOC_ELEMENTS_CONFIGURATION_NAME)]) { - mapToOptional() - } - addVariantsFromConfiguration(configurations[modPlatform.mapConfigurationName(JvmConstants.SOURCES_ELEMENTS_CONFIGURATION_NAME)]) { - mapToOptional() - } -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/publish.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/publish.gradle.kts deleted file mode 100644 index c56ca4a..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/publish.gradle.kts +++ /dev/null @@ -1,66 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.base - -import lgbt.greenhouse.menderman.gradle.Properties - -plugins { - id("lgbt.greenhouse.menderman.gradle.base.java") - `maven-publish` -} - -val fabricProject = project(":fabric") - -val hasApi = components.findByName("api") != null - -publishing { - publications { - create("mavenJava") { - artifactId = base.archivesName.get() - from(components["java"]) - suppressAllPomMetadataWarnings() - } - if (hasApi) { - create("mavenJavaApi") { - artifactId = base.archivesName.get() - from(components["api"]) - suppressAllPomMetadataWarnings() - } - } - } - repositories { - maven { - name = "Greenhouse" - url = uri(Properties.MAVEN_URL) - credentials { - username = System.getenv("MAVEN_USERNAME") - password = System.getenv("MAVEN_PASSWORD") - } - authentication { - create("basic") - } - } - } -} - -afterEvaluate { - tasks.named("generateMetadataFileForMavenJavaPublication") { - dependsOn(fabricProject.tasks["jar"]) - dependsOn(fabricProject.tasks["javadocJar"]) - dependsOn(fabricProject.tasks["sourcesJar"]) - - if (hasApi) { - val fabricApiJar = fabricProject.tasks.findByName("apiJar") - - dependsOn(tasks["apiJar"]) - - if (fabricApiJar != null) { - dependsOn(fabricApiJar) - } - - dependsOn(tasks["javadocJar"]) - dependsOn(tasks["sourcesJar"]) - - dependsOn(fabricProject.tasks["javadocJar"]) - dependsOn(fabricProject.tasks["sourcesJar"]) - } - } -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/repositories.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/repositories.gradle.kts deleted file mode 100644 index 2f0382a..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/repositories.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.base - -plugins { - id("lgbt.greenhouse.menderman.gradle.base.root") -} - -repositories { - maven("https://maven.terraformersmc.com/") { - name = "TerraformersMC" - } - maven("https://maven.greenhouse.lgbt/releases") { - name = "Greenhouse Modding" - } - maven("https://maven.greenhouse.lgbt/snapshots/") { - name = "Greenhouse Modding (Snapshots)" - } - maven( "https://maven.blamejared.com/") { - name = "BlameJared" - } - maven("https://maven.shedaniel.me") { - name = "Shedaniel" - } - maven("https://maven.cassian.cc") { - name = "Cassian's Maven" - } - mavenCentral() - mavenLocal() -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/root.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/root.gradle.kts deleted file mode 100644 index 68290e6..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/base/root.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.base - -import dev.yumi.gradle.licenser.YumiLicenserGradleExtension -import lgbt.greenhouse.menderman.gradle.Properties -import lgbt.greenhouse.menderman.gradle.ModPlatform -import org.gradle.accessors.dm.LibrariesForLibs - -plugins { - base - idea -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() - -val modPlatform = ModPlatform.getProjectPlatform(project.name) -val platformAttribute = Attribute.of("lgbt.greenhouse.modding.platform", String::class.java) - -// Cursed but it works! -plugins.apply(libs.plugins.yumi.licenser.get().pluginId) - -base.archivesName.set(Properties.ARCHIVES_BASE_NAME) -group = Properties.GROUP -version = "${Properties.MOD_VERSION}+${Properties.FRIENDLY_MINECRAFT_VERSION}" - -extensions.configure("license") { - rule(rootProject.file("build_logic/src/main/resources/HEADER")) - include("**/*.java") -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/fabric.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/fabric.gradle.kts deleted file mode 100644 index ad0e0d7..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/fabric.gradle.kts +++ /dev/null @@ -1,76 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.platform - -import lgbt.greenhouse.menderman.gradle.Properties -import net.fabricmc.loom.api.LoomGradleExtensionAPI -import org.gradle.accessors.dm.LibrariesForLibs - -plugins { - id("lgbt.greenhouse.menderman.gradle.platform.loader") - id("lgbt.greenhouse.menderman.gradle.base.repositories") -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() - -val xplatProject = project(":xplat") - -// Cursed but it works! -plugins.apply(libs.plugins.loom.get().pluginId) - -sourceSets { - getByName("gametest") { - // Loom seems to only like it when I do this, annoying but reasonable for it to do the bare minimum within the 'mods' block. - runtimeClasspath += sourceSets["main"].output - } -} - -xplatProject.tasks { - named("mergeJar") { - dependsOn(tasks["jar"]) - from(zipTree(tasks.getByName("jar").archiveFile.get())) - } - named("mergeJavadocJar") { - dependsOn(tasks["javadocJar"]) - from(zipTree(tasks.getByName("javadocJar").archiveFile.get())) - } - named("mergeSourcesJar") { - dependsOn(tasks["sourcesJar"]) - from(zipTree(tasks.getByName("sourcesJar").archiveFile.get())) - } -} - -repositories { - maven("https://maven.fabricmc.net/") { - name = "Fabric" - } -} - -dependencies { - "minecraft"(libs.minecraft) - - implementation(libs.fabric.loader) - implementation(libs.fabric.api) - - "localRuntime"(libs.mod.menu) - - runtimeOnly(libs.greenhouse.config) - "include"(libs.greenhouse.config) - - runtimeOnly(libs.greenhouse.config.extensions.gamerules) - "include"(libs.greenhouse.config.extensions.gamerules) - - // Uncomment the below to test JEI. -// "localRuntime"(libs.jei.fabric) - - "localCompile"(libs.rei.fabric) - // Uncomment the below to test REI. -// "localRuntime"(libs.rei.fabric) - - "localRuntime"(libs.rrv.fabric) -} - -extensions.configure("loom") { - val ct = file("src/main/resources/${Properties.MOD_ID}.classtweaker") - if (ct.exists()) - accessWidenerPath.set(ct) -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/loader.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/loader.gradle.kts index c24a85c..e69de29 100644 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/loader.gradle.kts +++ b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/loader.gradle.kts @@ -1,70 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.platform - -import lgbt.greenhouse.menderman.gradle.ModPlatform -import org.gradle.accessors.dm.LibrariesForLibs - -plugins { - id("lgbt.greenhouse.menderman.gradle.base.java") -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() -val platform = ModPlatform.getProjectPlatform(name) -val platformAttribute = Attribute.of("lgbt.greenhouse.modding.platform", String::class.java) - -val xplatProject = project(":xplat") -evaluationDependsOn(":xplat") - -sourceSets { - getByName("main") { - compileClasspath += xplatProject.sourceSets["main"].output - runtimeClasspath += xplatProject.sourceSets["main"].output - } - getByName("gametest") { - compileClasspath += xplatProject.sourceSets["gametest"].output - runtimeClasspath += xplatProject.sourceSets["gametest"].output - - // Loom seems to only like it when I do this, annoying but reasonable for it to do the bare minimum within the 'mods' block. - runtimeClasspath += xplatProject.sourceSets["main"].output - } -} - -xplatProject.tasks { - named("mergeJar") { - dependsOn(tasks["jar"]) - from(zipTree(tasks.getByName("jar").archiveFile.get())) - } - named("mergeJavadocJar") { - dependsOn(tasks["javadocJar"]) - from(zipTree(tasks.getByName("javadocJar").archiveFile.get())) - } - named("mergeSourcesJar") { - dependsOn(tasks["sourcesJar"]) - from(zipTree(tasks.getByName("sourcesJar").archiveFile.get())) - } -} - -configurations { - named("gametestRuntimeClasspath") { - extendsFrom(configurations["runtimeClasspath"]) - } -} - -dependencies { - compileOnlyApi(project(":xplat")) - "platformApi"(project(":xplat")) { - attributes { - attribute(platformAttribute, ":xplat") - } - } -} - -tasks { - named("compileGametestJava") { - dependsOn(xplatProject.tasks["compileGametestJava"]) - } - - named("processGametestResources") { - dependsOn(xplatProject.tasks["processGametestResources"]) - } -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/neoforge.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/neoforge.gradle.kts deleted file mode 100644 index 10319c8..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/neoforge.gradle.kts +++ /dev/null @@ -1,75 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.platform - -import lgbt.greenhouse.menderman.gradle.Properties -import net.neoforged.moddevgradle.dsl.NeoForgeExtension -import org.gradle.accessors.dm.LibrariesForLibs - -plugins { - id("lgbt.greenhouse.menderman.gradle.platform.loader") - id("lgbt.greenhouse.menderman.gradle.base.repositories") -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() -val xplatProject = project(":xplat") - -// Cursed but it works! -plugins.apply(libs.plugins.moddev.get().pluginId) - -configurations { - register("localRuntime") { - isCanBeResolved = true - isCanBeConsumed = false - } - getByName("runtimeClasspath") { - extendsFrom(configurations["localRuntime"]) - } - register("include") { - isCanBeResolved = true - isCanBeConsumed = true - isTransitive = false - } -} - -repositories { - maven("https://maven.neoforged.net/releases") { - name = "NeoForge" - } -} - -dependencies { - runtimeOnly(libs.greenhouse.config) - "include"(libs.greenhouse.config) - - runtimeOnly(libs.greenhouse.config.extensions.gamerules) - "include"(libs.greenhouse.config.extensions.gamerules) - - // Uncomment the below to test JEI. -// "localRuntime"(libs.jei.neoforge) - - "localCompile"(libs.rei.neoforge) - // Uncomment the below to test REI. -// "localRuntime"(libs.rei.neoforge) - - "localRuntime"(libs.rrv.neoforge) -} - - -tasks { - getByName("processResources") { - dependsOn(xplatProject.tasks.getByName("processResources")) - into("META-INF/jars") { - from(configurations["include"]) - } - } -} - - -extensions.configure("neoForge") { - version = libs.versions.neoforge.get() - - val at = file("src/main/resources/${Properties.MOD_ID}.cfg") - if (at.exists()) - setAccessTransformers(at) - validateAccessTransformers = true -} diff --git a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/xplat.gradle.kts b/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/xplat.gradle.kts deleted file mode 100644 index c11a24b..0000000 --- a/build_logic/src/main/kotlin/lgbt/greenhouse/menderman/gradle/platform/xplat.gradle.kts +++ /dev/null @@ -1,66 +0,0 @@ -package lgbt.greenhouse.menderman.gradle.platform - -import gradle.kotlin.dsl.accessors._53d1812366d96f3ba14deef8baabc09a.sourceSets -import lgbt.greenhouse.menderman.gradle.Properties -import net.fabricmc.loom.api.LoomGradleExtensionAPI -import org.gradle.accessors.dm.LibrariesForLibs - -plugins { - id("lgbt.greenhouse.menderman.gradle.base.java") - id("lgbt.greenhouse.menderman.gradle.base.merge") - id("lgbt.greenhouse.menderman.gradle.base.repositories") - id("lgbt.greenhouse.menderman.gradle.base.publish") -} - -// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 -val libs = the() -val platformAttribute = Attribute.of("lgbt.greenhouse.modding.platform", String::class.java) - -// Cursed but it works! -plugins.apply(libs.plugins.loom.get().pluginId) - -sourceSets { - register("generated") -} - -tasks { - named("mergeJar") { - dependsOn(tasks["jar"]) - from(zipTree(tasks.getByName("jar").archiveFile.get())) - } - named("mergeJavadocJar") { - dependsOn(tasks["javadocJar"]) - from(zipTree(tasks.getByName("javadocJar").archiveFile.get())) - } - named("mergeSourcesJar") { - dependsOn(tasks["sourcesJar"]) - from(zipTree(tasks.getByName("sourcesJar").archiveFile.get())) - } - - named("processResources") { - from(sourceSets["generated"].resources) - } -} - -repositories { - maven("https://repo.spongepowered.org/repository/maven-public") { - name = "Sponge" - } -} - -dependencies { - "minecraft"(libs.minecraft) - - compileOnly(libs.mixin) - compileOnly(libs.mixin.extras) - annotationProcessor(libs.mixin.extras) - - "localCompile"(libs.architectury) - "localCompile"(libs.rei.fabric) -} - -extensions.configure("loom") { - val ct = rootProject.file("fabric/src/main/resources/${Properties.MOD_ID}.classtweaker") - if (ct.exists()) - accessWidenerPath.set(ct) -} diff --git a/build_logic/src/main/resources/HEADER b/build_logic/src/main/resources/HEADER deleted file mode 100644 index b217648..0000000 --- a/build_logic/src/main/resources/HEADER +++ /dev/null @@ -1,7 +0,0 @@ -Copyright © ${CREATION_YEAR} Greenhouse Modding - -This Source Code Form is subject to the terms of the Mozilla Public -License, v. 2.0. If a copy of the MPL was not distributed with this -file, You can obtain one at https://mozilla.org/MPL/2.0/. - -#year_selection file diff --git a/codeformat/LICENSE_HEADER b/codeformat/LICENSE_HEADER new file mode 100644 index 0000000..efa1654 --- /dev/null +++ b/codeformat/LICENSE_HEADER @@ -0,0 +1,8 @@ +Copyright (c) ${CREATION_YEAR} Vulpixel , Greenhouse Modding + +This Source Code Form is subject to the terms of the NON-AI Mozilla +Public License, v. 2.0. If a copy of the NON-AI MPL was not +distributed with this file, You can obtain one at +https://vulpixel.org/licenses/non-ai-mpl-2.0. + +#year_selection file diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts deleted file mode 100644 index a420f2d..0000000 --- a/fabric/build.gradle.kts +++ /dev/null @@ -1,66 +0,0 @@ -import lgbt.greenhouse.menderman.gradle.Properties - -plugins { - id("lgbt.greenhouse.menderman.gradle.platform.fabric") -} - -val xplatProject = project(":xplat") - -sourceSets { - register("datagen") { - compileClasspath += main.get().compileClasspath - runtimeClasspath += main.get().runtimeClasspath - } -} - -loom { - mods { - register(Properties.MOD_ID) { - sourceSet(xplatProject.sourceSets["main"]) - sourceSet(sourceSets["main"]) - } - -// register("${Properties.MOD_ID}_gametest") { -// sourceSet(xplatProject.sourceSets["gametest"]) -// sourceSet(sourceSets["gametest"]) -// } - } - - runs { - named("client") { - client() - displayName.set("Fabric Client") - runDirectory.set(project.file("runs/client")) - sourceSet.set("main") - generateRunConfig.set(true) - jvmArguments.addAll("-Dmixin.debug.export=true", "-Dfabric-api.gametest") - } - named("server") { - server() - displayName.set("Fabric Server") - runDirectory.set(project.file("runs/server")) - sourceSet.set("main") - generateRunConfig.set(true) - jvmArguments.add("-Dmixin.debug.export=true") - } - register("datagen") { - server() - displayName.set("Fabric Datagen") - runDirectory.set(project.file("runs/datagen")) - sourceSet.set("datagen") - generateRunConfig.set(true) - jvmArguments.addAll( - "-Dfabric-api.datagen", - "-Dfabric-api.datagen.output-dir=${file("../xplat/src/generated/resources")}", - "-Dfabric-api.datagen.modid=${Properties.MOD_ID}_datagen" - ) - } -// register("gametest") { -// server() -// displayName.set("Fabric Game Test") -// runDirectory.set(project.file("runs/gametest")) -// generateRunConfig.set(true) -// jvmArguments.add("-Dfabric-api.gametest") -// } - } -} diff --git a/fabric/src/datagen/resources/fabric.mod.json b/fabric/src/datagen/resources/fabric.mod.json deleted file mode 100644 index 31a11a6..0000000 --- a/fabric/src/datagen/resources/fabric.mod.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "schemaVersion": 1, - "id": "${mod_id}_datagen", - "version": "${mod_version}+${minecraft_version}", - "name": "${mod_name} Datagen", - "description": "${mod_description}", - "authors": [ - "${mod_author}" - ], - "contributors": [ - "${fabric_mod_contributors}" - ], - "contact": { - "homepage": "${modrinth_page}", - "issues": "${sources}/issues", - "sources": "${sources}" - }, - "license": "${mod_license}", - "environment": "*", - "entrypoints": { - "fabric-datagen": [ - "lgbt.greenhouse.menderman.datagen.MendermanDataGenerator" - ] - }, - "depends": { - "fabricloader": "${fabric_loader_version_range}", - "fabric-api": "*", - "minecraft": "${fabric_minecraft_version_range}", - "java": ">=${java_version}" - }, - "custom": { - "modmenu": { - "links": { - "modmenu.curseforge": "${curseforge_page}", - "modmenu.modrinth": "${modrinth_page}" - } - } - } -} diff --git a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/mixin/Mixin_AnvilMenu.java b/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/mixin/Mixin_AnvilMenu.java deleted file mode 100644 index bb9b413..0000000 --- a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/mixin/Mixin_AnvilMenu.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.fabric.mixin; - -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; -import net.minecraft.world.inventory.AnvilMenu; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(AnvilMenu.class) -public class Mixin_AnvilMenu { - @Shadow - private int repairItemCountCost; - - @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/DataSlot;set(I)V", ordinal = 5), name = "price") - private int menderman$cancelCostForChecksAfterRenaming(int price, @Local(name = "namingCost") int namingCost, @Share(namespace = "menderman", value = "renameOnly") LocalBooleanRef renameOnlyRef) { - if (renameOnlyRef.get() || repairItemCountCost > 0) { - return renameOnlyRef.get() ? namingCost : repairItemCountCost; - } - return price; - } -} diff --git a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/platform/MendermanPlatformHelperFabric.java b/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/platform/MendermanPlatformHelperFabric.java deleted file mode 100644 index 28243d6..0000000 --- a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/platform/MendermanPlatformHelperFabric.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.fabric.platform; - -import lgbt.greenhouse.menderman.platform.MendermanPlatformHelper; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.core.Registry; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.Identifier; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; - -public class MendermanPlatformHelperFabric implements MendermanPlatformHelper { - @Override - public boolean isModLoaded(String modId) { - return FabricLoader.getInstance().isModLoaded(modId); - } - - @Override - public void aliasRegistryValue(Registry registry, Identifier from, Identifier to) { - registry.addAlias(from, to); - } - - @Override - public void sendPacketToPlayer(ServerPlayer player, CustomPacketPayload payload) { - ServerPlayNetworking.send(player, payload); - } - - @Override - public void sendPacketsToAllServerPlayers(MinecraftServer server, CustomPacketPayload payload) { - for (ServerPlayer player : server.getPlayerList().getPlayers()) { - ServerPlayNetworking.send(player, payload); - } - } -} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json deleted file mode 100644 index 852fe2d..0000000 --- a/fabric/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "schemaVersion": 1, - "id": "${mod_id}", - "version": "${mod_version}+${minecraft_version}", - "name": "${mod_name}", - "description": "${mod_description}", - "authors": [ - "${mod_author}" - ], - "contributors": [ - "${fabric_mod_contributors}" - ], - "contact": { - "homepage": "${modrinth_page}", - "issues": "${sources}/issues", - "sources": "${sources}" - }, - "license": "${mod_license}", - "icon": "${mod_id}.png", - "environment": "*", - "entrypoints": { - "main": [ - "lgbt.greenhouse.menderman.fabric.MendermanFabric" - ], - "client": [ - "lgbt.greenhouse.menderman.fabric.client.MendermanClientFabric" - ], - "rei_client": [ - "lgbt.greenhouse.menderman.integration.rei.MendermanReiClientPlugin" - ] - }, - "mixins": [ - "${mod_id}.mixins.json", - "${mod_id}.fabric.mixins.json" - ], - "depends": { - "fabricloader": "${fabric_loader_version_range}", - "fabric-api": "${fabric_api_version_range}", - "minecraft": "${fabric_minecraft_version_range}", - "java": ">=${java_version}" - }, - "custom": { - "modmenu": { - "links": { - "modmenu.curseforge": "${curseforge_page}", - "modmenu.modrinth": "${modrinth_page}" - } - } - } -} diff --git a/fabric/src/main/resources/menderman.fabric.mixins.json b/fabric/src/main/resources/menderman.fabric.mixins.json deleted file mode 100644 index c575eee..0000000 --- a/fabric/src/main/resources/menderman.fabric.mixins.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "lgbt.greenhouse.menderman.fabric.mixin", - "compatibilityLevel": "JAVA_25", - "mixins": [ - "Mixin_AnvilMenu" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric/src/testmod/resources/fabric.mod.json b/fabric/src/testmod/resources/fabric.mod.json deleted file mode 100644 index ad5ef41..0000000 --- a/fabric/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "schemaVersion": 1, - "id": "${mod_id}_test", - "version": "${mod_version}+${minecraft_version}", - "name": "${mod_name} Test", - "description": "${mod_description}", - "authors": [ - "${mod_author}" - ], - "contributors": [ - "${fabric_mod_contributors}" - ], - "contact": { - "homepage": "${modrinth_page}", - "issues": "${sources}/issues", - "sources": "${sources}" - }, - "license": "${mod_license}", - "environment": "*", - "depends": { - "fabricloader": "${fabric_loader_version_range}", - "fabric-api": "*", - "minecraft": "${fabric_minecraft_version_range}", - "java": ">=${java_version}" - }, - "custom": { - "modmenu": { - "links": { - "modmenu.curseforge": "${curseforge_page}", - "modmenu.modrinth": "${modrinth_page}" - } - } - } -} diff --git a/gradle.properties b/gradle.properties index a807b47..3c4ce97 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,13 @@ org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false + +mod_version = 0.3.0-pre.2 +maven_group = lgbt.greenhouse.menderman +mod_id = menderman + +minecraft_versions = 26.1, 26.1.1, 26.1.2 +friendly_minecraft_version = 26.1.x +curseforge_project_id = ?????? +modrinth_project_id = C7Hovsc7 + +git_commitish = 26.1.x diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2bd7c3c..c94e43f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -minecraft = "26.2" +minecraft = "26.1.2" # Xplat mixin = "0.17.3+mixin.0.8.7" @@ -10,9 +10,6 @@ fabric-loader = "0.19.3" fabric-api = "0.155.0+26.2" mod-menu = "20.0.1" -# NeoForge -neoforge = "26.2.0.15-beta" - # Dependencies greenhouse_config = "3.1.0+26.2.x" greenhouse_config_extensions_gamerules = "0.1.1+26.2.x" @@ -48,15 +45,12 @@ jei-common-api = { module = "mezz.jei:jei-26.2-common-api", version.ref = "jei" jei-common = { module = "mezz.jei:jei-26.2-common", version.ref = "jei" } jei-lib = { module = "mezz.jei:jei-26.2-lib", version.ref = "jei" } jei-fabric = { module = "mezz.jei:jei-26.2-fabric", version.ref = "jei" } -jei-neoforge = { module = "mezz.jei:jei-26.2-neoforge", version.ref = "jei" } # Bleh architectury = { module = "dev.architectury:architectury-fabric", version.ref = "architectury" } rei-fabric = { module = "me.shedaniel:RoughlyEnoughItems-fabric", version.ref = "rei" } -rei-neoforge = { module = "me.shedaniel:RoughlyEnoughItems-neoforge", version.ref = "rei" } rrv-fabric = { module = "cc.cassian.rrv:reliable-recipe-viewer-fabric", version.ref = "rrv" } -rrv-neoforge = { module = "cc.cassian.rrv:reliable-recipe-viewer-neoforge", version.ref = "rrv" } [plugins] loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" } diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts deleted file mode 100644 index 213e87d..0000000 --- a/neoforge/build.gradle.kts +++ /dev/null @@ -1,69 +0,0 @@ -import lgbt.greenhouse.menderman.gradle.Properties - -plugins { - id("lgbt.greenhouse.menderman.gradle.platform.neoforge") -} - -val xplatProject = project(":xplat") - -configurations { - getByName("testRuntimeClasspath") { - extendsFrom(configurations["localRuntime"]) - } -} - -neoForge { - mods { - register(Properties.MOD_ID) { - sourceSet(xplatProject.sourceSets["main"]) - sourceSet(sourceSets["main"]) - } - -// register("${Properties.MOD_ID}_gametest") { -// sourceSet(xplatProject.sourceSets["gametest"]) -// sourceSet(sourceSets["gametest"]) -// } - } - - runs { - configureEach { - tasksBefore.add(xplatProject.tasks.named("compileGametestJava")) - tasksBefore.add(xplatProject.tasks.named("processGametestResources")) - tasksBefore.add(tasks.named("compileGametestJava")) - tasksBefore.add(tasks.named("processGametestResources")) - - systemProperty("forge.logging.markers", "REGISTRIES") - systemProperty("forge.logging.console.level", "debug") - systemProperty("neoforge.enabledGameTestNamespaces", "${Properties.MOD_ID},${Properties.MOD_ID}_gametest") - } - register("client") { - client() - ideName = "NeoForge Client (:${project().name})" - gameDirectory.set(file("runs/client")) - sourceSet = sourceSets["main"] - jvmArguments.set(setOf("-Dmixin.debug.export=true")) - } - register("server") { - server() - ideName = "NeoForge Server (:${project().name})" - gameDirectory.set(file("runs/server")) - programArgument("--nogui") - sourceSet = sourceSets["main"] - jvmArguments.set(setOf("-Dmixin.debug.export=true")) - } -// create("gameTest") { -// server() -// type = "gameTestServer" -// ideName = "NeoForge Game Test (:${project().name})" -// gameDirectory.set(file("build/gametest")) -// programArgument("--nogui") -// sourceSet = sourceSets["gametest"] -// loadedMods = setOf( -// mods.getByName(Properties.MOD_ID), -// mods.getByName("${Properties.MOD_ID}_gametest") -// ) -// systemProperty("neoforge.enabledGameTestNamespaces", Properties.MOD_ID + "_gametest") -// } - - } -} diff --git a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/MendermanNeoForge.java b/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/MendermanNeoForge.java deleted file mode 100644 index bdbc382..0000000 --- a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/MendermanNeoForge.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.neoforge; - -import lgbt.greenhouse.menderman.Menderman; -import lgbt.greenhouse.menderman.api.gamerule.MendermanGamerules; -import lgbt.greenhouse.menderman.api.component.MendermanDataComponents; -import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; -import lgbt.greenhouse.menderman.world.item.MendermanDefaultComponents; -import lgbt.greenhouse.menderman.network.clientbound.SyncFallbackDataComponentsClientboundPacket; -import lgbt.greenhouse.menderman.network.clientbound.SyncGamerulesClientboundPacket; -import lgbt.greenhouse.menderman.network.clientbound.UpdateGameruleClientboundPacket; -import net.minecraft.core.registries.Registries; -import net.minecraft.server.level.ServerPlayer; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.neoforge.event.ModifyDefaultComponentsEvent; -import net.neoforged.neoforge.event.entity.player.PlayerEvent; -import net.neoforged.neoforge.event.server.ServerStartedEvent; -import net.neoforged.neoforge.event.server.ServerStoppingEvent; -import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; -import net.neoforged.neoforge.registries.RegisterEvent; - -@EventBusSubscriber(modid = Menderman.MOD_ID) -public class MendermanNeoForge { - @SubscribeEvent - public static void registerContent(RegisterEvent event) { - if (event.getRegistryKey().equals(Registries.DATA_COMPONENT_TYPE)) { - MendermanDataComponents.DEFERRED.registerContents(); - } - if (event.getRegistryKey().equals(Registries.GAME_RULE)) { - MendermanGamerules.DEFERRED.registerContents(); - } - } - - @SubscribeEvent - public static void onServerStart(ServerStartedEvent event) { - MendermanDefaultComponents.createFallbackRepairRequirements(event.getServer().overworld()); - } - - @SubscribeEvent - public static void onServerStop(ServerStoppingEvent event) { - MendermanDefaultComponents.resetFallbackRepairRequirements(); - } - - @SubscribeEvent - public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) { - if (event.getEntity() instanceof ServerPlayer player) { - MendermanDefaultComponents.syncFallbackRepairRequirements(player); - MendermanGamerulesInternal.syncGamerulesToPlayer(player); - } - } - - @SubscribeEvent - public static void modifyDefaultComponents(ModifyDefaultComponentsEvent event) { - event.modifyMatching((_, _) -> true, (builder, lookupProvider, item) -> { - MendermanDefaultComponents.modifyRepairRequirements(builder, lookupProvider, item); - MendermanDefaultComponents.modifyItemRepairMaterials(builder, lookupProvider, item); - }); - } - - @SubscribeEvent - public static void registerPayloadHandlers(RegisterPayloadHandlersEvent event) { - event.registrar("1.0.0") - .playToClient(SyncFallbackDataComponentsClientboundPacket.TYPE, SyncFallbackDataComponentsClientboundPacket.STREAM_CODEC) - .playToClient(SyncGamerulesClientboundPacket.TYPE, SyncGamerulesClientboundPacket.STREAM_CODEC) - .playToClient(UpdateGameruleClientboundPacket.TYPE, UpdateGameruleClientboundPacket.STREAM_CODEC); - } -} diff --git a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/client/MendermanClientNeoForge.java b/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/client/MendermanClientNeoForge.java deleted file mode 100644 index 926e2ae..0000000 --- a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/client/MendermanClientNeoForge.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.neoforge.client; - -import lgbt.greenhouse.menderman.Menderman; -import lgbt.greenhouse.menderman.client.network.MendermanClientNetworkHandlers; -import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; -import lgbt.greenhouse.menderman.network.clientbound.SyncFallbackDataComponentsClientboundPacket; -import lgbt.greenhouse.menderman.network.clientbound.SyncGamerulesClientboundPacket; -import lgbt.greenhouse.menderman.network.clientbound.UpdateGameruleClientboundPacket; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent; -import net.neoforged.neoforge.client.network.event.RegisterClientPayloadHandlersEvent; - -@Mod(Menderman.MOD_ID) -@EventBusSubscriber(modid = Menderman.MOD_ID, value = Dist.CLIENT) -public class MendermanClientNeoForge { - public MendermanClientNeoForge(IEventBus bus) { - MendermanGamerulesInternal.init(); - } - - @SubscribeEvent - public static void onLoggingOut(ClientPlayerNetworkEvent.LoggingOut event) { - MendermanGamerulesInternal.resetGameruleStorage(); - } - - @SubscribeEvent - public static void registerClientPayloadHandlers(RegisterClientPayloadHandlersEvent event) { - event.register(SyncFallbackDataComponentsClientboundPacket.TYPE, (packet, _) -> MendermanClientNetworkHandlers.handleFallbackComponentSync(packet)); - event.register(SyncGamerulesClientboundPacket.TYPE, (packet, _) -> MendermanClientNetworkHandlers.handleGameruleSync(packet)); - event.register(UpdateGameruleClientboundPacket.TYPE, (packet, _) -> MendermanClientNetworkHandlers.handleGameruleUpdate(packet)); - } -} diff --git a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/mixin/Mixin_AnvilMenu.java b/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/mixin/Mixin_AnvilMenu.java deleted file mode 100644 index 52cafc6..0000000 --- a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/mixin/Mixin_AnvilMenu.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.neoforge.mixin; - -import com.llamalad7.mixinextras.sugar.Local; -import com.llamalad7.mixinextras.sugar.Share; -import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; -import net.minecraft.world.inventory.AnvilMenu; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -@Mixin(AnvilMenu.class) -public class Mixin_AnvilMenu { - @Shadow - public int repairItemCountCost; - - @ModifyVariable(method = "createResultInternal", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/DataSlot;set(I)V", ordinal = 4), ordinal = 0) - private int menderman$cancelCostForChecksAfterRenaming(int original, @Local(ordinal = 1) int namingCost, @Share(namespace = "menderman", value = "renameOnly") LocalBooleanRef renameOnlyRef) { - if (renameOnlyRef.get() || repairItemCountCost > 0) { - return renameOnlyRef.get() ? namingCost : repairItemCountCost; - } - return original; - } -} diff --git a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/platform/MendermanPlatformHelperNeoForge.java b/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/platform/MendermanPlatformHelperNeoForge.java deleted file mode 100644 index 7b2f853..0000000 --- a/neoforge/src/main/java/lgbt/greenhouse/menderman/neoforge/platform/MendermanPlatformHelperNeoForge.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.neoforge.platform; - -import lgbt.greenhouse.menderman.platform.MendermanPlatformHelper; -import net.minecraft.core.Registry; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.Identifier; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; -import net.neoforged.fml.ModList; -import net.neoforged.fml.loading.FMLLoader; -import net.neoforged.neoforge.network.PacketDistributor; - -public class MendermanPlatformHelperNeoForge implements MendermanPlatformHelper { - @Override - public boolean isModLoaded(String modId) { - if (ModList.get() != null) { - return ModList.get().isLoaded(modId); - } - return FMLLoader.getCurrent() - .getLoadingModList() - .getMods() - .stream() - .anyMatch(modInfo -> modInfo.getModId().equals(modId)); - } - - @Override - public void aliasRegistryValue(Registry registry, Identifier from, Identifier to) { - registry.addAlias(from, to); - } - - @Override - public void sendPacketToPlayer(ServerPlayer player, CustomPacketPayload payload) { - PacketDistributor.sendToPlayer(player, payload); - } - - @Override - public void sendPacketsToAllServerPlayers(MinecraftServer server, CustomPacketPayload payload) { - PacketDistributor.sendToAllPlayers(payload); - } -} diff --git a/neoforge/src/main/resources/META-INF/jarjar/metadata.json b/neoforge/src/main/resources/META-INF/jarjar/metadata.json deleted file mode 100644 index 69eb16e..0000000 --- a/neoforge/src/main/resources/META-INF/jarjar/metadata.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "jars": [ - { - "identifier": { - "group": "lgbt.greenhouse.config", - "artifact": "greenhouse-config" - }, - "version": { - "range": "[${config_version},)", - "artifactVersion": "${config_version}" - }, - "path": "META-INF/jars/greenhouse-config-${config_version}.jar", - "isObfuscated": false - }, - { - "identifier": { - "group": "lgbt.greenhouse.config_extensions", - "artifact": "greenhouse-config-extensions-gamerules" - }, - "version": { - "range": "[${config_extensions_gamerules_version},)", - "artifactVersion": "${config_extensions_gamerules_version}" - }, - "path": "META-INF/jars/greenhouse-config-extensions-gamerules-${config_extensions_gamerules_version}.jar", - "isObfuscated": false - } - ] -} diff --git a/neoforge/src/main/resources/META-INF/neoforge.mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml deleted file mode 100644 index b57ab79..0000000 --- a/neoforge/src/main/resources/META-INF/neoforge.mods.toml +++ /dev/null @@ -1,35 +0,0 @@ -modLoader = "javafml" -loaderVersion = "${neoforge_loader_version_range}" -issueTrackerURL = "${sources}/issues" -license = "${mod_license}" - -[[mods]] -modId = "${mod_id}" -version = "${mod_version}+${minecraft_version}" -displayName = "${mod_name}" -logoFile = "${mod_id}.png" -logoBlur = false -authors = "${mod_author}" -credits = "${neoforge_mod_contributors}" -description = ''' -${mod_description} -''' - -[[mixins]] -config = "${mod_id}.mixins.json" -[[mixins]] -config = "${mod_id}.neoforge.mixins.json" - -[[dependencies.${ mod_id }]] -modId = "neoforge" -mandatory = true -versionRange = "${neoforge_version_range}" -ordering = "NONE" -side = "BOTH" - -[[dependencies.${ mod_id }]] -modId = "minecraft" -mandatory = true -versionRange = "${neoforge_minecraft_version_range}" -ordering = "NONE" -side = "BOTH" diff --git a/neoforge/src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json b/neoforge/src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json deleted file mode 100644 index 1462afc..0000000 --- a/neoforge/src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:netherite_scrap" - ], -} diff --git a/neoforge/src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json b/neoforge/src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json deleted file mode 100644 index 73213ea..0000000 --- a/neoforge/src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "replace": false, - "values": [ - "minecraft:netherite_scrap" - ], - "remove": [ - "minecraft:netherite_ingot" - ] -} diff --git a/neoforge/src/main/resources/menderman.neoforge.mixins.json b/neoforge/src/main/resources/menderman.neoforge.mixins.json deleted file mode 100644 index 3fe5549..0000000 --- a/neoforge/src/main/resources/menderman.neoforge.mixins.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "lgbt.greenhouse.menderman.neoforge.mixin", - "compatibilityLevel": "JAVA_25", - "mixins": [ - "Mixin_AnvilMenu" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/neoforge/src/testmod/resources/META-INF/neoforge.mods.toml b/neoforge/src/testmod/resources/META-INF/neoforge.mods.toml deleted file mode 100644 index 4dbe8fe..0000000 --- a/neoforge/src/testmod/resources/META-INF/neoforge.mods.toml +++ /dev/null @@ -1,28 +0,0 @@ -modLoader = "javafml" -loaderVersion = "${neoforge_loader_version_range}" -issueTrackerURL = "${sources}/issues" -license = "${mod_license}" - -[[mods]] -modId = "${mod_id}_test" -version = "${mod_version}+${minecraft_version}" -displayName = "${mod_name} Test" -authors = "${mod_author}" -credits = "${neoforge_mod_contributors}" -description = ''' -${mod_description} -''' - -[[dependencies.${ mod_id }]] -modId = "neoforge" -mandatory = true -versionRange = "${neoforge_loader_version_range}" -ordering = "NONE" -side = "BOTH" - -[[dependencies.${ mod_id }]] -modId = "minecraft" -mandatory = true -versionRange = "${neoforge_minecraft_version_range}" -ordering = "NONE" -side = "BOTH" diff --git a/settings.gradle.kts b/settings.gradle.kts index 8a65b47..04bda7f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,5 +26,3 @@ plugins { // This should match the folder name of the project, or else IDEA may complain (see https://youtrack.jetbrains.com/issue/IDEA-317606) rootProject.name = "menderman" -includeBuild("build_logic") -include("xplat", "fabric") diff --git a/fabric/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator.java b/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator.java similarity index 91% rename from fabric/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator.java rename to src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator.java index 891a5ac..1ec39e4 100644 --- a/fabric/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator.java +++ b/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.datagen; diff --git a/fabric/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator_TagsProvider_Multiver.java b/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator_TagsProvider_Multiver.java similarity index 82% rename from fabric/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator_TagsProvider_Multiver.java rename to src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator_TagsProvider_Multiver.java index 5afbee9..47e3b6f 100644 --- a/fabric/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator_TagsProvider_Multiver.java +++ b/src/datagen/java/lgbt/greenhouse/menderman/datagen/MendermanDataGenerator_TagsProvider_Multiver.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.datagen; diff --git a/src/datagen/resources/fabric.mod.json b/src/datagen/resources/fabric.mod.json new file mode 100644 index 0000000..87caf43 --- /dev/null +++ b/src/datagen/resources/fabric.mod.json @@ -0,0 +1,43 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}_datagen", + "version": "${mod_version}+${minecraft_version}", + "name": "${mod_name} Datagen", + "description": "Minor repairing reworks for the anvil.", + "authors": [ + "Vulpixel", + "MerchantCalico" + ], + "contributors": [ + "MerchantCalico", + "Sylv " + ], + "contact": { + "homepage": "https://vulpixel.org/", + "issues": "https://tangled.org/vulpixel.org/enchiridion/issues", + "sources": "https://tangled.org/vulpixel.org/enchiridion" + }, + "license": "NON-AI-MPL-2.0", + "icon": "assets/${mod_id}/icon.png", + "environment": "*", + "entrypoints": { + "fabric-datagen": [ + "lgbt.greenhouse.menderman.datagen.MendermanDataGenerator" + ] + }, + "depends": { + "fabricloader": ">=0.19", + "fabric-api": ">=0.149.1", + "minecraft": "~26.1", + "java": ">=25" + }, + "custom": { + "modmenu": { + "links": { + "modmenu.curseforge": "https://curseforge.com/minecraft/mc-mods/enchiridion-enchanting", + "modmenu.modrinth": "https://modrinth.com/project/enchiridion", + "modmenu.kofi": "https://ko-fi.com/sylv256" + } + } + } +} diff --git a/xplat/src/generated/resources/data/menderman/tags/item/bow_materials.json b/src/main/generated/resources/data/menderman/tags/item/bow_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/bow_materials.json rename to src/main/generated/resources/data/menderman/tags/item/bow_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/brush_materials.json b/src/main/generated/resources/data/menderman/tags/item/brush_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/brush_materials.json rename to src/main/generated/resources/data/menderman/tags/item/brush_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/carrot_on_a_stick_materials.json b/src/main/generated/resources/data/menderman/tags/item/carrot_on_a_stick_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/carrot_on_a_stick_materials.json rename to src/main/generated/resources/data/menderman/tags/item/carrot_on_a_stick_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/crossbow_materials.json b/src/main/generated/resources/data/menderman/tags/item/crossbow_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/crossbow_materials.json rename to src/main/generated/resources/data/menderman/tags/item/crossbow_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/elytra_materials.json b/src/main/generated/resources/data/menderman/tags/item/elytra_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/elytra_materials.json rename to src/main/generated/resources/data/menderman/tags/item/elytra_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/fishing_rod_materials.json b/src/main/generated/resources/data/menderman/tags/item/fishing_rod_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/fishing_rod_materials.json rename to src/main/generated/resources/data/menderman/tags/item/fishing_rod_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/flint_and_steel_materials.json b/src/main/generated/resources/data/menderman/tags/item/flint_and_steel_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/flint_and_steel_materials.json rename to src/main/generated/resources/data/menderman/tags/item/flint_and_steel_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/mace_materials.json b/src/main/generated/resources/data/menderman/tags/item/mace_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/mace_materials.json rename to src/main/generated/resources/data/menderman/tags/item/mace_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/shears_materials.json b/src/main/generated/resources/data/menderman/tags/item/shears_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/shears_materials.json rename to src/main/generated/resources/data/menderman/tags/item/shears_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/shield_materials.json b/src/main/generated/resources/data/menderman/tags/item/shield_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/shield_materials.json rename to src/main/generated/resources/data/menderman/tags/item/shield_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/trident_materials.json b/src/main/generated/resources/data/menderman/tags/item/trident_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/trident_materials.json rename to src/main/generated/resources/data/menderman/tags/item/trident_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/turtle_helmet_materials.json b/src/main/generated/resources/data/menderman/tags/item/turtle_helmet_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/turtle_helmet_materials.json rename to src/main/generated/resources/data/menderman/tags/item/turtle_helmet_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/warped_fungus_on_a_stick_materials.json b/src/main/generated/resources/data/menderman/tags/item/warped_fungus_on_a_stick_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/warped_fungus_on_a_stick_materials.json rename to src/main/generated/resources/data/menderman/tags/item/warped_fungus_on_a_stick_materials.json diff --git a/xplat/src/generated/resources/data/menderman/tags/item/wolf_armor_materials.json b/src/main/generated/resources/data/menderman/tags/item/wolf_armor_materials.json similarity index 100% rename from xplat/src/generated/resources/data/menderman/tags/item/wolf_armor_materials.json rename to src/main/generated/resources/data/menderman/tags/item/wolf_armor_materials.json diff --git a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/MendermanFabric.java b/src/main/java/lgbt/greenhouse/menderman/Menderman.java similarity index 50% rename from fabric/src/main/java/lgbt/greenhouse/menderman/fabric/MendermanFabric.java rename to src/main/java/lgbt/greenhouse/menderman/Menderman.java index 87025de..6e44ca5 100644 --- a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/MendermanFabric.java +++ b/src/main/java/lgbt/greenhouse/menderman/Menderman.java @@ -1,27 +1,40 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ -package lgbt.greenhouse.menderman.fabric; +package lgbt.greenhouse.menderman; -import lgbt.greenhouse.menderman.api.gamerule.MendermanGamerules; +import lgbt.greenhouse.config.api.v3.GreenhouseConfigHolder; +import lgbt.greenhouse.config.api.v3.GreenhouseConfigSide; +import lgbt.greenhouse.config.api.v3.lang.GreenhouseConfigJsonCLang; import lgbt.greenhouse.menderman.api.component.MendermanDataComponents; -import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; -import lgbt.greenhouse.menderman.world.item.MendermanDefaultComponents; +import lgbt.greenhouse.menderman.api.config.MendermanConfig; +import lgbt.greenhouse.menderman.api.config.MendermanGameruleConfig; +import lgbt.greenhouse.menderman.api.gamerule.MendermanGamerules; import lgbt.greenhouse.menderman.network.clientbound.SyncFallbackDataComponentsClientboundPacket; import lgbt.greenhouse.menderman.network.clientbound.SyncGamerulesClientboundPacket; import lgbt.greenhouse.menderman.network.clientbound.UpdateGameruleClientboundPacket; +import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; +import lgbt.greenhouse.menderman.world.item.MendermanDefaultComponents; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.item.v1.DefaultItemComponentEvents; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; +import net.minecraft.resources.Identifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Menderman implements ModInitializer { + public static final String MOD_ID = "menderman"; + public static final String MOD_NAME = "Menderman"; + public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); -public class MendermanFabric implements ModInitializer { @Override public void onInitialize() { MendermanGamerules.DEFERRED.registerContents(); @@ -49,4 +62,30 @@ public class MendermanFabric implements ModInitializer { PayloadTypeRegistry.clientboundPlay().register(SyncGamerulesClientboundPacket.TYPE, SyncGamerulesClientboundPacket.STREAM_CODEC); PayloadTypeRegistry.clientboundPlay().register(UpdateGameruleClientboundPacket.TYPE, UpdateGameruleClientboundPacket.STREAM_CODEC); } + + public static final GreenhouseConfigHolder CONFIG = GreenhouseConfigHolder.register( + MendermanConfig.class, + MOD_ID, + 1, + GreenhouseConfigJsonCLang.INSTANCE, + GreenhouseConfigSide.COMMON, + builder -> builder + .withMapValue( + MendermanGameruleConfig.class, + "gamerules", + """ + Default values for Menderman's gamerules. + + Can be modified on a per world basis via the gamerule screen + or the /gamerule command.""", + MendermanConfig::gamerules, + MendermanGameruleConfig::configBuilder + ) + ); + + public static boolean shouldNotDamageAnvil = false; + + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(MOD_ID, path); + } } diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/MendermanCompatibilityKeys.java b/src/main/java/lgbt/greenhouse/menderman/MendermanCompatibilityKeys.java similarity index 82% rename from xplat/src/main/java/lgbt/greenhouse/menderman/MendermanCompatibilityKeys.java rename to src/main/java/lgbt/greenhouse/menderman/MendermanCompatibilityKeys.java index 134d12d..0f0cb77 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/MendermanCompatibilityKeys.java +++ b/src/main/java/lgbt/greenhouse/menderman/MendermanCompatibilityKeys.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/MendermanMixinConfigPlugin.java b/src/main/java/lgbt/greenhouse/menderman/MendermanMixinConfigPlugin.java similarity index 75% rename from xplat/src/main/java/lgbt/greenhouse/menderman/MendermanMixinConfigPlugin.java rename to src/main/java/lgbt/greenhouse/menderman/MendermanMixinConfigPlugin.java index 3d2dcf1..3537b23 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/MendermanMixinConfigPlugin.java +++ b/src/main/java/lgbt/greenhouse/menderman/MendermanMixinConfigPlugin.java @@ -1,14 +1,15 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman; -import lgbt.greenhouse.menderman.platform.MendermanPlatformHelper; +import net.fabricmc.loader.api.FabricLoader; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -33,7 +34,7 @@ public class MendermanMixinConfigPlugin implements IMixinConfigPlugin { public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { if (mixinClassName.startsWith(INTEGRATION_MIXIN_PACKAGE)) { String modId = mixinClassName.substring(INTEGRATION_MIXIN_PACKAGE.length()).split("\\.", 2)[0]; - return Menderman.getPlatformHelper().isModLoaded(modId); + return FabricLoader.getInstance().isModLoaded(modId); } return true; } diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/MendermanTags.java b/src/main/java/lgbt/greenhouse/menderman/MendermanTags.java similarity index 86% rename from xplat/src/main/java/lgbt/greenhouse/menderman/MendermanTags.java rename to src/main/java/lgbt/greenhouse/menderman/MendermanTags.java index 9ed5472..09a265d 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/MendermanTags.java +++ b/src/main/java/lgbt/greenhouse/menderman/MendermanTags.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/api/MendermanRepairHelper.java b/src/main/java/lgbt/greenhouse/menderman/api/MendermanRepairHelper.java similarity index 90% rename from xplat/src/main/java/lgbt/greenhouse/menderman/api/MendermanRepairHelper.java rename to src/main/java/lgbt/greenhouse/menderman/api/MendermanRepairHelper.java index e80b282..1b43df4 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/api/MendermanRepairHelper.java +++ b/src/main/java/lgbt/greenhouse/menderman/api/MendermanRepairHelper.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.api; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/api/component/MendermanDataComponents.java b/src/main/java/lgbt/greenhouse/menderman/api/component/MendermanDataComponents.java similarity index 72% rename from xplat/src/main/java/lgbt/greenhouse/menderman/api/component/MendermanDataComponents.java rename to src/main/java/lgbt/greenhouse/menderman/api/component/MendermanDataComponents.java index 21fa0ee..be251fc 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/api/component/MendermanDataComponents.java +++ b/src/main/java/lgbt/greenhouse/menderman/api/component/MendermanDataComponents.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.api.component; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/api/component/RepairRequirements.java b/src/main/java/lgbt/greenhouse/menderman/api/component/RepairRequirements.java similarity index 88% rename from xplat/src/main/java/lgbt/greenhouse/menderman/api/component/RepairRequirements.java rename to src/main/java/lgbt/greenhouse/menderman/api/component/RepairRequirements.java index bf182d6..1838bcb 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/api/component/RepairRequirements.java +++ b/src/main/java/lgbt/greenhouse/menderman/api/component/RepairRequirements.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.api.component; diff --git a/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanConfig.java b/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanConfig.java new file mode 100644 index 0000000..99b491c --- /dev/null +++ b/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanConfig.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2026 Vulpixel , Greenhouse Modding + * + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. + */ + +package lgbt.greenhouse.menderman.api.config; + +public record MendermanConfig(MendermanGameruleConfig gamerules) { +} diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanGameruleConfig.java b/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanGameruleConfig.java similarity index 82% rename from xplat/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanGameruleConfig.java rename to src/main/java/lgbt/greenhouse/menderman/api/config/MendermanGameruleConfig.java index a2dc545..f56f897 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanGameruleConfig.java +++ b/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanGameruleConfig.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.api.config; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/api/gamerule/MendermanGamerules.java b/src/main/java/lgbt/greenhouse/menderman/api/gamerule/MendermanGamerules.java similarity index 91% rename from xplat/src/main/java/lgbt/greenhouse/menderman/api/gamerule/MendermanGamerules.java rename to src/main/java/lgbt/greenhouse/menderman/api/gamerule/MendermanGamerules.java index 88fc81b..2220403 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/api/gamerule/MendermanGamerules.java +++ b/src/main/java/lgbt/greenhouse/menderman/api/gamerule/MendermanGamerules.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.api.gamerule; @@ -62,8 +63,7 @@ public class MendermanGamerules { ); public static void init() { - Menderman.getPlatformHelper().aliasRegistryValue( - BuiltInRegistries.GAME_RULE, + BuiltInRegistries.GAME_RULE.addAlias( Menderman.id("compounding_repair_cost"), Menderman.id("compounding_repair_costs") ); diff --git a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/client/MendermanClientFabric.java b/src/main/java/lgbt/greenhouse/menderman/client/MendermanClient.java similarity index 65% rename from fabric/src/main/java/lgbt/greenhouse/menderman/fabric/client/MendermanClientFabric.java rename to src/main/java/lgbt/greenhouse/menderman/client/MendermanClient.java index eb8169a..7087d52 100644 --- a/fabric/src/main/java/lgbt/greenhouse/menderman/fabric/client/MendermanClientFabric.java +++ b/src/main/java/lgbt/greenhouse/menderman/client/MendermanClient.java @@ -1,32 +1,33 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ -package lgbt.greenhouse.menderman.fabric.client; +package lgbt.greenhouse.menderman.client; import lgbt.greenhouse.menderman.client.network.MendermanClientNetworkHandlers; -import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; -import lgbt.greenhouse.menderman.world.item.MendermanDefaultComponents; import lgbt.greenhouse.menderman.network.clientbound.SyncFallbackDataComponentsClientboundPacket; import lgbt.greenhouse.menderman.network.clientbound.SyncGamerulesClientboundPacket; import lgbt.greenhouse.menderman.network.clientbound.UpdateGameruleClientboundPacket; +import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; +import lgbt.greenhouse.menderman.world.item.MendermanDefaultComponents; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -public class MendermanClientFabric implements ClientModInitializer { +public class MendermanClient implements ClientModInitializer { @Override public void onInitializeClient() { - MendermanGamerulesInternal.init(); + MendermanGamerulesInternal.clientInit(); ClientPlayConnectionEvents.DISCONNECT.register((_, _) -> { MendermanDefaultComponents.resetFallbackRepairRequirements(); - MendermanGamerulesInternal.resetGameruleStorage(); + MendermanGamerulesInternal.resetClientGameruleStorage(); }); ClientPlayNetworking.registerGlobalReceiver(SyncFallbackDataComponentsClientboundPacket.TYPE, diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/client/MendermanLangHelper.java b/src/main/java/lgbt/greenhouse/menderman/client/MendermanLangHelper.java similarity index 72% rename from xplat/src/main/java/lgbt/greenhouse/menderman/client/MendermanLangHelper.java rename to src/main/java/lgbt/greenhouse/menderman/client/MendermanLangHelper.java index 34c1712..be2a7c6 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/client/MendermanLangHelper.java +++ b/src/main/java/lgbt/greenhouse/menderman/client/MendermanLangHelper.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.client; @@ -18,7 +19,7 @@ public class MendermanLangHelper { private static ClientLanguage defaultLang; private static ClientLanguage currentLangWithoutDefault; - public static void checkForSpecificLangEntry(ResourceManager manager, String langCode) { + public static void checkLangEntry(ResourceManager manager, String langCode) { if (defaultLang == null) { // We check en_us to automatically handle other shared key languages. defaultLang = ClientLanguage.loadFrom(manager, List.of("en_us"), false); } diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/client/network/MendermanClientNetworkHandlers.java b/src/main/java/lgbt/greenhouse/menderman/client/network/MendermanClientNetworkHandlers.java similarity index 78% rename from xplat/src/main/java/lgbt/greenhouse/menderman/client/network/MendermanClientNetworkHandlers.java rename to src/main/java/lgbt/greenhouse/menderman/client/network/MendermanClientNetworkHandlers.java index 79a41e4..7fa2648 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/client/network/MendermanClientNetworkHandlers.java +++ b/src/main/java/lgbt/greenhouse/menderman/client/network/MendermanClientNetworkHandlers.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.client.network; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/integration/MendermanRecipeViewerHelper.java b/src/main/java/lgbt/greenhouse/menderman/integration/MendermanRecipeViewerHelper.java similarity index 83% rename from xplat/src/main/java/lgbt/greenhouse/menderman/integration/MendermanRecipeViewerHelper.java rename to src/main/java/lgbt/greenhouse/menderman/integration/MendermanRecipeViewerHelper.java index 20a98a2..9e398e6 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/integration/MendermanRecipeViewerHelper.java +++ b/src/main/java/lgbt/greenhouse/menderman/integration/MendermanRecipeViewerHelper.java @@ -1,14 +1,16 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.integration; import lgbt.greenhouse.menderman.Menderman; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponents; @@ -26,7 +28,7 @@ public class MendermanRecipeViewerHelper { public static boolean hasRecipeViewer() { return RECIPE_VIEWERS_WITH_REPAIR_RECIPES.stream().anyMatch(string -> - Menderman.getPlatformHelper().isModLoaded(string)); + FabricLoader.getInstance().isModLoaded(string)); } public static void specifyAsMendermanRepairableItem(Item item) { diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/integration/jei/MendermanJeiHelper.java b/src/main/java/lgbt/greenhouse/menderman/integration/jei/MendermanJeiHelper.java similarity index 93% rename from xplat/src/main/java/lgbt/greenhouse/menderman/integration/jei/MendermanJeiHelper.java rename to src/main/java/lgbt/greenhouse/menderman/integration/jei/MendermanJeiHelper.java index ed2b54b..10de7b2 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/integration/jei/MendermanJeiHelper.java +++ b/src/main/java/lgbt/greenhouse/menderman/integration/jei/MendermanJeiHelper.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ /** diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/integration/rei/MendermanReiClientPlugin.java b/src/main/java/lgbt/greenhouse/menderman/integration/rei/MendermanReiClientPlugin.java similarity index 95% rename from xplat/src/main/java/lgbt/greenhouse/menderman/integration/rei/MendermanReiClientPlugin.java rename to src/main/java/lgbt/greenhouse/menderman/integration/rei/MendermanReiClientPlugin.java index 1ad98af..fe873c8 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/integration/rei/MendermanReiClientPlugin.java +++ b/src/main/java/lgbt/greenhouse/menderman/integration/rei/MendermanReiClientPlugin.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.integration.rei; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_AnvilMenu.java b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_AnvilMenu.java similarity index 65% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_AnvilMenu.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_AnvilMenu.java index 6f7c871..51b320c 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_AnvilMenu.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_AnvilMenu.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin; @@ -46,22 +47,30 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { } @ModifyExpressionValue(method = "mayPickup", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/DataSlot;get()I", ordinal = 1)) - private int menderman$allowPickingUpForZeroCostActions(int original, @Local(argsOnly = true) boolean hasItem) { + private int menderman$allowPickingUpForZeroCostActions(int original, @Local(argsOnly = true, name = "hasItem") boolean hasItem) { if (original == 0 && hasItem) { return Integer.MAX_VALUE; } return original; } - @ModifyVariable(method = {"createResult", "createResultInternal"}, at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I"), name = "price") - private int menderman$modifyRepairExperienceCost(int price, @Local(ordinal = 0) ItemStack input, @Local(ordinal = 2) ItemStack addition) { + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/DataSlot;set(I)V", ordinal = 5), name = "price") + private int menderman$cancelCostForChecksAfterRenaming(int price, @Local(name = "namingCost") int namingCost, @Share(namespace = "menderman", value = "renameOnly") LocalBooleanRef renameOnlyRef) { + if (renameOnlyRef.get() || repairItemCountCost > 0) { + return renameOnlyRef.get() ? namingCost : repairItemCountCost; + } + return price; + } + + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(II)I"), name = "price") + private int menderman$modifyRepairExperienceCost(int price, @Local(name = "input") ItemStack input, @Local(name = "addition") ItemStack addition) { if (!MendermanGamerules.doesRepairingCostExperience(player.level())) { return 0; } return MendermanRepairHelper.getRepairItemCount(input, addition); } - @Inject(method = { "createResult", "createResultInternal" }, at = @At(value = "FIELD", target = "Lnet/minecraft/world/inventory/AnvilMenu;repairItemCountCost:I", ordinal = 1, shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD)) + @Inject(method = "createResult", at = @At(value = "FIELD", target = "Lnet/minecraft/world/inventory/AnvilMenu;repairItemCountCost:I", ordinal = 1, shift = At.Shift.AFTER, opcode = Opcodes.PUTFIELD)) private void menderman$modifyRepairMaterialCost(CallbackInfo ci, @Local(name = "input") ItemStack input, @Local(name = "result") ItemStack result, @Local(name = "addition") ItemStack addition) { OptionalInt repairRequirementAmount = MendermanRepairHelper.getRepairRequirementsRepairAmount(input, addition); if (repairRequirementAmount.isPresent()) { @@ -70,7 +79,7 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { repairItemCountCost = Math.min(repairItemCountCost, MendermanRepairHelper.getRepairItemCount(input, addition)); } - @ModifyVariable(method = { "createResult", "createResultInternal" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getDamageValue()I", ordinal = 5), name = "resultDamage") + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;getDamageValue()I", ordinal = 5), name = "resultDamage") private int menderman$modifyItemCombiningRepairValue(int resultDamage, @Local(name = "input") ItemStack input, @Local(name = "addition") ItemStack otherInput) { if (input.has(MendermanDataComponents.REPAIR_REQUIREMENTS.get())) { return MendermanRepairHelper.getRepairRequirementsCombineAmount( @@ -81,7 +90,7 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { return resultDamage; } - @ModifyExpressionValue(method = { "createResult", "createResultInternal" }, at = @At(value = "INVOKE", target = "Ljava/lang/Integer;intValue()I")) + @ModifyExpressionValue(method = "createResult", at = @At(value = "INVOKE", target = "Ljava/lang/Integer;intValue()I")) private int menderman$cancelIncreasedRepairCostStarting(int original) { if (!MendermanGamerules.compoundingRepairCost(player.level())) { return 0; @@ -89,7 +98,7 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { return original; } - @ModifyVariable(method = { "createResult", "createResultInternal" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;set(Lnet/minecraft/core/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 1), name = "finalPrice") + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;set(Lnet/minecraft/core/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 1), name = "finalPrice") private int menderman$cancelIncreasedRepairCostBeforeRepairCost(int finalPrice) { if (!MendermanGamerules.compoundingRepairCost(player.level())) { return 0; @@ -98,12 +107,12 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { } @SuppressWarnings("WrapWithConditionTargetsNonVoid") - @WrapWithCondition(method = { "createResult", "createResultInternal" }, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;set(Lnet/minecraft/core/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 1)) + @WrapWithCondition(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;set(Lnet/minecraft/core/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 1)) private boolean menderman$cancelSettingItemRepairCost(ItemStack instance, DataComponentType type, Object value) { return MendermanGamerules.compoundingRepairCost(player.level()); } - @ModifyVariable(method = {"createResult", "createResultInternal"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;setDamageValue(I)V"), name = "price") + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;setDamageValue(I)V"), name = "price") private int menderman$decreaseCombiningCost(int price, @Local(name = "input") ItemStack input) { if (!MendermanGamerules.doesRepairingCostExperience(player.level())) { return price - 2; @@ -114,7 +123,7 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { return price; } - @ModifyVariable(method = {"createResult", "createResultInternal"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;set(Lnet/minecraft/core/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0), name = "price") + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;set(Lnet/minecraft/core/component/DataComponentType;Ljava/lang/Object;)Ljava/lang/Object;", ordinal = 0), name = "price") private int menderman$cancelRenamingCost(int price, @Local(name = "namingCost") int namingCost, @Share(namespace = "menderman", value = "renameOnly") LocalBooleanRef renameOnlyRef) { if (!MendermanGamerules.doesRenameCostExperience(player.level())) { renameOnlyRef.set(price == namingCost); @@ -123,7 +132,7 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { return price; } - @ModifyVariable(method = {"createResult", "createResultInternal"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;remove(Lnet/minecraft/core/component/DataComponentType;)Ljava/lang/Object;"), name = "price") + @ModifyVariable(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;remove(Lnet/minecraft/core/component/DataComponentType;)Ljava/lang/Object;"), name = "price") private int menderman$cancelNameRemovalCost(int price, @Local(name = "namingCost") int namingCost, @Share(namespace = "menderman", value = "renameOnly") LocalBooleanRef renameOnlyRef) { if (!MendermanGamerules.doesRenameCostExperience(player.level())) { renameOnlyRef.set(price == namingCost); @@ -132,7 +141,7 @@ public abstract class Mixin_AnvilMenu extends ItemCombinerMenu { return price; } - @ModifyExpressionValue(method = { "createResult", "createResultInternal" }, at = @At(value = "FIELD", target = "Lnet/minecraft/world/item/ItemStack;EMPTY:Lnet/minecraft/world/item/ItemStack;", ordinal = 4, opcode = Opcodes.GETSTATIC)) + @ModifyExpressionValue(method = "createResult", at = @At(value = "FIELD", target = "Lnet/minecraft/world/item/ItemStack;EMPTY:Lnet/minecraft/world/item/ItemStack;", ordinal = 4, opcode = Opcodes.GETSTATIC)) private ItemStack menderman$dontSetAnvilResultToEmpty(ItemStack original, @Local(name = "input") ItemStack input, @Local(name = "result") ItemStack result, @Local(name = "price") int price) { if (price == 0 && !ItemStack.isSameItemSameComponents(input, result)) { return result; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GameRuleRegistryFix.java b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GameRuleRegistryFix.java similarity index 80% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GameRuleRegistryFix.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GameRuleRegistryFix.java index e465111..3d6c93c 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GameRuleRegistryFix.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GameRuleRegistryFix.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GrindstoneMenu.java b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GrindstoneMenu.java similarity index 88% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GrindstoneMenu.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GrindstoneMenu.java index 65ebad0..64f81a5 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GrindstoneMenu.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_GrindstoneMenu.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_MinecraftServer.java b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_MinecraftServer.java similarity index 57% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_MinecraftServer.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_MinecraftServer.java index e1111ae..ffc6eda 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_MinecraftServer.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/Mixin_MinecraftServer.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin; @@ -11,19 +12,28 @@ package lgbt.greenhouse.menderman.mixin; import lgbt.greenhouse.menderman.Menderman; import lgbt.greenhouse.menderman.world.gamerule.MendermanGamerulesInternal; import lgbt.greenhouse.menderman.network.clientbound.UpdateGameruleClientboundPacket; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.players.PlayerList; import net.minecraft.world.level.gamerules.GameRule; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(MinecraftServer.class) -public class Mixin_MinecraftServer { +public abstract class Mixin_MinecraftServer { + @Shadow + public abstract PlayerList getPlayerList(); + @Inject(method = "onGameRuleChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/notifications/NotificationManager;onGameRuleChanged(Lnet/minecraft/world/level/gamerules/GameRule;Ljava/lang/Object;)V", shift = At.Shift.AFTER), cancellable = true) private void menderman$onGameRuleChanged(GameRule rule, T value, CallbackInfo ci) { if (MendermanGamerulesInternal.isMendermanGameRule(rule) && value instanceof Boolean bool) { - Menderman.getPlatformHelper().sendPacketsToAllServerPlayers((MinecraftServer)(Object)this, new UpdateGameruleClientboundPacket(rule.getIdentifier(), bool)); + for (ServerPlayer player : getPlayerList().getPlayers()) { + ServerPlayNetworking.send(player, new UpdateGameruleClientboundPacket(rule.getIdentifier(), bool)); + } ci.cancel(); } } diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_AnvilScreen.java b/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_AnvilScreen.java similarity index 84% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_AnvilScreen.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_AnvilScreen.java index e706035..c9212e8 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_AnvilScreen.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_AnvilScreen.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.client; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_LanguageManager.java b/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_LanguageManager.java similarity index 67% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_LanguageManager.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_LanguageManager.java index a0ffea4..e407ffd 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_LanguageManager.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/client/Mixin_LanguageManager.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.client; @@ -24,6 +25,6 @@ public class Mixin_LanguageManager { @Inject(method = "onResourceManagerReload", at = @At("TAIL")) private void menderman$reloadLangHelper(ResourceManager resourceManager, CallbackInfo ci) { - MendermanLangHelper.checkForSpecificLangEntry(resourceManager, currentCode); + MendermanLangHelper.checkLangEntry(resourceManager, currentCode); } } diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeCategory.java b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeCategory.java similarity index 92% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeCategory.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeCategory.java index c2bd7c4..3084eb7 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeCategory.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeCategory.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.integration.jei; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeMaker.java b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeMaker.java similarity index 83% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeMaker.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeMaker.java index c428ee6..b71c5db 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeMaker.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_AnvilRecipeMaker.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.integration.jei; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_IRecipeCategory.java b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_IRecipeCategory.java similarity index 87% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_IRecipeCategory.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_IRecipeCategory.java index 38d736a..9508587 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_IRecipeCategory.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/jei/Mixin_IRecipeCategory.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.integration.jei; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DefaultAnvilCategory.java b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DefaultAnvilCategory.java similarity index 88% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DefaultAnvilCategory.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DefaultAnvilCategory.java index 76f129b..7e72569 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DefaultAnvilCategory.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DefaultAnvilCategory.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.integration.roughlyenoughitems; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DisplaysHolderImpl.java b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DisplaysHolderImpl.java similarity index 76% rename from xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DisplaysHolderImpl.java rename to src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DisplaysHolderImpl.java index 9124911..a09fdf1 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DisplaysHolderImpl.java +++ b/src/main/java/lgbt/greenhouse/menderman/mixin/integration/roughlyenoughitems/Mixin_DisplaysHolderImpl.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.mixin.integration.roughlyenoughitems; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncFallbackDataComponentsClientboundPacket.java b/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncFallbackDataComponentsClientboundPacket.java similarity index 82% rename from xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncFallbackDataComponentsClientboundPacket.java rename to src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncFallbackDataComponentsClientboundPacket.java index 40e32c4..df37966 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncFallbackDataComponentsClientboundPacket.java +++ b/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncFallbackDataComponentsClientboundPacket.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.network.clientbound; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncGamerulesClientboundPacket.java b/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncGamerulesClientboundPacket.java similarity index 79% rename from xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncGamerulesClientboundPacket.java rename to src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncGamerulesClientboundPacket.java index b4c7f3a..79248c4 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncGamerulesClientboundPacket.java +++ b/src/main/java/lgbt/greenhouse/menderman/network/clientbound/SyncGamerulesClientboundPacket.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.network.clientbound; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/UpdateGameruleClientboundPacket.java b/src/main/java/lgbt/greenhouse/menderman/network/clientbound/UpdateGameruleClientboundPacket.java similarity index 78% rename from xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/UpdateGameruleClientboundPacket.java rename to src/main/java/lgbt/greenhouse/menderman/network/clientbound/UpdateGameruleClientboundPacket.java index 98ee698..db4db2d 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/network/clientbound/UpdateGameruleClientboundPacket.java +++ b/src/main/java/lgbt/greenhouse/menderman/network/clientbound/UpdateGameruleClientboundPacket.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.network.clientbound; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredRegistry.java b/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredRegistry.java similarity index 82% rename from xplat/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredRegistry.java rename to src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredRegistry.java index 3823b8e..91b2c05 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredRegistry.java +++ b/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredRegistry.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.registry; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredValue.java b/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredValue.java similarity index 78% rename from xplat/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredValue.java rename to src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredValue.java index 0cd0da4..d2df6ab 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredValue.java +++ b/src/main/java/lgbt/greenhouse/menderman/registry/MendermanDeferredValue.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.registry; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/util/multiver/ItemsOrIds.java b/src/main/java/lgbt/greenhouse/menderman/util/multiver/ItemsOrIds.java similarity index 80% rename from xplat/src/main/java/lgbt/greenhouse/menderman/util/multiver/ItemsOrIds.java rename to src/main/java/lgbt/greenhouse/menderman/util/multiver/ItemsOrIds.java index ba087ac..d89a453 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/util/multiver/ItemsOrIds.java +++ b/src/main/java/lgbt/greenhouse/menderman/util/multiver/ItemsOrIds.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.util.multiver; diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/world/gamerule/MendermanGamerulesInternal.java b/src/main/java/lgbt/greenhouse/menderman/world/gamerule/MendermanGamerulesInternal.java similarity index 87% rename from xplat/src/main/java/lgbt/greenhouse/menderman/world/gamerule/MendermanGamerulesInternal.java rename to src/main/java/lgbt/greenhouse/menderman/world/gamerule/MendermanGamerulesInternal.java index 4a6a4b7..e1745f9 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/world/gamerule/MendermanGamerulesInternal.java +++ b/src/main/java/lgbt/greenhouse/menderman/world/gamerule/MendermanGamerulesInternal.java @@ -1,17 +1,18 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.world.gamerule; import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; -import lgbt.greenhouse.menderman.Menderman; import lgbt.greenhouse.menderman.api.gamerule.MendermanGamerules; import lgbt.greenhouse.menderman.network.clientbound.SyncGamerulesClientboundPacket; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -31,7 +32,7 @@ public class MendermanGamerulesInternal { return CLIENT_GAMERULE_STORAGE.containsKey(gameRule.getIdentifier()); } - public static void init() { + public static void clientInit() { CLIENT_GAMERULE_STORAGE.put(MendermanGamerules.COMPOUNDING_REPAIR_COSTS.key().identifier(), false); CLIENT_GAMERULE_STORAGE.put(MendermanGamerules.RENAMING_CAN_DAMAGE_ANVIL.key().identifier(), false); CLIENT_GAMERULE_STORAGE.put(MendermanGamerules.RENAMING_COSTS_EXPERIENCE.key().identifier(), false); @@ -42,7 +43,7 @@ public class MendermanGamerulesInternal { CLIENT_GAMERULE_STORAGE.put(id, value); } - public static void resetGameruleStorage() { + public static void resetClientGameruleStorage() { var newMap = CLIENT_GAMERULE_STORAGE.keySet() .stream() .collect(Collectors.toMap(o -> o, o -> false, (_, _) -> false)); @@ -51,7 +52,7 @@ public class MendermanGamerulesInternal { } public static void syncGamerulesToPlayer(ServerPlayer player) { - Menderman.getPlatformHelper().sendPacketToPlayer(player, new SyncGamerulesClientboundPacket(constructStorageMap(player.level().getGameRules()))); + ServerPlayNetworking.send(player, new SyncGamerulesClientboundPacket(constructStorageMap(player.level().getGameRules()))); } private static Object2ObjectArrayMap constructStorageMap(GameRules gameRules) { diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/world/item/MendermanDefaultComponents.java b/src/main/java/lgbt/greenhouse/menderman/world/item/MendermanDefaultComponents.java similarity index 97% rename from xplat/src/main/java/lgbt/greenhouse/menderman/world/item/MendermanDefaultComponents.java rename to src/main/java/lgbt/greenhouse/menderman/world/item/MendermanDefaultComponents.java index 25bde0e..5f8301d 100644 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/world/item/MendermanDefaultComponents.java +++ b/src/main/java/lgbt/greenhouse/menderman/world/item/MendermanDefaultComponents.java @@ -1,9 +1,10 @@ /* - * Copyright © 2026 Greenhouse Modding + * Copyright (c) 2026 Vulpixel , Greenhouse Modding * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * This Source Code Form is subject to the terms of the NON-AI Mozilla + * Public License, v. 2.0. If a copy of the NON-AI MPL was not + * distributed with this file, You can obtain one at + * https://vulpixel.org/licenses/non-ai-mpl-2.0. */ package lgbt.greenhouse.menderman.world.item; @@ -15,6 +16,7 @@ import lgbt.greenhouse.menderman.api.component.RepairRequirements; import lgbt.greenhouse.menderman.api.component.MendermanDataComponents; import lgbt.greenhouse.menderman.integration.MendermanRecipeViewerHelper; import lgbt.greenhouse.menderman.network.clientbound.SyncFallbackDataComponentsClientboundPacket; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.core.HolderLookup; import net.minecraft.core.HolderSet; import net.minecraft.core.component.DataComponentMap; @@ -294,7 +296,7 @@ public class MendermanDefaultComponents { public static void syncFallbackRepairRequirements(ServerPlayer player) { if (!FALLBACK_REPAIR_REQUIREMENTS.isEmpty()) { - Menderman.getPlatformHelper().sendPacketToPlayer(player, new SyncFallbackDataComponentsClientboundPacket(FALLBACK_REPAIR_REQUIREMENTS)); + ServerPlayNetworking.send(player, new SyncFallbackDataComponentsClientboundPacket(FALLBACK_REPAIR_REQUIREMENTS)); } } diff --git a/xplat/src/main/resources/assets/menderman/lang/en_us.json b/src/main/resources/assets/menderman/lang/en_us.json similarity index 100% rename from xplat/src/main/resources/assets/menderman/lang/en_us.json rename to src/main/resources/assets/menderman/lang/en_us.json diff --git a/xplat/src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json b/src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json similarity index 100% rename from xplat/src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json rename to src/main/resources/data/minecraft/tags/item/netherite_tool_materials.json diff --git a/xplat/src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json b/src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json similarity index 100% rename from xplat/src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json rename to src/main/resources/data/minecraft/tags/item/repairs_netherite_armor.json diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..5e89253 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,49 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "version": "${mod_version}+${minecraft_version}", + "name": "${mod_name}", + "description": "Minor repairing reworks for the anvil.", + "authors": [ + "Vulpixel", + "MerchantCalico" + ], + "contributors": [ + "MerchantCalico", + "Sylv " + ], + "contact": { + "homepage": "https://vulpixel.org/", + "issues": "https://tangled.org/vulpixel.org/enchiridion/issues", + "sources": "https://tangled.org/vulpixel.org/enchiridion" + }, + "license": "NON-AI-MPL-2.0", + "icon": "assets/${mod_id}/icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "lgbt.greenhouse.menderman.Menderman" + ], + "client": [ + "lgbt.greenhouse.menderman.client.MendermanClient" + ] + }, + "mixins": [ + "${mod_id}.mixins.json" + ], + "depends": { + "fabricloader": ">=0.19", + "fabric-api": ">=0.149.1", + "minecraft": "~26.1", + "java": ">=25" + }, + "custom": { + "modmenu": { + "links": { + "modmenu.curseforge": "https://curseforge.com/minecraft/mc-mods/enchiridion-enchanting", + "modmenu.modrinth": "https://modrinth.com/project/enchiridion", + "modmenu.kofi": "https://ko-fi.com/sylv256" + } + } + } +} diff --git a/xplat/src/main/resources/menderman.mixins.json b/src/main/resources/menderman.mixins.json similarity index 100% rename from xplat/src/main/resources/menderman.mixins.json rename to src/main/resources/menderman.mixins.json diff --git a/xplat/src/main/resources/menderman.png b/src/main/resources/menderman.png similarity index 100% rename from xplat/src/main/resources/menderman.png rename to src/main/resources/menderman.png diff --git a/xplat/build.gradle.kts b/xplat/build.gradle.kts index 3eb64af..e69de29 100644 --- a/xplat/build.gradle.kts +++ b/xplat/build.gradle.kts @@ -1,22 +0,0 @@ -import lgbt.greenhouse.menderman.gradle.Properties -import me.modmuss50.mpp.ReleaseType - -plugins { - id("lgbt.greenhouse.menderman.gradle.platform.xplat") - alias(libs.plugins.mod.publish) -} - -publishMods { - changelog = rootProject.file("CHANGELOG.md").readText() - displayName = "v${Properties.MOD_VERSION} (Minecraft ${Properties.FRIENDLY_MINECRAFT_VERSION})" - version = "${Properties.MOD_VERSION}+${Properties.FRIENDLY_MINECRAFT_VERSION}" - type = STABLE - - modrinth { - accessToken = providers.environmentVariable("MODRINTH_TOKEN") - projectId = Properties.MODRINTH_PROJECT_ID - minecraftVersions.addAll(Properties.SUPPORTED_MINECRAFT_VERSIONS) - type = ReleaseType.STABLE - requires("fabric-api") - } -} diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/Menderman.java b/xplat/src/main/java/lgbt/greenhouse/menderman/Menderman.java deleted file mode 100644 index 91366cb..0000000 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/Menderman.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman; - -import lgbt.greenhouse.config.api.v3.GreenhouseConfigHolder; -import lgbt.greenhouse.config.api.v3.GreenhouseConfigSide; -import lgbt.greenhouse.config.api.v3.lang.GreenhouseConfigJsonCLang; -import lgbt.greenhouse.menderman.api.config.MendermanConfig; -import lgbt.greenhouse.menderman.api.config.MendermanGameruleConfig; -import lgbt.greenhouse.menderman.platform.MendermanHelperLoaders; -import lgbt.greenhouse.menderman.platform.MendermanPlatformHelper; -import net.minecraft.resources.Identifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Menderman { - public static final String MOD_ID = "menderman"; - public static final String MOD_NAME = "Menderman"; - public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); - - public static final GreenhouseConfigHolder CONFIG = GreenhouseConfigHolder.register( - MendermanConfig.class, - MOD_ID, - 1, - GreenhouseConfigJsonCLang.INSTANCE, - GreenhouseConfigSide.COMMON, - builder -> builder - .withMapValue( - MendermanGameruleConfig.class, - "gamerules", - """ - Default values for Menderman's gamerules. - - Can be modified on a per world basis via the gamerule screen - or the /gamerule command.""", - MendermanConfig::gamerules, - MendermanGameruleConfig::configBuilder - ) - ); - - private static MendermanPlatformHelper platformHelper; - - public static boolean shouldNotDamageAnvil = false; - - public static Identifier id(String path) { - return Identifier.fromNamespaceAndPath(MOD_ID, path); - } - - public static MendermanPlatformHelper getPlatformHelper() { - if (platformHelper == null) { - platformHelper = MendermanHelperLoaders.createPlatformHelper(); - } - return platformHelper; - } -} diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanConfig.java b/xplat/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanConfig.java deleted file mode 100644 index f31fc86..0000000 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/api/config/MendermanConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.api.config; - -public record MendermanConfig(MendermanGameruleConfig gamerules) { -} diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/platform/MendermanHelperLoaders.java b/xplat/src/main/java/lgbt/greenhouse/menderman/platform/MendermanHelperLoaders.java deleted file mode 100644 index b8fd9be..0000000 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/platform/MendermanHelperLoaders.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.platform; - -import lgbt.greenhouse.menderman.Menderman; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; - -/// We have {@link java.util.ServiceLoader}s at home. -@ApiStatus.Internal -public class MendermanHelperLoaders { - private static final String FABRIC_CLASS = "lgbt.greenhouse.menderman.fabric.platform.MendermanPlatformHelperFabric"; - private static final String NEOFORGE_CLASS = "lgbt.greenhouse.menderman.neoforge.platform.MendermanPlatformHelperNeoForge"; - - @Nullable - public static final MethodHandle NEOFORGE_PLATFORM_HELPER = find(lookup -> { - if (isNeoForge()) { - Class clazz = lookup.findClass(NEOFORGE_CLASS); - return lookup.findConstructor(clazz, MethodType.methodType(void.class)); - } - return null; - }); - @Nullable - public static final MethodHandle FABRIC_PLATFORM_HELPER = find(lookup -> { - if (isFabric()) { - Class clazz = lookup.findClass(FABRIC_CLASS); - return lookup.findConstructor(clazz, MethodType.methodType(void.class)); - } - return null; - }); - - public static MendermanPlatformHelper createPlatformHelper() { - try { - if (NEOFORGE_PLATFORM_HELPER != null) { - return (MendermanPlatformHelper) NEOFORGE_PLATFORM_HELPER.invoke(); - } - if (FABRIC_PLATFORM_HELPER != null) { - return (MendermanPlatformHelper) FABRIC_PLATFORM_HELPER.invoke(); - } - } catch (Throwable e) { - Menderman.LOG.error("", e); - } - throw new IllegalStateException("No " + MendermanPlatformHelper.class.getName() + " implementation found"); - } - - private static boolean isFabric() { - try { - // Check for Fabric Loader - Class.forName("net.fabricmc.loader.api.FabricLoader"); - return true; - } catch (ClassNotFoundException ignored) { - return false; - } - } - - private static boolean isNeoForge() { - try { - // Check for FancyModLoader - Class.forName("net.neoforged.fml.loading.FMLLoader"); - return true; - } catch (ClassNotFoundException ignored) { - return false; - } - } - - private interface Finder { - @Nullable MethodHandle find(MethodHandles.Lookup lookup) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException; - } - - @Nullable - private static MethodHandle find(Finder finder) { - try { - return finder.find(MethodHandles.lookup()); - } catch (ReflectiveOperationException e) { - return null; - } - } -} diff --git a/xplat/src/main/java/lgbt/greenhouse/menderman/platform/MendermanPlatformHelper.java b/xplat/src/main/java/lgbt/greenhouse/menderman/platform/MendermanPlatformHelper.java deleted file mode 100644 index 07d1d48..0000000 --- a/xplat/src/main/java/lgbt/greenhouse/menderman/platform/MendermanPlatformHelper.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright © 2026 Greenhouse Modding - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -package lgbt.greenhouse.menderman.platform; - -import net.minecraft.core.Registry; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.Identifier; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerPlayer; - -public interface MendermanPlatformHelper { - boolean isModLoaded(String modId); - - void aliasRegistryValue(Registry registry, Identifier from, Identifier to); - - void sendPacketToPlayer(ServerPlayer player, CustomPacketPayload payload); - - void sendPacketsToAllServerPlayers(MinecraftServer server, CustomPacketPayload payload); -}