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

Don't convert back and forth between Explosion objects and their unpacked data. #1368

Merged

Conversation

JBYoshi
Copy link
Member

@JBYoshi JBYoshi commented May 24, 2017

This PR:

  • Inlines newExplosion() in MixinWorld.triggerExplosion()
  • Moves the explosion code in MixinWorldServer from triggerExplosion() and newExplosion() to triggerExplosionInternal()
  • Corrects a few defaults in SpongeExplosionBuilder that badly messed up my testing

Fixes #1367.

Copy link
Member

@gabizou gabizou left a comment

Choose a reason for hiding this comment

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

Some cause tracking details are missing in my opinion.

// Sponge End
// Sponge start - move this behavior to another method to allow precreated explosions to be used
// All of the original behavior is in triggerExplosion().
triggerExplosion((org.spongepowered.api.world.explosion.Explosion) explosion, Cause.of(NamedCause.source(entityIn == null ? this : entityIn)));
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather use the CauseTracker to define what Cause to use for the explosion source. Since the source passed in as Entity is usually an entity ticking, or in some cases a TileEntity passing null for explosions. You may also want to verify the explosion optimization (not really optimization, it's an optimization for clients on the server due to the unperformant explosion packets and what they entail) still functions as expected.

Copy link
Member Author

@JBYoshi JBYoshi May 25, 2017

Choose a reason for hiding this comment

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

Fixed. Although pretty much the entire PR changed - you may need to re-review it.

@gabizou gabizou added system: phase tracker system: event version: 1.11 (u) API: 6 (unsupported since Jan 1st 2018) labels May 24, 2017
@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch 4 times, most recently from 149d94f to 100a236 Compare May 25, 2017 02:43
@JBYoshi JBYoshi added status: needs review a code review is needed status: needs updating hey, origin changed, you need to update and removed version: 1.11 (u) API: 6 (unsupported since Jan 1st 2018) labels Aug 6, 2017
@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch from 100a236 to f57951d Compare August 6, 2017 03:00
@JBYoshi JBYoshi removed the status: needs updating hey, origin changed, you need to update label Aug 6, 2017
@@ -48,21 +50,23 @@
@Mixin(value = WorldServer.class, priority = 1111)
public abstract class MixinWorldServer_Explosion extends MixinWorld {
Copy link
Member

Choose a reason for hiding this comment

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

@gabizou @JBYoshi Any reason why this mixin is on its own and not in MixinWorldServer?

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like it's separate because it's a configurable optimization.

Copy link
Member

Choose a reason for hiding this comment

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

@Zidane because it's altering the mechanics of multiple explosions occurring at the same time. This goes about removing the point of sending explosion packets (reducing lag on clients), this was meddled with @amaranth a while back but I haven't verified whether it should be enabled by default now or not.

@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch from f57951d to 0717cce Compare August 27, 2017 03:22
@JBYoshi JBYoshi closed this Sep 24, 2017
@JBYoshi JBYoshi deleted the fix/explosion-reuse-existing branch September 24, 2017 19:52
@JBYoshi JBYoshi restored the fix/explosion-reuse-existing branch September 24, 2017 20:00
@JBYoshi JBYoshi reopened this Sep 24, 2017
@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch from 0717cce to 1fe0d7d Compare October 3, 2017 21:37
@Deamon5550 Deamon5550 removed their request for review October 4, 2017 00:16
@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch from 1fe0d7d to 46397a7 Compare October 12, 2017 01:10
@JBYoshi
Copy link
Member Author

JBYoshi commented Oct 30, 2017

Can this be merged?

import org.spongepowered.common.event.tracking.phase.TrackingPhase;
import org.spongepowered.common.event.tracking.phase.general.ExplosionContext;
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra import?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops :P I will revert that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, this was intended. It now uses this class instead of the previous ExplosionContext class that was in this package.

@@ -29,7 +29,7 @@
import org.spongepowered.common.event.tracking.phase.TrackingPhase;
import org.spongepowered.common.event.tracking.phase.TrackingPhases;

public abstract class PluginPhaseState<P extends PluginPhaseContext<P>> implements IPhaseState<P> {
public abstract class PluginPhaseState<P extends PhaseContext<P>> implements IPhaseState<P> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

This was to allow CustomExplosionState to use the same context class as ExplosionState (of GeneralPhase); there's pretty much no difference between the two types.

@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch 2 times, most recently from ce3eb47 to d563de7 Compare December 2, 2017 23:13
@JBYoshi
Copy link
Member Author

JBYoshi commented Dec 2, 2017

@liach I found a way to make this work without messing with the PhaseContext class hierarchy. The callers now create a context and pass the explosion to it.

@ryantheleach ryantheleach added this to Acknowledged in gabizou's TODO List via automation Jan 30, 2018
@ryantheleach
Copy link
Contributor

ryantheleach commented Jan 30, 2018

~qa

@gabizou You offered review advice earlier, so I'm looking to see a final review to see if it's ready, or else give to someone else.

@JBYoshi I'll make a test plugin that tests the original issue tonight.

@limbo-app limbo-app added the status: needs testing does this run, does it solve the issue etc label Jan 30, 2018
@JBYoshi JBYoshi force-pushed the fix/explosion-reuse-existing branch from d563de7 to a36842d Compare February 4, 2018 00:36
@JBYoshi JBYoshi changed the base branch from bleeding to stable-7 February 4, 2018 00:36
@phit
Copy link
Contributor

phit commented Apr 19, 2018

@ryantheleach status?

@ryantheleach
Copy link
Contributor

I know that I said previously that I was going to make a test plugin, but at this stage I have no idea if I did that or not, I've been somewhat MIA over the last few months.

At present anything that's blocked on me should be considered up for fair game until I can find the time to invest back into Sponge.

@ImMorpheus ImMorpheus added type: bug Something isn't working status: needs updating hey, origin changed, you need to update and removed status: needs review a code review is needed status: needs testing does this run, does it solve the issue etc labels Aug 29, 2018
@ImMorpheus
Copy link
Contributor

Updated (after asking @JBYoshi about it).

Note: PluginPhase.State.CUSTOM_EXPLOSION was removed by 0e16a5d#diff-789d0465f5f0c54bb475b2958e6263d6 so I'm using GeneralPhase.State.EXPLOSION.

@ImMorpheus ImMorpheus added status: needs review a code review is needed status: needs testing does this run, does it solve the issue etc and removed status: needs updating hey, origin changed, you need to update labels Oct 13, 2018
Copy link
Member

@gabizou gabizou left a comment

Choose a reason for hiding this comment

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

Looks good to me. Just may need to add explosion event ShouldFire checks to reduce potential stack frame creation unnecessarily.

@ImMorpheus
Copy link
Contributor

@gabizou I'll add it with other performance improvements once I reopen the explosions part of #2031

@ImMorpheus
Copy link
Contributor

Conflicts fixed and rebased.

A note (In case some plugins complain about this being a breaking change): the default value of shouldBreakBlocks (and shouldDamageEntities) is an implementation detail, it's not mentioned in the API. If you're creating an explosion with the ExplosionBuilder without explicitly setting those flags, then it's your fault for relying on the default value.

@ImMorpheus ImMorpheus merged commit a8cddaf into SpongePowered:stable-7 Feb 1, 2019
gabizou's TODO List automation moved this from Acknowledged to Done Feb 1, 2019
ImMorpheus pushed a commit to ImMorpheus/SpongeCommon that referenced this pull request Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs review a code review is needed status: needs testing does this run, does it solve the issue etc system: event system: phase tracker type: bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

None yet

8 participants