InvalidBlockEntityLockFix .java

net.minecraft.util.datafix.fixes.InvalidBlockEntityLockFix (class): members: makeRule. strings: "BlockEntityLockToComponentFix", "lock". imports: DataFix.

net.minecraft.util.datafix.fixesclass32 linescommonextends DataFix1004 B

API Surface (1)

TypeRewriteRule makeRule()

String literals (2)

"BlockEntityLockToComponentFix"
"lock"

Code Graph: Dependencies (1)

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

Full Source

InvalidBlockEntityLockFix.java32 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
import java.util.Optional;
9
10
public class InvalidBlockEntityLockFix extends DataFix {
11
	public InvalidBlockEntityLockFix(final Schema outputSchema) {
12
		super(outputSchema, false);
13
	}
14
15
	@Override
16
	protected TypeRewriteRule makeRule() {
17
		return this.fixTypeEverywhereTyped(
18
			"BlockEntityLockToComponentFix",
19
			this.getInputSchema().getType(References.BLOCK_ENTITY),
20
			blockEntity -> blockEntity.update(DSL.remainderFinder(), remainder -> {
21
				Optional<? extends Dynamic<?>> lock = remainder.get("lock").result();
22
				if (lock.isEmpty()) {
23
					return remainder;
24
				}
25
26
				Dynamic<?> newLock = InvalidLockComponentFix.fixLock((Dynamic<?>)lock.get());
27
				return newLock != null ? remainder.set("lock", newLock) : remainder.remove("lock");
28
			})
29
		);
30
	}
31
}
32

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