-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathAttribute.java
More file actions
209 lines (201 loc) · 6.85 KB
/
Attribute.java
File metadata and controls
209 lines (201 loc) · 6.85 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package org.bukkit.attribute;
import com.google.common.base.Preconditions;
import io.papermc.paper.registry.RegistryElement;
import io.papermc.paper.registry.RegistryKey;
import java.util.Locale;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
/**
* Types of attributes which may be present on an {@link Attributable}.
*/
public interface Attribute extends RegistryElement<Attribute>, OldEnum<Attribute>, Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations
/**
* Maximum health of an Entity.
*/
Attribute MAX_HEALTH = getAttribute("max_health");
/**
* Range at which an Entity will follow others.
*/
Attribute FOLLOW_RANGE = getAttribute("follow_range");
/**
* Resistance of an Entity to knockback.
*/
Attribute KNOCKBACK_RESISTANCE = getAttribute("knockback_resistance");
/**
* Movement speed of an Entity.
*/
Attribute MOVEMENT_SPEED = getAttribute("movement_speed");
/**
* Flying speed of an Entity.
*/
Attribute FLYING_SPEED = getAttribute("flying_speed");
/**
* Attack damage of an Entity.
*/
Attribute ATTACK_DAMAGE = getAttribute("attack_damage");
/**
* Attack knockback of an Entity.
*/
Attribute ATTACK_KNOCKBACK = getAttribute("attack_knockback");
/**
* Attack speed of an Entity.
*/
Attribute ATTACK_SPEED = getAttribute("attack_speed");
/**
* Armor bonus of an Entity.
*/
Attribute ARMOR = getAttribute("armor");
/**
* Armor durability bonus of an Entity.
*/
Attribute ARMOR_TOUGHNESS = getAttribute("armor_toughness");
/**
* The fall damage multiplier of an Entity.
*/
Attribute FALL_DAMAGE_MULTIPLIER = getAttribute("fall_damage_multiplier");
/**
* Luck bonus of an Entity.
*/
Attribute LUCK = getAttribute("luck");
/**
* Maximum absorption of an Entity.
*/
Attribute MAX_ABSORPTION = getAttribute("max_absorption");
/**
* The distance which an Entity can fall without damage.
*/
Attribute SAFE_FALL_DISTANCE = getAttribute("safe_fall_distance");
/**
* The relative scale of an Entity.
*/
Attribute SCALE = getAttribute("scale");
/**
* The height which an Entity can walk over.
*/
Attribute STEP_HEIGHT = getAttribute("step_height");
/**
* The gravity applied to an Entity.
*/
Attribute GRAVITY = getAttribute("gravity");
/**
* Strength with which an Entity will jump.
*/
Attribute JUMP_STRENGTH = getAttribute("jump_strength");
/**
* How long an entity remains burning after ignition.
*/
Attribute BURNING_TIME = getAttribute("burning_time");
/**
* The camera distance of a player to their own entity.
*/
Attribute CAMERA_DISTANCE = getAttribute("camera_distance");
/**
* Resistance to knockback from explosions.
*/
Attribute EXPLOSION_KNOCKBACK_RESISTANCE = getAttribute("explosion_knockback_resistance");
/**
* Movement speed through difficult terrain.
*/
Attribute MOVEMENT_EFFICIENCY = getAttribute("movement_efficiency");
/**
* Oxygen use underwater.
*/
Attribute OXYGEN_BONUS = getAttribute("oxygen_bonus");
/**
* Movement speed through water.
*/
Attribute WATER_MOVEMENT_EFFICIENCY = getAttribute("water_movement_efficiency");
/**
* Range at which mobs will be tempted by items.
*/
Attribute TEMPT_RANGE = getAttribute("tempt_range");
/**
* The block reach distance of a Player.
*/
Attribute BLOCK_INTERACTION_RANGE = getAttribute("block_interaction_range");
/**
* The entity reach distance of a Player.
*/
Attribute ENTITY_INTERACTION_RANGE = getAttribute("entity_interaction_range");
/**
* Block break speed of a Player.
*/
Attribute BLOCK_BREAK_SPEED = getAttribute("block_break_speed");
/**
* Mining speed for correct tools.
*/
Attribute MINING_EFFICIENCY = getAttribute("mining_efficiency");
/**
* Sneaking speed.
*/
Attribute SNEAKING_SPEED = getAttribute("sneaking_speed");
/**
* Underwater mining speed.
*/
Attribute SUBMERGED_MINING_SPEED = getAttribute("submerged_mining_speed");
/**
* Sweeping damage.
*/
Attribute SWEEPING_DAMAGE_RATIO = getAttribute("sweeping_damage_ratio");
/**
* Chance of a zombie to spawn reinforcements.
*/
Attribute SPAWN_REINFORCEMENTS = getAttribute("spawn_reinforcements");
/**
* Attribute controlling the range an entity transmits itself as a waypoint.
*/
Attribute WAYPOINT_TRANSMIT_RANGE = getAttribute("waypoint_transmit_range");
/**
* Attribute controlling the range an entity receives other waypoints from.
*/
Attribute WAYPOINT_RECEIVE_RANGE = getAttribute("waypoint_receive_range");
@NotNull
private static Attribute getAttribute(@NotNull @KeyPattern.Value String key) {
return Registry.ATTRIBUTE.getOrThrow(Key.key(Key.MINECRAFT_NAMESPACE, key));
}
/**
* {@return the sentiment of this attribute}
*/
@NotNull
Sentiment getSentiment();
/**
* @param name of the attribute.
* @return the attribute with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Attribute valueOf(@NotNull String name) {
final NamespacedKey key = NamespacedKey.fromString(name.toLowerCase(Locale.ROOT));
Attribute attribute = key == null ? null : Bukkit.getUnsafe().get(RegistryKey.ATTRIBUTE, key);
Preconditions.checkArgument(attribute != null, "No attribute found with the name %s", name);
return attribute;
}
/**
* @return an array of all known attributes.
* @deprecated use {@link Registry#stream()}.
*/
@NotNull
@Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils
static Attribute[] values() {
return Registry.ATTRIBUTE.stream().toArray(Attribute[]::new);
}
/**
* An attribute sentiment describes the intent behind the attribute, meaning
* whether it is supposed to be a positive, neutral, or negative attribute.
*/
enum Sentiment {
// Start generate - AttributeSentiment
POSITIVE,
NEUTRAL,
NEGATIVE;
// End generate - AttributeSentiment
}
}