diff --git a/src/main/java/org/auioc/mcmod/arnicalib/mod/mixin/server/MixinBowItem.java b/src/main/java/org/auioc/mcmod/arnicalib/mod/mixin/server/MixinBowItem.java new file mode 100644 index 00000000..9b839aae --- /dev/null +++ b/src/main/java/org/auioc/mcmod/arnicalib/mod/mixin/server/MixinBowItem.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 AUIOC.ORG + * + * This file is part of ArnicaLib, a mod made for Minecraft. + * + * ArnicaLib is free software: you can redistribute it and/or modify it under + * the terms of the GNU 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 General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +package org.auioc.mcmod.arnicalib.mod.mixin.server; + +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.AbstractArrow; +import net.minecraft.world.item.ArrowItem; +import net.minecraft.world.item.BowItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.auioc.mcmod.arnicalib.mod.server.event.AHServerEventFactory; +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.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Mixin(value = BowItem.class) +public class MixinBowItem { + + @Inject( + method = "Lnet/minecraft/world/item/BowItem;releaseUsing(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;I)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z", + shift = At.Shift.BEFORE + ), + locals = LocalCapture.CAPTURE_FAILHARD, + require = 1, + allow = 1 + ) + public void releaseUsing( + ItemStack pStack, Level pLevel, LivingEntity pEntityLiving, int pTimeLeft, + CallbackInfo ci, + Player player, boolean flag, ItemStack itemstack, int i, float f, boolean flag1, ArrowItem arrowitem, AbstractArrow abstractarrow, int j, int k + ) { + AHServerEventFactory.preProjectileWeaponRelease(player, pStack, abstractarrow); + } + +} diff --git a/src/main/resources/arnicalib.mixin.json b/src/main/resources/arnicalib.mixin.json index 46277444..969e36ce 100644 --- a/src/main/resources/arnicalib.mixin.json +++ b/src/main/resources/arnicalib.mixin.json @@ -7,6 +7,7 @@ "common.MixinAccessorEnchantment", "common.MixinAccessorMobEffectInstance", "common.MixinProjectile", + "server.MixinBowItem", "server.MixinMemoryServerHandshakePacketListenerImpl", "server.MixinServerHandshakePacketListenerImpl" ],