PaperMC/nms-patches/EntityArrow.patch

72 lines
3.7 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
2019-04-23 04:00:00 +02:00
@@ -9,6 +9,12 @@
import java.util.UUID;
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;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
2016-02-29 22:32:46 +01:00
public abstract class EntityArrow extends Entity implements IProjectile {
2019-12-10 23:00:00 +01:00
private static final DataWatcherObject<Byte> ao = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a);
@@ -255,6 +261,7 @@
2018-07-15 02:00:00 +02:00
}
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
2019-04-23 04:00:00 +02:00
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
2019-12-10 23:00:00 +01:00
@@ -336,7 +343,13 @@
2019-06-21 12:00:00 +02:00
int j = entity.ad();
2015-02-26 23:41:06 +01:00
2019-12-10 23:00:00 +01:00
if (this.isBurning() && !flag) {
2018-07-15 02:00:00 +02:00
- 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(), false);
2018-07-15 02:00:00 +02:00
+ }
+ // CraftBukkit end
}
2018-07-15 02:00:00 +02:00
if (entity.damageEntity(damagesource, (float) i)) {
2019-12-10 23:00:00 +01:00
@@ -477,6 +490,7 @@
2018-08-26 04:00:00 +02:00
public void setShooter(@Nullable Entity entity) {
this.shooter = entity == null ? null : entity.getUniqueID();
+ this.projectileSource = entity == null ? null : (LivingEntity) entity.getBukkitEntity(); // CraftBukkit
2019-04-23 04:00:00 +02:00
if (entity instanceof EntityHuman) {
this.fromPlayer = ((EntityHuman) entity).abilities.canInstantlyBuild ? EntityArrow.PickupStatus.CREATIVE_ONLY : EntityArrow.PickupStatus.ALLOWED;
}
2019-12-10 23:00:00 +01:00
@@ -491,9 +505,23 @@
2019-04-23 04:00:00 +02:00
@Override
public void pickup(EntityHuman entityhuman) {
if (!this.world.isClientSide && (this.inGround || this.v()) && this.shake <= 0) {
+ // CraftBukkit start
2018-07-15 02:00:00 +02:00
+ ItemStack itemstack = this.getItemStack();
+ if (this.fromPlayer == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.inventory.canHold(itemstack) > 0) {
2019-12-10 23:00:00 +01:00
+ EntityItem item = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), itemstack);
2019-04-30 22:48:56 +02:00
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity());
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ itemstack = item.getItemStack();
+ }
2019-04-23 04:00:00 +02:00
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.v() && this.getShooter().getUniqueID() == entityhuman.getUniqueID();
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(itemstack)) {
+ // CraftBukkit end
flag = false;
}