AggregatedTelemetryEvent .java

net.minecraft.client.telemetry.events.AggregatedTelemetryEvent (class, 57 lines): members: SAMPLE_INTERVAL_MS, SAMPLES_PER_EVENT, shouldTakeSample, stop.

net.minecraft.client.telemetry.eventsclass57 linesclient1.4 KB

API Surface (6)

void start()
void tick(final TelemetryEventSender eventSender)
boolean shouldTakeSample()
boolean shouldSentEvent()
void stop()
int getSampleCount()

Fields & Constants (5)

SAMPLE_INTERVAL_MS
SAMPLES_PER_EVENT
sampleCount
ticking
lastSampleTime

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

AggregatedTelemetryEvent.java57 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.telemetry.events;
2
3
import java.time.Duration;
4
import java.time.Instant;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import net.minecraft.client.telemetry.TelemetryEventSender;
8
import org.jspecify.annotations.Nullable;
9
10
@Environment(EnvType.CLIENT)
11
public abstract class AggregatedTelemetryEvent {
12
	private static final int SAMPLE_INTERVAL_MS = 60000;
13
	private static final int SAMPLES_PER_EVENT = 10;
14
	private int sampleCount;
15
	private boolean ticking = false;
16
	private @Nullable Instant lastSampleTime;
17
18
	public void start() {
19
		this.ticking = true;
20
		this.lastSampleTime = Instant.now();
21
		this.sampleCount = 0;
22
	}
23
24
	public void tick(final TelemetryEventSender eventSender) {
25
		if (this.shouldTakeSample()) {
26
			this.takeSample();
27
			this.sampleCount++;
28
			this.lastSampleTime = Instant.now();
29
		}
30
31
		if (this.shouldSentEvent()) {
32
			this.sendEvent(eventSender);
33
			this.sampleCount = 0;
34
		}
35
	}
36
37
	public boolean shouldTakeSample() {
38
		return this.ticking && this.lastSampleTime != null && Duration.between(this.lastSampleTime, Instant.now()).toMillis() > 60000L;
39
	}
40
41
	public boolean shouldSentEvent() {
42
		return this.sampleCount >= 10;
43
	}
44
45
	public void stop() {
46
		this.ticking = false;
47
	}
48
49
	protected int getSampleCount() {
50
		return this.sampleCount;
51
	}
52
53
	public abstract void takeSample();
54
55
	public abstract void sendEvent(TelemetryEventSender eventSender);
56
}
57

Decompiled Minecraft 26.3 source of AggregatedTelemetryEvent (net/minecraft/client/telemetry/events/AggregatedTelemetryEvent.java) with Mojang official mappings, stored verbatim on the site.