RemapChunkStatusFix .java

net.minecraft.util.datafix.fixes.RemapChunkStatusFix (class): members: mapper, makeRule, name. strings: "below_zero_retrogen", "target_status", "Status".

net.minecraft.util.datafix.fixesclass41 linescommonextends DataFix1.3 KB

API Surface (1)

TypeRewriteRule makeRule()

Fields & Constants (2)

name
mapper

String literals (3)

"Status"
"below_zero_retrogen"
"target_status"

Code Graph: Dependencies (1)

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

Full Source

RemapChunkStatusFix.java41 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.DataFixUtils;
6
import com.mojang.datafixers.TypeRewriteRule;
7
import com.mojang.datafixers.schemas.Schema;
8
import com.mojang.serialization.Dynamic;
9
import java.util.Optional;
10
import java.util.function.UnaryOperator;
11
import net.minecraft.util.datafix.schemas.NamespacedSchema;
12
13
public class RemapChunkStatusFix extends DataFix {
14
	private final String name;
15
	private final UnaryOperator<String> mapper;
16
17
	public RemapChunkStatusFix(final Schema schema, final String name, final UnaryOperator<String> mapper) {
18
		super(schema, false);
19
		this.name = name;
20
		this.mapper = mapper;
21
	}
22
23
	@Override
24
	protected TypeRewriteRule makeRule() {
25
		return this.fixTypeEverywhereTyped(
26
			this.name,
27
			this.getInputSchema().getType(References.CHUNK),
28
			input -> input.update(
29
				DSL.remainderFinder(),
30
				data -> data.update("Status", this::fixStatus)
31
					.update("below_zero_retrogen", belowZeroRetrogen -> belowZeroRetrogen.update("target_status", this::fixStatus))
32
			)
33
		);
34
	}
35
36
	private <T> Dynamic<T> fixStatus(final Dynamic<T> dynamic) {
37
		Optional<Dynamic<T>> remapped = dynamic.asString().result().map(NamespacedSchema::ensureNamespaced).map(this.mapper).map(dynamic::createString);
38
		return DataFixUtils.orElse(remapped, dynamic);
39
	}
40
}
41

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