V704 .java

net.minecraft.util.datafix.schemas.V704 (class): members: ITEM_TO_BLOCKENTITY, getChoiceType, ADD_NAMES, registerTypes, registerBlockEntities, entityTypes.

net.minecraft.util.datafix.schemasclass186 linescommonextends Schema9.2 KB

API Surface (4)

<T> T apply(final DynamicOps<T> ops, final T value)
Type<?> getChoiceType(final TypeReference type, final String choiceName)
Map<String, Supplier<TypeTemplate>> registerBlockEntities(final Schema schema)
void registerTypes(final Schema schema, final Map<String, Supplier<TypeTemplate>> entityTypes, final Map<String, Supplier<TypeTemplate>> blockEntityTypes)

Fields & Constants (3)

ITEM_TO_BLOCKENTITY
ADD_NAMES
entityTypes

String literals (121)

"minecraft:furnace"
"minecraft:lit_furnace"
"minecraft:chest"
"minecraft:trapped_chest"
"minecraft:ender_chest"
"minecraft:jukebox"
"minecraft:dispenser"
"minecraft:dropper"
"minecraft:sign"
"minecraft:mob_spawner"
"minecraft:spawner"
"minecraft:noteblock"
"minecraft:brewing_stand"
"minecraft:enhanting_table"
"minecraft:enchanting_table"
"minecraft:command_block"
"minecraft:beacon"
"minecraft:skull"
"minecraft:daylight_detector"
"minecraft:hopper"
"minecraft:banner"
"minecraft:flower_pot"
"minecraft:repeating_command_block"
"minecraft:chain_command_block"

Code Graph: Dependencies (4)

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

Full Source

