3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/EntityArrow.patch

88 Zeilen
4.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
2016-02-29 22:32:46 +01:00
@@ -4,6 +4,12 @@
import com.google.common.base.Predicates;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
+// CraftBukkit end
+
2016-02-29 22:32:46 +01:00
public abstract class EntityArrow extends Entity implements IProjectile {
2016-02-29 22:32:46 +01:00
private static final Predicate<Entity> f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() {
@@ -49,6 +55,7 @@
public EntityArrow(World world, EntityLiving entityliving) {
this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
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;
}
2016-02-29 22:32:46 +01:00
@@ -228,7 +235,7 @@
2016-02-29 22:32:46 +01:00
protected void a(MovingObjectPosition movingobjectposition) {
Entity entity = movingobjectposition.entity;
-
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
if (entity != null) {
float f = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ);
int i = MathHelper.f((double) f * this.damage);
@@ -245,11 +252,18 @@
damagesource = DamageSource.arrow(this, this.shooter);
}
2015-02-26 23:41:06 +01:00
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start - Moved damage call
+ if (movingobjectposition.entity.damageEntity(damagesource, (float) i)) {
if (this.isBurning() && !(entity instanceof EntityEnderman)) {
- entity.setOnFire(5);
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
+ if (!combustEvent.isCancelled()) {
+ entity.setOnFire(combustEvent.getDuration());
+ }
+ // CraftBukkit end
}
2016-02-29 22:32:46 +01:00
- if (entity.damageEntity(damagesource, (float) i)) {
+ // if (entity.damageEntity(damagesource, (float) i)) { // CraftBukkit - moved up
if (entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) entity;
2016-02-29 22:32:46 +01:00
@@ -395,6 +409,20 @@
public void d(EntityHuman entityhuman) {
2015-02-26 23:41:06 +01:00
if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
+ // CraftBukkit start
+ ItemStack itemstack = new ItemStack(Items.ARROW);
2016-02-29 22:32:46 +01:00
+ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+
+ PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0);
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
+ }
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild;
2016-02-29 22:32:46 +01:00
if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
@@ -453,6 +481,12 @@
return (b0 & 1) != 0;
}
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ public boolean isInGround() {
+ return inGround;
+ }
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
+
public static enum PickupStatus {
DISALLOWED, ALLOWED, CREATIVE_ONLY;