Impl ServerTickEvent and RenderTickEvent#158
Impl ServerTickEvent and RenderTickEvent#158TheGlitch76 merged 8 commits intoPatchworkMC:masterfrom GammaWhiskey:feature/tickevents
Conversation
|
Ehhh. I wouldn't be too torn up if the profiler results were slightly thrown off. However, you can inject to after a method call (and any variable assignment with the return value) with INVOKE_ASSIGN. Does that help? |
...ork-events-lifecycle/src/main/java/net/patchworkmc/impl/event/lifecycle/LifecycleEvents.java
Show resolved
Hide resolved
I was under the impression that INVOKE_ASSIGN could only be used if the method returned a value, and DisableableProfiler.pop() returns void. |
|
https://jenkins.liteloader.com/view/Other/job/Mixin/javadoc/index.html?org/spongepowered/asm/mixin/injection/Inject.html says that it merely has special handling for invokes that return and immediately assign, not that it can only be used in that case. Even if it couldn't be used, you could use 'shift' to shift the injection point to after the method call. EDIT: apparently i copied the wrong link, I need to fix that. |
|
Huh. That seems to contradict the Mixin wiki:
Plus, whenever I set it to use INVOKE_ASSIGN, it fails. Either way, I can just shift the injection point, so I'll do that! |
|
Huh, I didn't see that. Fair enough! |
|
if |
|
At worst it could cause an off-by-one error, but having that cause a genuine issue is very unlikely. |
TheGlitch76
left a comment
There was a problem hiding this comment.
One nitpick about the (relatively) massive ordinal and then this is good to go.
...ents-lifecycle/src/main/java/net/patchworkmc/mixin/event/lifecycle/MixinMinecraftClient.java
Outdated
Show resolved
Hide resolved
|
Thank you for the in-depth PR description by the way, it was very helpful! |
I always aspire to be helpful. 👈😉👈 |
Contained herein are my efforts to eliminate every
TODOfrom the TickEvent class!A few things of note here:
START_SERVER_TICKevent, which is what I've used to implementServerTickEvent(trying not to reinvent the wheel here), fires slightly later than theSTARTphase of Forge'sServerTickEvent. Here's what I mean:If this is problematic, I could create a custom inject to match Forge. (This issue does not exist with Fabric API's
END_SERVER_TICK, which I've also used, as both Forge and Fabric API fire their respective events at the very end of the method.)... if (!this.skipGameRender) { // RenderTickEvent START phase fires here with both stock Forge and the mixin this.profiler.swap("gameRenderer"); this.gameRenderer.render(this.paused ? this.pausedTickDelta : this.renderTickCounter.tickDelta, l, tick); this.profiler.swap("toasts"); this.toastManager.draw(); // RenderTickEvent END phase fires here with the mixin this.profiler.pop(); // RenderTickEvent END phase fires here with stock Forge } // Could potentially mixin another (!this.skipGameRender) conditional here as a workaround this.profiler.endTick(); ...Frankly, I'm not quite sure how to mixin where Forge patches it in. However, if the event firing before
this.profiler.pop()is problematic, then the workaround specified above would theoretically accomplish the same thing - albeit in a way that isn't as clean. (How important is the profiler in relation to this event?)