ItemStackTheFlatteningFix .java

net.minecraft.util.datafix.fixes.ItemStackTheFlatteningFix (class, 444 lines): members: DAMAGE_IDS, updateItem, IDS, MAP, makeRule. imports: DataFixUtils.

net.minecraft.util.datafix.fixesclass444 linescommonextends DataFix24.2 KB

API Surface (1)

TypeRewriteRule makeRule()

Fields & Constants (3)

MAP
IDS
DAMAGE_IDS

String literals (693)

"minecraft:stone.0"
"minecraft:stone"
"minecraft:stone.1"
"minecraft:granite"
"minecraft:stone.2"
"minecraft:polished_granite"
"minecraft:stone.3"
"minecraft:diorite"
"minecraft:stone.4"
"minecraft:polished_diorite"
"minecraft:stone.5"
"minecraft:andesite"
"minecraft:stone.6"
"minecraft:polished_andesite"
"minecraft:dirt.0"
"minecraft:dirt"
"minecraft:dirt.1"
"minecraft:coarse_dirt"
"minecraft:dirt.2"
"minecraft:podzol"
"minecraft:leaves.0"
"minecraft:oak_leaves"
"minecraft:leaves.1"
"minecraft:spruce_leaves"

Code Graph: Dependencies (1)

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

Full Source

