AttributeModifier .java

net.minecraft.entity.ai.attributes.AttributeModifier (class): members: getOperation, getAmount, operation, setSaved, isSaved, amount, getID, id, name.

net.minecraft.entity.ai.attributesclass113 linescommon2.6 KB

API Surface (9)

UUID getID()
String getName()
int getOperation()
double getAmount()
boolean isSaved()
AttributeModifier setSaved(boolean saved)
boolean equals(Object p_equals_1_)
int hashCode()
String toString()

Fields & Constants (5)

amount
operation
name
id
isSaved

String literals (6)

"Modifier name cannot be empty"
"Invalid operation"
"AttributeModifier{amount="
", operation="
", name=\'"
", serialize="

Code Graph: Dependencies (1)

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

Full Source

AttributeModifier.java113 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.ai.attributes;
2
3
import io.netty.util.internal.ThreadLocalRandom;
4
import java.util.UUID;
5
import net.minecraft.util.MathHelper;
6
import org.apache.commons.lang3.Validate;
7
8
public class AttributeModifier
9
{
10
    private final double amount;
11
    private final int operation;
12
    private final String name;
13
    private final UUID id;
14
15
    /**
16
     * If false, this modifier is not saved in NBT. Used for "natural" modifiers like speed boost from sprinting
17
     */
18
    private boolean isSaved;
19
20
    public AttributeModifier(String nameIn, double amountIn, int operationIn)
21
    {
22
        this(MathHelper.getRandomUuid(ThreadLocalRandom.current()), nameIn, amountIn, operationIn);
23
    }
24
25
    public AttributeModifier(UUID idIn, String nameIn, double amountIn, int operationIn)
26
    {
27
        this.isSaved = true;
28
        this.id = idIn;
29
        this.name = nameIn;
30
        this.amount = amountIn;
31
        this.operation = operationIn;
32
        Validate.notEmpty(nameIn, "Modifier name cannot be empty", new Object[0]);
33
        Validate.inclusiveBetween(0L, 2L, (long)operationIn, "Invalid operation");
34
    }
35
36
    public UUID getID()
37
    {
38
        return this.id;
39
    }
40
41
    public String getName()
42
    {
43
        return this.name;
44
    }
45
46
    public int getOperation()
47
    {
48
        return this.operation;
49
    }
50
51
    public double getAmount()
52
    {
53
        return this.amount;
54
    }
55
56
    /**
57
     * @see #isSaved
58
     */
59
    public boolean isSaved()
60
    {
61
        return this.isSaved;
62
    }
63
64
    /**
65
     * @see #isSaved
66
     */
67
    public AttributeModifier setSaved(boolean saved)
68
    {
69
        this.isSaved = saved;
70
        return this;
71
    }
72
73
    public boolean equals(Object p_equals_1_)
74
    {
75
        if (this == p_equals_1_)
76
        {
77
            return true;
78
        }
79
        else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass())
80
        {
81
            AttributeModifier attributemodifier = (AttributeModifier)p_equals_1_;
82
83
            if (this.id != null)
84
            {
85
                if (!this.id.equals(attributemodifier.id))
86
                {
87
                    return false;
88
                }
89
            }
90
            else if (attributemodifier.id != null)
91
            {
92
                return false;
93
            }
94
95
            return true;
96
        }
97
        else
98
        {
99
            return false;
100
        }
101
    }
102
103
    public int hashCode()
104
    {
105
        return this.id != null ? this.id.hashCode() : 0;
106
    }
107
108
    public String toString()
109
    {
110
        return "AttributeModifier{amount=" + this.amount + ", operation=" + this.operation + ", name=\'" + this.name + '\'' + ", id=" + this.id + ", serialize=" + this.isSaved + '}';
111
    }
112
}
113

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