BlendingDataNoValueHeightFix .java

net.minecraft.util.datafix.fixes.BlendingDataNoValueHeightFix (class, 35 lines): members: makeRule. strings: "heights", "blending_data". imports: DataFix.

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

API Surface (1)

TypeRewriteRule makeRule()

String literals (2)

"blending_data"
"heights"

Full Source

BlendingDataNoValueHeightFix.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
9
public class BlendingDataNoValueHeightFix extends DataFix {
10
	public BlendingDataNoValueHeightFix(final Schema outputSchema) {
11
		super(outputSchema, false);
12
	}
13
14
	@Override
15
	protected TypeRewriteRule makeRule() {
16
		return this.fixTypeEverywhereTyped(
17
			"BlendingDataNoValueHeightFix",
18
			this.getInputSchema().getType(References.CHUNK),
19
			chunk -> chunk.update(DSL.remainderFinder(), BlendingDataNoValueHeightFix::fix)
20
		);
21
	}
22
23
	private static Dynamic<?> fix(final Dynamic<?> chunk) {
24
		return chunk.update(
25
			"blending_data",
26
			blendingData -> blendingData.update("heights", heights -> heights.createList(heights.asStream().map(BlendingDataNoValueHeightFix::fixHeightValue)))
27
		);
28
	}
29
30
	private static Dynamic<?> fixHeightValue(final Dynamic<?> height) {
31
		double heightValue = height.asDouble(Double.MAX_VALUE);
32
		return heightValue == Double.MAX_VALUE ? height.createFloat(Float.MAX_VALUE) : height.createFloat((float)heightValue);
33
	}
34
}
35

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