/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.DataResult * com.mojang.serialization.DynamicOps * com.mojang.serialization.MapCodec * com.mojang.serialization.MapLike * com.mojang.serialization.RecordBuilder * it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap * org.jspecify.annotations.Nullable */ package net.minecraft.client.telemetry; import com.mojang.serialization.DataResult; import com.mojang.serialization.DynamicOps; import com.mojang.serialization.MapCodec; import com.mojang.serialization.MapLike; import com.mojang.serialization.RecordBuilder; import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Stream; import net.minecraft.client.telemetry.TelemetryProperty; import org.jspecify.annotations.Nullable; public class TelemetryPropertyMap { private final Map, Object> entries; private TelemetryPropertyMap(Map, Object> entries) { this.entries = entries; } public static Builder builder() { return new Builder(); } public static MapCodec createCodec(final List> properties) { return new MapCodec(){ public RecordBuilder encode(TelemetryPropertyMap input, DynamicOps ops, RecordBuilder prefix) { RecordBuilder result = prefix; for (TelemetryProperty property : properties) { result = this.encodeProperty(input, result, property); } return result; } private RecordBuilder encodeProperty(TelemetryPropertyMap input, RecordBuilder result, TelemetryProperty property) { V value = input.get(property); if (value != null) { return result.add(property.id(), value, property.codec()); } return result; } public DataResult decode(DynamicOps ops, MapLike input) { DataResult result = DataResult.success((Object)new Builder()); for (TelemetryProperty property : properties) { result = this.decodeProperty(result, ops, input, property); } return result.map(Builder::build); } private DataResult decodeProperty(DataResult result, DynamicOps ops, MapLike input, TelemetryProperty property) { Object value = input.get(property.id()); if (value != null) { DataResult parse = property.codec().parse(ops, value); return result.apply2stable((b, v) -> b.put(property, v), parse); } return result; } public Stream keys(DynamicOps ops) { return properties.stream().map(TelemetryProperty::id).map(arg_0 -> ops.createString(arg_0)); } }; } public @Nullable T get(TelemetryProperty property) { return (T)this.entries.get(property); } public String toString() { return this.entries.toString(); } public Set> propertySet() { return this.entries.keySet(); } public static class Builder { private final Map, Object> entries = new Reference2ObjectOpenHashMap(); private Builder() { } public Builder put(TelemetryProperty property, T value) { this.entries.put(property, value); return this; } public Builder putIfNotNull(TelemetryProperty property, @Nullable T value) { if (value != null) { this.entries.put(property, value); } return this; } public Builder putAll(TelemetryPropertyMap properties) { this.entries.putAll(properties.entries); return this; } public TelemetryPropertyMap build() { return new TelemetryPropertyMap(this.entries); } } }