NamedEntityFix .java

net.minecraft.util.datafix.fixes.NamedEntityFix (class): members: entityName, fix, makeRule, name, type. imports: TypeReference, OpticFinder, Typed.

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

API Surface (1)

TypeRewriteRule makeRule()

Fields & Constants (3)

name
entityName
type

Full Source

NamedEntityFix.java36 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.OpticFinder;
6
import com.mojang.datafixers.TypeRewriteRule;
7
import com.mojang.datafixers.Typed;
8
import com.mojang.datafixers.DSL.TypeReference;
9
import com.mojang.datafixers.schemas.Schema;
10
11
public abstract class NamedEntityFix extends DataFix {
12
	private final String name;
13
	protected final String entityName;
14
	protected final TypeReference type;
15
16
	public NamedEntityFix(final Schema outputSchema, final boolean changesType, final String name, final TypeReference type, final String entityName) {
17
		super(outputSchema, changesType);
18
		this.name = name;
19
		this.type = type;
20
		this.entityName = entityName;
21
	}
22
23
	@Override
24
	public TypeRewriteRule makeRule() {
25
		OpticFinder<?> entityF = DSL.namedChoice(this.entityName, this.getInputSchema().getChoiceType(this.type, this.entityName));
26
		return this.fixTypeEverywhereTyped(
27
			this.name,
28
			this.getInputSchema().getType(this.type),
29
			this.getOutputSchema().getType(this.type),
30
			input -> input.updateTyped(entityF, this.getOutputSchema().getChoiceType(this.type, this.entityName), this::fix)
31
		);
32
	}
33
34
	protected abstract Typed<?> fix(final Typed<?> entity);
35
}
36

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