Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.papermc.paper.event.entity;

import org.bukkit.entity.Zombie;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityEvent;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.NullMarked;

/**
* Called when a zombie becomes a leader zombie and gets extra attributes
* and the ability to break door.
* <p>
* If the event is cancelled, the zombie will not have the extra attributes
* or door-breaking ability.
*/

@NullMarked
public class ZombieBecomeLeaderEvent extends EntityEvent implements Cancellable {

private static final HandlerList HANDLER_LIST = new HandlerList();
private boolean cancelled;

@ApiStatus.Internal
public ZombieBecomeLeaderEvent(final Zombie zombie) {
super(zombie);
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(final boolean cancel) {
this.cancelled = cancel;
}

@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,21 @@
}
}

@@ -545,7 +_,7 @@
);
}

- if (this.random.nextFloat() < difficultyModifier * 0.05F) {
+ if (this.random.nextFloat() < difficultyModifier * 0.05F && (new io.papermc.paper.event.entity.ZombieBecomeLeaderEvent((org.bukkit.entity.Zombie) this.getBukkitEntity())).callEvent()) { // Paper start - Add ZombieBecomeLeaderEvent
this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE)
.addOrReplacePermanentModifier(
new AttributeModifier(LEADER_ZOMBIE_BONUS_ID, this.random.nextDouble() * 0.25 + 0.5, AttributeModifier.Operation.ADD_VALUE)
@@ -559,7 +_,7 @@
}

this.setCanBreakDoors(true);
- }
+ } // Paper end - Add ZombieBecomeLeaderEvent
}

protected void randomizeReinforcementsChance() {
Loading