V704.java186 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.schemas;
2
3
import com.google.common.collect.ImmutableMap;
4
import com.google.common.collect.Maps;
5
import com.mojang.datafixers.DSL;
6
import com.mojang.datafixers.DataFixUtils;
7
import com.mojang.datafixers.DSL.TypeReference;
8
import com.mojang.datafixers.schemas.Schema;
9
import com.mojang.datafixers.types.Type;
10
import com.mojang.datafixers.types.templates.TypeTemplate;
11
import com.mojang.datafixers.types.templates.Hook.HookFunction;
12
import com.mojang.serialization.Dynamic;
13
import com.mojang.serialization.DynamicOps;
14
import java.util.Map;
15
import java.util.Objects;
16
import java.util.function.Supplier;
17
import net.minecraft.util.datafix.fixes.BlockEntityIdFix;
18
import net.minecraft.util.datafix.fixes.References;
19
20
public class V704 extends Schema {
21
	protected static final Map<String, String> ITEM_TO_BLOCKENTITY = DataFixUtils.make(() -> {
22
		Map<String, String> map = Maps.newHashMap();
23
		map.put("minecraft:furnace", "minecraft:furnace");
24
		map.put("minecraft:lit_furnace", "minecraft:furnace");
25
		map.put("minecraft:chest", "minecraft:chest");
26
		map.put("minecraft:trapped_chest", "minecraft:chest");
27
		map.put("minecraft:ender_chest", "minecraft:ender_chest");
28
		map.put("minecraft:jukebox", "minecraft:jukebox");
29
		map.put("minecraft:dispenser", "minecraft:dispenser");
30
		map.put("minecraft:dropper", "minecraft:dropper");
31
		map.put("minecraft:sign", "minecraft:sign");
32
		map.put("minecraft:mob_spawner", "minecraft:mob_spawner");
33
		map.put("minecraft:spawner", "minecraft:mob_spawner");
34
		map.put("minecraft:noteblock", "minecraft:noteblock");
35
		map.put("minecraft:brewing_stand", "minecraft:brewing_stand");
36
		map.put("minecraft:enhanting_table", "minecraft:enchanting_table");
37
		map.put("minecraft:command_block", "minecraft:command_block");
38
		map.put("minecraft:beacon", "minecraft:beacon");
39
		map.put("minecraft:skull", "minecraft:skull");
40
		map.put("minecraft:daylight_detector", "minecraft:daylight_detector");
41
		map.put("minecraft:hopper", "minecraft:hopper");
42
		map.put("minecraft:banner", "minecraft:banner");
43
		map.put("minecraft:flower_pot", "minecraft:flower_pot");
44
		map.put("minecraft:repeating_command_block", "minecraft:command_block");
45
		map.put("minecraft:chain_command_block", "minecraft:command_block");
46
		map.put("minecraft:shulker_box", "minecraft:shulker_box");
47
		map.put("minecraft:white_shulker_box", "minecraft:shulker_box");
48
		map.put("minecraft:orange_shulker_box", "minecraft:shulker_box");
49
		map.put("minecraft:magenta_shulker_box", "minecraft:shulker_box");
50
		map.put("minecraft:light_blue_shulker_box", "minecraft:shulker_box");
51
		map.put("minecraft:yellow_shulker_box", "minecraft:shulker_box");
52
		map.put("minecraft:lime_shulker_box", "minecraft:shulker_box");
53
		map.put("minecraft:pink_shulker_box", "minecraft:shulker_box");
54
		map.put("minecraft:gray_shulker_box", "minecraft:shulker_box");
55
		map.put("minecraft:silver_shulker_box", "minecraft:shulker_box");
56
		map.put("minecraft:cyan_shulker_box", "minecraft:shulker_box");
57
		map.put("minecraft:purple_shulker_box", "minecraft:shulker_box");
58
		map.put("minecraft:blue_shulker_box", "minecraft:shulker_box");
59
		map.put("minecraft:brown_shulker_box", "minecraft:shulker_box");
60
		map.put("minecraft:green_shulker_box", "minecraft:shulker_box");
61
		map.put("minecraft:red_shulker_box", "minecraft:shulker_box");
62
		map.put("minecraft:black_shulker_box", "minecraft:shulker_box");
63
		map.put("minecraft:bed", "minecraft:bed");
64
		map.put("minecraft:light_gray_shulker_box", "minecraft:shulker_box");
65
		map.put("minecraft:banner", "minecraft:banner");
66
		map.put("minecraft:white_banner", "minecraft:banner");
67
		map.put("minecraft:orange_banner", "minecraft:banner");
68
		map.put("minecraft:magenta_banner", "minecraft:banner");
69
		map.put("minecraft:light_blue_banner", "minecraft:banner");
70
		map.put("minecraft:yellow_banner", "minecraft:banner");
71
		map.put("minecraft:lime_banner", "minecraft:banner");
72
		map.put("minecraft:pink_banner", "minecraft:banner");
73
		map.put("minecraft:gray_banner", "minecraft:banner");
74
		map.put("minecraft:silver_banner", "minecraft:banner");
75
		map.put("minecraft:light_gray_banner", "minecraft:banner");
76
		map.put("minecraft:cyan_banner", "minecraft:banner");
77
		map.put("minecraft:purple_banner", "minecraft:banner");
78
		map.put("minecraft:blue_banner", "minecraft:banner");
79
		map.put("minecraft:brown_banner", "minecraft:banner");
80
		map.put("minecraft:green_banner", "minecraft:banner");
81
		map.put("minecraft:red_banner", "minecraft:banner");
82
		map.put("minecraft:black_banner", "minecraft:banner");
83
		map.put("minecraft:standing_sign", "minecraft:sign");
84
		map.put("minecraft:wall_sign", "minecraft:sign");
85
		map.put("minecraft:piston_head", "minecraft:piston");
86
		map.put("minecraft:daylight_detector_inverted", "minecraft:daylight_detector");
87
		map.put("minecraft:unpowered_comparator", "minecraft:comparator");
88
		map.put("minecraft:powered_comparator", "minecraft:comparator");
89
		map.put("minecraft:wall_banner", "minecraft:banner");
90
		map.put("minecraft:standing_banner", "minecraft:banner");
91
		map.put("minecraft:structure_block", "minecraft:structure_block");
92
		map.put("minecraft:end_portal", "minecraft:end_portal");
93
		map.put("minecraft:end_gateway", "minecraft:end_gateway");
94
		map.put("minecraft:sign", "minecraft:sign");
95
		map.put("minecraft:shield", "minecraft:banner");
96
		map.put("minecraft:white_bed", "minecraft:bed");
97
		map.put("minecraft:orange_bed", "minecraft:bed");
98
		map.put("minecraft:magenta_bed", "minecraft:bed");
99
		map.put("minecraft:light_blue_bed", "minecraft:bed");
100
		map.put("minecraft:yellow_bed", "minecraft:bed");
101
		map.put("minecraft:lime_bed", "minecraft:bed");
102
		map.put("minecraft:pink_bed", "minecraft:bed");
103
		map.put("minecraft:gray_bed", "minecraft:bed");
104
		map.put("minecraft:silver_bed", "minecraft:bed");
105
		map.put("minecraft:light_gray_bed", "minecraft:bed");
106
		map.put("minecraft:cyan_bed", "minecraft:bed");
107
		map.put("minecraft:purple_bed", "minecraft:bed");
108
		map.put("minecraft:blue_bed", "minecraft:bed");
109
		map.put("minecraft:brown_bed", "minecraft:bed");
110
		map.put("minecraft:green_bed", "minecraft:bed");
111
		map.put("minecraft:red_bed", "minecraft:bed");
112
		map.put("minecraft:black_bed", "minecraft:bed");
113
		map.put("minecraft:oak_sign", "minecraft:sign");
114
		map.put("minecraft:spruce_sign", "minecraft:sign");
115
		map.put("minecraft:birch_sign", "minecraft:sign");
116
		map.put("minecraft:jungle_sign", "minecraft:sign");
117
		map.put("minecraft:acacia_sign", "minecraft:sign");
118
		map.put("minecraft:dark_oak_sign", "minecraft:sign");
119
		map.put("minecraft:crimson_sign", "minecraft:sign");
120
		map.put("minecraft:warped_sign", "minecraft:sign");
121
		map.put("minecraft:skeleton_skull", "minecraft:skull");
122
		map.put("minecraft:wither_skeleton_skull", "minecraft:skull");
123
		map.put("minecraft:zombie_head", "minecraft:skull");
124
		map.put("minecraft:player_head", "minecraft:skull");
125
		map.put("minecraft:creeper_head", "minecraft:skull");
126
		map.put("minecraft:dragon_head", "minecraft:skull");
127
		map.put("minecraft:barrel", "minecraft:barrel");
128
		map.put("minecraft:conduit", "minecraft:conduit");
129
		map.put("minecraft:smoker", "minecraft:smoker");
130
		map.put("minecraft:blast_furnace", "minecraft:blast_furnace");
131
		map.put("minecraft:lectern", "minecraft:lectern");
132
		map.put("minecraft:bell", "minecraft:bell");
133
		map.put("minecraft:jigsaw", "minecraft:jigsaw");
134
		map.put("minecraft:campfire", "minecraft:campfire");
135
		map.put("minecraft:bee_nest", "minecraft:beehive");
136
		map.put("minecraft:beehive", "minecraft:beehive");
137
		map.put("minecraft:sculk_sensor", "minecraft:sculk_sensor");
138
		map.put("minecraft:decorated_pot", "minecraft:decorated_pot");
139
		map.put("minecraft:crafter", "minecraft:crafter");
140
		return ImmutableMap.copyOf(map);
141
	});
142
	protected static final HookFunction ADD_NAMES = new HookFunction() {
143
		@Override
144
		public <T> T apply(final DynamicOps<T> ops, final T value) {
145
			return V99.addNames(new Dynamic<>(ops, value), V704.ITEM_TO_BLOCKENTITY, V99.ITEM_TO_ENTITY);
146
		}
147
	};
148
149
	public V704(final int versionKey, final Schema parent) {
150
		super(versionKey, parent);
151
	}
152
153
	@Override
154
	public Type<?> getChoiceType(final TypeReference type, final String choiceName) {
155
		return Objects.equals(type.typeName(), References.BLOCK_ENTITY.typeName())
156
			? super.getChoiceType(type, NamespacedSchema.ensureNamespaced(choiceName))
157
			: super.getChoiceType(type, choiceName);
158
	}
159
160
	@Override
161
	public Map<String, Supplier<TypeTemplate>> registerBlockEntities(final Schema schema) {
162
		Map<String, Supplier<TypeTemplate>> map = super.registerBlockEntities(schema);
163
		BlockEntityIdFix.ID_MAP.forEach((oldId, newId) -> map.put(newId, Objects.requireNonNull(map.remove(oldId), () -> "Didn't find " + oldId + " in schema")));
164
		return map;
165
	}
166
167
	@Override
168
	public void registerTypes(
169
		final Schema schema, final Map<String, Supplier<TypeTemplate>> entityTypes, final Map<String, Supplier<TypeTemplate>> blockEntityTypes
170
	) {
171
		super.registerTypes(schema, entityTypes, blockEntityTypes);
172
		schema.registerType(
173
			true,
174
			References.BLOCK_ENTITY,
175
			() -> DSL.optionalFields(
176
				"components", References.DATA_COMPONENTS.in(schema), DSL.taggedChoiceLazy("id", NamespacedSchema.namespacedString(), blockEntityTypes)
177
			)
178
		);
179
		schema.registerType(
180
			true,
181
			References.ITEM_STACK,
182
			() -> DSL.hook(DSL.optionalFields("id", References.ITEM_NAME.in(schema), "tag", V99.itemStackTag(schema)), ADD_NAMES, HookFunction.IDENTITY)
183
		);
184
	}
185
}
186

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