From d4a689ccc3e911394722e6cd87c551a6c870c0e4 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sun, 27 Oct 2024 23:25:16 +0100 Subject: [PATCH] Fix hand swinging in animal/zombie villager entities If action was previously SUCCESS, we need to change that since SUCCESS_SERVER is only handled on newer servers, if it was previously CONSUME the change can stay. --- .../viafabricplus/ViaFabricPlus.java | 3 +++ .../fixes/minecraft/entity/MixinAnimalEntity.java | 10 ++++++++++ .../MixinZombieVillagerEntity.java} | 14 +++++++------- src/main/resources/viafabricplus.mixins.json | 5 ++++- 4 files changed, 24 insertions(+), 8 deletions(-) rename src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/{block/MixinVaultBlock.java => entity/MixinZombieVillagerEntity.java} (78%) diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 5605769a..eb8c9d04 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -36,6 +36,9 @@ import java.util.concurrent.CompletableFuture; * TODO | Port 1.21.3 * - VehicleMovePacket handling now has distance check * - Game options are now only send if they changed + * - ArmorStand/MobEntity interaction CONSUME->SUCESS_SERVER + * - Illusioner/Sniffer doesn't override visibility bounding box anymore + * - AbstractFireabll#shouldRender new * * TODO | Port 1.20.6 * - ClientPlayerInteractionManager#interactBlockInternal added new condition diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java index 02ad7fd2..d4ea27b4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinAnimalEntity.java @@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.util.ActionResult; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -30,6 +31,15 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(AnimalEntity.class) public abstract class MixinAnimalEntity { + @Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/util/ActionResult;SUCCESS_SERVER:Lnet/minecraft/util/ActionResult$Success;")) + private ActionResult.Success swingHand() { + if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) { + return ActionResult.SUCCESS; + } else { + return ActionResult.SUCCESS_SERVER; + } + } + @Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isClient:Z")) private boolean changeIsClientCondition(World instance) { return instance.isClient && ProtocolTranslator.getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_15); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinVaultBlock.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinZombieVillagerEntity.java similarity index 78% rename from src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinVaultBlock.java rename to src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinZombieVillagerEntity.java index 98d5a110..f9a760a6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/block/MixinVaultBlock.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinZombieVillagerEntity.java @@ -17,23 +17,23 @@ * along with this program. If not, see . */ -package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.block; +package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.entity; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; -import net.minecraft.block.VaultBlock; +import net.minecraft.entity.mob.ZombieVillagerEntity; import net.minecraft.util.ActionResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(VaultBlock.class) -public abstract class MixinVaultBlock { +@Mixin(ZombieVillagerEntity.class) +public abstract class MixinZombieVillagerEntity { - @Redirect(method = "onUseWithItem", at = @At(value = "FIELD", target = "Lnet/minecraft/util/ActionResult;SUCCESS_SERVER:Lnet/minecraft/util/ActionResult$Success;")) - private ActionResult.Success dontSwingHand() { + @Redirect(method = "interactMob", at = @At(value = "FIELD", target = "Lnet/minecraft/util/ActionResult;SUCCESS_SERVER:Lnet/minecraft/util/ActionResult$Success;")) + private ActionResult.Success swingHand() { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_21)) { - return ActionResult.CONSUME; + return ActionResult.SUCCESS; } else { return ActionResult.SUCCESS_SERVER; } diff --git a/src/main/resources/viafabricplus.mixins.json b/src/main/resources/viafabricplus.mixins.json index 7d0b9e2d..df60f131 100644 --- a/src/main/resources/viafabricplus.mixins.json +++ b/src/main/resources/viafabricplus.mixins.json @@ -219,5 +219,8 @@ }, "overwrites": { "requireAnnotations": true - } + }, + "mixins": [ + "fixes.minecraft.entity.MixinZombieVillagerEntity" + ] }