Add debug logging

This commit is contained in:
IThundxr 2024-10-23 11:25:37 -04:00
parent 6383cebda9
commit c2120d87ea
No known key found for this signature in database
3 changed files with 33 additions and 21 deletions

View File

@ -77,8 +77,6 @@ jobs:
# Lock to a specific commit, it would be bad if the tag is re-pushed with unwanted changes
- name: Run the MC client
uses: 3arthqu4ke/mc-runtime-test@e72f8fe1134aabf6fc749a2a8c09bb56dd7d283e
env:
FLYWHEEL_AUTO_TEST: true
with:
mc: ${{ env.MINECRAFT_VERSION }}
modloader: ${{ matrix.loader }}

View File

@ -1,22 +1,31 @@
package dev.engine_room.flywheel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.MixinEnvironment;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
public class FlywheelTestModClient implements ClientModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger("Flywheel Test Mod");
private int ticks = 0;
@Override
public void onInitializeClient() {
if (Boolean.parseBoolean(System.getProperty("FLYWHEEL_AUTO_TEST"))) {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (++ticks == 50) {
MixinEnvironment.getCurrentEnvironment().audit();
client.stop();
}
});
}
LOGGER.info("Starting Test Mod");
ClientTickEvents.END_CLIENT_TICK.register(client -> {
LOGGER.info("Tick Count: {}", ticks);
if (++ticks == 50) {
LOGGER.info("Running mixin audit");
MixinEnvironment.getCurrentEnvironment().audit();
LOGGER.info("Ran mixin audit, stopping client.");
client.stop();
}
});
}
}

View File

@ -1,5 +1,9 @@
package dev.engine_room.flywheel;
import net.minecraftforge.common.MinecraftForge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.MixinEnvironment;
import net.minecraft.client.Minecraft;
@ -10,22 +14,23 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Mod("flywheel_testmod")
public class FlywheelTestModClient {
private static final Logger LOGGER = LoggerFactory.getLogger("Flywheel Test Mod");
private int ticks = 0;
public FlywheelTestModClient() {
if (Boolean.parseBoolean(System.getProperty("FLYWHEEL_AUTO_TEST"))) {
MinecraftForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> {
if (e.phase == TickEvent.Phase.END) {
LOGGER.info("Tick Count: {}", ticks);
IEventBus modEventBus = FMLJavaModLoadingContext.get()
.getModEventBus();
if (++ticks == 50) {
LOGGER.info("Running mixin audit");
MixinEnvironment.getCurrentEnvironment().audit();
modEventBus.addListener((TickEvent.ClientTickEvent e) -> {
if (e.phase == TickEvent.Phase.END) {
if (++ticks == 50) {
MixinEnvironment.getCurrentEnvironment().audit();
Minecraft.getInstance().stop();
}
LOGGER.info("Ran mixin audit, stopping client.");
Minecraft.getInstance().stop();
}
});
}
}
});
}
}