mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-25 09:34:44 +01:00
65bc2541a3
By: md_5 <git@md-5.net>
103 lines
4.5 KiB
Diff
103 lines
4.5 KiB
Diff
--- a/net/minecraft/world/entity/projectile/EntityArrow.java
|
|
+++ b/net/minecraft/world/entity/projectile/EntityArrow.java
|
|
@@ -49,6 +49,13 @@
|
|
import net.minecraft.world.phys.Vec3D;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
+// CraftBukkit start
|
|
+import net.minecraft.world.entity.item.EntityItem;
|
|
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
|
+import org.bukkit.event.player.PlayerPickupArrowEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public abstract class EntityArrow extends IProjectile {
|
|
|
|
private static final double ARROW_BASE_DAMAGE = 2.0D;
|
|
@@ -225,7 +232,7 @@
|
|
}
|
|
|
|
if (object != null && !flag) {
|
|
- ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf((MovingObjectPosition) object);
|
|
+ ProjectileDeflection projectiledeflection = this.preHitTargetOrDeflectSelf((MovingObjectPosition) object); // CraftBukkit - projectile hit event
|
|
|
|
this.hasImpulse = true;
|
|
if (projectiledeflection != ProjectileDeflection.NONE) {
|
|
@@ -316,7 +323,7 @@
|
|
protected void tickDespawn() {
|
|
++this.life;
|
|
if (this.life >= 1200) {
|
|
- this.discard();
|
|
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
|
}
|
|
|
|
}
|
|
@@ -349,7 +356,7 @@
|
|
}
|
|
|
|
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
|
|
- this.discard();
|
|
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
|
return;
|
|
}
|
|
|
|
@@ -378,7 +385,13 @@
|
|
int k = entity.getRemainingFireTicks();
|
|
|
|
if (this.isOnFire() && !flag) {
|
|
- entity.igniteForSeconds(5);
|
|
+ // CraftBukkit start
|
|
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
|
+ if (!combustEvent.isCancelled()) {
|
|
+ entity.igniteForSeconds(combustEvent.getDuration(), false);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
if (entity.hurt(damagesource, (float) i)) {
|
|
@@ -429,7 +442,7 @@
|
|
|
|
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
|
|
if (this.getPierceLevel() <= 0) {
|
|
- this.discard();
|
|
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
|
}
|
|
} else {
|
|
entity.setRemainingFireTicks(k);
|
|
@@ -440,7 +453,7 @@
|
|
this.spawnAtLocation(this.getPickupItem(), 0.1F);
|
|
}
|
|
|
|
- this.discard();
|
|
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
|
|
}
|
|
}
|
|
|
|
@@ -547,9 +560,24 @@
|
|
@Override
|
|
public void playerTouch(EntityHuman entityhuman) {
|
|
if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
|
|
- if (this.tryPickup(entityhuman)) {
|
|
+ // CraftBukkit start
|
|
+ ItemStack itemstack = this.getPickupItem();
|
|
+ if (this.pickup == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.getInventory().canHold(itemstack) > 0) {
|
|
+ EntityItem item = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack);
|
|
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level().getCraftServer(), item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity());
|
|
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
|
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ itemstack = item.getItem();
|
|
+ }
|
|
+
|
|
+ if ((this.pickup == EntityArrow.PickupStatus.ALLOWED && entityhuman.getInventory().add(itemstack)) || (this.pickup == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.getAbilities().instabuild)) {
|
|
+ // CraftBukkit end
|
|
entityhuman.take(this, 1);
|
|
- this.discard();
|
|
+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
|
}
|
|
|
|
}
|