OptionsKeyTranslationFix.java
net.minecraft.util.datafix.fixes.OptionsKeyTranslationFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.OptionsKeyTranslationFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/OptionsKeyTranslationFix.java
- 起始行号:L10
- 继承:DataFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public OptionsKeyTranslationFix(Schema outputSchema, boolean changesType) @ L11
- 构造器名:OptionsKeyTranslationFix
- 源码定位:L11
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TypeRewriteRule makeRule() @ L15
- 方法名:makeRule
- 源码定位:L15
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class OptionsKeyTranslationFix extends DataFix {
public OptionsKeyTranslationFix(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType);
}
@Override
public TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped(
"OptionsKeyTranslationFix",
this.getInputSchema().getType(References.OPTIONS),
input -> input.update(DSL.remainderFinder(), tag -> tag.getMapValues().map(map1 -> tag.createMap(map1.entrySet().stream().map(entry -> {
if (entry.getKey().asString("").startsWith("key_")) {
String oldValue = entry.getValue().asString("");
if (!oldValue.startsWith("key.mouse") && !oldValue.startsWith("scancode.")) {
return Pair.of(entry.getKey(), tag.createString("key.keyboard." + oldValue.substring("key.".length())));
}
}
return Pair.of(entry.getKey(), entry.getValue());
}).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)))).result().orElse((com.mojang.serialization.Dynamic)tag))
);
}
}引用的其他类
- Schema
- 引用位置:
参数
- 引用位置: