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

72 Zeilen
3.7 KiB
Diff

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-04-23 04:00:00 +02:00
private static final DataWatcherObject<Byte> ar = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a);
2019-04-25 04:00:00 +02:00
@@ -252,6 +258,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-04-25 04:00:00 +02:00
@@ -332,7 +339,13 @@
2018-07-15 02:00:00 +02:00
}
2015-02-26 23:41:06 +01:00
2018-07-15 02:00:00 +02:00
if (this.isBurning() && !(entity instanceof EntityEnderman)) {
- 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-04-25 04:00:00 +02:00
@@ -468,6 +481,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-04-25 04:00:00 +02:00
@@ -482,9 +496,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) {
+ 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;
}