-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
AttributesContainer.java
68 lines (56 loc) · 2.13 KB
/
AttributesContainer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package net.bettercombat.api;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
/**
* Represents the content of a weapon attributes json file.
* If the name of the containing json file matches an existing item (for example: "data/minecraft/weapon_attributes/wooden_sword.json),
* the attributes will be assigned to the item, after the attribute inheritance has been automatically resolved."
*/
public final class AttributesContainer {
/**
* Specifies the attributes container to inherit from.
* If not specified (or null), no inheritance is looked up, make sure `attributes` has fully parsable value.
* Value must be an identifier, formula: "namespace:resource".
* Examples:
* "minecraft:wooden_sword"
* "my-mod-id:my-sword"
* "my-mod-id:my-abstract-weapon-attributes"
*/
@Nullable
private final String parent;
/**
* The actual attributes we want to assign to an existing item, or abstract attributes.
* If not specified (or null), make sure `parent` has a valid value.
* Check out the documentation of `WeaponAttributes` to see its structure and member wise explanation.
*/
@Nullable
private final WeaponAttributes attributes;
public AttributesContainer(@Nullable String parent, @Nullable WeaponAttributes attributes) {
this.parent = parent;
this.attributes = attributes;
}
public String parent() {
return parent;
}
public WeaponAttributes attributes() {
return attributes;
}
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != this.getClass()) return false;
var that = (AttributesContainer) obj;
return Objects.equals(this.parent, that.parent) &&
Objects.equals(this.attributes, that.attributes);
}
@Override
public int hashCode() {
return Objects.hash(parent, attributes);
}
@Override
public String toString() {
return "AttributesContainer[" +
"parent=" + parent + ", " +
"attributes=" + attributes + ']';
}
}