Fabricators-of-Create / Porting-Lib

A collection of utilities for porting mods from Forge to Fabric.
Other
112 stars 32 forks source link

PlayerTickEvents runs twice per tick on the server-side #117

Open BluSpring opened 2 months ago

BluSpring commented 2 months ago

I've been trying to figure out why things were going so fast in a mod I was porting, and turns out, PlayerTickEvents runs twice!

https://github.com/Fabricators-of-Create/Porting-Lib/blob/1.20.1/modules/entity/src/main/java/io/github/fabricators_of_create/porting_lib/entity/mixin/common/ServerPlayerMixin.java#L99-L107 https://github.com/Fabricators-of-Create/Porting-Lib/blob/1.20.1/modules/entity/src/main/java/io/github/fabricators_of_create/porting_lib/entity/mixin/common/PlayerMixin.java#L52-L60

When looking at ServerPlayer in Minecraft, you really wouldn't think much about it, because it doesn't look like it calls Player#tick in ServerPlayer#tick. However, just below it in ServerPlayer#doTick, it does in fact call Player#tick in there, and as such, it ends up running twice in one tick.

AlphaMode commented 2 months ago

I just noticed this a hour ago lol. I already fixed it in the 1.21 port I can look into backing it