mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
SPIGOT-4938: Call EntityPickupItemEvent for dolphins
This commit is contained in:
parent
a278e4453a
commit
09d00e9f90
@ -9,7 +9,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -422,7 +422,7 @@
|
||||
@@ -178,6 +178,11 @@
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
if (this.g(itemstack)) {
|
||||
+ // CraftBukkit start - call EntityPickupItemEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setSlot(EnumItemSlot.MAINHAND, itemstack);
|
||||
this.dropChanceHand[EnumItemSlot.MAINHAND.b()] = 2.0F;
|
||||
this.receive(entityitem, itemstack.getCount());
|
||||
@@ -422,7 +427,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
@ -18,7 +30,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -441,7 +441,7 @@
|
||||
@@ -441,7 +446,7 @@
|
||||
}
|
||||
|
||||
if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) {
|
||||
|
@ -112,18 +112,14 @@
|
||||
|
||||
@Override
|
||||
protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) {
|
||||
@@ -462,11 +522,21 @@
|
||||
@@ -462,11 +522,17 @@
|
||||
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
||||
boolean flag = this.a(itemstack, itemstack1, enumitemslot);
|
||||
|
||||
- if (flag && this.g(itemstack)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean canPickup = flag && this.g(itemstack);
|
||||
+
|
||||
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((LivingEntity) getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity(), 0);
|
||||
+ entityEvent.setCancelled(!canPickup);
|
||||
+ this.world.getServer().getPluginManager().callEvent(entityEvent);
|
||||
+ canPickup = !entityEvent.isCancelled();
|
||||
+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
|
||||
+ if (canPickup) {
|
||||
+ // CraftBukkit end
|
||||
double d0 = (double) this.d(enumitemslot);
|
||||
@ -135,7 +131,7 @@
|
||||
}
|
||||
|
||||
this.setSlot(enumitemslot, itemstack);
|
||||
@@ -544,11 +614,11 @@
|
||||
@@ -544,11 +610,11 @@
|
||||
if (entityhuman != null) {
|
||||
double d0 = entityhuman.h(this);
|
||||
|
||||
@ -149,7 +145,7 @@
|
||||
this.die();
|
||||
} else if (d0 < 1024.0D) {
|
||||
this.ticksFarFromPlayer = 0;
|
||||
@@ -944,12 +1014,24 @@
|
||||
@@ -944,12 +1010,24 @@
|
||||
if (!this.isAlive()) {
|
||||
return false;
|
||||
} else if (this.getLeashHolder() == entityhuman) {
|
||||
@ -174,7 +170,7 @@
|
||||
this.setLeashHolder(entityhuman, true);
|
||||
itemstack.subtract(1);
|
||||
return true;
|
||||
@@ -995,6 +1077,7 @@
|
||||
@@ -995,6 +1073,7 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
@ -182,7 +178,7 @@
|
||||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1010,7 +1093,9 @@
|
||||
@@ -1010,7 +1089,9 @@
|
||||
|
||||
this.leashHolder = null;
|
||||
if (!this.world.isClientSide && flag1) {
|
||||
@ -192,7 +188,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
|
||||
@@ -1079,6 +1164,7 @@
|
||||
@@ -1079,6 +1160,7 @@
|
||||
|
||||
this.setLeashHolder(EntityLeash.a(this.world, blockposition), true);
|
||||
} else {
|
||||
@ -200,7 +196,7 @@
|
||||
this.unleash(false, true);
|
||||
}
|
||||
|
||||
@@ -1186,7 +1272,14 @@
|
||||
@@ -1186,7 +1268,14 @@
|
||||
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
||||
|
||||
if (i > 0) {
|
||||
|
@ -92,6 +92,7 @@ import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Pig;
|
||||
@ -137,6 +138,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.EntityPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
@ -1419,4 +1421,11 @@ public class CraftEventFactory {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
public static EntityPickupItemEvent callEntityPickupItemEvent(Entity who, EntityItem item, int remaining, boolean cancelled) {
|
||||
EntityPickupItemEvent event = new EntityPickupItemEvent((LivingEntity) who.getBukkitEntity(), (Item) item.getBukkitEntity(), remaining);
|
||||
event.setCancelled(cancelled);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user