Skip to content

Add CreeperSwellEvent#13912

Open
shrayus-masanam wants to merge 2 commits into
PaperMC:mainfrom
shrayus-masanam:feat/creeper-swell-event
Open

Add CreeperSwellEvent#13912
shrayus-masanam wants to merge 2 commits into
PaperMC:mainfrom
shrayus-masanam:feat/creeper-swell-event

Conversation

@shrayus-masanam
Copy link
Copy Markdown

There's currently no event that fires when a creeper's swell level changes, and there's currently no way to stop a creeper from swelling. CreeperIgniteEvent does not fire when a creeper primes due to proximity, EntityExplodeEvent only fires at the end of swelling, and GenericGameEvent of type GameEvent.PRIME_FUSE doesn't allow for cancelling and doesn't fire for individual swell steps.

The proposed CreeperSwellEvent fires whenever a creeper's internal swell level changes, and it also differentiates different reasons for the swell: PRIMED (proximity or ignition), FALL_DAMAGE (falling from a height), or CUSTOM (plugin adjusting swell).

Fixes #12620

@shrayus-masanam shrayus-masanam requested a review from a team as a code owner May 24, 2026 18:31
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue May 24, 2026
@shrayus-masanam
Copy link
Copy Markdown
Author

Example usages:

cancel_fall_damage_swell.mp4
sound_on_swell.mp4

@mbax
Copy link
Copy Markdown
Contributor

mbax commented May 24, 2026

  1. Why wouldn't the client reflect the unswelling if cancelled, as it does if you back off from a creeper?

  2. I see you're firing a swell event on cancelled explosion. Bizarre edge case question: What happens if someone is always cancelling explosion events and then cancels that specific post-cancel swell event as well? Will the creeper be continuously trying to explode?

@shrayus-masanam
Copy link
Copy Markdown
Author

After reading your reply, I noticed a bug that would let a primed creeper's swell level to continue to change even if the event was cancelled. It happened because cancelling the event set the final swell change to 0, so the vanilla logic kicked in and continued to increment the swell level. Now, the tick function will instead check for a nonzero swellDir to decide whether or not to fire the event and handle its cancellation state.


  1. Why wouldn't the client reflect the unswelling if cancelled, as it does if you back off from a creeper?

The client does render an unswell, but it seems like the client is only programmed to render a full swell in one direction. For example, if I use this code in a plugin to only allow a creeper to swell half-way:

@EventHandler
public void onCreeperSwell(CreeperSwellEvent event) {
    if (event.getCurrentSwell() + event.getFinalSwellChange() > event.getMaxSwell()/2)
        event.setCancelled(true);
}

the client still sees the creeper swelling completely:

stop_swell_halfway.mp4
  1. I see you're firing a swell event on cancelled explosion. Bizarre edge case question: What happens if someone is always cancelling explosion events and then cancels that specific post-cancel swell event as well? Will the creeper be continuously trying to explode?

It depends, if the creeper was ignited and is not being primed, it will simply unswell. But if the creeper is actively being primed (e.g. due to proximity), then yes, the creeper is stuck at max swell and tries to explode until it's no longer being primed:

cancel_explosion_and_swell.mp4

Although, I think this is desired behavior rather than a bug? If you cancel a CUSTOM swell then you are cancelling a swell change caused by a plugin, which may or may not cause conflicts

@Warriorrrr Warriorrrr added type: feature Request for a new Feature. scope: api labels May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: api type: feature Request for a new Feature.

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

Event for when a Creeper starts swelling

3 participants