mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
43702a9e10
By: md_5 <git@md-5.net>
42 lines
2 KiB
Diff
42 lines
2 KiB
Diff
--- a/net/minecraft/world/item/ItemCrossbow.java
|
|
+++ b/net/minecraft/world/item/ItemCrossbow.java
|
|
@@ -114,6 +114,10 @@
|
|
if (itemstack1.isEmpty() && flag) {
|
|
itemstack1 = new ItemStack(Items.ARROW);
|
|
itemstack2 = itemstack1.copy();
|
|
+ // CraftBukkit start - SPIGOT-4870, MC-150847
|
|
+ } else if (itemstack1.isEmpty()) {
|
|
+ return false;
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
if (!loadProjectile(entityliving, itemstack, itemstack1, k > 0, flag)) {
|
|
@@ -238,11 +242,27 @@
|
|
vector3fa.transform(quaternion);
|
|
((IProjectile) object).shoot((double) vector3fa.x(), (double) vector3fa.y(), (double) vector3fa.z(), f1, f2);
|
|
}
|
|
+ // CraftBukkit start
|
|
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, itemstack1, (Entity) object, entityliving.getUsedItemHand(), f, true);
|
|
+ if (event.isCancelled()) {
|
|
+ event.getProjectile().remove();
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
itemstack.hurtAndBreak(flag1 ? 3 : 1, entityliving, (entityliving1) -> {
|
|
entityliving1.broadcastBreakEvent(enumhand);
|
|
});
|
|
- world.addFreshEntity((Entity) object);
|
|
+ // CraftBukkit start
|
|
+ if (event.getProjectile() == ((Entity) object).getBukkitEntity()) {
|
|
+ if (!world.addFreshEntity((Entity) object)) {
|
|
+ if (entityliving instanceof EntityPlayer) {
|
|
+ ((EntityPlayer) entityliving).getBukkitEntity().updateInventory();
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
world.playSound((EntityHuman) null, entityliving.getX(), entityliving.getY(), entityliving.getZ(), SoundEffects.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
|
|
}
|
|
}
|