EntityPickupItemEvent fixes

Fixes double firing of the event in PiglinAi

Fixes cancelling the event for piglins still triggering the
advancement trigger

Fires the event when a Raider tries to pick up a raid banner
to become raid leader.
This commit is contained in:
Jake Potrebic
2022-07-04 21:45:36 -07:00
parent 3f8bb2073a
commit 945f6ef6e6
3 changed files with 48 additions and 22 deletions

View File

@@ -10,7 +10,17 @@
public abstract class Raider extends PatrollingMonster {
@@ -230,13 +233,15 @@
@@ -225,18 +228,25 @@
boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) {
+ // Paper start - EntityPickupItemEvent fixes
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, 0, false).isCancelled()) {
+ return;
+ }
+ // Paper end - EntityPickupItemEvent fixes
EquipmentSlot enumitemslot = EquipmentSlot.HEAD;
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
@@ -27,7 +37,7 @@
this.getCurrentRaid().setLeader(this.getWave(), this);
this.setPatrolLeader(true);
} else {
@@ -290,7 +295,7 @@
@@ -290,7 +300,7 @@
@Nullable
private ItemEntity pursuedBannerItemEntity;
@@ -36,7 +46,7 @@
this.mob = entityraider;
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
}
@@ -335,6 +340,7 @@
@@ -335,6 +345,7 @@
}
private boolean cannotPickUpBanner() {
@@ -44,7 +54,7 @@
if (!this.mob.hasActiveRaid()) {
return true;
} else if (this.mob.getCurrentRaid().isOver()) {
@@ -518,7 +524,7 @@
@@ -518,7 +529,7 @@
}
}
@@ -53,7 +63,7 @@
private final Raider mob;
private final float hostileRadiusSqr;
@@ -547,7 +553,7 @@
@@ -547,7 +558,7 @@
while (iterator.hasNext()) {
Raider entityraider = (Raider) iterator.next();
@@ -62,7 +72,7 @@
}
}
@@ -564,7 +570,7 @@
@@ -564,7 +575,7 @@
while (iterator.hasNext()) {
Raider entityraider = (Raider) iterator.next();