Paper/nms-patches/EntityArrow.patch

89 lines
4.0 KiB
Diff
Raw Normal View History

2015-05-25 18:37:24 +08:00
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
2018-08-26 10:00:00 +08:00
@@ -7,6 +7,13 @@
2018-07-15 08:00:00 +08:00
import java.util.function.Predicate;
2016-05-10 19:47:39 +08:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
2016-11-17 09:41:03 +08:00
+import org.bukkit.event.entity.EntityCombustEvent;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
2016-03-01 05:32:46 +08:00
public abstract class EntityArrow extends Entity implements IProjectile {
2018-08-26 10:00:00 +08:00
private static final Predicate<Entity> g = IEntitySelector.f.and(IEntitySelector.a.and(Entity::isInteractable));
@@ -250,6 +257,7 @@
2018-07-15 08:00:00 +08:00
}
2016-03-01 05:32:46 +08:00
protected void a(MovingObjectPosition movingobjectposition) {
2016-11-28 09:47:01 +08:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
2018-07-15 08:00:00 +08:00
if (movingobjectposition.entity != null) {
this.b(movingobjectposition);
} else {
2018-08-26 10:00:00 +08:00
@@ -299,7 +307,13 @@
2018-07-15 08:00:00 +08:00
}
2015-02-27 06:41:06 +08:00
2018-07-15 08:00:00 +08:00
if (this.isBurning() && !(entity instanceof EntityEnderman)) {
- entity.setOnFire(5);
+ // CraftBukkit start
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
+ if (!combustEvent.isCancelled()) {
+ entity.setOnFire(combustEvent.getDuration());
+ }
+ // CraftBukkit end
}
2018-07-15 08:00:00 +08:00
if (entity.damageEntity(damagesource, (float) i)) {
2018-08-26 10:00:00 +08:00
@@ -444,6 +458,7 @@
public void setShooter(@Nullable Entity entity) {
this.shooter = entity == null ? null : entity.getUniqueID();
+ this.projectileSource = entity == null ? null : (LivingEntity) entity.getBukkitEntity(); // CraftBukkit
}
@Nullable
@@ -453,9 +468,23 @@
public void d(EntityHuman entityhuman) {
2018-08-26 10:00:00 +08:00
if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) {
+ // CraftBukkit start
2018-07-15 08:00:00 +08:00
+ ItemStack itemstack = this.getItemStack();
+ if (this.fromPlayer == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.inventory.canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity());
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ itemstack = item.getItemStack();
+ }
2018-08-26 10:00:00 +08:00
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.q() && this.getShooter().getUniqueID() == entityhuman.getUniqueID();
2018-07-15 08:00:00 +08:00
- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) {
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(itemstack)) {
+ // CraftBukkit end
flag = false;
}
@@ -528,7 +557,14 @@
2016-11-17 09:41:03 +08:00
}
2016-03-01 05:32:46 +08:00
2016-11-17 09:41:03 +08:00
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) {
- this.setOnFire(100);
+ // CraftBukkit start - call EntityCombustEvent
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 100);
+ this.world.getServer().getPluginManager().callEvent(event);
2016-03-01 05:32:46 +08:00
+
2016-11-17 09:41:03 +08:00
+ if (!event.isCancelled()) {
+ this.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
}
2016-03-01 05:32:46 +08:00
2016-11-17 09:41:03 +08:00
}