package net.minecraft.client.telemetry; import com.mojang.authlib.minecraft.TelemetryEvent; import com.mojang.authlib.minecraft.TelemetrySession; import com.mojang.serialization.Codec; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public record TelemetryEventInstance(TelemetryEventType type, TelemetryPropertyMap properties) { public static final Codec CODEC = TelemetryEventType.CODEC.dispatchStable(TelemetryEventInstance::type, TelemetryEventType::codec); public TelemetryEventInstance(TelemetryEventType type, TelemetryPropertyMap properties) { properties.propertySet().forEach(telemetryProperty -> { if (!telemetryEventType.contains(telemetryProperty)) { throw new IllegalArgumentException("Property '" + telemetryProperty.id() + "' not expected for event: '" + telemetryEventType.id() + "'"); } }); this.type = type; this.properties = properties; } public TelemetryEvent export(TelemetrySession session) { return this.type.export(session, this.properties); } }