2015-05-25 18:37:24 +08:00
|
|
|
--- a/net/minecraft/server/EntityArrow.java
|
|
|
|
+++ b/net/minecraft/server/EntityArrow.java
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -5,6 +5,13 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
import java.util.List;
|
2016-05-10 19:47:39 +08:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-26 05:32:16 +08:00
|
|
|
|
|
|
|
+// 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;
|
2016-03-23 02:03:48 +08:00
|
|
|
+import org.bukkit.event.player.PlayerPickupArrowEvent;
|
2014-11-26 05:32:16 +08:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
2016-03-01 05:32:46 +08:00
|
|
|
public abstract class EntityArrow extends Entity implements IProjectile {
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
private static final Predicate<Entity> f = Predicates.and(new Predicate[] { IEntitySelector.e, IEntitySelector.a, new Predicate() {
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -50,6 +57,7 @@
|
2016-03-01 05:32:46 +08:00
|
|
|
public EntityArrow(World world, EntityLiving entityliving) {
|
|
|
|
this(world, entityliving.locX, entityliving.locY + (double) entityliving.getHeadHeight() - 0.10000000149011612D, entityliving.locZ);
|
2014-11-26 05:32:16 +08:00
|
|
|
this.shooter = entityliving;
|
|
|
|
+ this.projectileSource = (LivingEntity) entityliving.getBukkitEntity(); // CraftBukkit
|
|
|
|
if (entityliving instanceof EntityHuman) {
|
2016-03-01 05:32:46 +08:00
|
|
|
this.fromPlayer = EntityArrow.PickupStatus.ALLOWED;
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -236,7 +244,7 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
|
|
|
Entity entity = movingobjectposition.entity;
|
|
|
|
-
|
2016-11-28 09:47:01 +08:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
|
2016-03-01 05:32:46 +08:00
|
|
|
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);
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -254,7 +262,13 @@
|
2016-03-01 05:32:46 +08:00
|
|
|
}
|
2015-02-27 06:41:06 +08:00
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
if (this.isBurning() && !(entity instanceof EntityEnderman)) {
|
|
|
|
- entity.setOnFire(5);
|
2016-05-28 20:10:59 +08:00
|
|
|
+ // CraftBukkit start
|
2016-03-01 05:32:46 +08:00
|
|
|
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
|
|
|
+ if (!combustEvent.isCancelled()) {
|
|
|
|
+ entity.setOnFire(combustEvent.getDuration());
|
|
|
|
+ }
|
2016-05-28 20:10:59 +08:00
|
|
|
+ // CraftBukkit end
|
2016-03-01 05:32:46 +08:00
|
|
|
}
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2016-05-28 20:10:59 +08:00
|
|
|
if (entity.damageEntity(damagesource, (float) i)) {
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -422,6 +436,20 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
|
|
|
|
public void d(EntityHuman entityhuman) {
|
2015-02-27 06:41:06 +08:00
|
|
|
if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ ItemStack itemstack = new ItemStack(Items.ARROW);
|
2016-03-01 05:32:46 +08:00
|
|
|
+ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
|
|
|
|
+
|
2016-03-23 02:03:48 +08: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.Arrow) this.getBukkitEntity());
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-03-01 05:32:46 +08:00
|
|
|
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild;
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -493,7 +521,14 @@
|
|
|
|
}
|
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
|
|
|
}
|