EntityPaintingMotiveFix.java

net.minecraft.util.datafix.fixes.EntityPaintingMotiveFix

信息

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

    TODO

字段/常量

  • MAP
    • 类型: Map<String,String>
    • 修饰符: private static final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

构造器

public EntityPaintingMotiveFix(Schema outputSchema, boolean changesType) @ L21

  • 构造器名:EntityPaintingMotiveFix
  • 源码定位:L21
  • 修饰符:public

参数:

  • outputSchema: Schema
  • changesType: boolean

说明:

TODO

方法

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

public Dynamic<?> fixTag(Dynamic<?> input) @ L25

  • 方法名:fixTag
  • 源码定位:L25
  • 返回类型:Dynamic<?>
  • 修饰符:public

参数:

  • input: Dynamic<?>

说明:

TODO

protected Typed<?> fix(Typed<?> entity) @ L35

  • 方法名:fix
  • 源码定位:L35
  • 返回类型:Typed<?>
  • 修饰符:protected

参数:

  • entity: Typed<?>

说明:

TODO

代码

public class EntityPaintingMotiveFix extends NamedEntityFix {
    private static final Map<String, String> MAP = DataFixUtils.make(Maps.newHashMap(), map -> {
        map.put("donkeykong", "donkey_kong");
        map.put("burningskull", "burning_skull");
        map.put("skullandroses", "skull_and_roses");
    });
 
    public EntityPaintingMotiveFix(Schema outputSchema, boolean changesType) {
        super(outputSchema, changesType, "EntityPaintingMotiveFix", References.ENTITY, "minecraft:painting");
    }
 
    public Dynamic<?> fixTag(Dynamic<?> input) {
        Optional<String> motive = input.get("Motive").asString().result();
        if (motive.isPresent()) {
            String lowerCaseMotive = motive.get().toLowerCase(Locale.ROOT);
            return input.set("Motive", input.createString(NamespacedSchema.ensureNamespaced(MAP.getOrDefault(lowerCaseMotive, lowerCaseMotive))));
        } else {
            return input;
        }
    }
 
    @Override
    protected Typed<?> fix(Typed<?> entity) {
        return entity.update(DSL.remainderFinder(), this::fixTag);
    }
}

引用的其他类