From ad35504c21be0cfc13cc117f6e7a190b93f43879 Mon Sep 17 00:00:00 2001 From: davidalb97 <43956418+davidalb97@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:22:09 +0100 Subject: [PATCH 1/3] Fixed PlayerAttackInvoker mixing loading crash on server side (#137) Signed-off-by: apple --- .../mixin/fabric/PlayerAttackInvoker.java | 4 +- .../client/ClientPlayerAttackInvoker.java | 41 +++++++++++++++++++ .../main/resources/architectury.mixins.json | 3 +- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java b/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java index dada8dab..3951daac 100644 --- a/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/PlayerAttackInvoker.java @@ -20,8 +20,6 @@ package dev.architectury.mixin.fabric; import dev.architectury.event.events.common.EntityEvent; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.client.player.RemotePlayer; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; @@ -30,7 +28,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(value = {LocalPlayer.class, Player.class, RemotePlayer.class}) +@Mixin(value = {Player.class}) public class PlayerAttackInvoker { @Inject(method = "hurt", at = @At("HEAD"), cancellable = true) private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable cir) { diff --git a/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java b/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java new file mode 100644 index 00000000..037ca90c --- /dev/null +++ b/fabric/src/main/java/dev/architectury/mixin/fabric/client/ClientPlayerAttackInvoker.java @@ -0,0 +1,41 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package dev.architectury.mixin.fabric.client; + +import dev.architectury.event.events.common.EntityEvent; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.player.RemotePlayer; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = {LocalPlayer.class, RemotePlayer.class}) +public class ClientPlayerAttackInvoker { + @Inject(method = "hurt", at = @At("HEAD"), cancellable = true) + private void hurt(DamageSource damageSource, float f, CallbackInfoReturnable cir) { + if (EntityEvent.LIVING_HURT.invoker().hurt((LivingEntity) (Object) this, damageSource, f).isFalse() && (Object) this instanceof Player) { + cir.setReturnValue(false); + } + } +} diff --git a/fabric/src/main/resources/architectury.mixins.json b/fabric/src/main/resources/architectury.mixins.json index 59818fa9..4738cb6c 100644 --- a/fabric/src/main/resources/architectury.mixins.json +++ b/fabric/src/main/resources/architectury.mixins.json @@ -16,7 +16,8 @@ "client.MixinMouseHandler", "client.MixinMultiPlayerGameMode", "client.MixinScreen", - "client.MixinTextureAtlas" + "client.MixinTextureAtlas", + "client.ClientPlayerAttackInvoker" ], "mixins": [ "ExplosionPreInvoker", From 404db2782a28b81d2724c35c2f8b8c4192d9611c Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Mon, 11 Oct 2021 08:59:02 +0300 Subject: [PATCH 2/3] Update deps in fabric.mod.json (#141) --- fabric/src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index f4465ae8..297bc6d8 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -32,7 +32,7 @@ "accessWidener": "architectury.accessWidener", "icon": "icon.png", "depends": { - "minecraft": ">=1.16.4" + "minecraft": "~1.17.1" }, "custom": { "modmenu:api": true From f636b1ad962e909597fe949b86d722f0d694d1ae Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 13 Oct 2021 22:08:53 +0800 Subject: [PATCH 3/3] Switch to gradle components --- fabric/build.gradle | 53 +++++++++++++++++++------------------ forge/build.gradle | 53 +++++++++++++++++++------------------ testmod-fabric/build.gradle | 21 +++++++-------- testmod-forge/build.gradle | 21 +++++++-------- 4 files changed, 72 insertions(+), 76 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index b1ee45af..1ae4b8f9 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -7,8 +7,17 @@ loom { accessWidenerPath = file("src/main/resources/architectury.accessWidener") } +architectury { + platformSetupLoomIde() + fabric() +} + configurations { - shadowCommon + 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 + developmentFabric.extendsFrom common dev } @@ -16,11 +25,6 @@ artifacts { dev(jar) } -architectury { - platformSetupLoomIde() - fabric() -} - repositories { maven { url "https://maven.terraformersmc.com/releases/" } } @@ -30,15 +34,8 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" modCompileOnly("com.terraformersmc:modmenu:${rootProject.mod_menu_version}") { transitive false } - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentFabric(project(path: ":common", configuration: "dev")) { - transitive = false - } - shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } } processResources { @@ -50,13 +47,17 @@ processResources { shadowJar { configurations = [project.configurations.shadowCommon] - classifier "shadow" + classifier "dev-shadow" } remapJar { - dependsOn(shadowJar) - input.set(shadowJar.archiveFile) - archiveClassifier = "fabric" + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" } sourcesJar { @@ -71,17 +72,17 @@ sourcesJar { } } +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + publishing { publications { mavenFabric(MavenPublication) { artifactId = rootProject.archivesBaseName + "-fabric" - artifact(remapJar) { classifier null } - afterEvaluate { - artifact(remapSourcesJar.output) { - builtBy remapSourcesJar - classifier "sources" - } - } + from components.java } } diff --git a/forge/build.gradle b/forge/build.gradle index 2a4d0dcd..b53619e5 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -10,8 +10,17 @@ loom { } } +architectury { + platformSetupLoomIde() + forge() +} + configurations { - shadowCommon + 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 dev } @@ -19,23 +28,11 @@ artifacts { dev(jar) } -architectury { - platformSetupLoomIde() - forge() -} - dependencies { forge "net.minecraftforge:forge:${rootProject.architectury.minecraft}-${rootProject.forge_version}" - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentForge(project(path: ":common", configuration: "dev")) { - transitive = false - } - shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive false } + shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false } } processResources { @@ -50,13 +47,17 @@ shadowJar { exclude "architectury-common.accessWidener" configurations = [project.configurations.shadowCommon] - classifier "shadow" + classifier "dev-shadow" } remapJar { - dependsOn(shadowJar) - input.set(shadowJar.archivePath) - archiveClassifier = "forge" + input.set shadowJar.archiveFile + dependsOn shadowJar + classifier null +} + +jar { + classifier "dev" } sourcesJar { @@ -71,17 +72,17 @@ sourcesJar { } } +components.java { + withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { + skip() + } +} + publishing { publications { mavenForge(MavenPublication) { artifactId = rootProject.archivesBaseName + "-forge" - artifact(remapJar) { classifier null } - afterEvaluate { - artifact(remapSourcesJar.output) { - builtBy remapSourcesJar - classifier "sources" - } - } + from components.java } } diff --git a/testmod-fabric/build.gradle b/testmod-fabric/build.gradle index 79a5813b..5179c899 100644 --- a/testmod-fabric/build.gradle +++ b/testmod-fabric/build.gradle @@ -12,21 +12,18 @@ architectury { fabric() } +configurations { + common + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentFabric.extendsFrom common +} + dependencies { modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" implementation project(path: ":fabric", configuration: "dev") - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentFabric(project(path: ":common", configuration: "dev")) { - transitive = false - } - implementation(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } - developmentFabric(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive = false } + common(project(path: ":testmod-common", configuration: "dev")) { transitive false } } diff --git a/testmod-forge/build.gradle b/testmod-forge/build.gradle index d71a7742..8b0fa5d0 100644 --- a/testmod-forge/build.gradle +++ b/testmod-forge/build.gradle @@ -20,20 +20,17 @@ architectury { forge() } +configurations { + common + compileClasspath.extendsFrom common + runtimeClasspath.extendsFrom common + developmentForge.extendsFrom common +} + dependencies { forge "net.minecraftforge:forge:${gradle.rootProject.architectury.minecraft}-${rootProject.forge_version}" implementation project(path: ":forge", configuration: "dev") - implementation(project(path: ":common", configuration: "dev")) { - transitive = false - } - developmentForge(project(path: ":common", configuration: "dev")) { - transitive = false - } - implementation(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } - developmentForge(project(path: ":testmod-common", configuration: "dev")) { - transitive = false - } + common(project(path: ":common", configuration: "dev")) { transitive false } + common(project(path: ":testmod-common", configuration: "dev")) { transitive false } }