OptionsGraphicsModeSplitFix.java
net.minecraft.util.datafix.fixes.OptionsGraphicsModeSplitFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.OptionsGraphicsModeSplitFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/OptionsGraphicsModeSplitFix.java
- 起始行号:L9
- 继承:DataFix
- 职责:
TODO
字段/常量
-
newFieldName- 类型:
String - 修饰符:
private final - 源码定位:
L10 - 说明:
TODO
- 类型:
-
valueIfFast- 类型:
String - 修饰符:
private final - 源码定位:
L11 - 说明:
TODO
- 类型:
-
valueIfFancy- 类型:
String - 修饰符:
private final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
valueIfFabulous- 类型:
String - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public OptionsGraphicsModeSplitFix(Schema outputSchema, String newFieldName, String valueIfFast, String valueIfFancy, String valueIfFabulous) @ L15
- 构造器名:OptionsGraphicsModeSplitFix
- 源码定位:L15
- 修饰符:public
参数:
- outputSchema: Schema
- newFieldName: String
- valueIfFast: String
- valueIfFancy: String
- valueIfFabulous: String
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TypeRewriteRule makeRule() @ L23
- 方法名:makeRule
- 源码定位:L23
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
private String getValue(String mode) @ L38
- 方法名:getValue
- 源码定位:L38
- 返回类型:String
- 修饰符:private
参数:
- mode: String
说明:
TODO
代码
public class OptionsGraphicsModeSplitFix extends DataFix {
private final String newFieldName;
private final String valueIfFast;
private final String valueIfFancy;
private final String valueIfFabulous;
public OptionsGraphicsModeSplitFix(Schema outputSchema, String newFieldName, String valueIfFast, String valueIfFancy, String valueIfFabulous) {
super(outputSchema, true);
this.newFieldName = newFieldName;
this.valueIfFast = valueIfFast;
this.valueIfFancy = valueIfFancy;
this.valueIfFabulous = valueIfFabulous;
}
@Override
public TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped(
"graphicsMode split to " + this.newFieldName,
this.getInputSchema().getType(References.OPTIONS),
input -> input.update(
DSL.remainderFinder(),
tag -> DataFixUtils.orElseGet(
tag.get("graphicsMode").asString().map(mode -> tag.set(this.newFieldName, tag.createString(this.getValue(mode)))).result(),
() -> tag.set(this.newFieldName, tag.createString(this.valueIfFancy))
)
)
);
}
private String getValue(String mode) {
return switch (mode) {
case "2" -> this.valueIfFabulous;
case "0" -> this.valueIfFast;
default -> this.valueIfFancy;
};
}
}引用的其他类
- Schema
- 引用位置:
参数
- 引用位置: