PlayerHeadBlockProfileFix .java

net.minecraft.util.datafix.fixes.PlayerHeadBlockProfileFix (class, 31 lines): members: fix. strings: "ExtraType", "SkullOwner", "profile". imports: Typed.

net.minecraft.util.datafix.fixesclass31 linescommonextends NamedEntityFix1.0 KB

API Surface (1)

Typed<?> fix(final Typed<?> entity)

String literals (4)

"minecraft:skull"
"SkullOwner"
"ExtraType"
"profile"

Code Graph: Dependencies (2)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PlayerHeadBlockProfileFix.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.Typed;
5
import com.mojang.datafixers.schemas.Schema;
6
import com.mojang.serialization.Dynamic;
7
import java.util.Optional;
8
9
public class PlayerHeadBlockProfileFix extends NamedEntityFix {
10
	public PlayerHeadBlockProfileFix(final Schema outputSchema) {
11
		super(outputSchema, false, "PlayerHeadBlockProfileFix", References.BLOCK_ENTITY, "minecraft:skull");
12
	}
13
14
	@Override
15
	protected Typed<?> fix(final Typed<?> entity) {
16
		return entity.update(DSL.remainderFinder(), this::fix);
17
	}
18
19
	private <T> Dynamic<T> fix(Dynamic<T> entity) {
20
		Optional<Dynamic<T>> skullOwner = entity.get("SkullOwner").result();
21
		Optional<Dynamic<T>> extraType = entity.get("ExtraType").result();
22
		Optional<Dynamic<T>> profile = skullOwner.or(() -> extraType);
23
		if (profile.isEmpty()) {
24
			return entity;
25
		}
26
27
		entity = entity.remove("SkullOwner").remove("ExtraType");
28
		return entity.set("profile", ItemStackComponentizationFix.fixProfile(profile.get()));
29
	}
30
}
31

Decompiled Minecraft 26.3 source of PlayerHeadBlockProfileFix (net/minecraft/util/datafix/fixes/PlayerHeadBlockProfileFix.java) with Mojang official mappings, stored verbatim on the site.