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