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

50 Zeilen
2.3 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ItemBow.java
+++ b/net/minecraft/server/ItemBow.java
2016-05-10 13:47:39 +02:00
@@ -1,6 +1,7 @@
package net.minecraft.server;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
2016-05-10 13:47:39 +02:00
public class ItemBow extends Item {
2016-05-10 13:47:39 +02:00
@@ -75,7 +76,20 @@
2016-02-29 22:32:46 +01:00
}
2016-02-29 22:32:46 +01:00
if (EnchantmentManager.getEnchantmentLevel(Enchantments.ARROW_FIRE, itemstack) > 0) {
- entityarrow.setOnFire(100);
+ // CraftBukkit start - call EntityCombustEvent
+ EntityCombustEvent event = new EntityCombustEvent(entityarrow.getBukkitEntity(), 100);
+ entityarrow.world.getServer().getPluginManager().callEvent(event);
+
2016-02-29 22:32:46 +01:00
+ if (!event.isCancelled()) {
+ entityarrow.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
+ }
+ // 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;
}
2016-02-29 22:32:46 +01:00
itemstack.damage(1, entityhuman);
2016-05-10 13:47:39 +02:00
@@ -83,7 +97,15 @@
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);
+ 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
}
2016-03-30 21:50:59 +02:00
world.a((EntityHuman) null, entityhuman.locX, entityhuman.locY, entityhuman.locZ, SoundEffects.v, SoundCategory.NEUTRAL, 1.0F, 1.0F / (ItemBow.j.nextFloat() * 0.4F + 1.2F) + f * 0.5F);