Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
72 Zeilen
3.7 KiB
Diff
72 Zeilen
3.7 KiB
Diff
--- a/net/minecraft/server/EntityArrow.java
|
|
+++ b/net/minecraft/server/EntityArrow.java
|
|
@@ -9,6 +9,12 @@
|
|
import java.util.UUID;
|
|
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
|
|
+
|
|
public abstract class EntityArrow extends Entity implements IProjectile {
|
|
|
|
private static final DataWatcherObject<Byte> ar = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a);
|
|
@@ -252,6 +258,7 @@
|
|
}
|
|
|
|
protected void a(MovingObjectPosition movingobjectposition) {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // CraftBukkit - Call event
|
|
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
|
|
|
|
if (movingobjectposition_enummovingobjecttype == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
|
@@ -334,7 +341,13 @@
|
|
int j = entity.ad();
|
|
|
|
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);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
if (entity.damageEntity(damagesource, (float) i)) {
|
|
@@ -471,6 +484,7 @@
|
|
|
|
public void setShooter(@Nullable Entity entity) {
|
|
this.shooter = entity == null ? null : entity.getUniqueID();
|
|
+ this.projectileSource = entity == null ? null : (LivingEntity) entity.getBukkitEntity(); // CraftBukkit
|
|
if (entity instanceof EntityHuman) {
|
|
this.fromPlayer = ((EntityHuman) entity).abilities.canInstantlyBuild ? EntityArrow.PickupStatus.CREATIVE_ONLY : EntityArrow.PickupStatus.ALLOWED;
|
|
}
|
|
@@ -485,9 +499,23 @@
|
|
@Override
|
|
public void pickup(EntityHuman entityhuman) {
|
|
if (!this.world.isClientSide && (this.inGround || this.v()) && this.shake <= 0) {
|
|
+ // CraftBukkit start
|
|
+ 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);
|
|
+ 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();
|
|
+ }
|
|
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.v() && this.getShooter().getUniqueID() == entityhuman.getUniqueID();
|
|
|
|
- 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;
|
|
}
|
|
|