3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-23 23:00:08 +01:00
Paper/nms-patches/ItemBow.patch

35 Zeilen
1.9 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemBow.java
+++ b/net/minecraft/server/ItemBow.java
2020-06-25 02:00:00 +02:00
@@ -50,6 +50,13 @@
2016-02-29 22:32:46 +01:00
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
entityarrow.setOnFire(100);
}
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
itemstack.damage(1, entityhuman, (entityhuman1) -> {
2020-01-21 22:00:00 +01:00
entityhuman1.broadcastItemBreak(entityhuman.getRaisedHand());
2020-06-25 02:00:00 +02:00
@@ -58,7 +65,16 @@
2016-02-29 22:32:46 +01:00
entityarrow.fromPlayer = EntityArrow.PickupStatus.CREATIVE_ONLY;
}
2016-02-29 22:32:46 +01:00
- world.addEntity(entityarrow);
+ // CraftBukkit start
2016-02-29 22:32:46 +01:00
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ if (!world.addEntity(entityarrow)) {
+ if (entityhuman instanceof EntityPlayer) {
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory();
+ }
+ return;
+ }
2016-02-29 22:32:46 +01:00
+ }
+ // CraftBukkit end
}
2020-06-25 02:00:00 +02:00
world.playSound((EntityHuman) null, entityhuman.locX(), entityhuman.locY(), entityhuman.locZ(), SoundEffects.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0F, 1.0F / (ItemBow.RANDOM.nextFloat() * 0.4F + 1.2F) + f * 0.5F);