BlockEntityRenameFix .java

net.minecraft.util.datafix.fixes.BlockEntityRenameFix (class): members: nameChangeLookup, makeRule, create, name. imports: TaggedChoiceType, DataFix.

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

API Surface (2)

TypeRewriteRule makeRule()
DataFix create(final Schema outputSchema, final String name, final UnaryOperator<String> nameChangeLookup)

Fields & Constants (2)

name
nameChangeLookup

Full Source

BlockEntityRenameFix.java30 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.mojang.datafixers.DataFix;
4
import com.mojang.datafixers.TypeRewriteRule;
5
import com.mojang.datafixers.schemas.Schema;
6
import com.mojang.datafixers.types.templates.TaggedChoice.TaggedChoiceType;
7
import java.util.function.UnaryOperator;
8
9
public class BlockEntityRenameFix extends DataFix {
10
	private final String name;
11
	private final UnaryOperator<String> nameChangeLookup;
12
13
	private BlockEntityRenameFix(final Schema outputSchema, final String name, final UnaryOperator<String> nameChangeLookup) {
14
		super(outputSchema, true);
15
		this.name = name;
16
		this.nameChangeLookup = nameChangeLookup;
17
	}
18
19
	@Override
20
	public TypeRewriteRule makeRule() {
21
		TaggedChoiceType<String> oldType = (TaggedChoiceType<String>)this.getInputSchema().findChoiceType(References.BLOCK_ENTITY);
22
		TaggedChoiceType<String> newType = (TaggedChoiceType<String>)this.getOutputSchema().findChoiceType(References.BLOCK_ENTITY);
23
		return this.fixTypeEverywhere(this.name, oldType, newType, ops -> input -> input.mapFirst(this.nameChangeLookup));
24
	}
25
26
	public static DataFix create(final Schema outputSchema, final String name, final UnaryOperator<String> nameChangeLookup) {
27
		return new BlockEntityRenameFix(outputSchema, name, nameChangeLookup);
28
	}
29
}
30

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