-
Notifications
You must be signed in to change notification settings - Fork 755
/
IMaterialStats.java
73 lines (62 loc) · 2.1 KB
/
IMaterialStats.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
69
70
71
72
73
package slimeknights.tconstruct.library.materials.stats;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus.NonExtendable;
import slimeknights.tconstruct.library.utils.Util;
import java.util.List;
/**
* Basic interface for all material stats.
*/
public interface IMaterialStats {
/**
* Returns the stat type, which is used for parsing the stat and getting default stats.
*/
MaterialStatType<?> getType();
/**
* Returns a unique ResourceLocation to identify the type of stats the material has.
*/
@NonExtendable
default MaterialStatsId getIdentifier() {
return getType().getId();
}
/**
* Returns the name of the stat type, to be displayed to the player.
*/
default MutableComponent getLocalizedName() {
return Component.translatable(Util.makeTranslationKey("stat", getIdentifier()));
}
/**
* Returns a list containing a String for each player-relevant value.</br>
* Each line should consist of the name of the value followed by the value itself.</br>
* Example: "Durability: 25"</br>
* </br>
* This is used to display properties of materials to the user.
*/
List<Component> getLocalizedInfo();
/**
* Returns a list containing a Text Component describing each player-relevant value.</br>
* The indices of the lines must line up with the lines from getLocalizedInfo()!</br>
* *
* This is used to display properties of materials to the user.
* @return a list of Text Components
*/
List<Component> getLocalizedDescriptions();
/* Helpers */
/**
* Helper to make a translation key for the given name
* @param name name
* @return Text component
*/
static String makeTooltipKey(ResourceLocation name) {
return Util.makeTranslationKey("tool_stat", name);
}
/**
* Helper to make a text component for the given name
* @param name name
* @return Text component
*/
static Component makeTooltip(ResourceLocation name) {
return Component.translatable(makeTooltipKey(name));
}
}