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

Add EntitySpawnByEntityEvent #12073

Open
NoyException opened this issue Feb 7, 2025 · 8 comments
Open

Add EntitySpawnByEntityEvent #12073

NoyException opened this issue Feb 7, 2025 · 8 comments

Comments

@NoyException
Copy link

NoyException commented Feb 7, 2025

Is your feature request related to a problem?

I'm currently making a roguelike plugin. I need to find out whether all the enemies are killed to accomplish a combat, so that's why I need to take those entities spawned by enemies into consideration (They should also be considered as enemies in this combat). So I wonder how can I find the entity who causes a spawn event.

Describe the solution you'd like.

Add EntitySpawnByEntityEvent which inherits EntitySpawnEvent

Describe alternatives you've considered.

  • (EDIT:) Refactor SpawnReason to make it carry more context
  • Add a method getWhoSpawn() in EntitySpawnEvent
  • Add a method getWhoSpawn() in Entity

Other

No response

@electronicboy
Copy link
Member

entities spawned by enemies, such as? Vanilla doesn't really have much of a "spawned by" concept, and I ponder the capability of exposing such a concept without having any form of proper cause API would just make such a concept be relatively broken in general, especially when it comes to determining what means it was "spawned by X"

@NoyException
Copy link
Author

entities spawned by enemies, such as? Vanilla doesn't really have much of a "spawned by" concept, and I ponder the capability of exposing such a concept without having any form of proper cause API would just make such a concept be relatively broken in general, especially when it comes to determining what means it was "spawned by X"

For example, a Jokey can spawn a vehicle, an egg can spawn a chicken, a small slime can be spawned by a dying big slime, an endermite can be spawned by a ender pearl, etc

@electronicboy
Copy link
Member

All of those generally sound okay, bar the slime one, as that falls into a really weird area as that's not considered a 'spawn' as such, that's effectively a transformation (and is already exposed in a specific event)

@NoyException
Copy link
Author

All of those generally sound okay, bar the slime one, as that falls into a really weird area as that's not considered a 'spawn' as such, that's effectively a transformation (and is already exposed in a specific event)

You're right, there's already a SlimeSplitEvent. But what about the others? I thought, maybe we can refactor the SpawnReason, make it an abstract class instead of a enum to carry more information?

@NonSwag
Copy link
Contributor

NonSwag commented Feb 7, 2025

All your examples can be covered with the entity spawn event and the spawn reason

@NoyException
Copy link
Author

All your examples can be covered with the entity spawn event and the spawn reason

Yeah, but the SpawnReason is a enum and it can't tell me which entity causes the spawn. That's why I edited the issue to ask whether we can make it more informative.

@Doc94
Copy link
Contributor

Doc94 commented Feb 7, 2025

Well this issue was already talked in: #11564 #10527 #6487
and have a PR related in #7377

not sure if cover all the cases here, but exists the disc about "i need know how this spawn" like this player/dispenser spawn a Wither...

@NoyException
Copy link
Author

NoyException commented Feb 7, 2025

Well this issue was already talked in: #11564 #10527 #6487 and have a PR related in #7377

not sure if cover all the cases here, but exists the disc about "i need know how this spawn" like this player/dispenser spawn a Wither...

This almost solves my problem. They nearly cover all the cases but jockey (and other compound entities), Vex and Evoker Fang(and other spells).

EDIT: I hope this PR merge as soon as possible. By the way, what I want is a unified interface to get the spawner entity, instead of collecting the information everywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants