Paper/nms-patches/EntityArrow.patch

88 Zeilen
4.1 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
2016-11-17 02:41:03 +01:00
@@ -5,6 +5,13 @@
2018-07-15 02:00:00 +02:00
import java.util.function.Predicate;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
2016-11-17 02:41:03 +01:00
+import org.bukkit.event.entity.EntityCombustEvent;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
2016-02-29 22:32:46 +01:00
public abstract class EntityArrow extends Entity implements IProjectile {
2018-07-15 02:00:00 +02:00
private static final Predicate<Entity> f = IEntitySelector.e.and(IEntitySelector.a.and(Entity::isInteractable));
@@ -42,6 +49,7 @@
protected EntityArrow(EntityTypes<?> entitytypes, EntityLiving entityliving, World world) {
this(entitytypes, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ, world);
this.shooter = entityliving;
+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
if (entityliving instanceof EntityHuman) {
2016-02-29 22:32:46 +01:00
this.fromPlayer = EntityArrow.PickupStatus.ALLOWED;
}
2018-07-15 02:00:00 +02:00
@@ -245,6 +253,7 @@
}
2016-02-29 22:32:46 +01:00
protected void a(MovingObjectPosition movingobjectposition) {
2016-11-28 02:47:01 +01:00
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
2018-07-15 02:00:00 +02:00
if (movingobjectposition.entity != null) {
this.b(movingobjectposition);
} else {
@@ -293,7 +302,13 @@
}
2015-02-26 23:41:06 +01:00
2018-07-15 02:00:00 +02: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 02:00:00 +02:00
if (entity.damageEntity(damagesource, (float) i)) {
@@ -430,9 +445,22 @@
public void d(EntityHuman entityhuman) {
2018-07-15 02:00:00 +02:00
if (!this.world.isClientSide && (this.inGround || this.p()) && this.shake <= 0) {
+ // CraftBukkit start
2018-07-15 02:00:00 +02:00
+ ItemStack itemstack = this.getItemStack();
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
2016-02-29 22:32:46 +01:00
+ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
+ 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;
+ }
+ }
2018-07-15 02:00:00 +02:00
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.p() && this.shooter == entityhuman;
2018-07-15 02:00:00 +02:00
- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.getItemStack())) {
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) {
+ // CraftBukkit end
flag = false;
}
2018-07-15 02:00:00 +02:00
@@ -505,7 +533,14 @@
2016-11-17 02:41:03 +01:00
}
2016-02-29 22:32:46 +01:00
2016-11-17 02:41:03 +01: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-02-29 22:32:46 +01:00
+
2016-11-17 02:41:03 +01:00
+ if (!event.isCancelled()) {
+ this.setOnFire(event.getDuration());
+ }
+ // CraftBukkit end
}
2016-02-29 22:32:46 +01:00
2016-11-17 02:41:03 +01:00
}