WorldGenSettingsDisallowOldCustomWorldsFix.java

net.minecraft.util.datafix.fixes.WorldGenSettingsDisallowOldCustomWorldsFix

信息

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

    TODO

字段/常量

内部类/嵌套类型

构造器

public WorldGenSettingsDisallowOldCustomWorldsFix(Schema outputSchema) @ L11

  • 构造器名:WorldGenSettingsDisallowOldCustomWorldsFix
  • 源码定位:L11
  • 修饰符:public

参数:

  • outputSchema: Schema

说明:

TODO

方法

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

protected TypeRewriteRule makeRule() @ L15

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

参数:

说明:

TODO

代码

public class WorldGenSettingsDisallowOldCustomWorldsFix extends DataFix {
    public WorldGenSettingsDisallowOldCustomWorldsFix(Schema outputSchema) {
        super(outputSchema, false);
    }
 
    @Override
    protected TypeRewriteRule makeRule() {
        Type<?> worldGenSettingsType = this.getInputSchema().getType(References.WORLD_GEN_SETTINGS);
        OpticFinder<?> dimensionsFinder = worldGenSettingsType.findField("dimensions");
        return this.fixTypeEverywhereTyped(
            "WorldGenSettingsDisallowOldCustomWorldsFix_" + this.getOutputSchema().getVersionKey(),
            worldGenSettingsType,
            input -> input.updateTyped(dimensionsFinder, dimensions -> {
                dimensions.write().map(tag -> tag.getMapValues().map(map -> {
                    map.forEach((key, value) -> {
                        if (value.get("type").asString().result().isEmpty()) {
                            throw new NbtFormatException("Unable load old custom worlds.");
                        }
                    });
                    return map;
                }));
                return dimensions;
            })
        );
    }
}

引用的其他类