Architectury port

because why not
This commit is contained in:
Martin Prokoph
2024-07-07 22:26:59 +02:00
parent d91ced885d
commit 2a03dd78fb
22 changed files with 402 additions and 123 deletions

View File

@@ -1,110 +1,80 @@
plugins { plugins {
id 'fabric-loom' version '1.6-SNAPSHOT' id "architectury-plugin" version "3.4-SNAPSHOT"
id "me.shedaniel.unified-publishing" version "0.1.+" id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "me.shedaniel.unified-publishing" version "0.1.+" apply false
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
} }
sourceCompatibility = JavaVersion.VERSION_17 architectury {
targetCompatibility = JavaVersion.VERSION_17 minecraft = rootProject.minecraft_version
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories { repositories {
maven { url "https://api.modrinth.com/maven" } maven {
url = "https://api.modrinth.com/maven"
}
} }
dependencies { subprojects {
//to change the versions see the gradle.properties file apply plugin: "dev.architectury.loom"
minecraft "com.mojang:minecraft:${project.minecraft_version}" repositories {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" maven {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" url = "https://api.modrinth.com/maven"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" }
maven { url 'https://jitpack.io' }
modImplementation "maven.modrinth:midnightlib:${midnightlib_version}" }
include "maven.modrinth:midnightlib:${midnightlib_version}"
} dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
processResources { // The following line declares the mojmap mappings, you may use other mappings as well
inputs.property "version", project.version //mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
filesMatching("fabric.mod.json") { mappings loom.layered {
expand "version": project.version it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
} it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 17
}
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()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
remapJar {
archiveVersion = "${project.version}-${project.minecraft_version}"
archiveBaseName = "${project.archivesBaseName}"
}
ext {
releaseChangelog = {
def changes = new StringBuilder()
changes << "## Sword Blocking v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/SwordBlocking/commits/)"
def proc = "git log --max-count=1 --pretty=format:%s".execute()
proc.in.eachLine { line ->
def processedLine = line.toString()
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
changes << "\n- ${processedLine.capitalize()}"
}
} }
proc.waitFor()
return changes.toString()
} }
} }
unifiedPublishing { allprojects {
project { apply plugin: "java"
displayName = "Sword Blocking v$project.version - Fabric $project.minecraft_version" apply plugin: "architectury-plugin"
releaseType = "$project.release_type" apply plugin: "maven-publish"
changelog = releaseChangelog()
gameVersions = []
gameLoaders = ["fabric","quilt"]
mainPublication remapJar
relations {
includes {
curseforge = "midnightlib"
modrinth = "midnightlib"
}
}
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN") archivesBaseName = rootProject.archives_base_name
if (CURSEFORGE_TOKEN != null) { version = rootProject.mod_version
curseforge { group = rootProject.maven_group
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version
}
}
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN") repositories {
if (MODRINTH_TOKEN != null) { // Add repositories to retrieve artifacts from in here.
modrinth { // You should only use this when depending on other mods because
token = MODRINTH_TOKEN // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
id = rootProject.modrinth_id // See https://docs.gradle.org/current/userguide/declaring_repositories.html
version = "$project.version" // for more information about repositories.
gameVersions.addAll project.minecraft_version }
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 21
}
ext {
releaseChangelog = {
def changes = new StringBuilder()
changes << "## SwordBlocking v$project.version for $project.minecraft_version\n[View the changelog](https://www.github.com/TeamMidnightDust/SwordBlocking/commits/)"
def proc = "git log --max-count=1 --pretty=format:%s".execute()
proc.in.eachLine { line ->
def processedLine = line.toString()
if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
changes << "\n- ${processedLine.capitalize()}"
}
} }
proc.waitFor()
return changes.toString()
} }
} }
java {
withSourcesJar()
}
} }

24
common/build.gradle Normal file
View File

@@ -0,0 +1,24 @@
architectury {
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}"
modCompileOnlyApi "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric"
}
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.
}
}

View File

