RangedAttribute .java

net.minecraft.entity.ai.attributes.RangedAttribute (class): members: setDescription, maximumValue, minimumValue, clampValue, getDescription, description.

net.minecraft.entity.ai.attributesclass48 linescommonextends BaseAttribute1.4 KB

API Surface (3)

RangedAttribute setDescription(String descriptionIn)
String getDescription()
double clampValue(double p_111109_1_)

Fields & Constants (3)

minimumValue
maximumValue
description

Code Graph: Dependencies (3)

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

Full Source

RangedAttribute.java48 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai.attributes;
2
3
import net.minecraft.util.MathHelper;
4
5
public class RangedAttribute extends BaseAttribute
6
{
7
    private final double minimumValue;
8
    private final double maximumValue;
9
    private String description;
10
11
    public RangedAttribute(IAttribute p_i45891_1_, String unlocalizedNameIn, double defaultValue, double minimumValueIn, double maximumValueIn)
12
    {
13
        super(p_i45891_1_, unlocalizedNameIn, defaultValue);
14
        this.minimumValue = minimumValueIn;
15
        this.maximumValue = maximumValueIn;
16
17
        if (minimumValueIn > maximumValueIn)
18
        {
19
            throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
20
        }
21
        else if (defaultValue < minimumValueIn)
22
        {
23
            throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
24
        }
25
        else if (defaultValue > maximumValueIn)
26
        {
27
            throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
28
        }
29
    }
30
31
    public RangedAttribute setDescription(String descriptionIn)
32
    {
33
        this.description = descriptionIn;
34
        return this;
35
    }
36
37
    public String getDescription()
38
    {
39
        return this.description;
40
    }
41
42
    public double clampValue(double p_111109_1_)
43
    {
44
        p_111109_1_ = MathHelper.clamp_double(p_111109_1_, this.minimumValue, this.maximumValue);
45
        return p_111109_1_;
46
    }
47
}
48

Deobfuscated MCP 1.8.9 source of RangedAttribute from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/ai/attributes/RangedAttribute.java), stored verbatim.