nageyqma·git
HTTPS https://git.nageyqma.icu/nageyqma/blade-addons-next.git SSH git@git.nageyqma.icu:nageyqma/blade-addons-next.git

HTTPS 链接可直接 git clone;推送代码请使用 SSH。

1.1 KB · 26 行raw
1234567891011121314151617181920212223242526
package blade.addon.mixin;

import blade.addon.features.other.SwingAnimation;
import blade.addon.utils.data.EntityUtil;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
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(LivingEntity.class)
public class LivingEntityMixin {


    // 26.3 replaced swing(InteractionHand, boolean) with
    // swing(InteractionHand, net.minecraft.world.item.component.SwingAnimation, boolean).
    @Inject(method = "swing(Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/component/SwingAnimation;Z)Z", at = @At("TAIL"))
    public void swingHand(InteractionHand hand, net.minecraft.world.item.component.SwingAnimation animation, boolean fromServerPlayer, CallbackInfoReturnable<Boolean> cir) {
        if (EntityUtil.isClientPlayer((Entity) (Object) this)) {
            SwingAnimation.consumeSwing();
        }
    }
}