PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
10.03k stars 2.33k forks source link

EntityBreeding Stuck in a Loop When Event is Cancelled #5444

Open WOLFI3654 opened 3 years ago

WOLFI3654 commented 3 years ago

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

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.

Proximyst commented 3 years ago

This must be submitted upstream as to not break API.

WOLFI3654 commented 3 years ago

Thank you, how exactly do I file an issue on the bukkit/spigot upstream?

Prof-Bloodstone commented 3 years ago

@WOLFI3654 you need to go to https://hub.spigotmc.org/jira/projects/SPIGOT/issues/ and create new issue there. For the future, this can be found by googling spigotmc jira

WOLFI3654 commented 3 years ago

Thanks, I already tried that at some point in time but I had a few issues. I'll see what I can do

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Prof-Bloodstone commented 3 years ago

Reported upstream: https://hub.spigotmc.org/jira/browse/SPIGOT-6495

WOLFI3654 commented 3 years ago

Thank you very much!