ItemStackTheFlatteningFix.java444 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.datafix.fixes;
2
3
import com.google.common.collect.Maps;
4
import com.google.common.collect.Sets;
5
import com.mojang.datafixers.DSL;
6
import com.mojang.datafixers.DataFix;
7
import com.mojang.datafixers.DataFixUtils;
8
import com.mojang.datafixers.OpticFinder;
9
import com.mojang.datafixers.TypeRewriteRule;
10
import com.mojang.datafixers.Typed;
11
import com.mojang.datafixers.schemas.Schema;
12
import com.mojang.datafixers.types.Type;
13
import com.mojang.datafixers.util.Pair;
14
import com.mojang.serialization.Dynamic;
15
import java.util.Map;
16
import java.util.Optional;
17
import java.util.Set;
18
import java.util.stream.Collectors;
19
import net.minecraft.util.datafix.schemas.NamespacedSchema;
20
import org.jspecify.annotations.Nullable;
21
22
public class ItemStackTheFlatteningFix extends DataFix {
23
	private static final Map<String, String> MAP = DataFixUtils.make(Maps.newHashMap(), map -> {
24
		map.put("minecraft:stone.0", "minecraft:stone");
25
		map.put("minecraft:stone.1", "minecraft:granite");
26
		map.put("minecraft:stone.2", "minecraft:polished_granite");
27
		map.put("minecraft:stone.3", "minecraft:diorite");
28
		map.put("minecraft:stone.4", "minecraft:polished_diorite");
29
		map.put("minecraft:stone.5", "minecraft:andesite");
30
		map.put("minecraft:stone.6", "minecraft:polished_andesite");
31
		map.put("minecraft:dirt.0", "minecraft:dirt");
32
		map.put("minecraft:dirt.1", "minecraft:coarse_dirt");
33
		map.put("minecraft:dirt.2", "minecraft:podzol");
34
		map.put("minecraft:leaves.0", "minecraft:oak_leaves");
35
		map.put("minecraft:leaves.1", "minecraft:spruce_leaves");
36
		map.put("minecraft:leaves.2", "minecraft:birch_leaves");
37
		map.put("minecraft:leaves.3", "minecraft:jungle_leaves");
38
		map.put("minecraft:leaves2.0", "minecraft:acacia_leaves");
39
		map.put("minecraft:leaves2.1", "minecraft:dark_oak_leaves");
40
		map.put("minecraft:log.0", "minecraft:oak_log");
41
		map.put("minecraft:log.1", "minecraft:spruce_log");
42
		map.put("minecraft:log.2", "minecraft:birch_log");
43
		map.put("minecraft:log.3", "minecraft:jungle_log");
44
		map.put("minecraft:log2.0", "minecraft:acacia_log");
45
		map.put("minecraft:log2.1", "minecraft:dark_oak_log");
46
		map.put("minecraft:sapling.0", "minecraft:oak_sapling");
47
		map.put("minecraft:sapling.1", "minecraft:spruce_sapling");
48
		map.put("minecraft:sapling.2", "minecraft:birch_sapling");
49
		map.put("minecraft:sapling.3", "minecraft:jungle_sapling");
50
		map.put("minecraft:sapling.4", "minecraft:acacia_sapling");
51
		map.put("minecraft:sapling.5", "minecraft:dark_oak_sapling");
52
		map.put("minecraft:planks.0", "minecraft:oak_planks");
53
		map.put("minecraft:planks.1", "minecraft:spruce_planks");
54
		map.put("minecraft:planks.2", "minecraft:birch_planks");
55
		map.put("minecraft:planks.3", "minecraft:jungle_planks");
56
		map.put("minecraft:planks.4", "minecraft:acacia_planks");
57
		map.put("minecraft:planks.5", "minecraft:dark_oak_planks");
58
		map.put("minecraft:sand.0", "minecraft:sand");
59
		map.put("minecraft:sand.1", "minecraft:red_sand");
60
		map.put("minecraft:quartz_block.0", "minecraft:quartz_block");
61
		map.put("minecraft:quartz_block.1", "minecraft:chiseled_quartz_block");
62
		map.put("minecraft:quartz_block.2", "minecraft:quartz_pillar");
63
		map.put("minecraft:anvil.0", "minecraft:anvil");
64
		map.put("minecraft:anvil.1", "minecraft:chipped_anvil");
65
		map.put("minecraft:anvil.2", "minecraft:damaged_anvil");
66
		map.put("minecraft:wool.0", "minecraft:white_wool");
67
		map.put("minecraft:wool.1", "minecraft:orange_wool");
68
		map.put("minecraft:wool.2", "minecraft:magenta_wool");
69
		map.put("minecraft:wool.3", "minecraft:light_blue_wool");
70
		map.put("minecraft:wool.4", "minecraft:yellow_wool");
71
		map.put("minecraft:wool.5", "minecraft:lime_wool");
72
		map.put("minecraft:wool.6", "minecraft:pink_wool");
73
		map.put("minecraft:wool.7", "minecraft:gray_wool");
74
		map.put("minecraft:wool.8", "minecraft:light_gray_wool");
75
		map.put("minecraft:wool.9", "minecraft:cyan_wool");
76
		map.put("minecraft:wool.10", "minecraft:purple_wool");
77
		map.put("minecraft:wool.11", "minecraft:blue_wool");
78
		map.put("minecraft:wool.12", "minecraft:brown_wool");
79
		map.put("minecraft:wool.13", "minecraft:green_wool");
80
		map.put("minecraft:wool.14", "minecraft:red_wool");
81
		map.put("minecraft:wool.15", "minecraft:black_wool");
82
		map.put("minecraft:carpet.0", "minecraft:white_carpet");
83
		map.put("minecraft:carpet.1", "minecraft:orange_carpet");
84
		map.put("minecraft:carpet.2", "minecraft:magenta_carpet");
85
		map.put("minecraft:carpet.3", "minecraft:light_blue_carpet");
86
		map.put("minecraft:carpet.4", "minecraft:yellow_carpet");
87
		map.put("minecraft:carpet.5", "minecraft:lime_carpet");
88
		map.put("minecraft:carpet.6", "minecraft:pink_carpet");
89
		map.put("minecraft:carpet.7", "minecraft:gray_carpet");
90
		map.put("minecraft:carpet.8", "minecraft:light_gray_carpet");
91
		map.put("minecraft:carpet.9", "minecraft:cyan_carpet");
92
		map.put("minecraft:carpet.10", "minecraft:purple_carpet");
93
		map.put("minecraft:carpet.11", "minecraft:blue_carpet");
94
		map.put("minecraft:carpet.12", "minecraft:brown_carpet");
95
		map.put("minecraft:carpet.13", "minecraft:green_carpet");
96
		map.put("minecraft:carpet.14", "minecraft:red_carpet");
97
		map.put("minecraft:carpet.15", "minecraft:black_carpet");
98
		map.put("minecraft:hardened_clay.0", "minecraft:terracotta");
99
		map.put("minecraft:stained_hardened_clay.0", "minecraft:white_terracotta");
100
		map.put("minecraft:stained_hardened_clay.1", "minecraft:orange_terracotta");
101
		map.put("minecraft:stained_hardened_clay.2", "minecraft:magenta_terracotta");
102
		map.put("minecraft:stained_hardened_clay.3", "minecraft:light_blue_terracotta");
103
		map.put("minecraft:stained_hardened_clay.4", "minecraft:yellow_terracotta");
104
		map.put("minecraft:stained_hardened_clay.5", "minecraft:lime_terracotta");
105
		map.put("minecraft:stained_hardened_clay.6", "minecraft:pink_terracotta");
106
		map.put("minecraft:stained_hardened_clay.7", "minecraft:gray_terracotta");
107
		map.put("minecraft:stained_hardened_clay.8", "minecraft:light_gray_terracotta");
108
		map.put("minecraft:stained_hardened_clay.9", "minecraft:cyan_terracotta");
109
		map.put("minecraft:stained_hardened_clay.10", "minecraft:purple_terracotta");
110
		map.put("minecraft:stained_hardened_clay.11", "minecraft:blue_terracotta");
111
		map.put("minecraft:stained_hardened_clay.12", "minecraft:brown_terracotta");
112
		map.put("minecraft:stained_hardened_clay.13", "minecraft:green_terracotta");
113
		map.put("minecraft:stained_hardened_clay.14", "minecraft:red_terracotta");
114
		map.put("minecraft:stained_hardened_clay.15", "minecraft:black_terracotta");
115
		map.put("minecraft:silver_glazed_terracotta.0", "minecraft:light_gray_glazed_terracotta");
116
		map.put("minecraft:stained_glass.0", "minecraft:white_stained_glass");
117
		map.put("minecraft:stained_glass.1", "minecraft:orange_stained_glass");
118
		map.put("minecraft:stained_glass.2", "minecraft:magenta_stained_glass");
119
		map.put("minecraft:stained_glass.3", "minecraft:light_blue_stained_glass");
120
		map.put("minecraft:stained_glass.4", "minecraft:yellow_stained_glass");
121
		map.put("minecraft:stained_glass.5", "minecraft:lime_stained_glass");
122
		map.put("minecraft:stained_glass.6", "minecraft:pink_stained_glass");
123
		map.put("minecraft:stained_glass.7", "minecraft:gray_stained_glass");
124
		map.put("minecraft:stained_glass.8", "minecraft:light_gray_stained_glass");
125
		map.put("minecraft:stained_glass.9", "minecraft:cyan_stained_glass");
126
		map.put("minecraft:stained_glass.10", "minecraft:purple_stained_glass");
127
		map.put("minecraft:stained_glass.11", "minecraft:blue_stained_glass");
128
		map.put("minecraft:stained_glass.12", "minecraft:brown_stained_glass");
129
		map.put("minecraft:stained_glass.13", "minecraft:green_stained_glass");
130
		map.put("minecraft:stained_glass.14", "minecraft:red_stained_glass");
131
		map.put("minecraft:stained_glass.15", "minecraft:black_stained_glass");
132
		map.put("minecraft:stained_glass_pane.0", "minecraft:white_stained_glass_pane");
133
		map.put("minecraft:stained_glass_pane.1", "minecraft:orange_stained_glass_pane");
134
		map.put("minecraft:stained_glass_pane.2", "minecraft:magenta_stained_glass_pane");
135
		map.put("minecraft:stained_glass_pane.3", "minecraft:light_blue_stained_glass_pane");
136
		map.put("minecraft:stained_glass_pane.4", "minecraft:yellow_stained_glass_pane");
137
		map.put("minecraft:stained_glass_pane.5", "minecraft:lime_stained_glass_pane");
138
		map.put("minecraft:stained_glass_pane.6", "minecraft:pink_stained_glass_pane");
139
		map.put("minecraft:stained_glass_pane.7", "minecraft:gray_stained_glass_pane");
140
		map.put("minecraft:stained_glass_pane.8", "minecraft:light_gray_stained_glass_pane");
141
		map.put("minecraft:stained_glass_pane.9", "minecraft:cyan_stained_glass_pane");
142
		map.put("minecraft:stained_glass_pane.10", "minecraft:purple_stained_glass_pane");
143
		map.put("minecraft:stained_glass_pane.11", "minecraft:blue_stained_glass_pane");
144
		map.put("minecraft:stained_glass_pane.12", "minecraft:brown_stained_glass_pane");
145
		map.put("minecraft:stained_glass_pane.13", "minecraft:green_stained_glass_pane");
146
		map.put("minecraft:stained_glass_pane.14", "minecraft:red_stained_glass_pane");
147
		map.put("minecraft:stained_glass_pane.15", "minecraft:black_stained_glass_pane");
148
		map.put("minecraft:prismarine.0", "minecraft:prismarine");
149
		map.put("minecraft:prismarine.1", "minecraft:prismarine_bricks");
150
		map.put("minecraft:prismarine.2", "minecraft:dark_prismarine");
151
		map.put("minecraft:concrete.0", "minecraft:white_concrete");
152
		map.put("minecraft:concrete.1", "minecraft:orange_concrete");
153
		map.put("minecraft:concrete.2", "minecraft:magenta_concrete");
154
		map.put("minecraft:concrete.3", "minecraft:light_blue_concrete");
155
		map.put("minecraft:concrete.4", "minecraft:yellow_concrete");
156
		map.put("minecraft:concrete.5", "minecraft:lime_concrete");
157
		map.put("minecraft:concrete.6", "minecraft:pink_concrete");
158
		map.put("minecraft:concrete.7", "minecraft:gray_concrete");
159
		map.put("minecraft:concrete.8", "minecraft:light_gray_concrete");
160
		map.put("minecraft:concrete.9", "minecraft:cyan_concrete");
161
		map.put("minecraft:concrete.10", "minecraft:purple_concrete");
162
		map.put("minecraft:concrete.11", "minecraft:blue_concrete");
163
		map.put("minecraft:concrete.12", "minecraft:brown_concrete");
164
		map.put("minecraft:concrete.13", "minecraft:green_concrete");
165
		map.put("minecraft:concrete.14", "minecraft:red_concrete");
166
		map.put("minecraft:concrete.15", "minecraft:black_concrete");
167
		map.put("minecraft:concrete_powder.0", "minecraft:white_concrete_powder");
168
		map.put("minecraft:concrete_powder.1", "minecraft:orange_concrete_powder");
169
		map.put("minecraft:concrete_powder.2", "minecraft:magenta_concrete_powder");
170
		map.put("minecraft:concrete_powder.3", "minecraft:light_blue_concrete_powder");
171
		map.put("minecraft:concrete_powder.4", "minecraft:yellow_concrete_powder");
172
		map.put("minecraft:concrete_powder.5", "minecraft:lime_concrete_powder");
173
		map.put("minecraft:concrete_powder.6", "minecraft:pink_concrete_powder");
174
		map.put("minecraft:concrete_powder.7", "minecraft:gray_concrete_powder");
175
		map.put("minecraft:concrete_powder.8", "minecraft:light_gray_concrete_powder");
176
		map.put("minecraft:concrete_powder.9", "minecraft:cyan_concrete_powder");
177
		map.put("minecraft:concrete_powder.10", "minecraft:purple_concrete_powder");
178
		map.put("minecraft:concrete_powder.11", "minecraft:blue_concrete_powder");
179
		map.put("minecraft:concrete_powder.12", "minecraft:brown_concrete_powder");
180
		map.put("minecraft:concrete_powder.13", "minecraft:green_concrete_powder");
181
		map.put("minecraft:concrete_powder.14", "minecraft:red_concrete_powder");
182
		map.put("minecraft:concrete_powder.15", "minecraft:black_concrete_powder");
183
		map.put("minecraft:cobblestone_wall.0", "minecraft:cobblestone_wall");
184
		map.put("minecraft:cobblestone_wall.1", "minecraft:mossy_cobblestone_wall");
185
		map.put("minecraft:sandstone.0", "minecraft:sandstone");
186
		map.put("minecraft:sandstone.1", "minecraft:chiseled_sandstone");
187
		map.put("minecraft:sandstone.2", "minecraft:cut_sandstone");
188
		map.put("minecraft:red_sandstone.0", "minecraft:red_sandstone");
189
		map.put("minecraft:red_sandstone.1", "minecraft:chiseled_red_sandstone");
190
		map.put("minecraft:red_sandstone.2", "minecraft:cut_red_sandstone");
191
		map.put("minecraft:stonebrick.0", "minecraft:stone_bricks");
192
		map.put("minecraft:stonebrick.1", "minecraft:mossy_stone_bricks");
193
		map.put("minecraft:stonebrick.2", "minecraft:cracked_stone_bricks");
194
		map.put("minecraft:stonebrick.3", "minecraft:chiseled_stone_bricks");
195
		map.put("minecraft:monster_egg.0", "minecraft:infested_stone");
196
		map.put("minecraft:monster_egg.1", "minecraft:infested_cobblestone");
197
		map.put("minecraft:monster_egg.2", "minecraft:infested_stone_bricks");
198
		map.put("minecraft:monster_egg.3", "minecraft:infested_mossy_stone_bricks");
199
		map.put("minecraft:monster_egg.4", "minecraft:infested_cracked_stone_bricks");
200
		map.put("minecraft:monster_egg.5", "minecraft:infested_chiseled_stone_bricks");
201
		map.put("minecraft:yellow_flower.0", "minecraft:dandelion");
202
		map.put("minecraft:red_flower.0", "minecraft:poppy");
203
		map.put("minecraft:red_flower.1", "minecraft:blue_orchid");
204
		map.put("minecraft:red_flower.2", "minecraft:allium");
205
		map.put("minecraft:red_flower.3", "minecraft:azure_bluet");
206
		map.put("minecraft:red_flower.4", "minecraft:red_tulip");
207
		map.put("minecraft:red_flower.5", "minecraft:orange_tulip");
208
		map.put("minecraft:red_flower.6", "minecraft:white_tulip");
209
		map.put("minecraft:red_flower.7", "minecraft:pink_tulip");
210
		map.put("minecraft:red_flower.8", "minecraft:oxeye_daisy");
211
		map.put("minecraft:double_plant.0", "minecraft:sunflower");
212
		map.put("minecraft:double_plant.1", "minecraft:lilac");
213
		map.put("minecraft:double_plant.2", "minecraft:tall_grass");
214
		map.put("minecraft:double_plant.3", "minecraft:large_fern");
215
		map.put("minecraft:double_plant.4", "minecraft:rose_bush");
216
		map.put("minecraft:double_plant.5", "minecraft:peony");
217
		map.put("minecraft:deadbush.0", "minecraft:dead_bush");
218
		map.put("minecraft:tallgrass.0", "minecraft:dead_bush");
219
		map.put("minecraft:tallgrass.1", "minecraft:grass");
220
		map.put("minecraft:tallgrass.2", "minecraft:fern");
221
		map.put("minecraft:sponge.0", "minecraft:sponge");
222
		map.put("minecraft:sponge.1", "minecraft:wet_sponge");
223
		map.put("minecraft:purpur_slab.0", "minecraft:purpur_slab");
224
		map.put("minecraft:stone_slab.0", "minecraft:stone_slab");
225
		map.put("minecraft:stone_slab.1", "minecraft:sandstone_slab");
226
		map.put("minecraft:stone_slab.2", "minecraft:petrified_oak_slab");
227
		map.put("minecraft:stone_slab.3", "minecraft:cobblestone_slab");
228
		map.put("minecraft:stone_slab.4", "minecraft:brick_slab");
229
		map.put("minecraft:stone_slab.5", "minecraft:stone_brick_slab");
230
		map.put("minecraft:stone_slab.6", "minecraft:nether_brick_slab");
231
		map.put("minecraft:stone_slab.7", "minecraft:quartz_slab");
232
		map.put("minecraft:stone_slab2.0", "minecraft:red_sandstone_slab");
233
		map.put("minecraft:wooden_slab.0", "minecraft:oak_slab");
234
		map.put("minecraft:wooden_slab.1", "minecraft:spruce_slab");
235
		map.put("minecraft:wooden_slab.2", "minecraft:birch_slab");
236
		map.put("minecraft:wooden_slab.3", "minecraft:jungle_slab");
237
		map.put("minecraft:wooden_slab.4", "minecraft:acacia_slab");
238
		map.put("minecraft:wooden_slab.5", "minecraft:dark_oak_slab");
239
		map.put("minecraft:coal.0", "minecraft:coal");
240
		map.put("minecraft:coal.1", "minecraft:charcoal");
241
		map.put("minecraft:fish.0", "minecraft:cod");
242
		map.put("minecraft:fish.1", "minecraft:salmon");
243
		map.put("minecraft:fish.2", "minecraft:clownfish");
244
		map.put("minecraft:fish.3", "minecraft:pufferfish");
245
		map.put("minecraft:cooked_fish.0", "minecraft:cooked_cod");
246
		map.put("minecraft:cooked_fish.1", "minecraft:cooked_salmon");
247
		map.put("minecraft:skull.0", "minecraft:skeleton_skull");
248
		map.put("minecraft:skull.1", "minecraft:wither_skeleton_skull");
249
		map.put("minecraft:skull.2", "minecraft:zombie_head");
250
		map.put("minecraft:skull.3", "minecraft:player_head");
251
		map.put("minecraft:skull.4", "minecraft:creeper_head");
252
		map.put("minecraft:skull.5", "minecraft:dragon_head");
253
		map.put("minecraft:golden_apple.0", "minecraft:golden_apple");
254
		map.put("minecraft:golden_apple.1", "minecraft:enchanted_golden_apple");
255
		map.put("minecraft:fireworks.0", "minecraft:firework_rocket");
256
		map.put("minecraft:firework_charge.0", "minecraft:firework_star");
257
		map.put("minecraft:dye.0", "minecraft:ink_sac");
258
		map.put("minecraft:dye.1", "minecraft:rose_red");
259
		map.put("minecraft:dye.2", "minecraft:cactus_green");
260
		map.put("minecraft:dye.3", "minecraft:cocoa_beans");
261
		map.put("minecraft:dye.4", "minecraft:lapis_lazuli");
262
		map.put("minecraft:dye.5", "minecraft:purple_dye");
263
		map.put("minecraft:dye.6", "minecraft:cyan_dye");
264
		map.put("minecraft:dye.7", "minecraft:light_gray_dye");
265
		map.put("minecraft:dye.8", "minecraft:gray_dye");
266
		map.put("minecraft:dye.9", "minecraft:pink_dye");
267
		map.put("minecraft:dye.10", "minecraft:lime_dye");
268
		map.put("minecraft:dye.11", "minecraft:dandelion_yellow");
269
		map.put("minecraft:dye.12", "minecraft:light_blue_dye");
270
		map.put("minecraft:dye.13", "minecraft:magenta_dye");
271
		map.put("minecraft:dye.14", "minecraft:orange_dye");
272
		map.put("minecraft:dye.15", "minecraft:bone_meal");
273
		map.put("minecraft:silver_shulker_box.0", "minecraft:light_gray_shulker_box");
274
		map.put("minecraft:fence.0", "minecraft:oak_fence");
275
		map.put("minecraft:fence_gate.0", "minecraft:oak_fence_gate");
276
		map.put("minecraft:wooden_door.0", "minecraft:oak_door");
277
		map.put("minecraft:boat.0", "minecraft:oak_boat");
278
		map.put("minecraft:lit_pumpkin.0", "minecraft:jack_o_lantern");
279
		map.put("minecraft:pumpkin.0", "minecraft:carved_pumpkin");
280
		map.put("minecraft:trapdoor.0", "minecraft:oak_trapdoor");
281
		map.put("minecraft:nether_brick.0", "minecraft:nether_bricks");
282
		map.put("minecraft:red_nether_brick.0", "minecraft:red_nether_bricks");
283
		map.put("minecraft:netherbrick.0", "minecraft:nether_brick");
284
		map.put("minecraft:wooden_button.0", "minecraft:oak_button");
285
		map.put("minecraft:wooden_pressure_plate.0", "minecraft:oak_pressure_plate");
286
		map.put("minecraft:noteblock.0", "minecraft:note_block");
287
		map.put("minecraft:bed.0", "minecraft:white_bed");
288
		map.put("minecraft:bed.1", "minecraft:orange_bed");
289
		map.put("minecraft:bed.2", "minecraft:magenta_bed");
290
		map.put("minecraft:bed.3", "minecraft:light_blue_bed");
291
		map.put("minecraft:bed.4", "minecraft:yellow_bed");
292
		map.put("minecraft:bed.5", "minecraft:lime_bed");
293
		map.put("minecraft:bed.6", "minecraft:pink_bed");
294
		map.put("minecraft:bed.7", "minecraft:gray_bed");
295
		map.put("minecraft:bed.8", "minecraft:light_gray_bed");
296
		map.put("minecraft:bed.9", "minecraft:cyan_bed");
297
		map.put("minecraft:bed.10", "minecraft:purple_bed");
298
		map.put("minecraft:bed.11", "minecraft:blue_bed");
299
		map.put("minecraft:bed.12", "minecraft:brown_bed");
300
		map.put("minecraft:bed.13", "minecraft:green_bed");
301
		map.put("minecraft:bed.14", "minecraft:red_bed");
302
		map.put("minecraft:bed.15", "minecraft:black_bed");
303
		map.put("minecraft:banner.15", "minecraft:white_banner");
304
		map.put("minecraft:banner.14", "minecraft:orange_banner");
305
		map.put("minecraft:banner.13", "minecraft:magenta_banner");
306
		map.put("minecraft:banner.12", "minecraft:light_blue_banner");
307
		map.put("minecraft:banner.11", "minecraft:yellow_banner");
308
		map.put("minecraft:banner.10", "minecraft:lime_banner");
309
		map.put("minecraft:banner.9", "minecraft:pink_banner");
310
		map.put("minecraft:banner.8", "minecraft:gray_banner");
311
		map.put("minecraft:banner.7", "minecraft:light_gray_banner");
312
		map.put("minecraft:banner.6", "minecraft:cyan_banner");
313
		map.put("minecraft:banner.5", "minecraft:purple_banner");
314
		map.put("minecraft:banner.4", "minecraft:blue_banner");
315
		map.put("minecraft:banner.3", "minecraft:brown_banner");
316
		map.put("minecraft:banner.2", "minecraft:green_banner");
317
		map.put("minecraft:banner.1", "minecraft:red_banner");
318
		map.put("minecraft:banner.0", "minecraft:black_banner");
319
		map.put("minecraft:grass.0", "minecraft:grass_block");
320
		map.put("minecraft:brick_block.0", "minecraft:bricks");
321
		map.put("minecraft:end_bricks.0", "minecraft:end_stone_bricks");
322
		map.put("minecraft:golden_rail.0", "minecraft:powered_rail");
323
		map.put("minecraft:magma.0", "minecraft:magma_block");
324
		map.put("minecraft:quartz_ore.0", "minecraft:nether_quartz_ore");
325
		map.put("minecraft:reeds.0", "minecraft:sugar_cane");
326
		map.put("minecraft:slime.0", "minecraft:slime_block");
327
		map.put("minecraft:stone_stairs.0", "minecraft:cobblestone_stairs");
328
		map.put("minecraft:waterlily.0", "minecraft:lily_pad");
329
		map.put("minecraft:web.0", "minecraft:cobweb");
330
		map.put("minecraft:snow.0", "minecraft:snow_block");
331
		map.put("minecraft:snow_layer.0", "minecraft:snow");
332
		map.put("minecraft:record_11.0", "minecraft:music_disc_11");
333
		map.put("minecraft:record_13.0", "minecraft:music_disc_13");
334
		map.put("minecraft:record_blocks.0", "minecraft:music_disc_blocks");
335
		map.put("minecraft:record_cat.0", "minecraft:music_disc_cat");
336
		map.put("minecraft:record_chirp.0", "minecraft:music_disc_chirp");
337
		map.put("minecraft:record_far.0", "minecraft:music_disc_far");
338
		map.put("minecraft:record_mall.0", "minecraft:music_disc_mall");
339
		map.put("minecraft:record_mellohi.0", "minecraft:music_disc_mellohi");
340
		map.put("minecraft:record_stal.0", "minecraft:music_disc_stal");
341
		map.put("minecraft:record_strad.0", "minecraft:music_disc_strad");
342
		map.put("minecraft:record_wait.0", "minecraft:music_disc_wait");
343
		map.put("minecraft:record_ward.0", "minecraft:music_disc_ward");
344
	});
345
	private static final Set<String> IDS = MAP.keySet().stream().map(k -> k.substring(0, k.indexOf(46))).collect(Collectors.toSet());
346
	private static final Set<String> DAMAGE_IDS = Sets.newHashSet(
347
		"minecraft:bow",
348
		"minecraft:carrot_on_a_stick",
349
		"minecraft:chainmail_boots",
350
		"minecraft:chainmail_chestplate",
351
		"minecraft:chainmail_helmet",
352
		"minecraft:chainmail_leggings",
353
		"minecraft:diamond_axe",
354
		"minecraft:diamond_boots",
355
		"minecraft:diamond_chestplate",
356
		"minecraft:diamond_helmet",
357
		"minecraft:diamond_hoe",
358
		"minecraft:diamond_leggings",
359
		"minecraft:diamond_pickaxe",
360
		"minecraft:diamond_shovel",
361
		"minecraft:diamond_sword",
362
		"minecraft:elytra",
363
		"minecraft:fishing_rod",
364
		"minecraft:flint_and_steel",
365
		"minecraft:golden_axe",
366
		"minecraft:golden_boots",
367
		"minecraft:golden_chestplate",
368
		"minecraft:golden_helmet",
369
		"minecraft:golden_hoe",
370
		"minecraft:golden_leggings",
371
		"minecraft:golden_pickaxe",
372
		"minecraft:golden_shovel",
373
		"minecraft:golden_sword",
374
		"minecraft:iron_axe",
375
		"minecraft:iron_boots",
376
		"minecraft:iron_chestplate",
377
		"minecraft:iron_helmet",
378
		"minecraft:iron_hoe",
379
		"minecraft:iron_leggings",
380
		"minecraft:iron_pickaxe",
381
		"minecraft:iron_shovel",
382
		"minecraft:iron_sword",
383
		"minecraft:leather_boots",
384
		"minecraft:leather_chestplate",
385
		"minecraft:leather_helmet",
386
		"minecraft:leather_leggings",
387
		"minecraft:shears",
388
		"minecraft:shield",
389
		"minecraft:stone_axe",
390
		"minecraft:stone_hoe",
391
		"minecraft:stone_pickaxe",
392
		"minecraft:stone_shovel",
393
		"minecraft:stone_sword",
394
		"minecraft:wooden_axe",
395
		"minecraft:wooden_hoe",
396
		"minecraft:wooden_pickaxe",
397
		"minecraft:wooden_shovel",
398
		"minecraft:wooden_sword"
399
	);
400
401
	public ItemStackTheFlatteningFix(final Schema outputSchema, final boolean changesType) {
402
		super(outputSchema, changesType);
403
	}
404
405
	@Override
406
	public TypeRewriteRule makeRule() {
407
		Type<?> itemStackType = this.getInputSchema().getType(References.ITEM_STACK);
408
		OpticFinder<Pair<String, String>> idF = DSL.fieldFinder("id", DSL.named(References.ITEM_NAME.typeName(), NamespacedSchema.namespacedString()));
409
		OpticFinder<?> tagF = itemStackType.findField("tag");
410
		return this.fixTypeEverywhereTyped("ItemInstanceTheFlatteningFix", itemStackType, input -> {
411
			Optional<Pair<String, String>> id = input.getOptional(idF);
412
			if (id.isEmpty()) {
413
				return input;
414
			}
415
416
			Typed<?> output = input;
417
			Dynamic<?> rest = input.get(DSL.remainderFinder());
418
			int data = rest.get("Damage").asInt(0);
419
			String newValue = updateItem(id.get().getSecond(), data);
420
			if (newValue != null) {
421
				output = output.set(idF, Pair.of(References.ITEM_NAME.typeName(), newValue));
422
			}
423
424
			if (DAMAGE_IDS.contains(id.get().getSecond())) {
425
				Typed<?> tag = input.getOrCreateTyped(tagF);
426
				Dynamic<?> tagRest = tag.get(DSL.remainderFinder());
427
				tagRest = tagRest.set("Damage", tagRest.createInt(data));
428
				output = output.set(tagF, tag.set(DSL.remainderFinder(), tagRest));
429
			}
430
431
			return output.set(DSL.remainderFinder(), rest.remove("Damage"));
432
		});
433
	}
434
435
	public static @Nullable String updateItem(final @Nullable String name, final int data) {
436
		if (IDS.contains(name)) {
437
			String newName = MAP.get(name + "." + data);
438
			return newName == null ? MAP.get(name + ".0") : newName;
439
		} else {
440
			return null;
441
		}
442
	}
443
}
444

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