VillagerFollowRangeFix .java

net.minecraft.util.datafix.fixes.VillagerFollowRangeFix (class, 35 lines): members: NEW_BASE_VALUE, ORIGINAL_VALUE, fix. strings: "generic.follow_range".

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

API Surface (1)

Typed<?> fix(final Typed<?> entity)

Fields & Constants (2)

ORIGINAL_VALUE
NEW_BASE_VALUE

String literals (5)

"Villager Follow Range Fix"
"minecraft:villager"
"Attributes"
"generic.follow_range"
"Base"

Code Graph: Dependencies (1)

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

Full Source

VillagerFollowRangeFix.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.Typed;
5
import com.mojang.datafixers.schemas.Schema;
6
import com.mojang.serialization.Dynamic;
7
8
public class VillagerFollowRangeFix extends NamedEntityFix {
9
	private static final double ORIGINAL_VALUE = 16.0;
10
	private static final double NEW_BASE_VALUE = 48.0;
11
12
	public VillagerFollowRangeFix(final Schema outputSchema) {
13
		super(outputSchema, false, "Villager Follow Range Fix", References.ENTITY, "minecraft:villager");
14
	}
15
16
	@Override
17
	protected Typed<?> fix(final Typed<?> entity) {
18
		return entity.update(DSL.remainderFinder(), VillagerFollowRangeFix::fixValue);
19
	}
20
21
	private static Dynamic<?> fixValue(final Dynamic<?> tag) {
22
		return tag.update(
23
			"Attributes",
24
			attributes -> tag.createList(
25
				attributes.asStream()
26
					.map(
27
						attribute -> attribute.get("Name").asString("").equals("generic.follow_range") && attribute.get("Base").asDouble(0.0) == 16.0
28
							? attribute.set("Base", attribute.createDouble(48.0))
29
							: attribute
30
					)
31
			)
32
		);
33
	}
34
}
35

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