EnchantmentNames.java
net.minecraft.client.gui.screens.inventory.EnchantmentNames
信息
- 全限定名:net.minecraft.client.gui.screens.inventory.EnchantmentNames
- 类型:public class
- 包:net.minecraft.client.gui.screens.inventory
- 源码路径:src/main/java/net/minecraft/client/gui/screens/inventory/EnchantmentNames.java
- 起始行号:L15
- 职责:
TODO
字段/常量
-
ALT_FONT- 类型:
FontDescription - 修饰符:
private static final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
ROOT_STYLE- 类型:
Style - 修饰符:
private static final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
INSTANCE- 类型:
EnchantmentNames - 修饰符:
private static final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
random- 类型:
RandomSource - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
words- 类型:
String[] - 修饰符:
private final - 源码定位:
L20 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private EnchantmentNames() @ L85
- 构造器名:EnchantmentNames
- 源码定位:L85
- 修饰符:private
参数:
- 无
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static EnchantmentNames getInstance() @ L88
- 方法名:getInstance
- 源码定位:L88
- 返回类型:EnchantmentNames
- 修饰符:public static
参数:
- 无
说明:
TODO
public FormattedText getRandomName(Font font, int maxWidth) @ L92
- 方法名:getRandomName
- 源码定位:L92
- 返回类型:FormattedText
- 修饰符:public
参数:
- font: Font
- maxWidth: int
说明:
TODO
public void initSeed(long seed) @ L107
- 方法名:initSeed
- 源码定位:L107
- 返回类型:void
- 修饰符:public
参数:
- seed: long
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class EnchantmentNames {
private static final FontDescription ALT_FONT = new FontDescription.Resource(Identifier.withDefaultNamespace("alt"));
private static final Style ROOT_STYLE = Style.EMPTY.withFont(ALT_FONT);
private static final EnchantmentNames INSTANCE = new EnchantmentNames();
private final RandomSource random = RandomSource.create();
private final String[] words = new String[]{
"the",
"elder",
"scrolls",
"klaatu",
"berata",
"niktu",
"xyzzy",
"bless",
"curse",
"light",
"darkness",
"fire",
"air",
"earth",
"water",
"hot",
"dry",
"cold",
"wet",
"ignite",
"snuff",
"embiggen",
"twist",
"shorten",
"stretch",
"fiddle",
"destroy",
"imbue",
"galvanize",
"enchant",
"free",
"limited",
"range",
"of",
"towards",
"inside",
"sphere",
"cube",
"self",
"other",
"ball",
"mental",
"physical",
"grow",
"shrink",
"demon",
"elemental",
"spirit",
"animal",
"creature",
"beast",
"humanoid",
"undead",
"fresh",
"stale",
"phnglui",
"mglwnafh",
"cthulhu",
"rlyeh",
"wgahnagl",
"fhtagn",
"baguette"
};
private EnchantmentNames() {
}
public static EnchantmentNames getInstance() {
return INSTANCE;
}
public FormattedText getRandomName(Font font, int maxWidth) {
StringBuilder result = new StringBuilder();
int wordCount = this.random.nextInt(2) + 3;
for (int i = 0; i < wordCount; i++) {
if (i != 0) {
result.append(" ");
}
result.append(Util.getRandom(this.words, this.random));
}
return font.getSplitter().headByWidth(Component.literal(result.toString()).withStyle(ROOT_STYLE), maxWidth, Style.EMPTY);
}
public void initSeed(long seed) {
this.random.setSeed(seed);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.literal()
- 引用位置:
-
- 引用位置:
字段/方法调用/构造调用 - 关联成员:
FontDescription.Resource(), Resource()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
RandomSource.create()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.getRandom()
- 引用位置: