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

Added option to ignore entities when lightning strikes #10689

Closed
wants to merge 4 commits into from

Conversation

Jakush
Copy link

@Jakush Jakush commented May 10, 2024

Hey, in short, this patch adds option to ignore specific entity (or type of entity) from being damaged by lightning when lightning strikes.

@Jakush Jakush requested a review from a team as a code owner May 10, 2024 19:21
@Jakush Jakush changed the title Added option to ignore entities when lightning strikes #10688 Added option to ignore entities when lightning strikes May 10, 2024
@lynxplay
Copy link
Contributor

Hi, thank you for your PR 🎉

Could you please elaborate on the usage of this API over simply listening to the respective events (Combust, HangingBreak, DamageEvent) which all expose the lightning strike entity?

This kind of API seems pretty counter active to the event driven design of the bukkit API.

@Machine-Maker
Copy link
Member

I would be more in favor of an event fired right before the lighting searches for an entity to hit to configure the parameters for that search or even to specify a specific entity before the search even happens. That seems more useful to me.

@Jakush
Copy link
Author

Jakush commented May 10, 2024

Hi, thank you for your PR 🎉

Could you please elaborate on the usage of this API over simply listening to the respective events (Combust, HangingBreak, DamageEvent) which all expose the lightning strike entity?

For me it is better to use more "direct" way to somehow ignore other entities than to check with EntityDamageByEntityEvent, of course it could be done just with this event.

I would be more in favor of an event fired right before the lighting searches for an entity to hit to configure the parameters for that search or even to specify a specific entity before the search even happens. That seems more useful to me.

That's good idea, I'll look how could I make it.

@lynxplay
Copy link
Contributor

Yea, then go with Machines way 👍
Adding this kind of state to the entity feels very off, an event prior to the lightnings actual strike sounds like the API friendlier approach.

@Jakush
Copy link
Author

Jakush commented May 10, 2024

Sure and thanks.

@Jakush
Copy link
Author

Jakush commented May 10, 2024

Should I create the event in paper package?

@lynxplay
Copy link
Contributor

Yup!

@Jakush
Copy link
Author

Jakush commented May 11, 2024

Hello, I am trying to rebase my commit as in method 1, though I am not able to select anything, could you help me please?

@lynxplay
Copy link
Contributor

Hello, I am trying to rebase my commit as in method 1, though I am not able to select anything, could you help me please?

Would probably be best if you ask for help on our discord, github isn't a good place for that.

… would be hit by the lightning, so parameters can be specified
@Jakush
Copy link
Author

Jakush commented May 11, 2024

Added same things as it was previously in LightningStrike nms class, although added predicate, so anyone can define their own behavior. By setting null in setter, default predicate will be used

Copy link
Contributor

@notTamion notTamion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding methods for ignoring entities seems wrong. Why not call the event right after the server looks for entities to hit? then you can pass in the entities to the event and let the user add/remove entities

@Jakush
Copy link
Author

Jakush commented May 11, 2024

Adding methods for ignoring entities seems wrong. Why not call the event right after the server looks for entities to hit? then you can pass in the entities to the event and let the user add/remove entities

In that case, I think it would make sense to be in LightningStrikeEvent then, though I don't really know how would I put entities there, as this method is called in tick method and I would be unable to get these entities. Though I think having event where you can specify your prediction on what entities do you really want there would be better. Passing a list with entities where you can add own entity could get little bit tricky and would probably require more checks, so making event through which you could make your own selection based on the predicate seems better for me.

@Jakush
Copy link
Author

Jakush commented May 11, 2024

-> I may said little bit non sense, LightningStrikeEvent is called, before tick method is even called (where you are searching for the entities)

@notTamion
Copy link
Contributor

For me it is better to use more "direct" way to somehow ignore other entities than to check with EntityDamageByEntityEvent, of course it could be done just with this event.

why exactly do you not want to use EntityDamageByEntityEvent? this really seems like a very simple and intended way of doing this. we also don't have an event that gets called for when a zombie is checking for players they can attack, so why add one for this?

@Jakush
Copy link
Author

Jakush commented May 11, 2024

For me it is better to use more "direct" way to somehow ignore other entities than to check with EntityDamageByEntityEvent, of course it could be done just with this event.

why exactly do you not want to use EntityDamageByEntityEvent? this really seems like a very simple and intended way of doing this. we also don't have an event that gets called for when a zombie is checking for players they can attack, so why add one for this?

You could use this event as a more direct way for filtering entities, I could also imagine more features in this event in the future as configuring selection radius which you wouldn't want in EntityDamageByEntityEvent. Event for zombie checking for players which he could attack does not exist though there is more general event for this EntityTargetEvent.

@Jakush Jakush requested a review from notTamion May 12, 2024 16:27
@notTamion
Copy link
Contributor

notTamion commented May 12, 2024

You could use this event as a more direct way for filtering entities

I feel like that event is already as direct as you need it to be

I could also imagine more features in this event in the future as configuring selection radius which you wouldn't want in EntityDamageByEntityEvent

Sure though i believe such a thing could be added to the LightningStrikeEvent or LightningStrike Entity. though you could also manually get the Entities in a specific area and damage them which gives you even more control over it.

Event for zombie checking for players which he could attack does not exist though there is more general event for this EntityTargetEvent

EntityTargetEvent is called when a Mob starts targeting a player not when they check if they are in reach to attack

@Jakush
Copy link
Author

Jakush commented May 12, 2024

You could use this event as a more direct way for filtering entities

I feel like that event is already as direct as you need it to be

I could also imagine more features in this event in the future as configuring selection radius which you wouldn't want in EntityDamageByEntityEvent

Sure though i believe such a thing could be added to the LightningStrikeEvent or LightningStrike Entity. though you could also manually get the Entities in a specific area and damage them which gives you even more control over it.

Event for zombie checking for players which he could attack does not exist though there is more general event for this EntityTargetEvent

EntityTargetEvent is called when a Mob starts targeting a player not when they check if they are in reach to attack

alright, well then this commit has no use and I can close this

@Jakush Jakush closed this May 12, 2024
@Jakush Jakush deleted the lightning-patch branch May 12, 2024 17:57
@notTamion
Copy link
Contributor

oh i would have waited for other peoples opinion on this. Perhaps someone else has a different opinion on it

@Jakush
Copy link
Author

Jakush commented May 12, 2024

Well, this can be reopened anytime, incase someone would really want this. Reason why I firstly made it, was I didn't get any idea how could I get entities which were struck by the lightning and in the lightningstrikeevent it wasn't contained, it had not occured me to use EntityDamageByEntityEvent, so I made this event where then lynx said normal events could be used instead, though I still saw some future potentional this event could have.

@Jakush
Copy link
Author

Jakush commented May 12, 2024

Though I don't know what could I say on it :D You're right that normal events can be used instead and this could be only a excess event

@notTamion
Copy link
Contributor

Thanks for your work on this anyways!

@Jakush
Copy link
Author

Jakush commented May 12, 2024

sure, I am also thankful for your time you have given there

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

Successfully merging this pull request may close these issues.

None yet

4 participants