LegacyDragonFightFix .java

net.minecraft.util.datafix.fixes.LegacyDragonFightFix (class, 35 lines): members: makeRule. strings: "ExitPortalLocation", "DimensionData", "DragonFight".

net.minecraft.util.datafix.fixesclass35 linescommonextends DataFix1.1 KB

API Surface (1)

TypeRewriteRule makeRule()

String literals (3)

"ExitPortalLocation"
"DragonFight"
"DimensionData"

Code Graph: Dependencies (1)

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

Full Source

LegacyDragonFightFix.java35 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.DataFix;
5
import com.mojang.datafixers.TypeRewriteRule;
6
import com.mojang.datafixers.schemas.Schema;
7
import com.mojang.serialization.Dynamic;
8
import com.mojang.serialization.OptionalDynamic;
9
import net.minecraft.util.datafix.ExtraDataFixUtils;
10
11
public class LegacyDragonFightFix extends DataFix {
12
	public LegacyDragonFightFix(final Schema outputSchema) {
13
		super(outputSchema, false);
14
	}
15
16
	private static <T> Dynamic<T> fixDragonFight(final Dynamic<T> tag) {
17
		return tag.update("ExitPortalLocation", ExtraDataFixUtils::fixBlockPos);
18
	}
19
20
	@Override
21
	protected TypeRewriteRule makeRule() {
22
		return this.fixTypeEverywhereTyped(
23
			"LegacyDragonFightFix", this.getInputSchema().getType(References.LEVEL), input -> input.update(DSL.remainderFinder(), tag -> {
24
				OptionalDynamic<?> dragonFight = tag.get("DragonFight");
25
				if (dragonFight.result().isPresent()) {
26
					return tag;
27
				}
28
29
				Dynamic<?> legacyFight = tag.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap();
30
				return tag.set("DragonFight", fixDragonFight(legacyFight));
31
			})
32
		);
33
	}
34
}
35

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