PaperMC/paper-server/nms-patches/net/minecraft/world/entity/projectile/EntityArrow.patch

64 lines
2.9 KiB
Diff
Raw Normal View History

2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/entity/projectile/EntityArrow.java
+++ b/net/minecraft/world/entity/projectile/EntityArrow.java
@@ -44,6 +44,12 @@
2021-03-15 23:00:00 +01:00
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShape;
+// CraftBukkit start
2021-03-15 23:00:00 +01:00
+import net.minecraft.world.entity.item.EntityItem;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
public abstract class EntityArrow extends IProjectile {
private static final double ARROW_BASE_DAMAGE = 2.0D;
@@ -210,7 +216,7 @@
}
if (object != null && !flag) {
- this.a((MovingObjectPosition) object);
+ this.preOnHit((MovingObjectPosition) object); // CraftBukkit - projectile hit event
this.hasImpulse = true;
}
@@ -357,7 +363,13 @@
int k = entity.getFireTicks();
if (this.isBurning() && !flag) {
- 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);
+ }
+ // CraftBukkit end
}
if (entity.damageEntity(damagesource, (float) i)) {
@@ -519,7 +531,22 @@
@Override
public void pickup(EntityHuman entityhuman) {
if (!this.level.isClientSide && (this.inGround || this.t()) && this.shakeTime <= 0) {
- if (this.a(entityhuman)) {
+ // CraftBukkit start
+ ItemStack itemstack = this.getItemStack();
+ if (this.pickup == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.getInventory().canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), itemstack);
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level.getServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity());
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ itemstack = item.getItemStack();
+ }
+
+ if ((this.pickup == EntityArrow.PickupStatus.ALLOWED && entityhuman.getInventory().pickup(itemstack)) || (this.pickup == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.getAbilities().instabuild)) {
+ // CraftBukkit end
entityhuman.receive(this, 1);
this.die();
}