ScoreboardDisplaySlotFix.java
net.minecraft.util.datafix.fixes.ScoreboardDisplaySlotFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.ScoreboardDisplaySlotFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/ScoreboardDisplaySlotFix.java
- 起始行号:L14
- 继承:DataFix
- 职责:
TODO
字段/常量
SLOT_RENAMES- 类型:
Map<String,String> - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ScoreboardDisplaySlotFix(Schema outputSchema) @ L37
- 构造器名:ScoreboardDisplaySlotFix
- 源码定位:L37
- 修饰符:public
参数:
- outputSchema: Schema
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static String rename(String key) @ L41
- 方法名:rename
- 源码定位:L41
- 返回类型:String
- 修饰符:private static
参数:
- key: String
说明:
TODO
protected TypeRewriteRule makeRule() @ L45
- 方法名:makeRule
- 源码定位:L45
- 返回类型:TypeRewriteRule
- 修饰符:protected
参数:
- 无
说明:
TODO
代码
public class ScoreboardDisplaySlotFix extends DataFix {
private static final Map<String, String> SLOT_RENAMES = ImmutableMap.<String, String>builder()
.put("slot_0", "list")
.put("slot_1", "sidebar")
.put("slot_2", "below_name")
.put("slot_3", "sidebar.team.black")
.put("slot_4", "sidebar.team.dark_blue")
.put("slot_5", "sidebar.team.dark_green")
.put("slot_6", "sidebar.team.dark_aqua")
.put("slot_7", "sidebar.team.dark_red")
.put("slot_8", "sidebar.team.dark_purple")
.put("slot_9", "sidebar.team.gold")
.put("slot_10", "sidebar.team.gray")
.put("slot_11", "sidebar.team.dark_gray")
.put("slot_12", "sidebar.team.blue")
.put("slot_13", "sidebar.team.green")
.put("slot_14", "sidebar.team.aqua")
.put("slot_15", "sidebar.team.red")
.put("slot_16", "sidebar.team.light_purple")
.put("slot_17", "sidebar.team.yellow")
.put("slot_18", "sidebar.team.white")
.build();
public ScoreboardDisplaySlotFix(Schema outputSchema) {
super(outputSchema, false);
}
private static @Nullable String rename(String key) {
return SLOT_RENAMES.get(key);
}
@Override
protected TypeRewriteRule makeRule() {
Type<?> scoreboardType = this.getInputSchema().getType(References.SAVED_DATA_SCOREBOARD);
OpticFinder<?> rootTagFinder = scoreboardType.findField("data");
return this.fixTypeEverywhereTyped(
"Scoreboard DisplaySlot rename",
scoreboardType,
input -> input.updateTyped(
rootTagFinder,
scoreboardInfo -> scoreboardInfo.update(
DSL.remainderFinder(),
tag -> tag.update(
"DisplaySlots",
slots -> slots.updateMapValues(
pair -> pair.mapFirst(
key -> DataFixUtils.orElse(key.asString().result().map(ScoreboardDisplaySlotFix::rename).map(key::createString), key)
)
)
)
)
)
);
}
}引用的其他类
- Schema
- 引用位置:
参数
- 引用位置: