OptionsAddTextBackgroundFix.java
net.minecraft.util.datafix.fixes.OptionsAddTextBackgroundFix
信息
- 全限定名:net.minecraft.util.datafix.fixes.OptionsAddTextBackgroundFix
- 类型:public class
- 包:net.minecraft.util.datafix.fixes
- 源码路径:src/main/java/net/minecraft/util/datafix/fixes/OptionsAddTextBackgroundFix.java
- 起始行号:L9
- 继承:DataFix
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
public OptionsAddTextBackgroundFix(Schema outputSchema, boolean changesType) @ L10
- 构造器名:OptionsAddTextBackgroundFix
- 源码定位:L10
- 修饰符:public
参数:
- outputSchema: Schema
- changesType: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TypeRewriteRule makeRule() @ L14
- 方法名:makeRule
- 源码定位:L14
- 返回类型:TypeRewriteRule
- 修饰符:public
参数:
- 无
说明:
TODO
private double calculateBackground(String textOpacity) @ L26
- 方法名:calculateBackground
- 源码定位:L26
- 返回类型:double
- 修饰符:private
参数:
- textOpacity: String
说明:
TODO
代码
public class OptionsAddTextBackgroundFix extends DataFix {
public OptionsAddTextBackgroundFix(Schema outputSchema, boolean changesType) {
super(outputSchema, changesType);
}
@Override
public TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped(
"OptionsAddTextBackgroundFix",
this.getInputSchema().getType(References.OPTIONS),
input -> input.update(DSL.remainderFinder(), tag -> DataFixUtils.orElse(tag.get("chatOpacity").asString().map(value -> {
double opacity = this.calculateBackground(value);
return tag.set("textBackgroundOpacity", tag.createString(String.valueOf(opacity)));
}).result(), tag))
);
}
private double calculateBackground(String textOpacity) {
try {
double textAlpha = 0.9 * Double.parseDouble(textOpacity) + 0.1;
return textAlpha / 2.0;
} catch (NumberFormatException var4) {
return 0.5;
}
}
}引用的其他类
- Schema
- 引用位置:
参数
- 引用位置: