Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cancelling PreCreatureSpawnEvent with per player mob spawns #9400

Conversation

Machine-Maker
Copy link
Member

@Machine-Maker Machine-Maker commented Jun 26, 2023

Re-implementation of #5460

Fixes #9393


Tracks an additional count of mobs per category for each category. The number is incremented on an aborted or cancelled PreCreatureSpawnEvent. That number is added to the true mob count per player when the game requests the mob count for a player. This "backoff number" is then decremented by 1 each tick for each player for each mob category.

A rudimentary test I did involved a plain server with 1 player not moving for 60 seconds. With the PreCreatureSpawnEvent set to be cancelled and aborted WITHOUT these changes, it fired ~48000 times during that time period. With the changes, it fired ~5000 times over the same time period. I included the test plugin I used to do this in the PR. Will be removed before merging.

The algorithm used to decrease the "backoff number" is linear and simple now, unclear if it should be customizable further, or default to a non-linear implementation.


Download the paperclip jar for this pull request: paper-9400.zip

@Machine-Maker Machine-Maker requested a review from a team as a code owner June 26, 2023 22:24
@dandud100
Copy link

Thank you, for this fast fix. I hope this gets merged soon.

@LucidAPs

This comment was marked as spam.

@Machine-Maker Machine-Maker force-pushed the fix/PreCreatureSpawnEvent-per-player-mob-spawns branch from 42efe70 to 1b22d9a Compare June 28, 2023 21:09
@dandud100
Copy link

dandud100 commented Jul 1, 2023

Any updates on this? Isn't it fine to merge already?

@LucidAPs
Copy link

LucidAPs commented Jul 5, 2023

Please do not let this die in pull request queue.

@dandud100
Copy link

Fixes also #5076

@dandud100
Copy link

Can you provide a snapshot build with this patch and without the test plugin to run a smoother server until this gets merged? @Machine-Maker

@Machine-Maker Machine-Maker added the build-pr-jar Enables a workflow to build Paperclip jars on the pull request. label Jul 15, 2023
@dandud100
Copy link

That was fast! Will the action to build the paperclip.jar get started automatically?

@Machine-Maker
Copy link
Member Author

Machine-Maker commented Jul 15, 2023

That was fast! Will the action to build the paperclip.jar get started automatically?

Huh, it should've automatically started when I added the label.

@Machine-Maker Machine-Maker added build-pr-jar Enables a workflow to build Paperclip jars on the pull request. and removed build-pr-jar Enables a workflow to build Paperclip jars on the pull request. labels Jul 15, 2023
@Machine-Maker Machine-Maker force-pushed the fix/PreCreatureSpawnEvent-per-player-mob-spawns branch from 1b22d9a to c15bf12 Compare July 15, 2023 19:13
@lynxplay lynxplay linked an issue Jul 22, 2023 that may be closed by this pull request
@Machine-Maker Machine-Maker force-pushed the fix/PreCreatureSpawnEvent-per-player-mob-spawns branch from c15bf12 to 135c45f Compare August 21, 2023 04:12
@kennytv kennytv force-pushed the fix/PreCreatureSpawnEvent-per-player-mob-spawns branch from 135c45f to 37d7fd7 Compare August 21, 2023 07:43
@kennytv kennytv merged commit 1b96c64 into PaperMC:master Aug 21, 2023
@Machine-Maker Machine-Maker deleted the fix/PreCreatureSpawnEvent-per-player-mob-spawns branch August 21, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-pr-jar Enables a workflow to build Paperclip jars on the pull request.
Projects
Status: Merged
4 participants