-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 API for explosions to damage the explosion cause #11180
base: master
Are you sure you want to change the base?
Add API for explosions to damage the explosion cause #11180
Conversation
b9f018f
to
03717d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay on the initial review, this PR seems to have fallen completely under my radar.
In general, when expanding a heavily overloaded API like this, we'd only want to add one more method.
In this case public boolean createExplosion(@Nullable Entity source, @NotNull Location loc, float power, boolean setFire, boolean breakBlocks, boolean damageSource);
.
Callers of as niche of an API as the damageSource
flag will be, can be expected to fully define all other parameters. The amount of methods added by this patch is way too many.
Beyond that, generally LGTM, but yea, please reduce this to a single added method on World, preferably just the method signature mentioned above. Your changes will also end up in the Expand-Explosions-API patch, so if you want to merge your changes into that patch directly, that would be great. Our contribution doc has a tutorial explaining how to edit patches.
Thanks for reviewing. I'll make sure to change what you requested ASAP. I'm currently on holidays, but I'll get to it as soon as I'm back. |
4d9afd8
to
ae12cce
Compare
ae12cce
to
2fdb2e9
Compare
Sorry, didn't realise that would close the PR. So far, I've reduced the PR to add a single method, as well as merge the changes into the Expand-Explosions-API patch, as requested. However, the build is currently failing at the javadoc task, not sure why. |
36028a9
to
b6401ad
Compare
I believe I have fixed the issue just now. |
0b0f86d
to
707c91a
Compare
I just tested this with the test plugin, and it does damage the source entity as intended, but there's an issue with the explosion sounds and particles, which I'll look into tomorrow. |
109d8ff
to
30d66e4
Compare
Just fixed the issue with particles and sound. |
Just tested this using the test plugin and everything works perfectly. |
e9df61b
to
eaf2f59
Compare
The more I look at the diff the less happy I am with it. Not that we can really get around overloading internal methods here, but maybe a Consumer would be more suited to avoid further diff if we expand the API even more? E.g. something like these two |
0d86679
to
5e73eed
Compare
5e73eed
to
4e680cd
Compare
This intends to give plugin developers more control over explosions created using the World#createExplosion method, specifically by adding the option for explosions to damage the explosion cause (not the default behavior, and previously impossible to do, as far as I know). This is done by overloading existing methods with an extra `excludeSourceFromDamage` parameter.
4e680cd
to
cafc4f8
Compare
I implemented these changes and everything seems to work. |
This PR is to add an API feature which expands the functionality of
World#createExplosion
by adding the option to deal damage to the source entity (this is not the default behaviour). This deals with this issue (not technically a bug, but still something that I think should be addressed).The API is expanded by overloading existing
World#createExplosion
methods with a newboolean shouldDamageSource
parameter. Whentrue
, the entity specified as thesource
will be damaged by the explosion. Existing behaviour is not changed.