Skip to content

Commit

Permalink
feat(mixin): bow item projectile weapon release event
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Feb 13, 2024
1 parent c131e55 commit de5c6cb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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);
}

}
1 change: 1 addition & 0 deletions src/main/resources/arnicalib.mixin.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"common.MixinAccessorEnchantment",
"common.MixinAccessorMobEffectInstance",
"common.MixinProjectile",
"server.MixinBowItem",
"server.MixinMemoryServerHandshakePacketListenerImpl",
"server.MixinServerHandshakePacketListenerImpl"
],
Expand Down

0 comments on commit de5c6cb

Please sign in to comment.