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

55 Zeilen
2.7 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityArrow.java
+++ b/net/minecraft/server/EntityArrow.java
2020-06-25 02:00:00 +02:00
@@ -8,6 +8,11 @@
import java.util.List;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerPickupArrowEvent;
+// CraftBukkit end
+
2020-06-25 02:00:00 +02:00
public abstract class EntityArrow extends IProjectile {
2020-06-25 02:00:00 +02:00
private static final DataWatcherObject<Byte> f = DataWatcher.a(EntityArrow.class, DataWatcherRegistry.a);
@@ -291,7 +296,13 @@
int k = entity.getFireTicks();
2015-02-26 23:41:06 +01:00
2019-12-10 23:00:00 +01:00
if (this.isBurning() && !flag) {
2018-07-15 02:00:00 +02:00
- 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)) {
2020-06-25 02:00:00 +02:00
@@ -458,9 +469,23 @@
2019-04-23 04:00:00 +02:00
@Override
public void pickup(EntityHuman entityhuman) {
2020-06-25 02:00:00 +02:00
if (!this.world.isClientSide && (this.inGround || this.t()) && 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) {
2019-12-10 23:00:00 +01:00
+ 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();
+ }
2020-06-25 02:00:00 +02:00
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.t() && 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;
}