2025-11-24 22:52:51 +03:00

40 lines
1.3 KiB
Java

/*
* 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.serialization.Dynamic
*/
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.serialization.Dynamic;
import java.util.function.Function;
import net.minecraft.util.datafix.fixes.References;
public class AdvancementsRenameFix
extends DataFix {
private final String name;
private final Function<String, String> renamer;
public AdvancementsRenameFix(Schema outputSchema, boolean changesType, String name, Function<String, String> renamer) {
super(outputSchema, changesType);
this.name = name;
this.renamer = renamer;
}
protected TypeRewriteRule makeRule() {
return this.fixTypeEverywhereTyped(this.name, this.getInputSchema().getType(References.ADVANCEMENTS), input -> input.update(DSL.remainderFinder(), tag -> tag.updateMapValues(entry -> {
String id = ((Dynamic)entry.getFirst()).asString("");
return entry.mapFirst(f -> tag.createString(this.renamer.apply(id)));
})));
}
}