Skip to content

EntityBreeding Stuck in a Loop When Event is Cancelled #5444

@WOLFI3654

Description

@WOLFI3654

Expected behavior

When the EntityBreedEvent is cancelled, their loveTicks should be reset.

Observed/Actual behavior

When cancelling the EntityBreedEvent the two animals will try again every few seconds to produce a baby as long as they are still willing. This results in subsequent calls the EntityBreedEvent.
If you cancel this event, your intention is generally to disallow breeding for the two animals, and not to postpone it.

Steps/models to reproduce

A very simple plugin is sufficient to experience this behavior:

  @Override
  public void onEnable() {
    Bukkit.getPluginManager().registerEvents(this,this);
  }
  
  @EventHandler
  public void onBreed(EntityBreedEvent e){
    e.setCancelled(true);
    Bukkit.broadcastMessage("Breed");
  }

Plugin list

Empty; Except plugin to test the EntityBreedEvent cancel behavior.

Paper version

[17:16:49 INFO]: This server is running Paper version git-Paper-575 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
You are running the latest version
Previous version: git-Paper-457 (MC: 1.16.5)

Agreements

  • I am running the latest version of Paper available from https://papermc.io/downloads.
  • I have searched for and ensured there isn't already an open issue regarding this.
  • My version of Minecraft is supported by Paper.

Its certainly not a behavior that should be expected when cancelling the event.
Tho this can be circumvented by resetting the loveModeTicks manually, just doing it by default when the event is cancelled would be a neat improvement to the api. Its really easy to miss that especially if you are new to plugin development and depending on your use case could result in quite unexpected and unnoticed performance issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.status: defer upstreamThis must be handled upstream due to some issue.type: bugSomething doesn't work as it was intended to.upstream: bukkitIssues exists in Bukkit and/or CraftBukkit.version: 1.16Game version 1.16

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions