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.serialization.Dynamic; import java.util.Optional; public class PlayerHeadBlockProfileFix extends NamedEntityFix { public PlayerHeadBlockProfileFix(Schema outputSchema) { super(outputSchema, false, "PlayerHeadBlockProfileFix", References.BLOCK_ENTITY, "minecraft:skull"); } @Override protected Typed fix(Typed typed) { return typed.update(DSL.remainderFinder(), this::fix); } private Dynamic fix(Dynamic tag) { Optional> optional = tag.get("SkullOwner").result(); Optional> optional2 = tag.get("ExtraType").result(); Optional> optional3 = optional.or(() -> optional2); if (optional3.isEmpty()) { return tag; } else { tag = tag.remove("SkullOwner").remove("ExtraType"); return tag.set("profile", ItemStackComponentizationFix.fixProfile((Dynamic)optional3.get())); } } }