@@ -1,7 +1,6 @@
package eu.midnightdust.swordblocking; package eu.midnightdust.swordblocking;
import eu.midnightdust.swordblocking.config.SwordBlockingConfig; import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.component.DataComponentTypes; import net.minecraft.component.DataComponentTypes;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem; import net.minecraft.item.AxeItem;
@@ -12,10 +11,11 @@ import net.minecraft.item.SwordItem;
import java.util.Objects; import java.util.Objects;
public class SwordBlockingClient implements ClientModInitializer { public class SwordBlockingClient {
@Override public static final String MOD_ID = "swordblocking";
public void onInitializeClient() {
SwordBlockingConfig.init("swordblocking", SwordBlockingConfig.class); public static void init() {
SwordBlockingConfig.init(MOD_ID, SwordBlockingConfig.class);
} }
public static boolean isWeaponBlocking(LivingEntity entity) { public static boolean isWeaponBlocking(LivingEntity entity) {

View File

@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.At;
@Mixin(InGameHud.class) @Mixin(InGameHud.class)
public abstract class MixinInGameHud { public abstract class MixinInGameHud {
@ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getOffHandStack()Lnet/minecraft/item/ItemStack;"), method = "renderHotbar") @ModifyExpressionValue(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;getOffHandStack()Lnet/minecraft/item/ItemStack;"), method = "renderHotbarVanilla")
public ItemStack swordblocking$hideOffHandSlot(ItemStack original) { public ItemStack swordblocking$hideOffHandSlot(ItemStack original) {
return (SwordBlockingConfig.enabled && SwordBlockingConfig.hideOffhandSlot && original.getItem() instanceof ShieldItem) ? ItemStack.EMPTY : original; return (SwordBlockingConfig.enabled && SwordBlockingConfig.hideOffhandSlot && original.getItem() instanceof ShieldItem) ? ItemStack.EMPTY : original;
} }

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

102
fabric/build.gradle Normal file
View File

@@ -0,0 +1,102 @@
plugins {
id 'com.github.johnrengelman.shadow'
id "me.shedaniel.unified-publishing"
}
architectury {
platformSetupLoomIde()
fabric()
}
loom {
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
archivesBaseName = rootProject.archives_base_name + "-fabric"
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-fabric")
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
shadowJar {
exclude "architectury.common.json"
configurations = [project.configurations.shadowCommon]
archiveClassifier = "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
unifiedPublishing {
project {
displayName = "SwordBlocking $project.version - Fabric $project.minecraft_version"
releaseType = "$project.release_type"
changelog = releaseChangelog()
gameVersions = []
gameLoaders = ["fabric","quilt"]
mainPublication remapJar
relations {
depends {
curseforge = "fabric-api"
modrinth = "fabric-api"
}
includes {
curseforge = "midnightlib"
modrinth = "midnightlib"
}
}
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version
}
}
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$project.version-$project.name"
gameVersions.addAll project.minecraft_version
}
}
}
}

View File

@@ -0,0 +1,11 @@
package eu.midnightdust.swordblocking.fabric;
import eu.midnightdust.swordblocking.SwordBlockingClient;
import net.fabricmc.api.ClientModInitializer;
public class SwordBlockingClientFabric implements ClientModInitializer {
@Override
public void onInitializeClient() {
SwordBlockingClient.init();
}
}

View File

@@ -4,7 +4,7 @@
"version": "${version}", "version": "${version}",
"name": "Sword Blocking", "name": "Sword Blocking",
"description": "Adds sword blocking to new versions, you just need a shield in your offhand!", "description": "Adds sword blocking to new versions, you just need a shield in your offhand (or ViaVersion)!",
"authors": [ "authors": [
"Motschen", "Motschen",
"TeamMidnightDust", "TeamMidnightDust",
@@ -22,7 +22,7 @@
"environment": "client", "environment": "client",
"entrypoints": { "entrypoints": {
"client": [ "client": [
"eu.midnightdust.swordblocking.SwordBlockingClient" "eu.midnightdust.swordblocking.fabric.SwordBlockingClientFabric"
] ]
}, },

View File

@@ -1,22 +1,24 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048M
# Fabric Properties minecraft_version=1.21
# check these on https://fabricmc.net/use yarn_mappings=1.21+build.2
minecraft_version=1.21 enabled_platforms=fabric,neoforge
yarn_mappings=1.21+build.1
loader_version=0.15.11
# Mod Properties archives_base_name=swordblocking
mod_version = 2.0.1 mod_version=2.1.0
maven_group = eu.midnightdust maven_group=eu.midnightdust
archives_base_name = swordblocking release_type=release
release_type=release curseforge_id=427738
curseforge_id=427738 modrinth_id=4q52b4lD
modrinth_id=4q52b4lD
# Dependencies midnightlib_version=1.5.7
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.100.1+1.21 fabric_loader_version=0.15.11
midnightlib_version=1.5.6-fabric fabric_api_version=0.100.1+1.21
neoforge_version=21.0.14-beta
yarn_mappings_patch_neoforge_version = 1.21+build.4
quilt_loader_version=0.19.0-beta.18
quilt_fabric_api_version=7.0.1+0.83.0-1.20

112
neoforge/build.gradle Normal file
View File

@@ -0,0 +1,112 @@
plugins {
id 'com.github.johnrengelman.shadow'
id "me.shedaniel.unified-publishing"
}
repositories {
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases'
}
}
architectury {
platformSetupLoomIde()
neoForge()
}
loom {
accessWidenerPath = project(":common").loom.accessWidenerPath
}
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
}
archivesBaseName = rootProject.archives_base_name + "-neoforge"
}
dependencies {
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
modImplementation include ("maven.modrinth:midnightlib:${rootProject.midnightlib_version}-neoforge")
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 {
input.set shadowJar.archiveFile
}
sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
}
components.java {
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
skip()
}
}
unifiedPublishing {
project {
displayName = "SwordBlocking $project.version - NeoForge $project.minecraft_version"
releaseType = "$project.release_type"
changelog = releaseChangelog()
gameVersions = []
gameLoaders = ["neoforge"]
mainPublication remapJar
relations {
includes {
curseforge = "midnightlib"
modrinth = "midnightlib"
}
}
var CURSEFORGE_TOKEN = project.findProperty("CURSEFORGE_TOKEN") ?: System.getenv("CURSEFORGE_TOKEN")
if (CURSEFORGE_TOKEN != null) {
curseforge {
token = CURSEFORGE_TOKEN
id = rootProject.curseforge_id
gameVersions.addAll "Java 21", project.minecraft_version
}
}
var MODRINTH_TOKEN = project.findProperty("MODRINTH_TOKEN") ?: System.getenv("MODRINTH_TOKEN")
if (MODRINTH_TOKEN != null) {
modrinth {
token = MODRINTH_TOKEN
id = rootProject.modrinth_id
version = "$project.version-$project.name"
gameVersions.addAll project.minecraft_version
}
}
}
}

