/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.DSL * com.mojang.datafixers.DataFix * com.mojang.datafixers.TypeRewriteRule * com.mojang.datafixers.schemas.Schema * com.mojang.datafixers.types.Type */ package net.minecraft.util.datafix.fixes; import com.mojang.datafixers.DSL; import com.mojang.datafixers.DataFix; import com.mojang.datafixers.TypeRewriteRule; import com.mojang.datafixers.schemas.Schema; import com.mojang.datafixers.types.Type; import java.util.Objects; import java.util.function.Function; import net.minecraft.util.datafix.fixes.References; import net.minecraft.util.datafix.schemas.NamespacedSchema; public abstract class ItemRenameFix extends DataFix { private final String name; public ItemRenameFix(Schema outputSchema, String name) { super(outputSchema, false); this.name = name; } public TypeRewriteRule makeRule() { Type itemNameType = DSL.named((String)References.ITEM_NAME.typeName(), NamespacedSchema.namespacedString()); if (!Objects.equals(this.getInputSchema().getType(References.ITEM_NAME), itemNameType)) { throw new IllegalStateException("item name type is not what was expected."); } return this.fixTypeEverywhere(this.name, itemNameType, ops -> input -> input.mapSecond(this::fixItem)); } protected abstract String fixItem(String var1); public static DataFix create(Schema outputSchema, String name, final Function fixItem) { return new ItemRenameFix(outputSchema, name){ @Override protected String fixItem(String item) { return (String)fixItem.apply(item); } }; } }