AddFlagIfNotPresentFix.java
net.minecraft.util.datafix.fixes.AddFlagIfNotPresentFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.AddFlagIfNotPresentFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/AddFlagIfNotPresentFix.java
- 起始行号:L11
- 继承:DataFix
- 职责:
TODO
字段/常量
-
name- 类型:
String - 修饰符:
private final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
flagValue- 类型:
boolean - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
flagKey- 类型:
String - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
typeReference- 类型:
TypeReference - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public AddFlagIfNotPresentFix(Schema outputSchema, TypeReference typeReference, String flagKey, boolean flagValue) @ L17
- 构造器名:AddFlagIfNotPresentFix
- 源码定位:L17
- 修饰符:public
参数:
- outputSchema: Schema
- typeReference: TypeReference
- flagKey: String
- flagValue: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected TypeRewriteRule makeRule() @ L25
- 方法名:makeRule
- 源码定位:L25
- 返回类型:TypeRewriteRule
- 修饰符:protected
参数:
- 无
说明:
TODO
代码
public class AddFlagIfNotPresentFix extends DataFix {
private final String name;
private final boolean flagValue;
private final String flagKey;
private final TypeReference typeReference;
public AddFlagIfNotPresentFix(Schema outputSchema, TypeReference typeReference, String flagKey, boolean flagValue) {
super(outputSchema, true);
this.flagValue = flagValue;
this.flagKey = flagKey;
this.name = "AddFlagIfNotPresentFix_" + this.flagKey + "=" + this.flagValue + " for " + outputSchema.getVersionKey();
this.typeReference = typeReference;
}
@Override
protected TypeRewriteRule makeRule() {
Type<?> worldGenSettingsType = this.getInputSchema().getType(this.typeReference);
return this.fixTypeEverywhereTyped(
this.name,
worldGenSettingsType,
settings -> settings.update(
DSL.remainderFinder(),
tag -> tag.set(this.flagKey, DataFixUtils.orElseGet(tag.get(this.flagKey).result(), () -> tag.createBoolean(this.flagValue)))
)
);
}
}引用的其他类
- Schema
- 引用位置:
参数
- 引用位置: