1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2024-12-15 03:05:39 +01:00
PaperMC/nms-patches/ItemCrossbow.patch
2020-06-25 10:00:00 +10:00

43 lines
1.9 KiB
Diff

--- a/net/minecraft/server/ItemCrossbow.java
+++ b/net/minecraft/server/ItemCrossbow.java
@@ -75,6 +75,11 @@
itemstack1 = new ItemStack(Items.ARROW);
itemstack2 = itemstack1.cloneItemStack();
}
+ // CraftBukkit start - SPIGOT-4870, MC-150847
+ else if (itemstack1.isEmpty()) {
+ return false;
+ }
+ // CraftBukkit end
if (!a(entityliving, itemstack, itemstack1, k > 0, flag)) {
return false;
@@ -198,11 +203,27 @@
vector3fa.a(quaternion);
((IProjectile) object).shoot((double) vector3fa.a(), (double) vector3fa.b(), (double) vector3fa.c(), f1, f2);
}
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityliving, itemstack, (Entity) object, f);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+ // CraftBukkit end
itemstack.damage(flag1 ? 3 : 1, entityliving, (entityliving1) -> {
entityliving1.broadcastItemBreak(enumhand);
});
- world.addEntity((Entity) object);
+ // CraftBukkit start
+ if (event.getProjectile() == ((Entity) object).getBukkitEntity()) {
+ if (!world.addEntity((Entity) object)) {
+ if (entityliving instanceof EntityPlayer) {
+ ((EntityPlayer) entityliving).getBukkitEntity().updateInventory();
+ }
+ return;
+ }
+ }
+ // CraftBukkit end
world.playSound((EntityHuman) null, entityliving.locX(), entityliving.locY(), entityliving.locZ(), SoundEffects.ITEM_CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, f);
}
}