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 ExplodeEvent and Improvement in Spigot Explode events #11840

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

Doc94
Copy link
Contributor

@Doc94 Doc94 commented Dec 27, 2024

This PR is a "copy" from a 2 years old PR in Spigot related to explosion, when this start the issue is how the gamerule for avoid mob griefing make the explosion event not being called, with recent changes now CraftBukkit pass the explosion behavior for make the user know what is the behaviour of this explosion.. with this in mind this PR takes that for well.. call the event for that also handle a issue where "explosions" created by Wind Burst call the block explosion with not data.

This PR implement a new "generic" event for any explosion generated by the server, this brings the same behaviour of the Spigot explode events (block,entity) this this event is intented for being called for all the explosions.. affects or not the environment.

@Doc94 Doc94 requested a review from a team as a code owner December 27, 2024 18:25
@Doc94
Copy link
Contributor Author

Doc94 commented Dec 27, 2024

PS: Very new with the new contribution system.. currently the ExplosionServer has unused CB imports but if remove that the fixupSourcePatches just fails

Copy link
Contributor

@lynxplay lynxplay left a comment

Choose a reason for hiding this comment

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

Alright, thank you for the PR!
We have reviewed it but are a bit (a bit too) hesitant to call these events when their javadocs do define them to not be called in these exact spots.

We could fire them pre-cancelled, but block break related events are obviously rather important for plugin data, and I'd rather avoid plugins dying/duping because they did not correctly check cancelled here.

Instead, Machine and I think it'd be best to use this API downside to finally create a better version of the "SomethingExplodeEvent" (better name pending) that covers both entities, blocks and nothing (like in the mace's case). Such an event can be called for these cases, specifying that no blocks will be broken etc.
The current events types could then be marked as Obsolete and the new event would be called after to allow people to take priority with the new API.

If you are up for implementing such a change yourself, feel free to just use this API, otherwise we can close it and open a feature request issue 👍

@Doc94
Copy link
Contributor Author

Doc94 commented Dec 29, 2024

Then you mean a new event "ExplodeEvent" for handle all the explosions, like a merge of the current entity and block not?
This require send a canceled state of this new event?
PD in teory just need call this new event in the sane place but later of the bukkit?

@Doc94 Doc94 changed the title Improvement Explosion events Add ExplodeEvent and Improvement in Spigot Explode events Dec 30, 2024
@Doc94
Copy link
Contributor Author

Doc94 commented Dec 30, 2024

Ok based in the comments here and in discord i rework this PR for keep the changes but also the new calls just being called in the new event called...
i dont like "duplicate" the CB code for the paper event but dont wanna mess with strange behaviours for use the same method for call the paper event and make changes...

@Doc94 Doc94 requested a review from lynxplay January 3, 2025 10:48
@kennytv kennytv added the type: feature Request for a new Feature. label Jan 12, 2025
@Doc94
Copy link
Contributor Author

Doc94 commented Jan 16, 2025

Exposed the DamageSource used in the explosion to the event... i feel this can help if consider the damage source can have many behaviours based in how datapacks can use the explode effect.

Copy link
Contributor

@Lulu13022002 Lulu13022002 left a comment

Choose a reason for hiding this comment

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

This pr break fire explosion done via world.createExplosion(location, 3, true, false) by filtering empty blocks i guess. Ideally should only affect the event but it's tricky cause block list is mutable

@Doc94
Copy link
Contributor Author

Doc94 commented Jan 18, 2025

This pr break fire explosion done via world.createExplosion(location, 3, true, false) by filtering empty blocks i guess. Ideally should only affect the event but it's tricky cause block list is mutable

not sure how handle this.. i mean still being the "normal" behaviour with or not this PR i think...

@Lulu13022002
Copy link
Contributor

With your PR that fire explosion doesn't spread fire on the ground which is an unintended side effect

@Doc94
Copy link
Contributor Author

Doc94 commented Jan 18, 2025

With your PR that fire explosion doesn't spread fire on the ground which is an unintended side effect

i see the issue... not sure when i broke maybe the change from getType.isAir to isEmpty... i make a change for allow the empty things for the fire and looks is working. if its not a good "fix" can just revert the thing for the empty check

also i remove the shuffle in the KEEP behaviour because just make changes not related to the vanilla behaviour...

@Lulu13022002
Copy link
Contributor

That change is completely irrelevant, i have already explained the cause of that issue in the original message. It's not only affect your new event but regular ones as well. So i will open a new issue about that (the fix you commited is a workaround). And you broke spigot further with your equivalent commit.

@Doc94
Copy link
Contributor Author

Doc94 commented Jan 22, 2025

That change is completely irrelevant, i have already explained the cause of that issue in the original message. It's not only affect your new event but regular ones as well. So i will open a new issue about that (the fix you commited is a workaround). And you broke spigot further with your equivalent commit.

Yeah for the not explosion is handled by the keep maybe and how im now calm the event in that place the filter take all... Currently not sure why even need filter that... That block is in the list maybe just send all blocks and if user wanna they can filter that... Based in the first commit.
Or not sure if you have another suggest for this thing

+ else {
+ io.papermc.paper.event.world.ExplodeEvent explodeEvent = CraftEventFactory.callExplodeEvent(this, list);
+ this.wasCanceled = explodeEvent.isCancelled();
+ this.yield = explodeEvent.getYield();
Copy link
Contributor

Choose a reason for hiding this comment

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

The yield shouldn't be needed there no blocks explode anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah but not make "damage" keep that.

@Doc94
Copy link
Contributor Author

Doc94 commented Jan 22, 2025

about resolve #11999 now the filter is gone for allow the event show the same blocks (from positions) used in vanilla and avoid the mess with reduction of the fire.

@Lulu13022002
Copy link
Contributor

You can't remove the filter for the old events without updating the javadocs which is kinda a breaking change so not sure but the new one can hold empty blocks fine.
Cancelling the events still spread fire it seems mainly because you removed the filter.

@Doc94
Copy link
Contributor Author

Doc94 commented Jan 22, 2025

You can't remove the filter for the old events without updating the javadocs which is kinda a breaking change so not sure but the new one can hold empty blocks fine. Cancelling the events still spread fire it seems mainly because you removed the filter.

well already can consider a "breaking" change the thing about how now spigot fire the events for the keep behaviour and paper not (not in that events but yes in the new) but i make the rollback with the patch for the bukkit events.

the fire thing is maybe because just check the cancel for the keep behaviour and not in the main condition.. i move that for cover all calls.

Doc94 and others added 27 commits January 26, 2025 22:24
Need to figure out what we do with EnderDragon.
@lynxplay lynxplay force-pushed the feature/event-explosion-improvements branch from daa652b to 4a47bd8 Compare January 26, 2025 23:01
@@ -1,11 +1,14 @@
package org.bukkit.event.block;

import java.util.List;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Request for a new Feature.
Projects
Status: PR Party candidate
Development

Successfully merging this pull request may close these issues.

5 participants