33 lines
1.1 KiB
Java
33 lines
1.1 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.schemas.Schema
|
|
*/
|
|
package net.minecraft.util.datafix.fixes;
|
|
|
|
import com.mojang.datafixers.schemas.Schema;
|
|
import java.util.List;
|
|
import net.minecraft.util.datafix.fixes.AttributesRenameFix;
|
|
import net.minecraft.util.datafix.schemas.NamespacedSchema;
|
|
|
|
public class AttributeIdPrefixFix
|
|
extends AttributesRenameFix {
|
|
private static final List<String> PREFIXES = List.of("generic.", "horse.", "player.", "zombie.");
|
|
|
|
public AttributeIdPrefixFix(Schema outputSchema) {
|
|
super(outputSchema, "AttributeIdPrefixFix", AttributeIdPrefixFix::replaceId);
|
|
}
|
|
|
|
private static String replaceId(String id) {
|
|
String namespacedId = NamespacedSchema.ensureNamespaced(id);
|
|
for (String prefix : PREFIXES) {
|
|
String namespacedPrefix = NamespacedSchema.ensureNamespaced(prefix);
|
|
if (!namespacedId.startsWith(namespacedPrefix)) continue;
|
|
return "minecraft:" + namespacedId.substring(namespacedPrefix.length());
|
|
}
|
|
return id;
|
|
}
|
|
}
|
|
|