ForcePoiRebuild .java

net.minecraft.util.datafix.fixes.ForcePoiRebuild (class, 31 lines): members: makeRule. strings: "POI rebuild", "Valid", "Sections". imports: Type.

net.minecraft.util.datafix.fixesclass31 linescommonextends DataFix1.2 KB

API Surface (1)

TypeRewriteRule makeRule()

String literals (4)

"Poi type is not what was expected."
"POI rebuild"
"Sections"
"Valid"

Full Source

ForcePoiRebuild.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.DataFix;
5
import com.mojang.datafixers.TypeRewriteRule;
6
import com.mojang.datafixers.schemas.Schema;
7
import com.mojang.datafixers.types.Type;
8
import com.mojang.datafixers.util.Pair;
9
import com.mojang.serialization.Dynamic;
10
import java.util.Objects;
11
12
public class ForcePoiRebuild extends DataFix {
13
	public ForcePoiRebuild(final Schema outputSchema, final boolean changesType) {
14
		super(outputSchema, changesType);
15
	}
16
17
	@Override
18
	protected TypeRewriteRule makeRule() {
19
		Type<Pair<String, Dynamic<?>>> poiChunkType = DSL.named(References.POI_CHUNK.typeName(), DSL.remainderType());
20
		if (!Objects.equals(poiChunkType, this.getInputSchema().getType(References.POI_CHUNK))) {
21
			throw new IllegalStateException("Poi type is not what was expected.");
22
		} else {
23
			return this.fixTypeEverywhere("POI rebuild", poiChunkType, ops -> input -> input.mapSecond(ForcePoiRebuild::cap));
24
		}
25
	}
26
27
	private static <T> Dynamic<T> cap(final Dynamic<T> input) {
28
		return input.update("Sections", sections -> sections.updateMapValues(entry -> entry.mapSecond(section -> section.remove("Valid"))));
29
	}
30
}
31

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