craftbukkit/nms-patches/net/minecraft/world/item/ItemCrossbow.patch

43 lines
2 KiB
Diff
Raw Normal View History

2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/ItemCrossbow.java
+++ b/net/minecraft/world/item/ItemCrossbow.java
2022-06-08 02:00:00 +10:00
@@ -112,6 +112,10 @@
2021-01-31 10:08:41 +11:00
if (itemstack1.isEmpty() && flag) {
itemstack1 = new ItemStack(Items.ARROW);
2021-11-22 09:00:00 +11:00
itemstack2 = itemstack1.copy();
2021-01-31 10:08:41 +11:00
+ // CraftBukkit start - SPIGOT-4870, MC-150847
+ } else if (itemstack1.isEmpty()) {
2019-05-14 10:00:00 +10:00
+ return false;
2021-01-31 10:08:41 +11:00
+ // CraftBukkit end
}
2021-11-22 09:00:00 +11:00
if (!loadProjectile(entityliving, itemstack, itemstack1, k > 0, flag)) {
2022-06-08 02:00:00 +10:00
@@ -236,11 +240,27 @@
2021-11-22 09:00:00 +11:00
vector3fa.transform(quaternion);
((IProjectile) object).shoot((double) vector3fa.x(), (double) vector3fa.y(), (double) vector3fa.z(), f1, f2);
2019-04-23 12:00:00 +10:00
}
+ // CraftBukkit start
2021-11-22 09:00:00 +11:00
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getUsedItemHand(), f, true);
2019-04-23 12:00:00 +10:00
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+ // CraftBukkit end
2021-11-22 09:00:00 +11:00
itemstack.hurtAndBreak(flag1 ? 3 : 1, entityliving, (entityliving1) -> {
entityliving1.broadcastBreakEvent(enumhand);
2019-04-23 12:00:00 +10:00
});
2021-11-22 09:00:00 +11:00
- world.addFreshEntity((Entity) object);
2019-04-23 12:00:00 +10:00
+ // CraftBukkit start
+ if (event.getProjectile() == ((Entity) object).getBukkitEntity()) {
2021-11-22 09:00:00 +11:00
+ if (!world.addFreshEntity((Entity) object)) {
2019-04-23 12:00:00 +10:00
+ if (entityliving instanceof EntityPlayer) {
+ ((EntityPlayer) entityliving).getBukkitEntity().updateInventory();
+ }
+ return;
+ }
+ }
+ // CraftBukkit end
2021-11-22 09:00:00 +11:00
world.playSound((EntityHuman) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
2019-04-23 12:00:00 +10:00
}
}