Skip to content

Commit

Permalink
Add debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Oct 23, 2024
1 parent 6383ceb commit c2120d8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
});
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,22 +14,23 @@

@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();
}
});
}
}
});
}
}

0 comments on commit c2120d8

Please sign in to comment.