Use dev.faststats.neoforge.NeoForgeContext for NeoForge mods. Requires Java 21+.
NeoForge supports Minecraft 1.20.6 and all newer versions. Select both the SDK
version and the exact Minecraft version in your dependency version. You can
find the available Minecraft version targets in the Maven
repository.
Use both implementation and jarJar. FastStats is provided as a mod through
jar-in-jar, so implementation puts it on your compile classpath and include
bundles it into your mod JAR.
The version format is {sdk-version}+mc{minecraft-version}, where
{sdk-version} is the FastStats SDK version and {minecraft-version} is the
exact Minecraft version you are targeting. Each artifact is built for a single
Minecraft version, so pick the one matching your mod.
import dev.faststats.ErrorTracker;
import dev.faststats.Metrics;
import dev.faststats.neoforge.NeoForgeContext;
import net.neoforged.fml.common.Mod;
@Mod("example_mod")
public class ExampleMod {
public static final ErrorTracker ERROR_TRACKER = ErrorTracker.contextAware();
private final NeoForgeContext context = new NeoForgeContext.Factory("example_mod", "YOUR_TOKEN")
.errorTrackerService(ERROR_TRACKER)
.metrics(Metrics.Factory::create)
.create();
}
Pass your mod ID, as defined in neoforge.mods.toml, to NeoForgeContext.Factory.
Explicit user consent is opt-in. To require it for your mod, call
requireConsent() on NeoForgeContext.Factory:
private final NeoForgeContext context = new NeoForgeContext.Factory("example_mod", "YOUR_TOKEN")
.requireConsent()
.errorTrackerService(ERROR_TRACKER)
.metrics(Metrics.Factory::create)
.create();
When at least one installed mod requires explicit consent, the client shows a
consent screen on startup. The screen is only shown once. If a mod that requires
explicit consent is installed after mods that did not require it, the screen is
still shown on the next startup.