/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.Codec * org.jspecify.annotations.Nullable */ package net.minecraft.world.attribute; import com.mojang.serialization.Codec; import java.util.Objects; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.util.Util; import net.minecraft.world.attribute.AttributeRange; import net.minecraft.world.attribute.AttributeType; import org.jspecify.annotations.Nullable; public class EnvironmentAttribute { private final AttributeType type; private final Value defaultValue; private final AttributeRange valueRange; private final boolean isSyncable; private final boolean isPositional; private final boolean isSpatiallyInterpolated; private EnvironmentAttribute(AttributeType type, Value defaultValue, AttributeRange valueRange, boolean isSyncable, boolean isPositional, boolean isSpatiallyInterpolated) { this.type = type; this.defaultValue = defaultValue; this.valueRange = valueRange; this.isSyncable = isSyncable; this.isPositional = isPositional; this.isSpatiallyInterpolated = isSpatiallyInterpolated; } public static Builder builder(AttributeType type) { return new Builder(type); } public AttributeType type() { return this.type; } public Value defaultValue() { return this.defaultValue; } public Codec valueCodec() { return this.type.valueCodec().validate(this.valueRange::validate); } public Value sanitizeValue(Value value) { return this.valueRange.sanitize(value); } public boolean isSyncable() { return this.isSyncable; } public boolean isPositional() { return this.isPositional; } public boolean isSpatiallyInterpolated() { return this.isSpatiallyInterpolated; } public String toString() { return Util.getRegisteredName(BuiltInRegistries.ENVIRONMENT_ATTRIBUTE, this); } public static class Builder { private final AttributeType type; private @Nullable Value defaultValue; private AttributeRange valueRange = AttributeRange.any(); private boolean isSyncable = false; private boolean isPositional = true; private boolean isSpatiallyInterpolated = false; public Builder(AttributeType type) { this.type = type; } public Builder defaultValue(Value defaultValue) { this.defaultValue = defaultValue; return this; } public Builder valueRange(AttributeRange valueRange) { this.valueRange = valueRange; return this; } public Builder syncable() { this.isSyncable = true; return this; } public Builder notPositional() { this.isPositional = false; return this; } public Builder spatiallyInterpolated() { this.isSpatiallyInterpolated = true; return this; } public EnvironmentAttribute build() { return new EnvironmentAttribute(this.type, Objects.requireNonNull(this.defaultValue, "Missing default value"), this.valueRange, this.isSyncable, this.isPositional, this.isSpatiallyInterpolated); } } }