StructureUpdater.java

net.minecraft.data.structures.StructureUpdater

信息

  • 全限定名:net.minecraft.data.structures.StructureUpdater
  • 类型:public class
  • 包:net.minecraft.data.structures
  • 源码路径:src/main/java/net/minecraft/data/structures/StructureUpdater.java
  • 起始行号:L13
  • 实现:SnbtToNbt.Filter
  • 职责:

    TODO

字段/常量

  • LOGGER

    • 类型: Logger
    • 修饰符: private static final
    • 源码定位: L14
    • 说明:

      TODO

  • PREFIX

    • 类型: String
    • 修饰符: private static final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public CompoundTag apply(String name, CompoundTag input) @ L17

  • 方法名:apply
  • 源码定位:L17
  • 返回类型:CompoundTag
  • 修饰符:public

参数:

  • name: String
  • input: CompoundTag

说明:

TODO

public static CompoundTag update(String name, CompoundTag tag) @ L22

  • 方法名:update
  • 源码定位:L22
  • 返回类型:CompoundTag
  • 修饰符:public static

参数:

  • name: String
  • tag: CompoundTag

说明:

TODO

代码

public class StructureUpdater implements SnbtToNbt.Filter {
    private static final Logger LOGGER = LogUtils.getLogger();
    private static final String PREFIX = PackType.SERVER_DATA.getDirectory() + "/minecraft/structure/";
 
    @Override
    public CompoundTag apply(String name, CompoundTag input) {
        return name.startsWith(PREFIX) ? update(name, input) : input;
    }
 
    public static CompoundTag update(String name, CompoundTag tag) {
        StructureTemplate structureTemplate = new StructureTemplate();
        int fromVersion = NbtUtils.getDataVersion(tag, 500);
        int toVersion = 4763;
        if (fromVersion < 4763) {
            LOGGER.warn("SNBT Too old, do not forget to update: {} < {}: {}", fromVersion, 4763, name);
        }
 
        CompoundTag updated = DataFixTypes.STRUCTURE.updateToCurrentVersion(DataFixers.getDataFixer(), tag, fromVersion);
        structureTemplate.load(BuiltInRegistries.BLOCK, updated);
        return structureTemplate.save(new CompoundTag());
    }
}

引用的其他类

  • SnbtToNbt

    • 引用位置: 实现
  • CompoundTag

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: CompoundTag()
  • NbtUtils

    • 引用位置: 方法调用
    • 关联成员: NbtUtils.getDataVersion()
  • DataFixers

    • 引用位置: 方法调用
    • 关联成员: DataFixers.getDataFixer()
  • StructureTemplate

    • 引用位置: 构造调用
    • 关联成员: StructureTemplate()