EntityPaintingMotiveFix .java

net.minecraft.util.datafix.fixes.EntityPaintingMotiveFix (class, 40 lines): members: MAP, fixTag, fix. strings: "skullandroses", "burningskull", "Motive".

net.minecraft.util.datafix.fixesclass40 linescommonextends NamedEntityFix1.4 KB

API Surface (2)

Dynamic<?> fixTag(final Dynamic<?> input)
Typed<?> fix(final Typed<?> entity)

Fields & Constants (1)

MAP

String literals (8)

"donkeykong"
"donkey_kong"
"burningskull"
"burning_skull"
"skullandroses"
"skull_and_roses"
"minecraft:painting"
"Motive"

Code Graph: Dependencies (2)

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

Full Source

EntityPaintingMotiveFix.java40 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.google.common.collect.Maps;
4
import com.mojang.datafixers.DSL;
5
import com.mojang.datafixers.DataFixUtils;
6
import com.mojang.datafixers.Typed;
7
import com.mojang.datafixers.schemas.Schema;
8
import com.mojang.serialization.Dynamic;
9
import java.util.Locale;
10
import java.util.Map;
11
import java.util.Optional;
12
import net.minecraft.util.datafix.schemas.NamespacedSchema;
13
14
public class EntityPaintingMotiveFix extends NamedEntityFix {
15
	private static final Map<String, String> MAP = DataFixUtils.make(Maps.newHashMap(), map -> {
16
		map.put("donkeykong", "donkey_kong");
17
		map.put("burningskull", "burning_skull");
18
		map.put("skullandroses", "skull_and_roses");
19
	});
20
21
	public EntityPaintingMotiveFix(final Schema outputSchema, final boolean changesType) {
22
		super(outputSchema, changesType, "EntityPaintingMotiveFix", References.ENTITY, "minecraft:painting");
23
	}
24
25
	public Dynamic<?> fixTag(final Dynamic<?> input) {
26
		Optional<String> motive = input.get("Motive").asString().result();
27
		if (motive.isPresent()) {
28
			String lowerCaseMotive = motive.get().toLowerCase(Locale.ROOT);
29
			return input.set("Motive", input.createString(NamespacedSchema.ensureNamespaced(MAP.getOrDefault(lowerCaseMotive, lowerCaseMotive))));
30
		} else {
31
			return input;
32
		}
33
	}
34
35
	@Override
36
	protected Typed<?> fix(final Typed<?> entity) {
37
		return entity.update(DSL.remainderFinder(), this::fixTag);
38
	}
39
}
40

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