API Surface (3) double getMinValue()
double getMaxValue()
double sanitizeValue(final double value)
Code Graph: Dependencies (2) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
RangedAttribute.java 39 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.world.entity.ai.attributes;
2
3 import net.minecraft.util.Mth;
4
5 public class RangedAttribute extends Attribute {
6 private final double minValue;
7 private final double maxValue;
8
9 public RangedAttribute(final String descriptionId, final double defaultValue, final double minValue, final double maxValue) {
10 super(descriptionId, defaultValue);
11 this.minValue = minValue;
12 this.maxValue = maxValue;
13 if (minValue > maxValue) {
14 throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
15 }
16
17 if (defaultValue < minValue) {
18 throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
19 }
20
21 if (defaultValue > maxValue) {
22 throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
23 }
24 }
25
26 public double getMinValue() {
27 return this.minValue;
28 }
29
30 public double getMaxValue() {
31 return this.maxValue;
32 }
33
34 @Override
35 public double sanitizeValue(final double value) {
36 return Double.isNaN(value) ? this.minValue : Mth.clamp(value, this.minValue, this.maxValue);
37 }
38 }
39
Decompiled Minecraft 26.3 source of RangedAttribute (net/minecraft/world/entity/ai/attributes/RangedAttribute.java) with Mojang official mappings, stored verbatim on the site.