Skip to content

Commit

Permalink
update to 1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ImUrX committed Feb 3, 2025
1 parent 8abe2f9 commit 3eb5061
Show file tree
Hide file tree
Showing 30 changed files with 285 additions and 432 deletions.
78 changes: 49 additions & 29 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
35 changes: 18 additions & 17 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
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}") {
exclude(group: "net.fabricmc.fabric-api")
}
}

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.
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 3 additions & 1 deletion common/src/main/resources/assets/screencopy/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -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"
}
14 changes: 14 additions & 0 deletions common/src/main/resources/screencopy.common.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"package": "io.github.imurx.screenshotcopy.mixins",
"compatibilityLevel": "JAVA_21",
"minVersion": "0.8",
"client": [
"NativeImageInvoker"
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}
12 changes: 0 additions & 12 deletions fabric-like/build.gradle

This file was deleted.

This file was deleted.

94 changes: 48 additions & 46 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
id "com.github.johnrengelman.shadow"
}
version = version + "-fabric"

architectury {
platformSetupLoomIde()
fabric()
}

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}"
Expand All @@ -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 {
Expand All @@ -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.
// }
//}
8 changes: 4 additions & 4 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"homepage": "https://github.com/imurx/screencopy",
"sources": "https://github.com/imurx/screencopy",
"issues": "https://github.com/imurx/screencopy/issues",
"email": "[email protected]"
"email": "[email protected]"
},
"license": "MIT OR Apache-2.0",
"icon": "icon.png",
Expand All @@ -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": "*"
},
Expand Down
Loading

0 comments on commit 3eb5061

Please sign in to comment.