50 lines
1.7 KiB
Java
50 lines
1.7 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.DSL
|
|
* com.mojang.datafixers.Typed
|
|
* com.mojang.datafixers.schemas.Schema
|
|
* com.mojang.datafixers.types.Type
|
|
* com.mojang.datafixers.util.Pair
|
|
* com.mojang.serialization.Dynamic
|
|
*/
|
|
package net.minecraft.util.datafix.fixes;
|
|
|
|
import com.mojang.datafixers.DSL;
|
|
import com.mojang.datafixers.Typed;
|
|
import com.mojang.datafixers.schemas.Schema;
|
|
import com.mojang.datafixers.types.Type;
|
|
import com.mojang.datafixers.util.Pair;
|
|
import com.mojang.serialization.Dynamic;
|
|
import java.util.Objects;
|
|
import net.minecraft.util.Util;
|
|
import net.minecraft.util.datafix.fixes.EntityRenameFix;
|
|
import net.minecraft.util.datafix.fixes.References;
|
|
|
|
public class EntityHorseSplitFix
|
|
extends EntityRenameFix {
|
|
public EntityHorseSplitFix(Schema outputSchema, boolean changesType) {
|
|
super("EntityHorseSplitFix", outputSchema, changesType);
|
|
}
|
|
|
|
@Override
|
|
protected Pair<String, Typed<?>> fix(String name, Typed<?> entity) {
|
|
if (Objects.equals("EntityHorse", name)) {
|
|
Dynamic tag = (Dynamic)entity.get(DSL.remainderFinder());
|
|
int type = tag.get("Type").asInt(0);
|
|
String newName = switch (type) {
|
|
default -> "Horse";
|
|
case 1 -> "Donkey";
|
|
case 2 -> "Mule";
|
|
case 3 -> "ZombieHorse";
|
|
case 4 -> "SkeletonHorse";
|
|
};
|
|
Type newType = (Type)this.getOutputSchema().findChoiceType(References.ENTITY).types().get(newName);
|
|
return Pair.of((Object)newName, Util.writeAndReadTypedOrThrow(entity, newType, dynamic -> dynamic.remove("Type")));
|
|
}
|
|
return Pair.of((Object)name, entity);
|
|
}
|
|
}
|
|
|