ForgePatch/patches/minecraft/net/minecraft/item/ItemBow.java.patch

38 lines
1.9 KiB
Diff

--- ../src-base/minecraft/net/minecraft/item/ItemBow.java
+++ ../src-work/minecraft/net/minecraft/item/ItemBow.java
@@ -83,6 +83,10 @@
boolean flag = entityplayer.field_71075_bZ.field_75098_d || EnchantmentHelper.func_77506_a(Enchantments.field_185312_x, p_77615_1_) > 0;
ItemStack itemstack = this.func_185060_a(entityplayer);
+ int i = this.func_77626_a(p_77615_1_) - p_77615_4_;
+ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_77615_1_, p_77615_2_, (EntityPlayer)p_77615_3_, i, itemstack != null || flag);
+ if (i < 0) return;
+
if (!itemstack.func_190926_b() || flag)
{
if (itemstack.func_190926_b())
@@ -90,12 +94,11 @@
itemstack = new ItemStack(Items.field_151032_g);
}
- int i = this.func_77626_a(p_77615_1_) - p_77615_4_;
float f = func_185059_b(i);
if ((double)f >= 0.1D)
{
- boolean flag1 = flag && itemstack.func_77973_b() == Items.field_151032_g;
+ boolean flag1 = entityplayer.field_71075_bZ.field_75098_d || (itemstack.func_77973_b() instanceof ItemArrow ? ((ItemArrow)itemstack.func_77973_b()).isInfinite(itemstack, p_77615_1_, entityplayer) : false);
if (!p_77615_2_.field_72995_K)
{
@@ -183,6 +186,9 @@
ItemStack itemstack = p_77659_2_.func_184586_b(p_77659_3_);
boolean flag = !this.func_185060_a(p_77659_2_).func_190926_b();
+ ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(itemstack, p_77659_1_, p_77659_2_, p_77659_3_, flag);
+ if (ret != null) return ret;
+
if (!p_77659_2_.field_71075_bZ.field_75098_d && !flag)
{
return flag ? new ActionResult(EnumActionResult.PASS, itemstack) : new ActionResult(EnumActionResult.FAIL, itemstack);