Don't tick gametests if the server isn't ticking ()

* Don't tick gametests if the server isn't ticking

* Fix import order

(cherry picked from commit 85d85a93b5)
This commit is contained in:
Jared 2024-01-15 06:40:07 -07:00 committed by modmuss50
parent fd154599a6
commit ab3cc93a49

View file

@ -18,21 +18,28 @@ package net.fabricmc.fabric.mixin.gametest;
import java.util.function.BooleanSupplier;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.SharedConstants;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerTickManager;
import net.minecraft.test.TestManager;
@Mixin(MinecraftServer.class)
public abstract class MinecraftServerMixin {
@Shadow
@Final
private ServerTickManager tickManager;
@Inject(method = "tickWorlds", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/PlayerManager;updatePlayerLatency()V", shift = At.Shift.AFTER))
private void tickWorlds(BooleanSupplier shouldKeepTicking, CallbackInfo callbackInfo) {
// Called by vanilla when isDevelopment is enabled.
if (!SharedConstants.isDevelopment) {
if (!SharedConstants.isDevelopment && this.tickManager.shouldTick()) {
TestManager.INSTANCE.tick();
}
}