BedItemColorFix.java

net.minecraft.util.datafix.fixes.BedItemColorFix

信息

  • 全限定名:net.minecraft.util.datafix.fixes.BedItemColorFix
  • 类型:public class
  • 包:net.minecraft.util.datafix.fixes
  • 源码路径:src/main/java/net/minecraft/util/datafix/fixes/BedItemColorFix.java
  • 起始行号:L14
  • 继承:DataFix
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

public BedItemColorFix(Schema outputSchema, boolean changesType) @ L15

  • 构造器名:BedItemColorFix
  • 源码定位:L15
  • 修饰符:public

参数:

  • outputSchema: Schema
  • changesType: boolean

说明:

TODO

方法

下面的方法块按源码顺序生成。

public TypeRewriteRule makeRule() @ L19

  • 方法名:makeRule
  • 源码定位:L19
  • 返回类型:TypeRewriteRule
  • 修饰符:public

参数:

说明:

TODO

代码

public class BedItemColorFix extends DataFix {
    public BedItemColorFix(Schema outputSchema, boolean changesType) {
        super(outputSchema, changesType);
    }
 
    @Override
    public TypeRewriteRule makeRule() {
        OpticFinder<Pair<String, String>> idF = DSL.fieldFinder("id", DSL.named(References.ITEM_NAME.typeName(), NamespacedSchema.namespacedString()));
        return this.fixTypeEverywhereTyped("BedItemColorFix", this.getInputSchema().getType(References.ITEM_STACK), input -> {
            Optional<Pair<String, String>> idOpt = input.getOptional(idF);
            if (idOpt.isPresent() && Objects.equals(idOpt.get().getSecond(), "minecraft:bed")) {
                Dynamic<?> tag = input.get(DSL.remainderFinder());
                if (tag.get("Damage").asInt(0) == 0) {
                    return input.set(DSL.remainderFinder(), tag.set("Damage", tag.createShort((short)14)));
                }
            }
 
            return input;
        });
    }
}

引用的其他类

  • Schema

    • 引用位置: 参数
  • NamespacedSchema

    • 引用位置: 方法调用
    • 关联成员: NamespacedSchema.namespacedString()