V3818_5 .java

net.minecraft.util.datafix.schemas.V3818_5 (class): members: UNPACK_PLAIN_ID, registerTypes, entityTypes. strings: "components", "count". imports: DSL.

net.minecraft.util.datafix.schemasclass40 linescommonextends NamespacedSchema1.4 KB

API Surface (2)

<T> T apply(final DynamicOps<T> ops, final T value)
void registerTypes(final Schema schema, final Map<String, Supplier<TypeTemplate>> entityTypes, final Map<String, Supplier<TypeTemplate>> blockEntityTypes)

Fields & Constants (2)

UNPACK_PLAIN_ID
entityTypes

String literals (2)

"count"
"components"

Code Graph: Dependencies (2)

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

Full Source

V3818_5.java40 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.schemas;
2
3
import com.mojang.datafixers.DSL;
4
import com.mojang.datafixers.schemas.Schema;
5
import com.mojang.datafixers.types.templates.TypeTemplate;
6
import com.mojang.datafixers.types.templates.Hook.HookFunction;
7
import com.mojang.serialization.DynamicOps;
8
import java.util.Map;
9
import java.util.Optional;
10
import java.util.function.Supplier;
11
import net.minecraft.util.datafix.fixes.References;
12
13
public class V3818_5 extends NamespacedSchema {
14
	protected static final HookFunction UNPACK_PLAIN_ID = new HookFunction() {
15
		@Override
16
		public <T> T apply(final DynamicOps<T> ops, final T value) {
17
			Optional<String> maybePlainId = ops.getStringValue(value).result();
18
			return maybePlainId.isPresent() ? ops.createMap(Map.of(ops.createString("id"), value, ops.createString("count"), ops.createInt(1))) : value;
19
		}
20
	};
21
22
	public V3818_5(final int versionKey, final Schema parent) {
23
		super(versionKey, parent);
24
	}
25
26
	@Override
27
	public void registerTypes(
28
		final Schema schema, final Map<String, Supplier<TypeTemplate>> entityTypes, final Map<String, Supplier<TypeTemplate>> blockEntityTypes
29
	) {
30
		super.registerTypes(schema, entityTypes, blockEntityTypes);
31
		schema.registerType(
32
			true,
33
			References.ITEM_STACK,
34
			() -> DSL.hook(
35
				DSL.optionalFields("id", References.ITEM_NAME.in(schema), "components", References.DATA_COMPONENTS.in(schema)), UNPACK_PLAIN_ID, HookFunction.IDENTITY
36
			)
37
		);
38
	}
39
}
40

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