Closed GammaWhiskey closed 4 years ago
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?
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?
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:
Like
BeforeInvoke
, this injection point searches for invoke instructions within the target instruction list and returns instructions which match the criteria. However the method targetted must return a value.
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 ++this.ticks;
is not public, then implementing Forge's ServerTickEvent
with Fabric API's START_SERVER_TICK
should be fine. I don't think there are any mod uses tick
as a timestamp or care about its state.
At worst it could cause an off-by-one error, but having that cause a genuine issue is very unlikely.
Thank you for the in-depth PR description by the way, it was very helpful!
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
TODO
from the TickEvent class! A few things of note here:START_SERVER_TICK
event, which is what I've used to implementServerTickEvent
(trying not to reinvent the wheel here), fires slightly later than theSTART
phase 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.)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?)