diff --git a/build.gradle b/build.gradle index 1806ed4..baf8c7f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,38 +1,27 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false + id 'com.github.johnrengelman.shadow' version '8.1.1' apply false } architectury { minecraft = rootProject.minecraft_version } -subprojects { - apply plugin: "dev.architectury.loom" - - loom { - silentMojangMappingsLicense() - } - - dependencies { - minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" - // The following line declares the mojmap mappings, you may use other mappings as well - // mappings loom.officialMojangMappings() - // The following line declares the yarn mappings you may select this one as well. - mappings "net.fabricmc:yarn:1.19.1+build.5" - - implementation "io.github.imurx:arboard:${rootProject.arboard_version}" - } +allprojects { + group = rootProject.maven_group + version = rootProject.mod_version } -allprojects { - apply plugin: "java" - apply plugin: "architectury-plugin" - apply plugin: "maven-publish" +subprojects { + apply plugin: 'dev.architectury.loom' + apply plugin: 'architectury-plugin' + apply plugin: 'maven-publish' - archivesBaseName = rootProject.archives_base_name - version = rootProject.mod_version - group = rootProject.maven_group + base { + // Set up a suffixed format for the mod jar names, e.g. `example-fabric`. + archivesName = "$rootProject.archives_name-$project.name" + } repositories { // Add repositories to retrieve artifacts from in here. @@ -52,14 +41,45 @@ allprojects { mavenCentral() } - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.release = 17 + dependencies { + minecraft "net.minecraft:minecraft:$rootProject.minecraft_version" + mappings loom.layered { + it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2") + it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version") + } + + implementation "io.github.imurx:arboard:${rootProject.arboard_version}" } 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() + + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + } + + tasks.withType(JavaCompile).configureEach { + it.options.release = 21 + } + + // Configure Maven publishing. + publishing { + publications { + mavenJava(MavenPublication) { + artifactId = base.archivesName.get() + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } } } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 diff --git a/common/build.gradle b/common/build.gradle index 0488344..f47f76b 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,11 +1,12 @@ architectury { - common(rootProject.enabled_platforms.split(",")) + common rootProject.enabled_platforms.split(",") } dependencies { - // We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies - // Do NOT use other classes from fabric loader - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" + // We depend on Fabric Loader here to use the Fabric @Environment annotations, + // which get remapped to the correct annotations on each platform. + // Do NOT use other classes from Fabric Loader. + modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" // Remove the next line if you don't want to depend on the API //modApi "dev.architectury:architectury:${rootProject.architectury_version}" modApi("me.shedaniel.cloth:cloth-config:${rootProject.cloth_config_version}") { @@ -13,16 +14,16 @@ dependencies { } } -publishing { - publications { - mavenCommon(MavenPublication) { - artifactId = rootProject.archives_base_name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} +//publishing { +// publications { +// mavenCommon(MavenPublication) { +// artifactId = rootProject.archives_base_name +// from components.java +// } +// } +// +// // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. +// repositories { +// // Add repositories to publish to here. +// } +//} diff --git a/common/src/main/java/io/github/imurx/screenshotcopy/ScreencopyConfig.java b/common/src/main/java/io/github/imurx/screenshotcopy/ScreencopyConfig.java index 526e6a1..7187847 100644 --- a/common/src/main/java/io/github/imurx/screenshotcopy/ScreencopyConfig.java +++ b/common/src/main/java/io/github/imurx/screenshotcopy/ScreencopyConfig.java @@ -3,10 +3,11 @@ import me.shedaniel.autoconfig.ConfigData; import me.shedaniel.autoconfig.annotation.Config; +import me.shedaniel.autoconfig.annotation.ConfigEntry; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; @Config(name = "screencopy") public class ScreencopyConfig implements ConfigData { - @Comment("Save screenshots to file aside from copying to clipboard") + @ConfigEntry.Gui.Tooltip public boolean saveScreenshot = true; } diff --git a/common/src/main/java/io/github/imurx/screenshotcopy/ScreenshotCopy.java b/common/src/main/java/io/github/imurx/screenshotcopy/ScreenshotCopy.java index 87bdd2c..dee9e40 100644 --- a/common/src/main/java/io/github/imurx/screenshotcopy/ScreenshotCopy.java +++ b/common/src/main/java/io/github/imurx/screenshotcopy/ScreenshotCopy.java @@ -1,6 +1,7 @@ package io.github.imurx.screenshotcopy; import io.github.imurx.arboard.ImageData; +import io.github.imurx.screenshotcopy.mixins.NativeImageInvoker; import net.minecraft.client.texture.NativeImage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,10 +29,11 @@ public static void stop() { } public static void copyScreenshot(NativeImage image) { + NativeImageInvoker invoker = ((NativeImageInvoker) (Object) image); ByteBuffer imageBytes = ByteBuffer.allocate(image.getWidth() * image.getHeight() * 4).order(ByteOrder.LITTLE_ENDIAN); for(int y = 0; y < image.getHeight(); y++) { for(int x = 0; x < image.getWidth(); x++) { - imageBytes.putInt(image.getColor(x, y)); + imageBytes.putInt(invoker.invokeGetColor(x, y)); } } copyScreenshot(image.getWidth(), image.getHeight(), imageBytes.array()); diff --git a/common/src/main/java/io/github/imurx/screenshotcopy/mixins/NativeImageInvoker.java b/common/src/main/java/io/github/imurx/screenshotcopy/mixins/NativeImageInvoker.java new file mode 100644 index 0000000..bbf04fc --- /dev/null +++ b/common/src/main/java/io/github/imurx/screenshotcopy/mixins/NativeImageInvoker.java @@ -0,0 +1,12 @@ +package io.github.imurx.screenshotcopy.mixins; + +import net.minecraft.client.texture.NativeImage; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(NativeImage.class) +public interface NativeImageInvoker { + + @Invoker("getColor") + int invokeGetColor(int x, int y); +} diff --git a/common/src/main/resources/assets/screencopy/lang/en_us.json b/common/src/main/resources/assets/screencopy/lang/en_us.json index 1dd0929..6ab41ae 100644 --- a/common/src/main/resources/assets/screencopy/lang/en_us.json +++ b/common/src/main/resources/assets/screencopy/lang/en_us.json @@ -1,5 +1,7 @@ { "text.screencopy.success": "Screenshot saved to clipboard", "text.screencopy.failure": "Couldn't save screenshot to clipboard: %s", - "text.autoconfig.screencopy.option.saveScreenshot": "Save screenshot file" + "text.autoconfig.screencopy.option.saveScreenshot": "Save screenshot file", + "text.autoconfig.screencopy.option.saveScreenshot.@Tooltip": "Save screenshots to file aside from copying to clipboard", + "fml.menu.mods.info.description.screencopy": "Let's you save screenshots to your clipboard" } \ No newline at end of file diff --git a/common/src/main/resources/screencopy.common.mixins.json b/common/src/main/resources/screencopy.common.mixins.json new file mode 100644 index 0000000..a23fdca --- /dev/null +++ b/common/src/main/resources/screencopy.common.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "io.github.imurx.screenshotcopy.mixins", + "compatibilityLevel": "JAVA_21", + "minVersion": "0.8", + "client": [ + "NativeImageInvoker" + ], + "mixins": [ + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric-like/build.gradle b/fabric-like/build.gradle deleted file mode 100644 index a2af4db..0000000 --- a/fabric-like/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -architectury { - common(rootProject.enabled_platforms.split(",")) -} - -dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" - // Remove the next line if you don't want to depend on the API - //modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" - - compileClasspath(project(path: ":common", configuration: "namedElements")) { transitive false } -} diff --git a/fabric-like/src/main/java/io/github/imurx/screenshotcopy/fabriclike/ScreenshotCopyFabricLike.java b/fabric-like/src/main/java/io/github/imurx/screenshotcopy/fabriclike/ScreenshotCopyFabricLike.java deleted file mode 100644 index 5588196..0000000 --- a/fabric-like/src/main/java/io/github/imurx/screenshotcopy/fabriclike/ScreenshotCopyFabricLike.java +++ /dev/null @@ -1,9 +0,0 @@ -package io.github.imurx.screenshotcopy.fabriclike; - -import io.github.imurx.screenshotcopy.fabriclike.ScreenshotCopyFabricLike; - -public class ScreenshotCopyFabricLike { - public static void init() { - - } -} diff --git a/fabric/build.gradle b/fabric/build.gradle index 277911e..69240f7 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,7 +1,6 @@ plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" } -version = version + "-fabric" architectury { platformSetupLoomIde() @@ -9,16 +8,25 @@ architectury { } configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. + common { + canBeResolved = true + canBeConsumed = false + } compileClasspath.extendsFrom common runtimeClasspath.extendsFrom common developmentFabric.extendsFrom common + + // Files in this configuration will be bundled into your mod using the Shadow plugin. + // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. + shadowBundle { + canBeResolved = true + canBeConsumed = false + } } dependencies { - modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" + modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" + modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version" // Remove the next line if you don't want to depend on the API //modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" @@ -31,9 +39,7 @@ dependencies { include "com.github.ramanrajarathinam:native-utils:1.0.0" include "io.github.imurx:arboard:${rootProject.arboard_version}" common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } - common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":fabric-like", configuration: "transformProductionFabric")) { transitive false } + shadowBundle project(path: ":common", configuration: "transformProductionFabric") // { transitive false } } processResources { @@ -45,45 +51,41 @@ processResources { } shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" +// exclude "architectury.common.json" + configurations = [project.configurations.shadowBundle] + archiveClassifier = "dev-shadow" } remapJar { - injectAccessWidener = true - input.set shadowJar.archiveFile - dependsOn shadowJar - classifier null -} - -jar { - classifier "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } + inputFile.set shadowJar.archiveFile } -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenFabric(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} +//jar { +// classifier "dev" +//} +// +//sourcesJar { +// def commonSources = project(":common").sourcesJar +// dependsOn commonSources +// from commonSources.archiveFile.map { zipTree(it) } +//} +// +//components.java { +// withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { +// skip() +// } +//} +// +//publishing { +// publications { +// mavenFabric(MavenPublication) { +// artifactId = rootProject.archives_base_name + "-" + project.name +// from components.java +// } +// } +// +// // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. +// repositories { +// // Add repositories to publish to here. +// } +//} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 22203d8..8656505 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -14,7 +14,7 @@ "homepage": "https://github.com/imurx/screencopy", "sources": "https://github.com/imurx/screencopy", "issues": "https://github.com/imurx/screencopy/issues", - "email": "urielfontan2002@gmail.com" + "email": "imurx@proton.me" }, "license": "MIT OR Apache-2.0", "icon": "icon.png", @@ -27,10 +27,10 @@ "io.github.imurx.screenshotcopy.fabric.ScreencopyMenuIntegration" ] }, - "mixins": ["screencopy.mixins.json"], + "mixins": ["screencopy.common.mixins.json","screencopy.mixins.json"], "depends": { - "minecraft": ">=1.19.1", - "cloth-config": ">=8.0.75", + "minecraft": ">=1.21.2", + "cloth-config": ">=16.0.141", "fabric-lifecycle-events-v1": "*", "fabric-resource-loader-v0": "*" }, diff --git a/fabric/src/main/resources/screencopy.mixins.json b/fabric/src/main/resources/screencopy.mixins.json index 64f5883..56e019b 100644 --- a/fabric/src/main/resources/screencopy.mixins.json +++ b/fabric/src/main/resources/screencopy.mixins.json @@ -1,7 +1,8 @@ { "required": true, "package": "io.github.imurx.screenshotcopy.fabric.mixins", - "compatibilityLevel": "JAVA_17", + "compatibilityLevel": "JAVA_21", + "minVersion": "0.8", "client": [ "MixinScreenshotRecorder" ], diff --git a/forge/build.gradle b/forge/build.gradle deleted file mode 100644 index 0ea5cb8..0000000 --- a/forge/build.gradle +++ /dev/null @@ -1,81 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" -} -version = version + "-forge" - -architectury { - platformSetupLoomIde() - forge() -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentForge.extendsFrom common -} - -dependencies { - forge "net.minecraftforge:forge:${rootProject.forge_version}" - // Remove the next line if you don't want to depend on the API - //modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}" - modApi "me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}" - - forgeRuntimeLibrary "io.github.imurx:arboard:${rootProject.arboard_version}" - shadowCommon "io.github.imurx:arboard:${rootProject.arboard_version}" - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false } -} - -processResources { - inputs.property "version", project.version - - filesMatching("META-INF/mods.toml") { - expand "version": project.version - } -} - -shadowJar { - exclude "fabric.mod.json" - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" -} - -remapJar { - input.set shadowJar.archiveFile - dependsOn shadowJar - classifier null -} - -jar { - classifier "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenForge(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index 32f842a..0000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/io/github/imurx/screenshotcopy/forge/ScreenshotCopyForge.java b/forge/src/main/java/io/github/imurx/screenshotcopy/forge/ScreenshotCopyForge.java deleted file mode 100644 index 48210a4..0000000 --- a/forge/src/main/java/io/github/imurx/screenshotcopy/forge/ScreenshotCopyForge.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.github.imurx.screenshotcopy.forge; - -import io.github.imurx.screenshotcopy.ScreencopyConfig; -import io.github.imurx.screenshotcopy.ScreenshotCopy; -import me.shedaniel.autoconfig.AutoConfig; -import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.ConfigScreenHandler; -import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.IExtensionPoint; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; - -@Mod(ScreenshotCopy.MOD_ID) -public class ScreenshotCopyForge { - public ScreenshotCopyForge() { - ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> "Client-side mod", (a, b) -> b)); - DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> this::client); - } - - public void client() { - AutoConfig.register(ScreencopyConfig.class, Toml4jConfigSerializer::new); - ScreenshotCopy.init(); - - ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((client, parent) -> - AutoConfig.getConfigScreen(ScreencopyConfig.class, parent).get() - )); - } -} diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta deleted file mode 100644 index a994d2d..0000000 --- a/forge/src/main/resources/pack.mcmeta +++ /dev/null @@ -1,6 +0,0 @@ -{ - "pack": { - "description": "Screencopy", - "pack_format": 8 - } -} diff --git a/gradle.properties b/gradle.properties index 1cab460..a244104 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,20 @@ org.gradle.jvmargs=-Xmx3050M -minecraft_version=1.19.1 -enabled_platforms=fabric,forge +minecraft_version = 1.21.2 +yarn_mappings = 1.21.2+build.1 -archives_base_name=screenshotcopy -mod_version=1.2.2 +archives_name=screenshotcopy +mod_version=1.2.3 maven_group=io.github.imurx +enabled_platforms=fabric,neoforge -cloth_config_version=8.0.75 +cloth_config_version=16.0.143 arboard_version=1.1.1 -fabric_loader_version=0.14.8 -fabric_api_version=0.58.5+1.19.1 -mod_menu_version=4.0.5 -fabrishot_version=1.8.0 +fabric_loader_version = 0.16.10 +fabric_api_version = 0.106.1+1.21.2 +mod_menu_version=12.0.0 +fabrishot_version=1.14.1 -forge_version=1.19.1-42.0.1 - -quilt_loader_version=0.17.0-beta.2 -quilt_fabric_api_version=1.0.0-beta.13+0.51.1-1.18.2 +neoforge_version = 21.2.1-beta +yarn_mappings_patch_neoforge_version = 1.21+build.4 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2e6e589..a441313 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/neoforge/build.gradle b/neoforge/build.gradle new file mode 100644 index 0000000..604df57 --- /dev/null +++ b/neoforge/build.gradle @@ -0,0 +1,63 @@ +plugins { + id 'com.github.johnrengelman.shadow' +} + +architectury { + platformSetupLoomIde() + neoForge() +} + +configurations { + common { + canBeResolved = true + canBeConsumed = false + } + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentNeoForge.extendsFrom common + + // Files in this configuration will be bundled into your mod using the Shadow plugin. + // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. + shadowBundle { + canBeResolved = true + canBeConsumed = false + } +} + +repositories { + maven { + name = 'NeoForged' + url = 'https://maven.neoforged.net/releases' + } +} + +dependencies { + neoForge "net.neoforged:neoforge:$rootProject.neoforge_version" + + modApi "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_config_version}" + + forgeRuntimeLibrary "io.github.imurx:arboard:${rootProject.arboard_version}" + shadowBundle "io.github.imurx:arboard:${rootProject.arboard_version}" +// include "com.github.ramanrajarathinam:native-utils:1.0.0" +// include "io.github.imurx:arboard:${rootProject.arboard_version}" + + common(project(path: ':common', configuration: 'namedElements')) { transitive false } + shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge') +} + +processResources { + inputs.property 'version', project.version + + filesMatching('META-INF/neoforge.mods.toml') { + expand version: project.version + } +} + +shadowJar { + configurations = [project.configurations.shadowBundle] + archiveClassifier = 'dev-shadow' +} + +remapJar { + inputFile.set shadowJar.archiveFile +} diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties new file mode 100644 index 0000000..2e6ed76 --- /dev/null +++ b/neoforge/gradle.properties @@ -0,0 +1 @@ +loom.platform = neoforge diff --git a/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotCopyNeoforge.java b/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotCopyNeoforge.java new file mode 100644 index 0000000..9524f7d --- /dev/null +++ b/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotCopyNeoforge.java @@ -0,0 +1,7 @@ +package io.github.imurx.screenshotcopy.neoforge; + +import io.github.imurx.screenshotcopy.ScreenshotCopy; +import net.neoforged.fml.common.Mod; + +@Mod(ScreenshotCopy.MOD_ID) +public class ScreenshotCopyNeoforge { } diff --git a/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotCopyNeoforgeClient.java b/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotCopyNeoforgeClient.java new file mode 100644 index 0000000..9da1ef6 --- /dev/null +++ b/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotCopyNeoforgeClient.java @@ -0,0 +1,22 @@ +package io.github.imurx.screenshotcopy.neoforge; + +import io.github.imurx.screenshotcopy.ScreencopyConfig; +import io.github.imurx.screenshotcopy.ScreenshotCopy; +import me.shedaniel.autoconfig.AutoConfig; +import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; + +@Mod(value = ScreenshotCopy.MOD_ID, dist = Dist.CLIENT) +public final class ScreenshotCopyNeoforgeClient { + public ScreenshotCopyNeoforgeClient() { + AutoConfig.register(ScreencopyConfig.class, Toml4jConfigSerializer::new); + ScreenshotCopy.init(); + + ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (client, parent) -> + AutoConfig.getConfigScreen(ScreencopyConfig.class, parent).get() + ); + } +} diff --git a/forge/src/main/java/io/github/imurx/screenshotcopy/forge/ScreenshotEventHandler.java b/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotEventHandler.java similarity index 69% rename from forge/src/main/java/io/github/imurx/screenshotcopy/forge/ScreenshotEventHandler.java rename to neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotEventHandler.java index 8cca648..50c0f0b 100644 --- a/forge/src/main/java/io/github/imurx/screenshotcopy/forge/ScreenshotEventHandler.java +++ b/neoforge/src/main/java/io/github/imurx/screenshotcopy/neoforge/ScreenshotEventHandler.java @@ -1,16 +1,16 @@ -package io.github.imurx.screenshotcopy.forge; +package io.github.imurx.screenshotcopy.neoforge; import io.github.imurx.screenshotcopy.ScreencopyConfig; import io.github.imurx.screenshotcopy.ScreenshotCopy; import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.text.Text; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.ScreenshotEvent; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.EventPriority; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.client.event.ScreenshotEvent; -@Mod.EventBusSubscriber(modid = ScreenshotCopy.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) +@EventBusSubscriber(modid = ScreenshotCopy.MOD_ID, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT) public class ScreenshotEventHandler { @SubscribeEvent(priority = EventPriority.LOWEST) public static void onScreenshot(ScreenshotEvent ev) { diff --git a/forge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/neoforge.mods.toml similarity index 65% rename from forge/src/main/resources/META-INF/mods.toml rename to neoforge/src/main/resources/META-INF/neoforge.mods.toml index 0339cba..87c021d 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,5 +1,5 @@ modLoader = "javafml" -loaderVersion = "[42,)" +loaderVersion = "[4,)" issueTrackerURL = "https://github.com/ImUrX/screencopy/issues" license = "MIT OR Apache-2.0" @@ -10,28 +10,29 @@ displayName = "Screencopy" displayURL = "https://github.com/ImUrX/screencopy" credits = "Thanks KiboTheCookie for the icon design." authors = "ImUrX" -description = ''' -Let's you save screenshots to your clipboard -''' logoFile = "icon.png" +updateJSONURL = "https://api.modrinth.com/updates/screencopy/forge_updates.json?neoforge=only" [[dependencies.screencopy]] -modId = "forge" -mandatory = true -versionRange = "[42,)" +modId = "neoforge" +type = "required" +versionRange = "[21.2,)" ordering = "NONE" side = "BOTH" [[dependencies.screencopy]] modId = "minecraft" -mandatory = true -versionRange = "[1.19.1,)" +type = "required" +versionRange = "[1.21.2,)" ordering = "NONE" side = "BOTH" [[dependencies.screencopy]] modId = "cloth_config" mandatory = true -versionRange = "[8.0.75,)" +versionRange = "[16.0.141,)" ordering = "NONE" side = "CLIENT" + +[[mixins]] +config = "screencopy.common.mixins.json" diff --git a/quilt/build.gradle b/quilt/build.gradle deleted file mode 100644 index 44a4f40..0000000 --- a/quilt/build.gradle +++ /dev/null @@ -1,90 +0,0 @@ -plugins { - id "com.github.johnrengelman.shadow" version "7.1.2" -} - -repositories { - maven { url "https://maven.quiltmc.org/repository/release/" } -} - -architectury { - platformSetupLoomIde() - loader("quilt") -} - -configurations { - common - shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentQuilt.extendsFrom common -} - -dependencies { - modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" - modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" - // Remove the next few lines if you don't want to depend on the API - /*modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { - // We must not pull Fabric Loader from Architectury Fabric - exclude group: "net.fabricmc" - exclude group: "net.fabricmc.fabric-api" - }*/ - - common(project(path: ":common", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } - common(project(path: ":fabric-like", configuration: "namedElements")) { transitive false } - shadowCommon(project(path: ":fabric-like", configuration: "transformProductionQuilt")) { transitive false } -} - -processResources { - inputs.property "group", rootProject.maven_group - inputs.property "version", project.version - - filesMatching("quilt.mod.json") { - expand "group": rootProject.maven_group, - "version": project.version - } -} - -shadowJar { - exclude "architectury.common.json" - - configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" -} - -remapJar { - injectAccessWidener = true - input.set shadowJar.archiveFile - dependsOn shadowJar - classifier null -} - -jar { - classifier "dev" -} - -sourcesJar { - def commonSources = project(":common").sourcesJar - dependsOn commonSources - from commonSources.archiveFile.map { zipTree(it) } -} - -components.java { - withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { - skip() - } -} - -publishing { - publications { - mavenQuilt(MavenPublication) { - artifactId = rootProject.archives_base_name + "-" + project.name - from components.java - } - } - - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. - repositories { - // Add repositories to publish to here. - } -} diff --git a/quilt/gradle.properties b/quilt/gradle.properties deleted file mode 100644 index 96758ce..0000000 --- a/quilt/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=quilt \ No newline at end of file diff --git a/quilt/src/main/java/io/github/imurx/screenshotcopy/fabric/ExampleExpectPlatformImpl.java b/quilt/src/main/java/io/github/imurx/screenshotcopy/fabric/ExampleExpectPlatformImpl.java deleted file mode 100644 index 64f2ec1..0000000 --- a/quilt/src/main/java/io/github/imurx/screenshotcopy/fabric/ExampleExpectPlatformImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package io.github.imurx.screenshotcopy.fabric; - -import org.quiltmc.loader.api.QuiltLoader; - -import java.nio.file.Path; - -public class ExampleExpectPlatformImpl { - /** - * This is our actual method to {@link ExampleExpectPlatform#getConfigDirectory()}. - */ - public static Path getConfigDirectory() { - return QuiltLoader.getConfigDir(); - } -} diff --git a/quilt/src/main/java/io/github/imurx/screenshotcopy/quilt/ExampleModQuilt.java b/quilt/src/main/java/io/github/imurx/screenshotcopy/quilt/ExampleModQuilt.java deleted file mode 100644 index 467c5b0..0000000 --- a/quilt/src/main/java/io/github/imurx/screenshotcopy/quilt/ExampleModQuilt.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.github.imurx.screenshotcopy.quilt; - -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; - -public class ExampleModQuilt implements ModInitializer { - @Override - public void onInitialize(ModContainer mod) { - - } -} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json deleted file mode 100644 index cac048f..0000000 --- a/quilt/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "schema_version": 1, - "quilt_loader": { - "group": "${group}", - "id": "examplemod", - "version": "${version}", - "name": "Example Mod", - "description": "This is an example description! Tell everyone what your mod is about!", - "authors": ["Me!"], - "contact": { - "sources": "https://github.com/architectury/architectury-templates" - }, - "license": "Insert License Here", - "icon": "assets/examplemod/icon.png", - "intermediate_mappings": "net.fabricmc:intermediary", - "environment": "*", - "entrypoints": { - "init": [ - "net.examplemod.quilt.ExampleModQuilt" - ] - }, - "depends": [ - { - "id": "quilt_loader", - "version": "*" - }, - { - "id": "quilt_base", - "version": "*" - }, - { - "id": "minecraft", - "version": ">=1.18.2" - }, - { - "id": "architectury", - "version": ">=4.4.59" - } - ] - } -} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 77d10cf..8b74e8a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,15 +2,13 @@ pluginManagement { repositories { maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.architectury.dev/" } - maven { url "https://maven.minecraftforge.net/" } + maven { url "https://files.minecraftforge.net/maven/" } gradlePluginPortal() } } -include("common") -include("fabric-like") -include("fabric") -//include("quilt") -include("forge") +include 'common' +include 'fabric' +include 'neoforge' rootProject.name = "screenshotcopy"