View File

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

View File

@@ -0,0 +1,15 @@
package eu.midnightdust.swordblocking.neoforge;
import eu.midnightdust.swordblocking.SwordBlockingClient;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.common.Mod;
import static eu.midnightdust.swordblocking.SwordBlockingClient.MOD_ID;
@SuppressWarnings("all")
@Mod(value = MOD_ID, dist = Dist.CLIENT)
public class SwordBlockingClientNeoForge {
public SwordBlockingClientNeoForge() {
SwordBlockingClient.init();
}
}

View File

@@ -0,0 +1,38 @@
modLoader = "javafml"
loaderVersion = "[2,)"
#issueTrackerURL = ""
license = "MIT License"
[[mods]]
modId = "swordblocking"
version = "${version}"
displayName = "Sword Blocking"
logoFile = "icon.png"
authors = "Motschen, TeamMidnightDust, lowercasebtw"
description = '''
Adds sword blocking to new versions, you just need a shield in your offhand (or ViaVersion)!
'''
[[mixins]]
config = "swordblocking.mixins.json"
[[dependencies.visualoverhaul]]
modId = "neoforge"
mandatory = true
versionRange = "[21.0,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.visualoverhaul]]
modId = "minecraft"
mandatory = true
versionRange = "[1.21,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.visualoverhaul]]
modId = "picturesign"
mandatory = true
versionRange = "[1.0,)"
ordering = "AFTER"
side = "BOTH"

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -1,11 +1,15 @@
pluginManagement { pluginManagement {
repositories { repositories {
jcenter() maven { url "https://maven.fabricmc.net/" }
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven { url "https://maven.architectury.dev/" } maven { url "https://maven.architectury.dev/" }
maven { url "https://maven.neoforged.net/releases" }
gradlePluginPortal() gradlePluginPortal()
} }
} }
include("common")
include("fabric")
//include("quilt")
include("neoforge")
rootProject.name = "swordblocking"