PocketMine-MP 5.41.1 git-4f563d39044b06d1e4724032369d67f347dd3b86
Loading...
Searching...
No Matches
VanillaBlockMappings.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\data\bedrock\block\convert;
25
92use pocketmine\block\utils\BellAttachmentType;
93use pocketmine\block\utils\BrewingStandSlot;
94use pocketmine\block\utils\ChiseledBookshelfSlot;
95use pocketmine\block\utils\CopperOxidation;
96use pocketmine\block\utils\DirtType;
97use pocketmine\block\utils\DripleafState;
98use pocketmine\block\utils\DyeColor;
99use pocketmine\block\utils\FroglightType;
101use pocketmine\block\utils\LeverFacing;
102use pocketmine\block\utils\MobHeadType;
103use pocketmine\block\utils\MushroomBlockType;
119use pocketmine\data\bedrock\block\convert\property\FlattenedCaveVinesVariant;
127use function array_map;
128use function min;
129use function range;
130
135
136 public static function init(BlockSerializerDeserializerRegistrar $reg) : void{
137 $commonProperties = CommonProperties::getInstance();
138 self::registerSimpleIdOnlyMappings($reg);
139 self::registerColoredMappings($reg, $commonProperties);
140 self::registerCandleMappings($reg, $commonProperties);
141 self::registerLeavesMappings($reg);
142 self::registerSaplingMappings($reg);
143 self::registerPlantMappings($reg, $commonProperties);
144 self::registerCoralMappings($reg, $commonProperties);
145 self::registerCopperMappings($reg, $commonProperties);
146 self::registerFlattenedEnumMappings($reg, $commonProperties);
147 self::registerFlattenedBoolMappings($reg, $commonProperties);
148 self::registerStoneLikeSlabMappings($reg);
149 self::registerStoneLikeStairMappings($reg);
150 self::registerStoneLikeWallMappings($reg, $commonProperties);
151
152 self::registerWoodMappings($reg, $commonProperties);
153 self::registerTorchMappings($reg, $commonProperties);
154 self::registerChemistryMappings($reg, $commonProperties);
155 self::register1to1CustomMappings($reg, $commonProperties);
156
157 self::registerSplitMappings($reg, $commonProperties);
158 }
159
160 private static function registerSimpleIdOnlyMappings(BlockSerializerDeserializerRegistrar $reg) : void{
161 $reg->mapSimple(Blocks::AIR(), Ids::AIR);
162 $reg->mapSimple(Blocks::AMETHYST(), Ids::AMETHYST_BLOCK);
163 $reg->mapSimple(Blocks::ANCIENT_DEBRIS(), Ids::ANCIENT_DEBRIS);
164 $reg->mapSimple(Blocks::ANDESITE(), Ids::ANDESITE);
165 $reg->mapSimple(Blocks::AZALEA(), Ids::AZALEA);
166 $reg->mapSimple(Blocks::BARRIER(), Ids::BARRIER);
167 $reg->mapSimple(Blocks::BEACON(), Ids::BEACON);
168 $reg->mapSimple(Blocks::BLACKSTONE(), Ids::BLACKSTONE);
169 $reg->mapSimple(Blocks::BLUE_ICE(), Ids::BLUE_ICE);
170 $reg->mapSimple(Blocks::BOOKSHELF(), Ids::BOOKSHELF);
171 $reg->mapSimple(Blocks::BRICKS(), Ids::BRICK_BLOCK);
172 $reg->mapSimple(Blocks::BROWN_MUSHROOM(), Ids::BROWN_MUSHROOM);
173 $reg->mapSimple(Blocks::BUDDING_AMETHYST(), Ids::BUDDING_AMETHYST);
174 $reg->mapSimple(Blocks::CALCITE(), Ids::CALCITE);
175 $reg->mapSimple(Blocks::CARTOGRAPHY_TABLE(), Ids::CARTOGRAPHY_TABLE);
176 $reg->mapSimple(Blocks::CHEMICAL_HEAT(), Ids::CHEMICAL_HEAT);
177 $reg->mapSimple(Blocks::CHISELED_DEEPSLATE(), Ids::CHISELED_DEEPSLATE);
178 $reg->mapSimple(Blocks::CHISELED_NETHER_BRICKS(), Ids::CHISELED_NETHER_BRICKS);
179 $reg->mapSimple(Blocks::CHISELED_POLISHED_BLACKSTONE(), Ids::CHISELED_POLISHED_BLACKSTONE);
180 $reg->mapSimple(Blocks::CHISELED_RED_SANDSTONE(), Ids::CHISELED_RED_SANDSTONE);
181 $reg->mapSimple(Blocks::CHISELED_RESIN_BRICKS(), Ids::CHISELED_RESIN_BRICKS);
182 $reg->mapSimple(Blocks::CHISELED_SANDSTONE(), Ids::CHISELED_SANDSTONE);
183 $reg->mapSimple(Blocks::CHISELED_STONE_BRICKS(), Ids::CHISELED_STONE_BRICKS);
184 $reg->mapSimple(Blocks::CHISELED_TUFF(), Ids::CHISELED_TUFF);
185 $reg->mapSimple(Blocks::CHISELED_TUFF_BRICKS(), Ids::CHISELED_TUFF_BRICKS);
186 $reg->mapSimple(Blocks::CHORUS_PLANT(), Ids::CHORUS_PLANT);
187 $reg->mapSimple(Blocks::CLAY(), Ids::CLAY);
188 $reg->mapSimple(Blocks::COAL(), Ids::COAL_BLOCK);
189 $reg->mapSimple(Blocks::COAL_ORE(), Ids::COAL_ORE);
190 $reg->mapSimple(Blocks::COBBLED_DEEPSLATE(), Ids::COBBLED_DEEPSLATE);
191 $reg->mapSimple(Blocks::COBBLESTONE(), Ids::COBBLESTONE);
192 $reg->mapSimple(Blocks::COBWEB(), Ids::WEB);
193 $reg->mapSimple(Blocks::COPPER_ORE(), Ids::COPPER_ORE);
194 $reg->mapSimple(Blocks::CRACKED_DEEPSLATE_BRICKS(), Ids::CRACKED_DEEPSLATE_BRICKS);
195 $reg->mapSimple(Blocks::CRACKED_DEEPSLATE_TILES(), Ids::CRACKED_DEEPSLATE_TILES);
196 $reg->mapSimple(Blocks::CRACKED_NETHER_BRICKS(), Ids::CRACKED_NETHER_BRICKS);
197 $reg->mapSimple(Blocks::CRACKED_POLISHED_BLACKSTONE_BRICKS(), Ids::CRACKED_POLISHED_BLACKSTONE_BRICKS);
198 $reg->mapSimple(Blocks::CRACKED_STONE_BRICKS(), Ids::CRACKED_STONE_BRICKS);
199 $reg->mapSimple(Blocks::CRAFTING_TABLE(), Ids::CRAFTING_TABLE);
200 $reg->mapSimple(Blocks::CRIMSON_ROOTS(), Ids::CRIMSON_ROOTS);
201 $reg->mapSimple(Blocks::CRYING_OBSIDIAN(), Ids::CRYING_OBSIDIAN);
202 $reg->mapSimple(Blocks::DANDELION(), Ids::DANDELION);
203 $reg->mapSimple(Blocks::CUT_RED_SANDSTONE(), Ids::CUT_RED_SANDSTONE);
204 $reg->mapSimple(Blocks::CUT_SANDSTONE(), Ids::CUT_SANDSTONE);
205 $reg->mapSimple(Blocks::DARK_PRISMARINE(), Ids::DARK_PRISMARINE);
206 $reg->mapSimple(Blocks::DEAD_BUSH(), Ids::DEADBUSH);
207 $reg->mapSimple(Blocks::DEEPSLATE_BRICKS(), Ids::DEEPSLATE_BRICKS);
208 $reg->mapSimple(Blocks::DEEPSLATE_COAL_ORE(), Ids::DEEPSLATE_COAL_ORE);
209 $reg->mapSimple(Blocks::DEEPSLATE_COPPER_ORE(), Ids::DEEPSLATE_COPPER_ORE);
210 $reg->mapSimple(Blocks::DEEPSLATE_DIAMOND_ORE(), Ids::DEEPSLATE_DIAMOND_ORE);
211 $reg->mapSimple(Blocks::DEEPSLATE_EMERALD_ORE(), Ids::DEEPSLATE_EMERALD_ORE);
212 $reg->mapSimple(Blocks::DEEPSLATE_GOLD_ORE(), Ids::DEEPSLATE_GOLD_ORE);
213 $reg->mapSimple(Blocks::DEEPSLATE_IRON_ORE(), Ids::DEEPSLATE_IRON_ORE);
214 $reg->mapSimple(Blocks::DEEPSLATE_LAPIS_LAZULI_ORE(), Ids::DEEPSLATE_LAPIS_ORE);
215 $reg->mapSimple(Blocks::DEEPSLATE_TILES(), Ids::DEEPSLATE_TILES);
216 $reg->mapSimple(Blocks::DIAMOND(), Ids::DIAMOND_BLOCK);
217 $reg->mapSimple(Blocks::DIAMOND_ORE(), Ids::DIAMOND_ORE);
218 $reg->mapSimple(Blocks::DIORITE(), Ids::DIORITE);
219 $reg->mapSimple(Blocks::DRAGON_EGG(), Ids::DRAGON_EGG);
220 $reg->mapSimple(Blocks::DRIED_KELP(), Ids::DRIED_KELP_BLOCK);
221 $reg->mapSimple(Blocks::ELEMENT_ACTINIUM(), Ids::ELEMENT_89);
222 $reg->mapSimple(Blocks::ELEMENT_ALUMINUM(), Ids::ELEMENT_13);
223 $reg->mapSimple(Blocks::ELEMENT_AMERICIUM(), Ids::ELEMENT_95);
224 $reg->mapSimple(Blocks::ELEMENT_ANTIMONY(), Ids::ELEMENT_51);
225 $reg->mapSimple(Blocks::ELEMENT_ARGON(), Ids::ELEMENT_18);
226 $reg->mapSimple(Blocks::ELEMENT_ARSENIC(), Ids::ELEMENT_33);
227 $reg->mapSimple(Blocks::ELEMENT_ASTATINE(), Ids::ELEMENT_85);
228 $reg->mapSimple(Blocks::ELEMENT_BARIUM(), Ids::ELEMENT_56);
229 $reg->mapSimple(Blocks::ELEMENT_BERKELIUM(), Ids::ELEMENT_97);
230 $reg->mapSimple(Blocks::ELEMENT_BERYLLIUM(), Ids::ELEMENT_4);
231 $reg->mapSimple(Blocks::ELEMENT_BISMUTH(), Ids::ELEMENT_83);
232 $reg->mapSimple(Blocks::ELEMENT_BOHRIUM(), Ids::ELEMENT_107);
233 $reg->mapSimple(Blocks::ELEMENT_BORON(), Ids::ELEMENT_5);
234 $reg->mapSimple(Blocks::ELEMENT_BROMINE(), Ids::ELEMENT_35);
235 $reg->mapSimple(Blocks::ELEMENT_CADMIUM(), Ids::ELEMENT_48);
236 $reg->mapSimple(Blocks::ELEMENT_CALCIUM(), Ids::ELEMENT_20);
237 $reg->mapSimple(Blocks::ELEMENT_CALIFORNIUM(), Ids::ELEMENT_98);
238 $reg->mapSimple(Blocks::ELEMENT_CARBON(), Ids::ELEMENT_6);
239 $reg->mapSimple(Blocks::ELEMENT_CERIUM(), Ids::ELEMENT_58);
240 $reg->mapSimple(Blocks::ELEMENT_CESIUM(), Ids::ELEMENT_55);
241 $reg->mapSimple(Blocks::ELEMENT_CHLORINE(), Ids::ELEMENT_17);
242 $reg->mapSimple(Blocks::ELEMENT_CHROMIUM(), Ids::ELEMENT_24);
243 $reg->mapSimple(Blocks::ELEMENT_COBALT(), Ids::ELEMENT_27);
244 $reg->mapSimple(Blocks::ELEMENT_COPERNICIUM(), Ids::ELEMENT_112);
245 $reg->mapSimple(Blocks::ELEMENT_COPPER(), Ids::ELEMENT_29);
246 $reg->mapSimple(Blocks::ELEMENT_CURIUM(), Ids::ELEMENT_96);
247 $reg->mapSimple(Blocks::ELEMENT_DARMSTADTIUM(), Ids::ELEMENT_110);
248 $reg->mapSimple(Blocks::ELEMENT_DUBNIUM(), Ids::ELEMENT_105);
249 $reg->mapSimple(Blocks::ELEMENT_DYSPROSIUM(), Ids::ELEMENT_66);
250 $reg->mapSimple(Blocks::ELEMENT_EINSTEINIUM(), Ids::ELEMENT_99);
251 $reg->mapSimple(Blocks::ELEMENT_ERBIUM(), Ids::ELEMENT_68);
252 $reg->mapSimple(Blocks::ELEMENT_EUROPIUM(), Ids::ELEMENT_63);
253 $reg->mapSimple(Blocks::ELEMENT_FERMIUM(), Ids::ELEMENT_100);
254 $reg->mapSimple(Blocks::ELEMENT_FLEROVIUM(), Ids::ELEMENT_114);
255 $reg->mapSimple(Blocks::ELEMENT_FLUORINE(), Ids::ELEMENT_9);
256 $reg->mapSimple(Blocks::ELEMENT_FRANCIUM(), Ids::ELEMENT_87);
257 $reg->mapSimple(Blocks::ELEMENT_GADOLINIUM(), Ids::ELEMENT_64);
258 $reg->mapSimple(Blocks::ELEMENT_GALLIUM(), Ids::ELEMENT_31);
259 $reg->mapSimple(Blocks::ELEMENT_GERMANIUM(), Ids::ELEMENT_32);
260 $reg->mapSimple(Blocks::ELEMENT_GOLD(), Ids::ELEMENT_79);
261 $reg->mapSimple(Blocks::ELEMENT_HAFNIUM(), Ids::ELEMENT_72);
262 $reg->mapSimple(Blocks::ELEMENT_HASSIUM(), Ids::ELEMENT_108);
263 $reg->mapSimple(Blocks::ELEMENT_HELIUM(), Ids::ELEMENT_2);
264 $reg->mapSimple(Blocks::ELEMENT_HOLMIUM(), Ids::ELEMENT_67);
265 $reg->mapSimple(Blocks::ELEMENT_HYDROGEN(), Ids::ELEMENT_1);
266 $reg->mapSimple(Blocks::ELEMENT_INDIUM(), Ids::ELEMENT_49);
267 $reg->mapSimple(Blocks::ELEMENT_IODINE(), Ids::ELEMENT_53);
268 $reg->mapSimple(Blocks::ELEMENT_IRIDIUM(), Ids::ELEMENT_77);
269 $reg->mapSimple(Blocks::ELEMENT_IRON(), Ids::ELEMENT_26);
270 $reg->mapSimple(Blocks::ELEMENT_KRYPTON(), Ids::ELEMENT_36);
271 $reg->mapSimple(Blocks::ELEMENT_LANTHANUM(), Ids::ELEMENT_57);
272 $reg->mapSimple(Blocks::ELEMENT_LAWRENCIUM(), Ids::ELEMENT_103);
273 $reg->mapSimple(Blocks::ELEMENT_LEAD(), Ids::ELEMENT_82);
274 $reg->mapSimple(Blocks::ELEMENT_LITHIUM(), Ids::ELEMENT_3);
275 $reg->mapSimple(Blocks::ELEMENT_LIVERMORIUM(), Ids::ELEMENT_116);
276 $reg->mapSimple(Blocks::ELEMENT_LUTETIUM(), Ids::ELEMENT_71);
277 $reg->mapSimple(Blocks::ELEMENT_MAGNESIUM(), Ids::ELEMENT_12);
278 $reg->mapSimple(Blocks::ELEMENT_MANGANESE(), Ids::ELEMENT_25);
279 $reg->mapSimple(Blocks::ELEMENT_MEITNERIUM(), Ids::ELEMENT_109);
280 $reg->mapSimple(Blocks::ELEMENT_MENDELEVIUM(), Ids::ELEMENT_101);
281 $reg->mapSimple(Blocks::ELEMENT_MERCURY(), Ids::ELEMENT_80);
282 $reg->mapSimple(Blocks::ELEMENT_MOLYBDENUM(), Ids::ELEMENT_42);
283 $reg->mapSimple(Blocks::ELEMENT_MOSCOVIUM(), Ids::ELEMENT_115);
284 $reg->mapSimple(Blocks::ELEMENT_NEODYMIUM(), Ids::ELEMENT_60);
285 $reg->mapSimple(Blocks::ELEMENT_NEON(), Ids::ELEMENT_10);
286 $reg->mapSimple(Blocks::ELEMENT_NEPTUNIUM(), Ids::ELEMENT_93);
287 $reg->mapSimple(Blocks::ELEMENT_NICKEL(), Ids::ELEMENT_28);
288 $reg->mapSimple(Blocks::ELEMENT_NIHONIUM(), Ids::ELEMENT_113);
289 $reg->mapSimple(Blocks::ELEMENT_NIOBIUM(), Ids::ELEMENT_41);
290 $reg->mapSimple(Blocks::ELEMENT_NITROGEN(), Ids::ELEMENT_7);
291 $reg->mapSimple(Blocks::ELEMENT_NOBELIUM(), Ids::ELEMENT_102);
292 $reg->mapSimple(Blocks::ELEMENT_OGANESSON(), Ids::ELEMENT_118);
293 $reg->mapSimple(Blocks::ELEMENT_OSMIUM(), Ids::ELEMENT_76);
294 $reg->mapSimple(Blocks::ELEMENT_OXYGEN(), Ids::ELEMENT_8);
295 $reg->mapSimple(Blocks::ELEMENT_PALLADIUM(), Ids::ELEMENT_46);
296 $reg->mapSimple(Blocks::ELEMENT_PHOSPHORUS(), Ids::ELEMENT_15);
297 $reg->mapSimple(Blocks::ELEMENT_PLATINUM(), Ids::ELEMENT_78);
298 $reg->mapSimple(Blocks::ELEMENT_PLUTONIUM(), Ids::ELEMENT_94);
299 $reg->mapSimple(Blocks::ELEMENT_POLONIUM(), Ids::ELEMENT_84);
300 $reg->mapSimple(Blocks::ELEMENT_POTASSIUM(), Ids::ELEMENT_19);
301 $reg->mapSimple(Blocks::ELEMENT_PRASEODYMIUM(), Ids::ELEMENT_59);
302 $reg->mapSimple(Blocks::ELEMENT_PROMETHIUM(), Ids::ELEMENT_61);
303 $reg->mapSimple(Blocks::ELEMENT_PROTACTINIUM(), Ids::ELEMENT_91);
304 $reg->mapSimple(Blocks::ELEMENT_RADIUM(), Ids::ELEMENT_88);
305 $reg->mapSimple(Blocks::ELEMENT_RADON(), Ids::ELEMENT_86);
306 $reg->mapSimple(Blocks::ELEMENT_RHENIUM(), Ids::ELEMENT_75);
307 $reg->mapSimple(Blocks::ELEMENT_RHODIUM(), Ids::ELEMENT_45);
308 $reg->mapSimple(Blocks::ELEMENT_ROENTGENIUM(), Ids::ELEMENT_111);
309 $reg->mapSimple(Blocks::ELEMENT_RUBIDIUM(), Ids::ELEMENT_37);
310 $reg->mapSimple(Blocks::ELEMENT_RUTHENIUM(), Ids::ELEMENT_44);
311 $reg->mapSimple(Blocks::ELEMENT_RUTHERFORDIUM(), Ids::ELEMENT_104);
312 $reg->mapSimple(Blocks::ELEMENT_SAMARIUM(), Ids::ELEMENT_62);
313 $reg->mapSimple(Blocks::ELEMENT_SCANDIUM(), Ids::ELEMENT_21);
314 $reg->mapSimple(Blocks::ELEMENT_SEABORGIUM(), Ids::ELEMENT_106);
315 $reg->mapSimple(Blocks::ELEMENT_SELENIUM(), Ids::ELEMENT_34);
316 $reg->mapSimple(Blocks::ELEMENT_SILICON(), Ids::ELEMENT_14);
317 $reg->mapSimple(Blocks::ELEMENT_SILVER(), Ids::ELEMENT_47);
318 $reg->mapSimple(Blocks::ELEMENT_SODIUM(), Ids::ELEMENT_11);
319 $reg->mapSimple(Blocks::ELEMENT_STRONTIUM(), Ids::ELEMENT_38);
320 $reg->mapSimple(Blocks::ELEMENT_SULFUR(), Ids::ELEMENT_16);
321 $reg->mapSimple(Blocks::ELEMENT_TANTALUM(), Ids::ELEMENT_73);
322 $reg->mapSimple(Blocks::ELEMENT_TECHNETIUM(), Ids::ELEMENT_43);
323 $reg->mapSimple(Blocks::ELEMENT_TELLURIUM(), Ids::ELEMENT_52);
324 $reg->mapSimple(Blocks::ELEMENT_TENNESSINE(), Ids::ELEMENT_117);
325 $reg->mapSimple(Blocks::ELEMENT_TERBIUM(), Ids::ELEMENT_65);
326 $reg->mapSimple(Blocks::ELEMENT_THALLIUM(), Ids::ELEMENT_81);
327 $reg->mapSimple(Blocks::ELEMENT_THORIUM(), Ids::ELEMENT_90);
328 $reg->mapSimple(Blocks::ELEMENT_THULIUM(), Ids::ELEMENT_69);
329 $reg->mapSimple(Blocks::ELEMENT_TIN(), Ids::ELEMENT_50);
330 $reg->mapSimple(Blocks::ELEMENT_TITANIUM(), Ids::ELEMENT_22);
331 $reg->mapSimple(Blocks::ELEMENT_TUNGSTEN(), Ids::ELEMENT_74);
332 $reg->mapSimple(Blocks::ELEMENT_URANIUM(), Ids::ELEMENT_92);
333 $reg->mapSimple(Blocks::ELEMENT_VANADIUM(), Ids::ELEMENT_23);
334 $reg->mapSimple(Blocks::ELEMENT_XENON(), Ids::ELEMENT_54);
335 $reg->mapSimple(Blocks::ELEMENT_YTTERBIUM(), Ids::ELEMENT_70);
336 $reg->mapSimple(Blocks::ELEMENT_YTTRIUM(), Ids::ELEMENT_39);
337 $reg->mapSimple(Blocks::ELEMENT_ZERO(), Ids::ELEMENT_0);
338 $reg->mapSimple(Blocks::ELEMENT_ZINC(), Ids::ELEMENT_30);
339 $reg->mapSimple(Blocks::ELEMENT_ZIRCONIUM(), Ids::ELEMENT_40);
340 $reg->mapSimple(Blocks::EMERALD(), Ids::EMERALD_BLOCK);
341 $reg->mapSimple(Blocks::EMERALD_ORE(), Ids::EMERALD_ORE);
342 $reg->mapSimple(Blocks::ENCHANTING_TABLE(), Ids::ENCHANTING_TABLE);
343 $reg->mapSimple(Blocks::END_STONE(), Ids::END_STONE);
344 $reg->mapSimple(Blocks::END_STONE_BRICKS(), Ids::END_BRICKS);
345 $reg->mapSimple(Blocks::FERN(), Ids::FERN);
346 $reg->mapSimple(Blocks::FLETCHING_TABLE(), Ids::FLETCHING_TABLE);
347 $reg->mapSimple(Blocks::FLOWERING_AZALEA(), Ids::FLOWERING_AZALEA);
348 $reg->mapSimple(Blocks::GILDED_BLACKSTONE(), Ids::GILDED_BLACKSTONE);
349 $reg->mapSimple(Blocks::GLASS(), Ids::GLASS);
350 $reg->mapSimple(Blocks::GLASS_PANE(), Ids::GLASS_PANE);
351 $reg->mapSimple(Blocks::GLOWING_OBSIDIAN(), Ids::GLOWINGOBSIDIAN);
352 $reg->mapSimple(Blocks::GLOWSTONE(), Ids::GLOWSTONE);
353 $reg->mapSimple(Blocks::GOLD(), Ids::GOLD_BLOCK);
354 $reg->mapSimple(Blocks::GOLD_ORE(), Ids::GOLD_ORE);
355 $reg->mapSimple(Blocks::GRANITE(), Ids::GRANITE);
356 $reg->mapSimple(Blocks::GRASS(), Ids::GRASS_BLOCK);
357 $reg->mapSimple(Blocks::GRASS_PATH(), Ids::GRASS_PATH);
358 $reg->mapSimple(Blocks::GRAVEL(), Ids::GRAVEL);
359 $reg->mapSimple(Blocks::HANGING_ROOTS(), Ids::HANGING_ROOTS);
360 $reg->mapSimple(Blocks::HARDENED_CLAY(), Ids::HARDENED_CLAY);
361 $reg->mapSimple(Blocks::HARDENED_GLASS(), Ids::HARD_GLASS);
362 $reg->mapSimple(Blocks::HARDENED_GLASS_PANE(), Ids::HARD_GLASS_PANE);
363 $reg->mapSimple(Blocks::HONEYCOMB(), Ids::HONEYCOMB_BLOCK);
364 $reg->mapSimple(Blocks::ICE(), Ids::ICE);
365 $reg->mapSimple(Blocks::INFESTED_CHISELED_STONE_BRICK(), Ids::INFESTED_CHISELED_STONE_BRICKS);
366 $reg->mapSimple(Blocks::INFESTED_COBBLESTONE(), Ids::INFESTED_COBBLESTONE);
367 $reg->mapSimple(Blocks::INFESTED_CRACKED_STONE_BRICK(), Ids::INFESTED_CRACKED_STONE_BRICKS);
368 $reg->mapSimple(Blocks::INFESTED_MOSSY_STONE_BRICK(), Ids::INFESTED_MOSSY_STONE_BRICKS);
369 $reg->mapSimple(Blocks::INFESTED_STONE(), Ids::INFESTED_STONE);
370 $reg->mapSimple(Blocks::INFESTED_STONE_BRICK(), Ids::INFESTED_STONE_BRICKS);
371 $reg->mapSimple(Blocks::INFO_UPDATE(), Ids::INFO_UPDATE);
372 $reg->mapSimple(Blocks::INFO_UPDATE2(), Ids::INFO_UPDATE2);
373 $reg->mapSimple(Blocks::INVISIBLE_BEDROCK(), Ids::INVISIBLE_BEDROCK);
374 $reg->mapSimple(Blocks::IRON(), Ids::IRON_BLOCK);
375 $reg->mapSimple(Blocks::IRON_BARS(), Ids::IRON_BARS);
376 $reg->mapSimple(Blocks::IRON_ORE(), Ids::IRON_ORE);
377 $reg->mapSimple(Blocks::JUKEBOX(), Ids::JUKEBOX);
378 $reg->mapSimple(Blocks::LAPIS_LAZULI(), Ids::LAPIS_BLOCK);
379 $reg->mapSimple(Blocks::LAPIS_LAZULI_ORE(), Ids::LAPIS_ORE);
380 $reg->mapSimple(Blocks::LEGACY_STONECUTTER(), Ids::STONECUTTER);
381 $reg->mapSimple(Blocks::LILY_PAD(), Ids::WATERLILY);
382 $reg->mapSimple(Blocks::MAGMA(), Ids::MAGMA);
383 $reg->mapSimple(Blocks::MANGROVE_ROOTS(), Ids::MANGROVE_ROOTS);
384 $reg->mapSimple(Blocks::MELON(), Ids::MELON_BLOCK);
385 $reg->mapSimple(Blocks::MONSTER_SPAWNER(), Ids::MOB_SPAWNER);
386 $reg->mapSimple(Blocks::MOSSY_COBBLESTONE(), Ids::MOSSY_COBBLESTONE);
387 $reg->mapSimple(Blocks::MOSSY_STONE_BRICKS(), Ids::MOSSY_STONE_BRICKS);
388 $reg->mapSimple(Blocks::MUD(), Ids::MUD);
389 $reg->mapSimple(Blocks::MUD_BRICKS(), Ids::MUD_BRICKS);
390 $reg->mapSimple(Blocks::MYCELIUM(), Ids::MYCELIUM);
391 $reg->mapSimple(Blocks::NETHERITE(), Ids::NETHERITE_BLOCK);
392 $reg->mapSimple(Blocks::NETHERRACK(), Ids::NETHERRACK);
393 $reg->mapSimple(Blocks::NETHER_BRICKS(), Ids::NETHER_BRICK);
394 $reg->mapSimple(Blocks::NETHER_BRICK_FENCE(), Ids::NETHER_BRICK_FENCE);
395 $reg->mapSimple(Blocks::NETHER_GOLD_ORE(), Ids::NETHER_GOLD_ORE);
396 $reg->mapSimple(Blocks::NETHER_QUARTZ_ORE(), Ids::QUARTZ_ORE);
397 $reg->mapSimple(Blocks::NETHER_REACTOR_CORE(), Ids::NETHERREACTOR);
398 $reg->mapSimple(Blocks::NETHER_WART_BLOCK(), Ids::NETHER_WART_BLOCK);
399 $reg->mapSimple(Blocks::NOTE_BLOCK(), Ids::NOTEBLOCK);
400 $reg->mapSimple(Blocks::OBSIDIAN(), Ids::OBSIDIAN);
401 $reg->mapSimple(Blocks::PACKED_ICE(), Ids::PACKED_ICE);
402 $reg->mapSimple(Blocks::PACKED_MUD(), Ids::PACKED_MUD);
403 $reg->mapSimple(Blocks::PODZOL(), Ids::PODZOL);
404 $reg->mapSimple(Blocks::POLISHED_ANDESITE(), Ids::POLISHED_ANDESITE);
405 $reg->mapSimple(Blocks::POLISHED_BLACKSTONE(), Ids::POLISHED_BLACKSTONE);
406 $reg->mapSimple(Blocks::POLISHED_BLACKSTONE_BRICKS(), Ids::POLISHED_BLACKSTONE_BRICKS);
407 $reg->mapSimple(Blocks::POLISHED_DEEPSLATE(), Ids::POLISHED_DEEPSLATE);
408 $reg->mapSimple(Blocks::POLISHED_DIORITE(), Ids::POLISHED_DIORITE);
409 $reg->mapSimple(Blocks::POLISHED_GRANITE(), Ids::POLISHED_GRANITE);
410 $reg->mapSimple(Blocks::POLISHED_TUFF(), Ids::POLISHED_TUFF);
411 $reg->mapSimple(Blocks::PRISMARINE(), Ids::PRISMARINE);
412 $reg->mapSimple(Blocks::PRISMARINE_BRICKS(), Ids::PRISMARINE_BRICKS);
413 $reg->mapSimple(Blocks::QUARTZ_BRICKS(), Ids::QUARTZ_BRICKS);
414 $reg->mapSimple(Blocks::RAW_COPPER(), Ids::RAW_COPPER_BLOCK);
415 $reg->mapSimple(Blocks::RAW_GOLD(), Ids::RAW_GOLD_BLOCK);
416 $reg->mapSimple(Blocks::RAW_IRON(), Ids::RAW_IRON_BLOCK);
417 $reg->mapSimple(Blocks::REDSTONE(), Ids::REDSTONE_BLOCK);
418 $reg->mapSimple(Blocks::RED_MUSHROOM(), Ids::RED_MUSHROOM);
419 $reg->mapSimple(Blocks::RED_NETHER_BRICKS(), Ids::RED_NETHER_BRICK);
420 $reg->mapSimple(Blocks::RED_SAND(), Ids::RED_SAND);
421 $reg->mapSimple(Blocks::RED_SANDSTONE(), Ids::RED_SANDSTONE);
422 $reg->mapSimple(Blocks::REINFORCED_DEEPSLATE(), Ids::REINFORCED_DEEPSLATE);
423 $reg->mapSimple(Blocks::RESERVED6(), Ids::RESERVED6);
424 $reg->mapSimple(Blocks::RESIN(), Ids::RESIN_BLOCK);
425 $reg->mapSimple(Blocks::RESIN_BRICKS(), Ids::RESIN_BRICKS);
426 $reg->mapSimple(Blocks::SAND(), Ids::SAND);
427 $reg->mapSimple(Blocks::SANDSTONE(), Ids::SANDSTONE);
428 $reg->mapSimple(Blocks::SCULK(), Ids::SCULK);
429 $reg->mapSimple(Blocks::SEA_LANTERN(), Ids::SEA_LANTERN);
430 $reg->mapSimple(Blocks::SHROOMLIGHT(), Ids::SHROOMLIGHT);
431 $reg->mapSimple(Blocks::SHULKER_BOX(), Ids::UNDYED_SHULKER_BOX);
432 $reg->mapSimple(Blocks::SLIME(), Ids::SLIME);
433 $reg->mapSimple(Blocks::SMITHING_TABLE(), Ids::SMITHING_TABLE);
434 $reg->mapSimple(Blocks::SMOOTH_BASALT(), Ids::SMOOTH_BASALT);
435 $reg->mapSimple(Blocks::SMOOTH_RED_SANDSTONE(), Ids::SMOOTH_RED_SANDSTONE);
436 $reg->mapSimple(Blocks::SMOOTH_SANDSTONE(), Ids::SMOOTH_SANDSTONE);
437 $reg->mapSimple(Blocks::SMOOTH_STONE(), Ids::SMOOTH_STONE);
438 $reg->mapSimple(Blocks::SNOW(), Ids::SNOW);
439 $reg->mapSimple(Blocks::SOUL_SAND(), Ids::SOUL_SAND);
440 $reg->mapSimple(Blocks::SOUL_SOIL(), Ids::SOUL_SOIL);
441 $reg->mapSimple(Blocks::SPORE_BLOSSOM(), Ids::SPORE_BLOSSOM);
442 $reg->mapSimple(Blocks::STONE(), Ids::STONE);
443 $reg->mapSimple(Blocks::STONE_BRICKS(), Ids::STONE_BRICKS);
444 $reg->mapSimple(Blocks::STRUCTURE_VOID(), Ids::STRUCTURE_VOID);
445 $reg->mapSimple(Blocks::TALL_GRASS(), Ids::SHORT_GRASS); //no, this is not a typo - tall_grass is now the double block, just to be confusing :(
446 $reg->mapSimple(Blocks::TINTED_GLASS(), Ids::TINTED_GLASS);
447 $reg->mapSimple(Blocks::TORCHFLOWER(), Ids::TORCHFLOWER);
448 $reg->mapSimple(Blocks::TUFF(), Ids::TUFF);
449 $reg->mapSimple(Blocks::TUFF_BRICKS(), Ids::TUFF_BRICKS);
450 $reg->mapSimple(Blocks::WARPED_WART_BLOCK(), Ids::WARPED_WART_BLOCK);
451 $reg->mapSimple(Blocks::WARPED_ROOTS(), Ids::WARPED_ROOTS);
452 $reg->mapSimple(Blocks::WITHER_ROSE(), Ids::WITHER_ROSE);
453
454 $reg->mapSimple(Blocks::ALLIUM(), Ids::ALLIUM);
455 $reg->mapSimple(Blocks::CORNFLOWER(), Ids::CORNFLOWER);
456 $reg->mapSimple(Blocks::AZURE_BLUET(), Ids::AZURE_BLUET);
457 $reg->mapSimple(Blocks::LILY_OF_THE_VALLEY(), Ids::LILY_OF_THE_VALLEY);
458 $reg->mapSimple(Blocks::BLUE_ORCHID(), Ids::BLUE_ORCHID);
459 $reg->mapSimple(Blocks::OXEYE_DAISY(), Ids::OXEYE_DAISY);
460 $reg->mapSimple(Blocks::POPPY(), Ids::POPPY);
461 $reg->mapSimple(Blocks::ORANGE_TULIP(), Ids::ORANGE_TULIP);
462 $reg->mapSimple(Blocks::PINK_TULIP(), Ids::PINK_TULIP);
463 $reg->mapSimple(Blocks::RED_TULIP(), Ids::RED_TULIP);
464 $reg->mapSimple(Blocks::WHITE_TULIP(), Ids::WHITE_TULIP);
465
466 $reg->mapSimple(Blocks::CACTUS_FLOWER(), Ids::CACTUS_FLOWER);
467 $reg->mapSimple(Blocks::CRIMSON_FUNGUS(), Ids::CRIMSON_FUNGUS);
468 $reg->mapSimple(Blocks::WARPED_FUNGUS(), Ids::WARPED_FUNGUS);
469 $reg->mapSimple(Blocks::NETHER_SPROUTS(), Ids::NETHER_SPROUTS);
470 $reg->mapSimple(Blocks::CRIMSON_NYLIUM(), Ids::CRIMSON_NYLIUM);
471 $reg->mapSimple(Blocks::WARPED_NYLIUM(), Ids::WARPED_NYLIUM);
472 }
473
474 private static function registerColoredMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
475 $reg->mapColored(Blocks::STAINED_HARDENED_GLASS(), "minecraft:hard_", "_stained_glass");
476 $reg->mapColored(Blocks::STAINED_HARDENED_GLASS_PANE(), "minecraft:hard_", "_stained_glass_pane");
477
478 $reg->mapColored(Blocks::CARPET(), "minecraft:", "_carpet");
479 $reg->mapColored(Blocks::CONCRETE(), "minecraft:", "_concrete");
480 $reg->mapColored(Blocks::CONCRETE_POWDER(), "minecraft:", "_concrete_powder");
481 $reg->mapColored(Blocks::DYED_SHULKER_BOX(), "minecraft:", "_shulker_box");
482 $reg->mapColored(Blocks::STAINED_CLAY(), "minecraft:", "_terracotta");
483 $reg->mapColored(Blocks::STAINED_GLASS(), "minecraft:", "_stained_glass");
484 $reg->mapColored(Blocks::STAINED_GLASS_PANE(), "minecraft:", "_stained_glass_pane");
485 $reg->mapColored(Blocks::WOOL(), "minecraft:", "_wool");
486
487 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::GLAZED_TERRACOTTA())
488 ->idComponents([
489 "minecraft:",
490 new ValueFromStringProperty("color", ValueMappings::getInstance()->dyeColorWithSilver, fn(GlazedTerracotta $b) => $b->getColor(), fn(GlazedTerracotta $b, DyeColor $v) => $b->setColor($v)),
491 "_glazed_terracotta"
492 ])
493 ->properties([$commonProperties->horizontalFacingClassic])
494 );
495 }
496
497 private static function registerCandleMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
498 $candleProperties = [
499 $commonProperties->lit,
500 new IntProperty(StateNames::CANDLES, 0, 3, fn(Candle $b) => $b->getCount(), fn(Candle $b, int $v) => $b->setCount($v), offset: 1),
501 ];
502 $cakeWithCandleProperties = [$commonProperties->lit];
503 $reg->mapModel(Model::create(Blocks::CANDLE(), Ids::CANDLE)->properties($candleProperties));
504 $reg->mapModel(Model::create(Blocks::CAKE_WITH_CANDLE(), Ids::CANDLE_CAKE)->properties($cakeWithCandleProperties));
505
506 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::DYED_CANDLE())
507 ->idComponents([
508 "minecraft:",
509 $commonProperties->dyeColorIdInfix,
510 "_candle"
511 ])
512 ->properties($candleProperties)
513 );
514 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CAKE_WITH_DYED_CANDLE())
515 ->idComponents([
516 "minecraft:",
517 $commonProperties->dyeColorIdInfix,
518 "_candle_cake"
519 ])
520 ->properties($cakeWithCandleProperties)
521 );
522 }
523
524 private static function registerLeavesMappings(BlockSerializerDeserializerRegistrar $reg) : void{
525 $properties = [
526 new BoolProperty(StateNames::PERSISTENT_BIT, fn(Leaves $b) => $b->isNoDecay(), fn(Leaves $b, bool $v) => $b->setNoDecay($v)),
527 new BoolProperty(StateNames::UPDATE_BIT, fn(Leaves $b) => $b->isCheckDecay(), fn(Leaves $b, bool $v) => $b->setCheckDecay($v)),
528 ];
529 foreach([
530 Ids::ACACIA_LEAVES => Blocks::ACACIA_LEAVES(),
531 Ids::AZALEA_LEAVES => Blocks::AZALEA_LEAVES(),
532 Ids::AZALEA_LEAVES_FLOWERED => Blocks::FLOWERING_AZALEA_LEAVES(),
533 Ids::BIRCH_LEAVES => Blocks::BIRCH_LEAVES(),
534 Ids::CHERRY_LEAVES => Blocks::CHERRY_LEAVES(),
535 Ids::DARK_OAK_LEAVES => Blocks::DARK_OAK_LEAVES(),
536 Ids::JUNGLE_LEAVES => Blocks::JUNGLE_LEAVES(),
537 Ids::MANGROVE_LEAVES => Blocks::MANGROVE_LEAVES(),
538 Ids::OAK_LEAVES => Blocks::OAK_LEAVES(),
539 Ids::PALE_OAK_LEAVES => Blocks::PALE_OAK_LEAVES(),
540 Ids::SPRUCE_LEAVES => Blocks::SPRUCE_LEAVES()
541 ] as $id => $block){
542 $reg->mapModel(Model::create($block, $id)->properties($properties));
543 }
544 }
545
546 private static function registerSaplingMappings(BlockSerializerDeserializerRegistrar $reg) : void{
547 $properties = [
548 new BoolProperty(StateNames::AGE_BIT, fn(Sapling $b) => $b->isReady(), fn(Sapling $b, bool $v) => $b->setReady($v)),
549 ];
550 foreach([
551 Ids::ACACIA_SAPLING => Blocks::ACACIA_SAPLING(),
552 Ids::BIRCH_SAPLING => Blocks::BIRCH_SAPLING(),
553 Ids::DARK_OAK_SAPLING => Blocks::DARK_OAK_SAPLING(),
554 Ids::JUNGLE_SAPLING => Blocks::JUNGLE_SAPLING(),
555 Ids::OAK_SAPLING => Blocks::OAK_SAPLING(),
556 Ids::SPRUCE_SAPLING => Blocks::SPRUCE_SAPLING(),
557 ] as $id => $block){
558 $reg->mapModel(Model::create($block, $id)->properties($properties));
559 }
560 }
561
562 private static function registerPlantMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
563 $reg->mapModel(Model::create(Blocks::BEETROOTS(), Ids::BEETROOT)->properties([$commonProperties->cropAgeMax7]));
564 $reg->mapModel(Model::create(Blocks::CARROTS(), Ids::CARROTS)->properties([$commonProperties->cropAgeMax7]));
565 $reg->mapModel(Model::create(Blocks::POTATOES(), Ids::POTATOES)->properties([$commonProperties->cropAgeMax7]));
566 $reg->mapModel(Model::create(Blocks::WHEAT(), Ids::WHEAT)->properties([$commonProperties->cropAgeMax7]));
567
568 $reg->mapModel(Model::create(Blocks::MELON_STEM(), Ids::MELON_STEM)->properties($commonProperties->stemProperties));
569 $reg->mapModel(Model::create(Blocks::PUMPKIN_STEM(), Ids::PUMPKIN_STEM)->properties($commonProperties->stemProperties));
570
571 foreach([
572 [Blocks::DOUBLE_TALLGRASS(), Ids::TALL_GRASS],
573 [Blocks::LARGE_FERN(), Ids::LARGE_FERN],
574 [Blocks::LILAC(), Ids::LILAC],
575 [Blocks::PEONY(), Ids::PEONY],
576 [Blocks::ROSE_BUSH(), Ids::ROSE_BUSH],
577 [Blocks::SUNFLOWER(), Ids::SUNFLOWER],
578 ] as [$block, $id]){
579 $reg->mapModel(Model::create($block, $id)->properties([$commonProperties->doublePlantHalf]));
580 }
581
582 foreach([
583 [Blocks::BROWN_MUSHROOM_BLOCK(), Ids::BROWN_MUSHROOM_BLOCK],
584 [Blocks::RED_MUSHROOM_BLOCK(), Ids::RED_MUSHROOM_BLOCK]
585 ] as [$block, $id]){
586 $reg->mapModel(Model::create($block, $id)->properties([
587 new ValueFromIntProperty(StateNames::HUGE_MUSHROOM_BITS, ValueMappings::getInstance()->mushroomBlockType, fn(RedMushroomBlock $b) => $b->getMushroomBlockType(), fn(RedMushroomBlock $b, MushroomBlockType $v) => $b->setMushroomBlockType($v)),
588 ]));
589 }
590
591 $reg->mapModel(Model::create(Blocks::GLOW_LICHEN(), Ids::GLOW_LICHEN)->properties([$commonProperties->multiFacingFlags]));
592 $reg->mapModel(Model::create(Blocks::RESIN_CLUMP(), Ids::RESIN_CLUMP)->properties([$commonProperties->multiFacingFlags]));
593
594 $reg->mapModel(Model::create(Blocks::VINES(), Ids::VINE)->properties([
596 StateNames::VINE_DIRECTION_BITS,
597 IntFromRawStateMap::int([
598 Facing::NORTH => BlockLegacyMetadata::VINE_FLAG_NORTH,
599 Facing::SOUTH => BlockLegacyMetadata::VINE_FLAG_SOUTH,
600 Facing::WEST => BlockLegacyMetadata::VINE_FLAG_WEST,
601 Facing::EAST => BlockLegacyMetadata::VINE_FLAG_EAST,
602 ]),
603 fn(Vine $b) => $b->getFaces(),
604 fn(Vine $b, array $v) => $b->setFaces($v)
605 )
606 ]));
607
608 $reg->mapModel(Model::create(Blocks::SWEET_BERRY_BUSH(), Ids::SWEET_BERRY_BUSH)->properties([
609 //TODO: berry bush only wants 0-3, but it can be bigger in MCPE due to misuse of GROWTH state which goes up to 7
610 new IntProperty(StateNames::GROWTH, 0, 7, fn(SweetBerryBush $b) => $b->getAge(), fn(SweetBerryBush $b, int $v) => $b->setAge(min($v, SweetBerryBush::STAGE_MATURE)))
611 ]));
612 $reg->mapModel(Model::create(Blocks::TORCHFLOWER_CROP(), Ids::TORCHFLOWER_CROP)->properties([
613 //TODO: this property can have values 0-7, but only 0-1 are valid
614 new IntProperty(StateNames::GROWTH, 0, 7, fn(TorchflowerCrop $b) => $b->isReady() ? 1 : 0, fn(TorchflowerCrop $b, int $v) => $b->setReady($v !== 0))
615 ]));
616 }
617
618 private static function registerCoralMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
619 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CORAL())->idComponents([...$commonProperties->coralIdPrefixes, "_coral"]));
620 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CORAL_BLOCK())->idComponents([...$commonProperties->coralIdPrefixes, "_coral_block"]));
621 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CORAL_FAN())
622 ->idComponents([...$commonProperties->coralIdPrefixes, "_coral_fan"])
623 ->properties([
624 new ValueFromIntProperty(StateNames::CORAL_FAN_DIRECTION, ValueMappings::getInstance()->coralAxis, fn(FloorCoralFan $b) => $b->getAxis(), fn(FloorCoralFan $b, int $v) => $b->setAxis($v))
625 ])
626 );
627 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::WALL_CORAL_FAN())
628 ->idComponents([...$commonProperties->coralIdPrefixes, "_coral_wall_fan"])
629 ->properties([
630 new ValueFromIntProperty(StateNames::CORAL_DIRECTION, ValueMappings::getInstance()->horizontalFacingCoral, fn(HorizontalFacing $b) => $b->getFacing(), fn(HorizontalFacing $b, int $v) => $b->setFacing($v)),
631 ])
632 );
633 }
634
635 private static function registerCopperMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
636 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_BULB())
637 ->idComponents([...$commonProperties->copperIdPrefixes, "copper_bulb"])
638 ->properties([
639 $commonProperties->lit,
640 new BoolProperty(StateNames::POWERED_BIT, fn(PoweredByRedstone $b) => $b->isPowered(), fn(PoweredByRedstone $b, bool $v) => $b->setPowered($v)),
641 ])
642 );
643 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER())
644 ->idComponents([
645 ...$commonProperties->copperIdPrefixes,
646 "copper",
647 //HACK: the non-waxed, non-oxidised variant has a _block suffix, but none of the others do
648 new BoolFromStringProperty("bruhhhh", "", "_block", fn(Copper $b) => !$b->isWaxed() && $b->getOxidation() === CopperOxidation::NONE, fn() => null)
649 ])
650 );
651 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CHISELED_COPPER())->idComponents([...$commonProperties->copperIdPrefixes, "chiseled_copper"]));
652 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_GRATE())->idComponents([...$commonProperties->copperIdPrefixes, "copper_grate"]));
653 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CUT_COPPER())->idComponents([...$commonProperties->copperIdPrefixes, "cut_copper"]));
654 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CUT_COPPER_STAIRS())
655 ->idComponents([...$commonProperties->copperIdPrefixes, "cut_copper_stairs"])
656 ->properties($commonProperties->stairProperties)
657 );
658 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_TRAPDOOR())
659 ->idComponents([...$commonProperties->copperIdPrefixes, "copper_trapdoor"])
660 ->properties($commonProperties->trapdoorProperties)
661 );
662 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_DOOR())
663 ->idComponents([...$commonProperties->copperIdPrefixes, "copper_door"])
664 ->properties($commonProperties->doorProperties)
665 );
666
667 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CUT_COPPER_SLAB())
668 ->idComponents([
669 ...$commonProperties->copperIdPrefixes,
670 $commonProperties->slabIdInfix,
671 "cut_copper_slab"
672 ])
673 ->properties([$commonProperties->slabPositionProperty])
674 );
675
676 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_BARS())->idComponents([...$commonProperties->copperIdPrefixes, "copper_bars"]));
677 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_CHAIN())
678 ->idComponents([...$commonProperties->copperIdPrefixes, "copper_chain"])
679 ->properties([$commonProperties->pillarAxis])
680 );
681 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::COPPER_LANTERN())
682 ->idComponents([...$commonProperties->copperIdPrefixes, "copper_lantern"])
683 ->properties([
684 new BoolProperty(StateNames::HANGING, fn(CopperLantern $b) => $b->isHanging(), fn(CopperLantern $b, bool $v) => $b->setHanging($v))
685 ])
686 );
687 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::LIGHTNING_ROD())
688 ->idComponents([...$commonProperties->copperIdPrefixes, "lightning_rod"])
689 ->properties([
690 $commonProperties->anyFacingClassic,
691 new DummyProperty(StateNames::POWERED_BIT, false) //TODO
692 ])
693 );
694 }
695
696 private static function registerFlattenedEnumMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
697 //A
698 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::ANVIL())
699 ->idComponents([
700 new ValueFromStringProperty("id", IntFromRawStateMap::string([
701 0 => Ids::ANVIL,
702 1 => Ids::CHIPPED_ANVIL,
703 2 => Ids::DAMAGED_ANVIL,
704 ]), fn(Anvil $b) => $b->getDamage(), fn(Anvil $b, int $v) => $b->setDamage($v))
705 ])
706 ->properties([$commonProperties->horizontalFacingCardinal])
707 );
708 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::AMETHYST_CLUSTER())
709 ->idComponents([
710 new ValueFromStringProperty("id", IntFromRawStateMap::string([
711 AmethystCluster::STAGE_SMALL_BUD => Ids::SMALL_AMETHYST_BUD,
712 AmethystCluster::STAGE_MEDIUM_BUD => Ids::MEDIUM_AMETHYST_BUD,
713 AmethystCluster::STAGE_LARGE_BUD => Ids::LARGE_AMETHYST_BUD,
714 AmethystCluster::STAGE_CLUSTER => Ids::AMETHYST_CLUSTER
715 ]), fn(AmethystCluster $b) => $b->getStage(), fn(AmethystCluster $b, int $v) => $b->setStage($v))
716 ])
717 ->properties([$commonProperties->blockFace])
718 );
719
720 //C
721 //This one is a special offender :<
722 //I have no idea why this only has 3 IDs - there are 4 in Java and 4 visually distinct states in Bedrock
723 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::CAVE_VINES())
724 ->idComponents([
725 "minecraft:cave_vines",
727 "variant",
728 EnumFromRawStateMap::string(FlattenedCaveVinesVariant::class, fn(FlattenedCaveVinesVariant $case) => $case->value),
729 fn(CaveVines $b) => $b->hasBerries() ?
730 ($b->isHead() ?
731 FlattenedCaveVinesVariant::HEAD_WITH_BERRIES :
732 FlattenedCaveVinesVariant::BODY_WITH_BERRIES) :
733 FlattenedCaveVinesVariant::NO_BERRIES,
734 fn(CaveVines $b, FlattenedCaveVinesVariant $v) => match($v){
735 FlattenedCaveVinesVariant::HEAD_WITH_BERRIES => $b->setBerries(true)->setHead(true),
736 FlattenedCaveVinesVariant::BODY_WITH_BERRIES => $b->setBerries(true)->setHead(false),
737 FlattenedCaveVinesVariant::NO_BERRIES => $b->setBerries(false)->setHead(false), //assume this isn't a head, since we don't have enough information
738 }
739 )
740 ])
741 ->properties([
742 new IntProperty(StateNames::GROWING_PLANT_AGE, 0, 25, fn(CaveVines $b) => $b->getAge(), fn(CaveVines $b, int $v) => $b->setAge($v)),
743 ])
744 );
745
746 //D
747 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::DIRT())
748 ->idComponents([
749 new ValueFromStringProperty("id", EnumFromRawStateMap::string(DirtType::class, fn(DirtType $case) => match ($case) {
750 DirtType::NORMAL => Ids::DIRT,
751 DirtType::COARSE => Ids::COARSE_DIRT,
752 DirtType::ROOTED => Ids::DIRT_WITH_ROOTS,
753 }), fn(Dirt $b) => $b->getDirtType(), fn(Dirt $b, DirtType $v) => $b->setDirtType($v))
754 ])
755 );
756
757 //F
758 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::FROGLIGHT())
759 ->idComponents([
760 new ValueFromStringProperty("id", ValueMappings::getInstance()->froglightType, fn(Froglight $b) => $b->getFroglightType(), fn(Froglight $b, FroglightType $v) => $b->setFroglightType($v)),
761 ])
762 ->properties([$commonProperties->pillarAxis])
763 );
764
765 //L
766 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::LIGHT())
767 ->idComponents([
768 "minecraft:light_block_",
769 //this is a bit shit but it's easier than adapting IntProperty to support flattening :D
771 "light_level",
772 IntFromRawStateMap::string(array_map(strval(...), range(0, 15))),
773 fn(Light $b) => $b->getLightLevel(),
774 fn(Light $b, int $v) => $b->setLightLevel($v)
775 )
776 ])
777 );
778
779 //M
780 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::MOB_HEAD())
781 ->idComponents([
782 new ValueFromStringProperty("id", ValueMappings::getInstance()->mobHeadType, fn(MobHead $b) => $b->getMobHeadType(), fn(MobHead $b, MobHeadType $v) => $b->setMobHeadType($v)),
783 ])
784 ->properties([
785 new ValueFromIntProperty(StateNames::FACING_DIRECTION, ValueMappings::getInstance()->facingExceptDown, fn(MobHead $b) => $b->getFacing(), fn(MobHead $b, int $v) => $b->setFacing($v))
786 ])
787 );
788
789 foreach([
790 [Blocks::LAVA(), "lava"],
791 [Blocks::WATER(), "water"]
792 ] as [$block, $idSuffix]){
794 ->idComponents([...$commonProperties->liquidIdPrefixes, $idSuffix])
795 ->properties([$commonProperties->liquidData])
796 );
797 }
798 }
799
800 private static function registerFlattenedBoolMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
801 foreach([
802 [Blocks::BLAST_FURNACE(), "blast_furnace"],
803 [Blocks::FURNACE(), "furnace"],
804 [Blocks::SMOKER(), "smoker"]
805 ] as [$block, $idSuffix]){
807 ->idComponents([...$commonProperties->furnaceIdPrefixes, $idSuffix])
808 ->properties([$commonProperties->horizontalFacingCardinal])
809 );
810 }
811
812 foreach([
813 [Blocks::REDSTONE_LAMP(), "redstone_lamp"],
814 [Blocks::REDSTONE_ORE(), "redstone_ore"],
815 [Blocks::DEEPSLATE_REDSTONE_ORE(), "deepslate_redstone_ore"]
816 ] as [$block, $idSuffix]){
817 $reg->mapFlattenedId(FlattenedIdModel::create($block)->idComponents(["minecraft:", $commonProperties->litIdInfix, $idSuffix]));
818 }
819
820 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::DAYLIGHT_SENSOR())
821 ->idComponents([
822 "minecraft:daylight_detector",
823 new BoolFromStringProperty("inverted", "", "_inverted", fn(DaylightSensor $b) => $b->isInverted(), fn(DaylightSensor $b, bool $v) => $b->setInverted($v))
824 ])
825 ->properties([$commonProperties->analogRedstoneSignal])
826 );
827 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::REDSTONE_REPEATER())
828 ->idComponents([
829 "minecraft:",
830 new BoolFromStringProperty("powered", "un", "", fn(RedstoneRepeater $b) => $b->isPowered(), fn(RedstoneRepeater $b, bool $v) => $b->setPowered($v)),
831 "powered_repeater"
832 ])
833 ->properties([
834 $commonProperties->horizontalFacingCardinal,
835 new IntProperty(StateNames::REPEATER_DELAY, 0, 3, fn(RedstoneRepeater $b) => $b->getDelay(), fn(RedstoneRepeater $b, int $v) => $b->setDelay($v), offset: 1),
836 ])
837 );
838 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::REDSTONE_COMPARATOR())
839 ->idComponents([
840 "minecraft:",
841 //this property also appears in the state, so we ignore it in the ID
842 //this is baked here purely to keep minecraft happy
843 new BoolFromStringProperty("dummy_powered", "un", "", fn(RedstoneComparator $b) => $b->isPowered(), fn() => null),
844 "powered_comparator"
845 ])
846 ->properties([
847 $commonProperties->horizontalFacingCardinal,
848 new BoolProperty(StateNames::OUTPUT_LIT_BIT, fn(RedstoneComparator $b) => $b->isPowered(), fn(RedstoneComparator $b, bool $v) => $b->setPowered($v)),
849 new BoolProperty(StateNames::OUTPUT_SUBTRACT_BIT, fn(RedstoneComparator $b) => $b->isSubtractMode(), fn(RedstoneComparator $b, bool $v) => $b->setSubtractMode($v)),
850 ])
851 );
852 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::REDSTONE_TORCH())
853 ->idComponents([
854 "minecraft:",
855 new BoolFromStringProperty("lit", "unlit_", "", fn(RedstoneTorch $b) => $b->isLit(), fn(RedstoneTorch $b, bool $v) => $b->setLit($v)),
856 "redstone_torch"
857 ])
858 ->properties([$commonProperties->torchFacing])
859 );
860 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::SPONGE())->idComponents([
861 "minecraft:",
862 new BoolFromStringProperty("wet", "", "wet_", fn(Sponge $b) => $b->isWet(), fn(Sponge $b, bool $v) => $b->setWet($v)),
863 "sponge"
864 ]));
865 $reg->mapFlattenedId(FlattenedIdModel::create(Blocks::TNT())
866 ->idComponents([
867 "minecraft:",
868 new BoolFromStringProperty("underwater", "", "underwater_", fn(TNT $b) => $b->worksUnderwater(), fn(TNT $b, bool $v) => $b->setWorksUnderwater($v)),
869 "tnt"
870 ])
871 ->properties([
872 new BoolProperty(StateNames::EXPLODE_BIT, fn(TNT $b) => $b->isUnstable(), fn(TNT $b, bool $v) => $b->setUnstable($v)),
873 ])
874 );
875 }
876
877 private static function registerStoneLikeSlabMappings(BlockSerializerDeserializerRegistrar $reg) : void{
878 $reg->mapSlab(Blocks::ANDESITE_SLAB(), "andesite");
879 $reg->mapSlab(Blocks::BLACKSTONE_SLAB(), "blackstone");
880 $reg->mapSlab(Blocks::BRICK_SLAB(), "brick");
881 $reg->mapSlab(Blocks::COBBLED_DEEPSLATE_SLAB(), "cobbled_deepslate");
882 $reg->mapSlab(Blocks::COBBLESTONE_SLAB(), "cobblestone");
883 $reg->mapSlab(Blocks::CUT_RED_SANDSTONE_SLAB(), "cut_red_sandstone");
884 $reg->mapSlab(Blocks::CUT_SANDSTONE_SLAB(), "cut_sandstone");
885 $reg->mapSlab(Blocks::DARK_PRISMARINE_SLAB(), "dark_prismarine");
886 $reg->mapSlab(Blocks::DEEPSLATE_BRICK_SLAB(), "deepslate_brick");
887 $reg->mapSlab(Blocks::DEEPSLATE_TILE_SLAB(), "deepslate_tile");
888 $reg->mapSlab(Blocks::DIORITE_SLAB(), "diorite");
889 $reg->mapSlab(Blocks::END_STONE_BRICK_SLAB(), "end_stone_brick");
890 $reg->mapSlab(Blocks::FAKE_WOODEN_SLAB(), "petrified_oak");
891 $reg->mapSlab(Blocks::GRANITE_SLAB(), "granite");
892 $reg->mapSlab(Blocks::MOSSY_COBBLESTONE_SLAB(), "mossy_cobblestone");
893 $reg->mapSlab(Blocks::MOSSY_STONE_BRICK_SLAB(), "mossy_stone_brick");
894 $reg->mapSlab(Blocks::MUD_BRICK_SLAB(), "mud_brick");
895 $reg->mapSlab(Blocks::NETHER_BRICK_SLAB(), "nether_brick");
896 $reg->mapSlab(Blocks::POLISHED_ANDESITE_SLAB(), "polished_andesite");
897 $reg->mapSlab(Blocks::POLISHED_BLACKSTONE_BRICK_SLAB(), "polished_blackstone_brick");
898 $reg->mapSlab(Blocks::POLISHED_BLACKSTONE_SLAB(), "polished_blackstone");
899 $reg->mapSlab(Blocks::POLISHED_DEEPSLATE_SLAB(), "polished_deepslate");
900 $reg->mapSlab(Blocks::POLISHED_DIORITE_SLAB(), "polished_diorite");
901 $reg->mapSlab(Blocks::POLISHED_GRANITE_SLAB(), "polished_granite");
902 $reg->mapSlab(Blocks::POLISHED_TUFF_SLAB(), "polished_tuff");
903 $reg->mapSlab(Blocks::PRISMARINE_BRICKS_SLAB(), "prismarine_brick");
904 $reg->mapSlab(Blocks::PRISMARINE_SLAB(), "prismarine");
905 $reg->mapSlab(Blocks::PURPUR_SLAB(), "purpur");
906 $reg->mapSlab(Blocks::QUARTZ_SLAB(), "quartz");
907 $reg->mapSlab(Blocks::RED_NETHER_BRICK_SLAB(), "red_nether_brick");
908 $reg->mapSlab(Blocks::RED_SANDSTONE_SLAB(), "red_sandstone");
909 $reg->mapSlab(Blocks::RESIN_BRICK_SLAB(), "resin_brick");
910 $reg->mapSlab(Blocks::SANDSTONE_SLAB(), "sandstone");
911 $reg->mapSlab(Blocks::SMOOTH_QUARTZ_SLAB(), "smooth_quartz");
912 $reg->mapSlab(Blocks::SMOOTH_RED_SANDSTONE_SLAB(), "smooth_red_sandstone");
913 $reg->mapSlab(Blocks::SMOOTH_SANDSTONE_SLAB(), "smooth_sandstone");
914 $reg->mapSlab(Blocks::SMOOTH_STONE_SLAB(), "smooth_stone");
915 $reg->mapSlab(Blocks::STONE_BRICK_SLAB(), "stone_brick");
916 $reg->mapSlab(Blocks::STONE_SLAB(), "normal_stone");
917 $reg->mapSlab(Blocks::TUFF_BRICK_SLAB(), "tuff_brick");
918 $reg->mapSlab(Blocks::TUFF_SLAB(), "tuff");
919 }
920
921 private static function registerStoneLikeStairMappings(BlockSerializerDeserializerRegistrar $reg) : void{
922 $reg->mapStairs(Blocks::ANDESITE_STAIRS(), Ids::ANDESITE_STAIRS);
923 $reg->mapStairs(Blocks::BLACKSTONE_STAIRS(), Ids::BLACKSTONE_STAIRS);
924 $reg->mapStairs(Blocks::BRICK_STAIRS(), Ids::BRICK_STAIRS);
925 $reg->mapStairs(Blocks::COBBLED_DEEPSLATE_STAIRS(), Ids::COBBLED_DEEPSLATE_STAIRS);
926 $reg->mapStairs(Blocks::COBBLESTONE_STAIRS(), Ids::STONE_STAIRS);
927 $reg->mapStairs(Blocks::DARK_PRISMARINE_STAIRS(), Ids::DARK_PRISMARINE_STAIRS);
928 $reg->mapStairs(Blocks::DEEPSLATE_BRICK_STAIRS(), Ids::DEEPSLATE_BRICK_STAIRS);
929 $reg->mapStairs(Blocks::DEEPSLATE_TILE_STAIRS(), Ids::DEEPSLATE_TILE_STAIRS);
930 $reg->mapStairs(Blocks::DIORITE_STAIRS(), Ids::DIORITE_STAIRS);
931 $reg->mapStairs(Blocks::END_STONE_BRICK_STAIRS(), Ids::END_BRICK_STAIRS);
932 $reg->mapStairs(Blocks::GRANITE_STAIRS(), Ids::GRANITE_STAIRS);
933 $reg->mapStairs(Blocks::MOSSY_COBBLESTONE_STAIRS(), Ids::MOSSY_COBBLESTONE_STAIRS);
934 $reg->mapStairs(Blocks::MOSSY_STONE_BRICK_STAIRS(), Ids::MOSSY_STONE_BRICK_STAIRS);
935 $reg->mapStairs(Blocks::MUD_BRICK_STAIRS(), Ids::MUD_BRICK_STAIRS);
936 $reg->mapStairs(Blocks::NETHER_BRICK_STAIRS(), Ids::NETHER_BRICK_STAIRS);
937 $reg->mapStairs(Blocks::POLISHED_ANDESITE_STAIRS(), Ids::POLISHED_ANDESITE_STAIRS);
938 $reg->mapStairs(Blocks::POLISHED_BLACKSTONE_BRICK_STAIRS(), Ids::POLISHED_BLACKSTONE_BRICK_STAIRS);
939 $reg->mapStairs(Blocks::POLISHED_BLACKSTONE_STAIRS(), Ids::POLISHED_BLACKSTONE_STAIRS);
940 $reg->mapStairs(Blocks::POLISHED_DEEPSLATE_STAIRS(), Ids::POLISHED_DEEPSLATE_STAIRS);
941 $reg->mapStairs(Blocks::POLISHED_DIORITE_STAIRS(), Ids::POLISHED_DIORITE_STAIRS);
942 $reg->mapStairs(Blocks::POLISHED_GRANITE_STAIRS(), Ids::POLISHED_GRANITE_STAIRS);
943 $reg->mapStairs(Blocks::POLISHED_TUFF_STAIRS(), Ids::POLISHED_TUFF_STAIRS);
944 $reg->mapStairs(Blocks::PRISMARINE_BRICKS_STAIRS(), Ids::PRISMARINE_BRICKS_STAIRS);
945 $reg->mapStairs(Blocks::PRISMARINE_STAIRS(), Ids::PRISMARINE_STAIRS);
946 $reg->mapStairs(Blocks::PURPUR_STAIRS(), Ids::PURPUR_STAIRS);
947 $reg->mapStairs(Blocks::QUARTZ_STAIRS(), Ids::QUARTZ_STAIRS);
948 $reg->mapStairs(Blocks::RED_NETHER_BRICK_STAIRS(), Ids::RED_NETHER_BRICK_STAIRS);
949 $reg->mapStairs(Blocks::RED_SANDSTONE_STAIRS(), Ids::RED_SANDSTONE_STAIRS);
950 $reg->mapStairs(Blocks::RESIN_BRICK_STAIRS(), Ids::RESIN_BRICK_STAIRS);
951 $reg->mapStairs(Blocks::SANDSTONE_STAIRS(), Ids::SANDSTONE_STAIRS);
952 $reg->mapStairs(Blocks::SMOOTH_QUARTZ_STAIRS(), Ids::SMOOTH_QUARTZ_STAIRS);
953 $reg->mapStairs(Blocks::SMOOTH_RED_SANDSTONE_STAIRS(), Ids::SMOOTH_RED_SANDSTONE_STAIRS);
954 $reg->mapStairs(Blocks::SMOOTH_SANDSTONE_STAIRS(), Ids::SMOOTH_SANDSTONE_STAIRS);
955 $reg->mapStairs(Blocks::STONE_BRICK_STAIRS(), Ids::STONE_BRICK_STAIRS);
956 $reg->mapStairs(Blocks::STONE_STAIRS(), Ids::NORMAL_STONE_STAIRS);
957 $reg->mapStairs(Blocks::TUFF_BRICK_STAIRS(), Ids::TUFF_BRICK_STAIRS);
958 $reg->mapStairs(Blocks::TUFF_STAIRS(), Ids::TUFF_STAIRS);
959 }
960
961 private static function registerStoneLikeWallMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
962 foreach([
963 Ids::ANDESITE_WALL => Blocks::ANDESITE_WALL(),
964 Ids::BLACKSTONE_WALL => Blocks::BLACKSTONE_WALL(),
965 Ids::BRICK_WALL => Blocks::BRICK_WALL(),
966 Ids::COBBLED_DEEPSLATE_WALL => Blocks::COBBLED_DEEPSLATE_WALL(),
967 Ids::COBBLESTONE_WALL => Blocks::COBBLESTONE_WALL(),
968 Ids::DEEPSLATE_BRICK_WALL => Blocks::DEEPSLATE_BRICK_WALL(),
969 Ids::DEEPSLATE_TILE_WALL => Blocks::DEEPSLATE_TILE_WALL(),
970 Ids::DIORITE_WALL => Blocks::DIORITE_WALL(),
971 Ids::END_STONE_BRICK_WALL => Blocks::END_STONE_BRICK_WALL(),
972 Ids::GRANITE_WALL => Blocks::GRANITE_WALL(),
973 Ids::MOSSY_COBBLESTONE_WALL => Blocks::MOSSY_COBBLESTONE_WALL(),
974 Ids::MOSSY_STONE_BRICK_WALL => Blocks::MOSSY_STONE_BRICK_WALL(),
975 Ids::MUD_BRICK_WALL => Blocks::MUD_BRICK_WALL(),
976 Ids::NETHER_BRICK_WALL => Blocks::NETHER_BRICK_WALL(),
977 Ids::POLISHED_BLACKSTONE_BRICK_WALL => Blocks::POLISHED_BLACKSTONE_BRICK_WALL(),
978 Ids::POLISHED_BLACKSTONE_WALL => Blocks::POLISHED_BLACKSTONE_WALL(),
979 Ids::POLISHED_DEEPSLATE_WALL => Blocks::POLISHED_DEEPSLATE_WALL(),
980 Ids::POLISHED_TUFF_WALL => Blocks::POLISHED_TUFF_WALL(),
981 Ids::PRISMARINE_WALL => Blocks::PRISMARINE_WALL(),
982 Ids::RED_NETHER_BRICK_WALL => Blocks::RED_NETHER_BRICK_WALL(),
983 Ids::RED_SANDSTONE_WALL => Blocks::RED_SANDSTONE_WALL(),
984 Ids::RESIN_BRICK_WALL => Blocks::RESIN_BRICK_WALL(),
985 Ids::SANDSTONE_WALL => Blocks::SANDSTONE_WALL(),
986 Ids::STONE_BRICK_WALL => Blocks::STONE_BRICK_WALL(),
987 Ids::TUFF_BRICK_WALL => Blocks::TUFF_BRICK_WALL(),
988 Ids::TUFF_WALL => Blocks::TUFF_WALL()
989 ] as $id => $block){
990 $reg->mapModel(Model::create($block, $id)->properties($commonProperties->wallProperties));
991 }
992 }
993
994 private static function registerWoodMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
995 //buttons
996 foreach([
997 [Blocks::ACACIA_BUTTON(), Ids::ACACIA_BUTTON],
998 [Blocks::BAMBOO_BUTTON(), Ids::BAMBOO_BUTTON],
999 [Blocks::BIRCH_BUTTON(), Ids::BIRCH_BUTTON],
1000 [Blocks::CHERRY_BUTTON(), Ids::CHERRY_BUTTON],
1001 [Blocks::CRIMSON_BUTTON(), Ids::CRIMSON_BUTTON],
1002 [Blocks::DARK_OAK_BUTTON(), Ids::DARK_OAK_BUTTON],
1003 [Blocks::JUNGLE_BUTTON(), Ids::JUNGLE_BUTTON],
1004 [Blocks::MANGROVE_BUTTON(), Ids::MANGROVE_BUTTON],
1005 [Blocks::OAK_BUTTON(), Ids::WOODEN_BUTTON],
1006 [Blocks::PALE_OAK_BUTTON(), Ids::PALE_OAK_BUTTON],
1007 [Blocks::SPRUCE_BUTTON(), Ids::SPRUCE_BUTTON],
1008 [Blocks::WARPED_BUTTON(), Ids::WARPED_BUTTON]
1009 ] as [$block, $id]){
1010 $reg->mapModel(Model::create($block, $id)->properties($commonProperties->buttonProperties));
1011 }
1012
1013 //doors
1014 foreach([
1015 [Blocks::ACACIA_DOOR(), Ids::ACACIA_DOOR],
1016 [Blocks::BAMBOO_DOOR(), Ids::BAMBOO_DOOR],
1017 [Blocks::BIRCH_DOOR(), Ids::BIRCH_DOOR],
1018 [Blocks::CHERRY_DOOR(), Ids::CHERRY_DOOR],
1019 [Blocks::CRIMSON_DOOR(), Ids::CRIMSON_DOOR],
1020 [Blocks::DARK_OAK_DOOR(), Ids::DARK_OAK_DOOR],
1021 [Blocks::JUNGLE_DOOR(), Ids::JUNGLE_DOOR],
1022 [Blocks::MANGROVE_DOOR(), Ids::MANGROVE_DOOR],
1023 [Blocks::OAK_DOOR(), Ids::WOODEN_DOOR],
1024 [Blocks::PALE_OAK_DOOR(), Ids::PALE_OAK_DOOR],
1025 [Blocks::SPRUCE_DOOR(), Ids::SPRUCE_DOOR],
1026 [Blocks::WARPED_DOOR(), Ids::WARPED_DOOR]
1027 ] as [$block, $id]){
1028 $reg->mapModel(Model::create($block, $id)->properties($commonProperties->doorProperties));
1029 }
1030
1031 //fences
1032 foreach([
1033 [Blocks::ACACIA_FENCE(), Ids::ACACIA_FENCE],
1034 [Blocks::BAMBOO_FENCE(), Ids::BAMBOO_FENCE],
1035 [Blocks::BIRCH_FENCE(), Ids::BIRCH_FENCE],
1036 [Blocks::CHERRY_FENCE(), Ids::CHERRY_FENCE],
1037 [Blocks::DARK_OAK_FENCE(), Ids::DARK_OAK_FENCE],
1038 [Blocks::JUNGLE_FENCE(), Ids::JUNGLE_FENCE],
1039 [Blocks::MANGROVE_FENCE(), Ids::MANGROVE_FENCE],
1040 [Blocks::OAK_FENCE(), Ids::OAK_FENCE],
1041 [Blocks::PALE_OAK_FENCE(), Ids::PALE_OAK_FENCE],
1042 [Blocks::SPRUCE_FENCE(), Ids::SPRUCE_FENCE],
1043 [Blocks::CRIMSON_FENCE(), Ids::CRIMSON_FENCE],
1044 [Blocks::WARPED_FENCE(), Ids::WARPED_FENCE]
1045 ] as [$block, $id]){
1046 $reg->mapSimple($block, $id);
1047 }
1048
1049 foreach([
1050 [Blocks::ACACIA_FENCE_GATE(), Ids::ACACIA_FENCE_GATE],
1051 [Blocks::BAMBOO_FENCE_GATE(), Ids::BAMBOO_FENCE_GATE],
1052 [Blocks::BIRCH_FENCE_GATE(), Ids::BIRCH_FENCE_GATE],
1053 [Blocks::CHERRY_FENCE_GATE(), Ids::CHERRY_FENCE_GATE],
1054 [Blocks::DARK_OAK_FENCE_GATE(), Ids::DARK_OAK_FENCE_GATE],
1055 [Blocks::JUNGLE_FENCE_GATE(), Ids::JUNGLE_FENCE_GATE],
1056 [Blocks::MANGROVE_FENCE_GATE(), Ids::MANGROVE_FENCE_GATE],
1057 [Blocks::OAK_FENCE_GATE(), Ids::FENCE_GATE],
1058 [Blocks::PALE_OAK_FENCE_GATE(), Ids::PALE_OAK_FENCE_GATE],
1059 [Blocks::SPRUCE_FENCE_GATE(), Ids::SPRUCE_FENCE_GATE],
1060 [Blocks::CRIMSON_FENCE_GATE(), Ids::CRIMSON_FENCE_GATE],
1061 [Blocks::WARPED_FENCE_GATE(), Ids::WARPED_FENCE_GATE]
1062 ] as [$block, $id]){
1063 $reg->mapModel(Model::create($block, $id)->properties($commonProperties->fenceGateProperties));
1064 }
1065
1066 foreach([
1067 [Blocks::ACACIA_SIGN(), Ids::ACACIA_STANDING_SIGN],
1068 [Blocks::BAMBOO_SIGN(), Ids::BAMBOO_STANDING_SIGN],
1069 [Blocks::BIRCH_SIGN(), Ids::BIRCH_STANDING_SIGN],
1070 [Blocks::CHERRY_SIGN(), Ids::CHERRY_STANDING_SIGN],
1071 [Blocks::DARK_OAK_SIGN(), Ids::DARKOAK_STANDING_SIGN],
1072 [Blocks::JUNGLE_SIGN(), Ids::JUNGLE_STANDING_SIGN],
1073 [Blocks::MANGROVE_SIGN(), Ids::MANGROVE_STANDING_SIGN],
1074 [Blocks::OAK_SIGN(), Ids::STANDING_SIGN],
1075 [Blocks::PALE_OAK_SIGN(), Ids::PALE_OAK_STANDING_SIGN],
1076 [Blocks::SPRUCE_SIGN(), Ids::SPRUCE_STANDING_SIGN],
1077 [Blocks::CRIMSON_SIGN(), Ids::CRIMSON_STANDING_SIGN],
1078 [Blocks::WARPED_SIGN(), Ids::WARPED_STANDING_SIGN]
1079 ] as [$block, $id]){
1080 $reg->mapModel(Model::create($block, $id)->properties([$commonProperties->floorSignLikeRotation]));
1081 }
1082
1083 //logs
1084 foreach([
1085 [Blocks::ACACIA_LOG(), "acacia_log"],
1086 [Blocks::BIRCH_LOG(), "birch_log"],
1087 [Blocks::CHERRY_LOG(), "cherry_log"],
1088 [Blocks::DARK_OAK_LOG(), "dark_oak_log"],
1089 [Blocks::JUNGLE_LOG(), "jungle_log"],
1090 [Blocks::MANGROVE_LOG(), "mangrove_log"],
1091 [Blocks::OAK_LOG(), "oak_log"],
1092 [Blocks::PALE_OAK_LOG(), "pale_oak_log"],
1093 [Blocks::SPRUCE_LOG(), "spruce_log"],
1094 [Blocks::CRIMSON_STEM(), "crimson_stem"],
1095 [Blocks::WARPED_STEM(), "warped_stem"],
1096
1097 //all-sided logs
1098 [Blocks::ACACIA_WOOD(), "acacia_wood"],
1099 [Blocks::BIRCH_WOOD(), "birch_wood"],
1100 [Blocks::CHERRY_WOOD(), "cherry_wood"],
1101 [Blocks::DARK_OAK_WOOD(), "dark_oak_wood"],
1102 [Blocks::JUNGLE_WOOD(), "jungle_wood"],
1103 [Blocks::MANGROVE_WOOD(), "mangrove_wood"],
1104 [Blocks::OAK_WOOD(), "oak_wood"],
1105 [Blocks::PALE_OAK_WOOD(), "pale_oak_wood"],
1106 [Blocks::SPRUCE_WOOD(), "spruce_wood"],
1107 [Blocks::CRIMSON_HYPHAE(), "crimson_hyphae"],
1108 [Blocks::WARPED_HYPHAE(), "warped_hyphae"],
1109
1110 //bamboo is a special cookie - its name differs and there's no all-sided variant
1111 [Blocks::BAMBOO_BLOCK(), "bamboo_block"],
1112 ] as [$block, $idSuffix]){
1114 ->idComponents([...$commonProperties->woodIdPrefixes, $idSuffix])
1115 ->properties([$commonProperties->pillarAxis])
1116 );
1117 }
1118
1119 //planks
1120 foreach([
1121 [Blocks::ACACIA_PLANKS(), Ids::ACACIA_PLANKS],
1122 [Blocks::BAMBOO_PLANKS(), Ids::BAMBOO_PLANKS],
1123 [Blocks::BAMBOO_MOSAIC(), Ids::BAMBOO_MOSAIC], //special bamboo variant block
1124 [Blocks::BIRCH_PLANKS(), Ids::BIRCH_PLANKS],
1125 [Blocks::CHERRY_PLANKS(), Ids::CHERRY_PLANKS],
1126 [Blocks::DARK_OAK_PLANKS(), Ids::DARK_OAK_PLANKS],
1127 [Blocks::JUNGLE_PLANKS(), Ids::JUNGLE_PLANKS],
1128 [Blocks::MANGROVE_PLANKS(), Ids::MANGROVE_PLANKS],
1129 [Blocks::OAK_PLANKS(), Ids::OAK_PLANKS],
1130 [Blocks::PALE_OAK_PLANKS(), Ids::PALE_OAK_PLANKS],
1131 [Blocks::SPRUCE_PLANKS(), Ids::SPRUCE_PLANKS],
1132 [Blocks::CRIMSON_PLANKS(), Ids::CRIMSON_PLANKS],
1133 [Blocks::WARPED_PLANKS(), Ids::WARPED_PLANKS]
1134 ] as [$block, $id]){
1135 $reg->mapSimple($block, $id);
1136 }
1137
1138 //pressure plates
1139 foreach([
1140 [Blocks::ACACIA_PRESSURE_PLATE(), Ids::ACACIA_PRESSURE_PLATE],
1141 [Blocks::BAMBOO_PRESSURE_PLATE(), Ids::BAMBOO_PRESSURE_PLATE],
1142 [Blocks::BIRCH_PRESSURE_PLATE(), Ids::BIRCH_PRESSURE_PLATE],
1143 [Blocks::CHERRY_PRESSURE_PLATE(), Ids::CHERRY_PRESSURE_PLATE],
1144 [Blocks::DARK_OAK_PRESSURE_PLATE(), Ids::DARK_OAK_PRESSURE_PLATE],
1145 [Blocks::JUNGLE_PRESSURE_PLATE(), Ids::JUNGLE_PRESSURE_PLATE],
1146 [Blocks::MANGROVE_PRESSURE_PLATE(), Ids::MANGROVE_PRESSURE_PLATE],
1147 [Blocks::OAK_PRESSURE_PLATE(), Ids::WOODEN_PRESSURE_PLATE],
1148 [Blocks::PALE_OAK_PRESSURE_PLATE(), Ids::PALE_OAK_PRESSURE_PLATE],
1149 [Blocks::SPRUCE_PRESSURE_PLATE(), Ids::SPRUCE_PRESSURE_PLATE],
1150 [Blocks::CRIMSON_PRESSURE_PLATE(), Ids::CRIMSON_PRESSURE_PLATE],
1151 [Blocks::WARPED_PRESSURE_PLATE(), Ids::WARPED_PRESSURE_PLATE]
1152 ] as [$block, $id]){
1153 $reg->mapModel(Model::create($block, $id)->properties($commonProperties->simplePressurePlateProperties));
1154 }
1155
1156 //slabs
1157 foreach([
1158 [Blocks::ACACIA_SLAB(), "acacia"],
1159 [Blocks::BAMBOO_SLAB(), "bamboo"],
1160 [Blocks::BAMBOO_MOSAIC_SLAB(), "bamboo_mosaic"], //special bamboo variant block
1161 [Blocks::BIRCH_SLAB(), "birch"],
1162 [Blocks::CHERRY_SLAB(), "cherry"],
1163 [Blocks::DARK_OAK_SLAB(), "dark_oak"],
1164 [Blocks::JUNGLE_SLAB(), "jungle"],
1165 [Blocks::MANGROVE_SLAB(), "mangrove"],
1166 [Blocks::OAK_SLAB(), "oak"],
1167 [Blocks::PALE_OAK_SLAB(), "pale_oak"],
1168 [Blocks::SPRUCE_SLAB(), "spruce"],
1169 [Blocks::CRIMSON_SLAB(), "crimson"],
1170 [Blocks::WARPED_SLAB(), "warped"]
1171 ] as [$block, $type]){
1172 $reg->mapSlab($block, $type);
1173 }
1174
1175 //stairs
1176 foreach([
1177 [Blocks::ACACIA_STAIRS(), Ids::ACACIA_STAIRS],
1178 [Blocks::BAMBOO_STAIRS(), Ids::BAMBOO_STAIRS],
1179 [Blocks::BAMBOO_MOSAIC_STAIRS(), Ids::BAMBOO_MOSAIC_STAIRS], //special bamboo variant block
1180 [Blocks::BIRCH_STAIRS(), Ids::BIRCH_STAIRS],
1181 [Blocks::CHERRY_STAIRS(), Ids::CHERRY_STAIRS],
1182 [Blocks::DARK_OAK_STAIRS(), Ids::DARK_OAK_STAIRS],
1183 [Blocks::JUNGLE_STAIRS(), Ids::JUNGLE_STAIRS],
1184 [Blocks::MANGROVE_STAIRS(), Ids::MANGROVE_STAIRS],
1185 [Blocks::OAK_STAIRS(), Ids::OAK_STAIRS],
1186 [Blocks::PALE_OAK_STAIRS(), Ids::PALE_OAK_STAIRS],
1187 [Blocks::SPRUCE_STAIRS(), Ids::SPRUCE_STAIRS],
1188 [Blocks::CRIMSON_STAIRS(), Ids::CRIMSON_STAIRS],
1189 [Blocks::WARPED_STAIRS(), Ids::WARPED_STAIRS]
1190 ] as [$block, $id]){
1191 $reg->mapStairs($block, $id);
1192 }
1193
1194 //trapdoors
1195 foreach([
1196 [Blocks::ACACIA_TRAPDOOR(), Ids::ACACIA_TRAPDOOR],
1197 [Blocks::BAMBOO_TRAPDOOR(), Ids::BAMBOO_TRAPDOOR],
1198 [Blocks::BIRCH_TRAPDOOR(), Ids::BIRCH_TRAPDOOR],
1199 [Blocks::CHERRY_TRAPDOOR(), Ids::CHERRY_TRAPDOOR],
1200 [Blocks::DARK_OAK_TRAPDOOR(), Ids::DARK_OAK_TRAPDOOR],
1201 [Blocks::JUNGLE_TRAPDOOR(), Ids::JUNGLE_TRAPDOOR],
1202 [Blocks::MANGROVE_TRAPDOOR(), Ids::MANGROVE_TRAPDOOR],
1203 [Blocks::OAK_TRAPDOOR(), Ids::TRAPDOOR],
1204 [Blocks::PALE_OAK_TRAPDOOR(), Ids::PALE_OAK_TRAPDOOR],
1205 [Blocks::SPRUCE_TRAPDOOR(), Ids::SPRUCE_TRAPDOOR],
1206 [Blocks::CRIMSON_TRAPDOOR(), Ids::CRIMSON_TRAPDOOR],
1207 [Blocks::WARPED_TRAPDOOR(), Ids::WARPED_TRAPDOOR]
1208 ] as [$block, $id]){
1209 $reg->mapModel(Model::create($block, $id)->properties($commonProperties->trapdoorProperties));
1210 }
1211
1212 //wall signs
1213 foreach([
1214 [Blocks::ACACIA_WALL_SIGN(), Ids::ACACIA_WALL_SIGN],
1215 [Blocks::BAMBOO_WALL_SIGN(), Ids::BAMBOO_WALL_SIGN],
1216 [Blocks::BIRCH_WALL_SIGN(), Ids::BIRCH_WALL_SIGN],
1217 [Blocks::CHERRY_WALL_SIGN(), Ids::CHERRY_WALL_SIGN],
1218 [Blocks::DARK_OAK_WALL_SIGN(), Ids::DARKOAK_WALL_SIGN],
1219 [Blocks::JUNGLE_WALL_SIGN(), Ids::JUNGLE_WALL_SIGN],
1220 [Blocks::MANGROVE_WALL_SIGN(), Ids::MANGROVE_WALL_SIGN],
1221 [Blocks::OAK_WALL_SIGN(), Ids::WALL_SIGN],
1222 [Blocks::PALE_OAK_WALL_SIGN(), Ids::PALE_OAK_WALL_SIGN],
1223 [Blocks::SPRUCE_WALL_SIGN(), Ids::SPRUCE_WALL_SIGN],
1224 [Blocks::CRIMSON_WALL_SIGN(), Ids::CRIMSON_WALL_SIGN],
1225 [Blocks::WARPED_WALL_SIGN(), Ids::WARPED_WALL_SIGN]
1226 ] as [$block, $id]){
1227 $reg->mapModel(Model::create($block, $id)->properties([$commonProperties->horizontalFacingClassic]));
1228 }
1229 }
1230
1231 private static function registerTorchMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
1232 foreach([
1233 [Blocks::BLUE_TORCH(), Ids::COLORED_TORCH_BLUE],
1234 [Blocks::COPPER_TORCH(), Ids::COPPER_TORCH],
1235 [Blocks::GREEN_TORCH(), Ids::COLORED_TORCH_GREEN],
1236 [Blocks::PURPLE_TORCH(), Ids::COLORED_TORCH_PURPLE],
1237 [Blocks::RED_TORCH(), Ids::COLORED_TORCH_RED],
1238 [Blocks::SOUL_TORCH(), Ids::SOUL_TORCH],
1239 [Blocks::TORCH(), Ids::TORCH],
1240 [Blocks::UNDERWATER_TORCH(), Ids::UNDERWATER_TORCH]
1241 ] as [$block, $id]){
1242 $reg->mapModel(Model::create($block, $id)->properties([$commonProperties->torchFacing]));
1243 }
1244 }
1245
1246 private static function registerChemistryMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
1247 foreach([
1248 [Blocks::COMPOUND_CREATOR(), Ids::COMPOUND_CREATOR],
1249 [Blocks::ELEMENT_CONSTRUCTOR(), Ids::ELEMENT_CONSTRUCTOR],
1250 [Blocks::LAB_TABLE(), Ids::LAB_TABLE],
1251 [Blocks::MATERIAL_REDUCER(), Ids::MATERIAL_REDUCER],
1252 ] as [$block, $id]){
1253 $reg->mapModel(Model::create($block, $id)->properties([$commonProperties->horizontalFacingSWNEInverted]));
1254 }
1255 }
1256
1257 private static function register1to1CustomMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
1258 //TODO: some of these have repeated accessor refs, we might be able to deduplicate them
1259 //A
1260 $reg->mapModel(Model::create(Blocks::ACTIVATOR_RAIL(), Ids::ACTIVATOR_RAIL)->properties([
1261 new BoolProperty(StateNames::RAIL_DATA_BIT, fn(ActivatorRail $b) => $b->isPowered(), fn(ActivatorRail $b, bool $v) => $b->setPowered($v)),
1262 new IntProperty(StateNames::RAIL_DIRECTION, 0, 5, fn(ActivatorRail $b) => $b->getShape(), fn(ActivatorRail $b, int $v) => $b->setShape($v))
1263 ]));
1264
1265 //B
1266 $reg->mapModel(Model::create(Blocks::BAMBOO(), Ids::BAMBOO)->properties([
1267 new ValueFromStringProperty(StateNames::BAMBOO_LEAF_SIZE, ValueMappings::getInstance()->bambooLeafSize, fn(Bamboo $b) => $b->getLeafSize(), fn(Bamboo $b, int $v) => $b->setLeafSize($v)),
1268 new BoolProperty(StateNames::AGE_BIT, fn(Bamboo $b) => $b->isReady(), fn(Bamboo $b, bool $v) => $b->setReady($v)),
1269 new BoolFromStringProperty(StateNames::BAMBOO_STALK_THICKNESS, StringValues::BAMBOO_STALK_THICKNESS_THIN, StringValues::BAMBOO_STALK_THICKNESS_THICK, fn(Bamboo $b) => $b->isThick(), fn(Bamboo $b, bool $v) => $b->setThick($v))
1270 ]));
1271 $reg->mapModel(Model::create(Blocks::BAMBOO_SAPLING(), Ids::BAMBOO_SAPLING)->properties([
1272 new BoolProperty(StateNames::AGE_BIT, fn(BambooSapling $b) => $b->isReady(), fn(BambooSapling $b, bool $v) => $b->setReady($v))
1273 ]));
1274 $reg->mapModel(Model::create(Blocks::BANNER(), Ids::STANDING_BANNER)->properties([$commonProperties->floorSignLikeRotation]));
1275 $reg->mapModel(Model::create(Blocks::BARREL(), Ids::BARREL)->properties([
1276 $commonProperties->anyFacingClassic,
1277 new BoolProperty(StateNames::OPEN_BIT, fn(Barrel $b) => $b->isOpen(), fn(Barrel $b, bool $v) => $b->setOpen($v))
1278 ]));
1279 $reg->mapModel(Model::create(Blocks::BASALT(), Ids::BASALT)->properties([$commonProperties->pillarAxis]));
1280 $reg->mapModel(Model::create(Blocks::BED(), Ids::BED)->properties([
1281 new BoolProperty(StateNames::HEAD_PIECE_BIT, fn(Bed $b) => $b->isHeadPart(), fn(Bed $b, bool $v) => $b->setHead($v)),
1282 new BoolProperty(StateNames::OCCUPIED_BIT, fn(Bed $b) => $b->isOccupied(), fn(Bed $b, bool $v) => $b->setOccupied($v)),
1283 $commonProperties->horizontalFacingSWNE
1284 ]));
1285 $reg->mapModel(Model::create(Blocks::BEDROCK(), Ids::BEDROCK)->properties([
1286 new BoolProperty(StateNames::INFINIBURN_BIT, fn(Bedrock $b) => $b->burnsForever(), fn(Bedrock $b, bool $v) => $b->setBurnsForever($v))
1287 ]));
1288 $reg->mapModel(Model::create(Blocks::BELL(), Ids::BELL)->properties([
1289 BoolProperty::unused(StateNames::TOGGLE_BIT, false),
1290 new ValueFromStringProperty(StateNames::ATTACHMENT, ValueMappings::getInstance()->bellAttachmentType, fn(Bell $b) => $b->getAttachmentType(), fn(Bell $b, BellAttachmentType $v) => $b->setAttachmentType($v)),
1291 $commonProperties->horizontalFacingSWNE
1292 ]));
1293 $reg->mapModel(Model::create(Blocks::BONE_BLOCK(), Ids::BONE_BLOCK)->properties([
1294 IntProperty::unused(StateNames::DEPRECATED, 0),
1295 $commonProperties->pillarAxis
1296 ]));
1297
1298 $reg->mapModel(Model::create(Blocks::BREWING_STAND(), Ids::BREWING_STAND)->properties(array_map(fn(BrewingStandSlot $slot) => new BoolProperty(match ($slot) {
1299 BrewingStandSlot::EAST => StateNames::BREWING_STAND_SLOT_A_BIT,
1300 BrewingStandSlot::SOUTHWEST => StateNames::BREWING_STAND_SLOT_B_BIT,
1301 BrewingStandSlot::NORTHWEST => StateNames::BREWING_STAND_SLOT_C_BIT
1302 }, fn(BrewingStand $b) => $b->hasSlot($slot), fn(BrewingStand $b, bool $v) => $b->setSlot($slot, $v)), BrewingStandSlot::cases())));
1303
1304 //C
1305 $reg->mapModel(Model::create(Blocks::CACTUS(), Ids::CACTUS)->properties([
1306 new IntProperty(StateNames::AGE, 0, 15, fn(Cactus $b) => $b->getAge(), fn(Cactus $b, int $v) => $b->setAge($v))
1307 ]));
1308 $reg->mapModel(Model::create(Blocks::CAKE(), Ids::CAKE)->properties([
1309 new IntProperty(StateNames::BITE_COUNTER, 0, 6, fn(Cake $b) => $b->getBites(), fn(Cake $b, int $v) => $b->setBites($v))
1310 ]));
1311 $reg->mapModel(Model::create(Blocks::CAMPFIRE(), Ids::CAMPFIRE)->properties($commonProperties->campfireProperties));
1312 $reg->mapModel(Model::create(Blocks::CARVED_PUMPKIN(), Ids::CARVED_PUMPKIN)->properties([
1313 $commonProperties->horizontalFacingCardinal
1314 ]));
1315 $reg->mapModel(Model::create(Blocks::CHAIN(), Ids::IRON_CHAIN)->properties([$commonProperties->pillarAxis]));
1316 $reg->mapModel(Model::create(Blocks::CHISELED_BOOKSHELF(), Ids::CHISELED_BOOKSHELF)->properties([
1317 $commonProperties->horizontalFacingSWNE,
1319 StateNames::BOOKS_STORED,
1320 EnumFromRawStateMap::int(ChiseledBookshelfSlot::class, fn(ChiseledBookshelfSlot $case) => match($case){
1321 //these are (currently) the same as the internal values, but it's best not to rely on those in case Mojang mess with the flags
1322 ChiseledBookshelfSlot::TOP_LEFT => 1 << 0,
1323 ChiseledBookshelfSlot::TOP_MIDDLE => 1 << 1,
1324 ChiseledBookshelfSlot::TOP_RIGHT => 1 << 2,
1325 ChiseledBookshelfSlot::BOTTOM_LEFT => 1 << 3,
1326 ChiseledBookshelfSlot::BOTTOM_MIDDLE => 1 << 4,
1327 ChiseledBookshelfSlot::BOTTOM_RIGHT => 1 << 5
1328 }),
1329 fn(ChiseledBookshelf $b) => $b->getSlots(),
1330 fn(ChiseledBookshelf $b, array $v) => $b->setSlots($v)
1331 )
1332 ]));
1333 $reg->mapModel(Model::create(Blocks::CHISELED_QUARTZ(), Ids::CHISELED_QUARTZ_BLOCK)->properties([$commonProperties->pillarAxis]));
1334 $reg->mapModel(Model::create(Blocks::CHEST(), Ids::CHEST)->properties([$commonProperties->horizontalFacingCardinal]));
1335 $reg->mapModel(Model::create(Blocks::CHORUS_FLOWER(), Ids::CHORUS_FLOWER)->properties([
1336 new IntProperty(StateNames::AGE, ChorusFlower::MIN_AGE, ChorusFlower::MAX_AGE, fn(ChorusFlower $b) => $b->getAge(), fn(ChorusFlower $b, int $v) => $b->setAge($v))
1337 ]));
1338 $reg->mapModel(Model::create(Blocks::COCOA_POD(), Ids::COCOA)->properties([
1339 new IntProperty(StateNames::AGE, 0, 2, fn(CocoaBlock $b) => $b->getAge(), fn(CocoaBlock $b, int $v) => $b->setAge($v)),
1340 $commonProperties->horizontalFacingSWNEInverted
1341 ]));
1342
1343 //D
1344 $reg->mapModel(Model::create(Blocks::DEEPSLATE(), Ids::DEEPSLATE)->properties([$commonProperties->pillarAxis]));
1345 $reg->mapModel(Model::create(Blocks::DETECTOR_RAIL(), Ids::DETECTOR_RAIL)->properties([
1346 new BoolProperty(StateNames::RAIL_DATA_BIT, fn(DetectorRail $b) => $b->isActivated(), fn(DetectorRail $b, bool $v) => $b->setActivated($v)),
1347 new IntProperty(StateNames::RAIL_DIRECTION, 0, 5, fn(StraightOnlyRail $b) => $b->getShape(), fn(StraightOnlyRail $b, int $v) => $b->setShape($v)) //TODO: shared with ActivatorRail
1348 ]));
1349
1350 //E
1351 $reg->mapModel(Model::create(Blocks::ENDER_CHEST(), Ids::ENDER_CHEST)->properties([$commonProperties->horizontalFacingCardinal]));
1352 $reg->mapModel(Model::create(Blocks::END_PORTAL_FRAME(), Ids::END_PORTAL_FRAME)->properties([
1353 new BoolProperty(StateNames::END_PORTAL_EYE_BIT, fn(EndPortalFrame $b) => $b->hasEye(), fn(EndPortalFrame $b, bool $v) => $b->setEye($v)),
1354 $commonProperties->horizontalFacingCardinal
1355 ]));
1356 $reg->mapModel(Model::create(Blocks::END_ROD(), Ids::END_ROD)->properties([
1357 new ValueFromIntProperty(StateNames::FACING_DIRECTION, ValueMappings::getInstance()->facingEndRod, fn(EndRod $b) => $b->getFacing(), fn(EndRod $b, int $v) => $b->setFacing($v)),
1358 ]));
1359
1360 //F
1361 $reg->mapModel(Model::create(Blocks::FARMLAND(), Ids::FARMLAND)->properties([
1362 new IntProperty(StateNames::MOISTURIZED_AMOUNT, 0, 7, fn(Farmland $b) => $b->getWetness(), fn(Farmland $b, int $v) => $b->setWetness($v))
1363 ]));
1364 $reg->mapModel(Model::create(Blocks::FIRE(), Ids::FIRE)->properties([
1365 new IntProperty(StateNames::AGE, 0, 15, fn(Fire $b) => $b->getAge(), fn(Fire $b, int $v) => $b->setAge($v))
1366 ]));
1367 $reg->mapModel(Model::create(Blocks::FLOWER_POT(), Ids::FLOWER_POT)->properties([
1368 BoolProperty::unused(StateNames::UPDATE_BIT, false)
1369 ]));
1370 $reg->mapModel(Model::create(Blocks::FROSTED_ICE(), Ids::FROSTED_ICE)->properties([
1371 new IntProperty(StateNames::AGE, 0, 3, fn(FrostedIce $b) => $b->getAge(), fn(FrostedIce $b, int $v) => $b->setAge($v))
1372 ]));
1373
1374 //G
1375 $reg->mapModel(Model::create(Blocks::GLOWING_ITEM_FRAME(), Ids::GLOW_FRAME)->properties($commonProperties->itemFrameProperties));
1376
1377 //H
1378 $reg->mapModel(Model::create(Blocks::HAY_BALE(), Ids::HAY_BLOCK)->properties([
1379 IntProperty::unused(StateNames::DEPRECATED, 0),
1380 $commonProperties->pillarAxis
1381 ]));
1382 $reg->mapModel(Model::create(Blocks::HOPPER(), Ids::HOPPER)->properties([
1383 //kinda weird this doesn't use powered_bit?
1384 new BoolProperty(StateNames::TOGGLE_BIT, fn(PoweredByRedstone $b) => $b->isPowered(), fn(PoweredByRedstone $b, bool $v) => $b->setPowered($v)),
1385 new ValueFromIntProperty(StateNames::FACING_DIRECTION, ValueMappings::getInstance()->facingExceptUp, fn(Hopper $b) => $b->getFacing(), fn(Hopper $b, int $v) => $b->setFacing($v)),
1386 ]));
1387
1388 //I
1389 $reg->mapModel(Model::create(Blocks::INFESTED_DEEPSLATE(), Ids::INFESTED_DEEPSLATE)->properties([$commonProperties->pillarAxis]));
1390 $reg->mapModel(Model::create(Blocks::IRON_DOOR(), Ids::IRON_DOOR)->properties($commonProperties->doorProperties));
1391 $reg->mapModel(Model::create(Blocks::IRON_TRAPDOOR(), Ids::IRON_TRAPDOOR)->properties($commonProperties->trapdoorProperties));
1392 $reg->mapModel(Model::create(Blocks::ITEM_FRAME(), Ids::FRAME)->properties($commonProperties->itemFrameProperties));
1393
1394 //L
1395 $reg->mapModel(Model::create(Blocks::LADDER(), Ids::LADDER)->properties([$commonProperties->horizontalFacingClassic]));
1396 $reg->mapModel(Model::create(Blocks::LANTERN(), Ids::LANTERN)->properties([
1397 new BoolProperty(StateNames::HANGING, fn(Lantern $b) => $b->isHanging(), fn(Lantern $b, bool $v) => $b->setHanging($v))
1398 ]));
1399 $reg->mapModel(Model::create(Blocks::LECTERN(), Ids::LECTERN)->properties([
1400 new BoolProperty(StateNames::POWERED_BIT, fn(Lectern $b) => $b->isProducingSignal(), fn(Lectern $b, bool $v) => $b->setProducingSignal($v)),
1401 $commonProperties->horizontalFacingCardinal,
1402 ]));
1403 $reg->mapModel(Model::create(Blocks::LEVER(), Ids::LEVER)->properties([
1404 new ValueFromStringProperty(StateNames::LEVER_DIRECTION, ValueMappings::getInstance()->leverFacing, fn(Lever $b) => $b->getFacing(), fn(Lever $b, LeverFacing $v) => $b->setFacing($v)),
1405 new BoolProperty(StateNames::OPEN_BIT, fn(Lever $b) => $b->isActivated(), fn(Lever $b, bool $v) => $b->setActivated($v)),
1406 ]));
1407 $reg->mapModel(Model::create(Blocks::LIT_PUMPKIN(), Ids::LIT_PUMPKIN)->properties([$commonProperties->horizontalFacingCardinal]));
1408 $reg->mapModel(Model::create(Blocks::LOOM(), Ids::LOOM)->properties([$commonProperties->horizontalFacingSWNE]));
1409
1410 //M
1411 $reg->mapModel(Model::create(Blocks::MUDDY_MANGROVE_ROOTS(), Ids::MUDDY_MANGROVE_ROOTS)->properties([$commonProperties->pillarAxis]));
1412 $reg->mapModel(Model::create(Blocks::NETHER_WART(), Ids::NETHER_WART)->properties([
1413 new IntProperty(StateNames::AGE, 0, 3, fn(NetherWartPlant $b) => $b->getAge(), fn(NetherWartPlant $b, int $v) => $b->setAge($v))
1414 ]));
1415 $reg->mapModel(Model::create(Blocks::NETHER_PORTAL(), Ids::PORTAL)->properties([
1416 new ValueFromStringProperty(StateNames::PORTAL_AXIS, ValueMappings::getInstance()->portalAxis, fn(NetherPortal $b) => $b->getAxis(), fn(NetherPortal $b, int $v) => $b->setAxis($v))
1417 ]));
1418
1419 //P
1420 $reg->mapModel(Model::create(Blocks::PINK_PETALS(), Ids::PINK_PETALS)->properties([
1421 //Pink petals only uses 0-3, but GROWTH state can go up to 7
1422 new IntProperty(StateNames::GROWTH, 0, 7, fn(PinkPetals $b) => $b->getCount(), fn(PinkPetals $b, int $v) => $b->setCount(min($v, PinkPetals::MAX_COUNT)), offset: 1),
1423 $commonProperties->horizontalFacingCardinal
1424 ]));
1425 $reg->mapModel(Model::create(Blocks::POWERED_RAIL(), Ids::GOLDEN_RAIL)->properties([
1426 new BoolProperty(StateNames::RAIL_DATA_BIT, fn(PoweredRail $b) => $b->isPowered(), fn(PoweredRail $b, bool $v) => $b->setPowered($v)), //TODO: shared with ActivatorRail
1427 new IntProperty(StateNames::RAIL_DIRECTION, 0, 5, fn(StraightOnlyRail $b) => $b->getShape(), fn(StraightOnlyRail $b, int $v) => $b->setShape($v)) //TODO: shared with ActivatorRail
1428 ]));
1429 $reg->mapModel(Model::create(Blocks::PITCHER_PLANT(), Ids::PITCHER_PLANT)->properties([
1430 new BoolProperty(StateNames::UPPER_BLOCK_BIT, fn(DoublePlant $b) => $b->isTop(), fn(DoublePlant $b, bool $v) => $b->setTop($v)), //TODO: don't we have helpers for this?
1431 ]));
1432 $reg->mapModel(Model::create(Blocks::POLISHED_BASALT(), Ids::POLISHED_BASALT)->properties([$commonProperties->pillarAxis]));
1433 $reg->mapModel(Model::create(Blocks::POLISHED_BLACKSTONE_BUTTON(), Ids::POLISHED_BLACKSTONE_BUTTON)->properties($commonProperties->buttonProperties));
1434 $reg->mapModel(Model::create(Blocks::POLISHED_BLACKSTONE_PRESSURE_PLATE(), Ids::POLISHED_BLACKSTONE_PRESSURE_PLATE)->properties($commonProperties->simplePressurePlateProperties));
1435 $reg->mapModel(Model::create(Blocks::PUMPKIN(), Ids::PUMPKIN)->properties([
1436 //not used, has no visible effect
1437 $commonProperties->dummyCardinalDirection
1438 ]));
1439 $reg->mapModel(Model::create(Blocks::PURPUR(), Ids::PURPUR_BLOCK)->properties([
1440 $commonProperties->dummyPillarAxis
1441 ]));
1442 $reg->mapModel(Model::create(Blocks::PURPUR_PILLAR(), Ids::PURPUR_PILLAR)->properties([$commonProperties->pillarAxis]));
1443
1444 //Q
1445 $reg->mapModel(Model::create(Blocks::QUARTZ(), Ids::QUARTZ_BLOCK)->properties([
1446 $commonProperties->dummyPillarAxis
1447 ]));
1448 $reg->mapModel(Model::create(Blocks::QUARTZ_PILLAR(), Ids::QUARTZ_PILLAR)->properties([$commonProperties->pillarAxis]));
1449
1450 //R
1451 $reg->mapModel(Model::create(Blocks::RAIL(), Ids::RAIL)->properties([
1452 new IntProperty(StateNames::RAIL_DIRECTION, 0, 9, fn(Rail $b) => $b->getShape(), fn(Rail $b, int $v) => $b->setShape($v))
1453 ]));
1454 $reg->mapModel(Model::create(Blocks::REDSTONE_WIRE(), Ids::REDSTONE_WIRE)->properties([$commonProperties->analogRedstoneSignal]));
1455 $reg->mapModel(Model::create(Blocks::RESPAWN_ANCHOR(), Ids::RESPAWN_ANCHOR)->properties([
1456 new IntProperty(StateNames::RESPAWN_ANCHOR_CHARGE, 0, 4, fn(RespawnAnchor $b) => $b->getCharges(), fn(RespawnAnchor $b, int $v) => $b->setCharges($v))
1457 ]));
1458
1459 //S
1460 $reg->mapModel(Model::create(Blocks::SEA_PICKLE(), Ids::SEA_PICKLE)->properties([
1461 new IntProperty(StateNames::CLUSTER_COUNT, 0, 3, fn(SeaPickle $b) => $b->getCount(), fn(SeaPickle $b, int $v) => $b->setCount($v), offset: 1),
1462 new BoolProperty(StateNames::DEAD_BIT, fn(SeaPickle $b) => $b->isUnderwater(), fn(SeaPickle $b, bool $v) => $b->setUnderwater($v), inverted: true)
1463 ]));
1464 $reg->mapModel(Model::create(Blocks::SMALL_DRIPLEAF(), Ids::SMALL_DRIPLEAF_BLOCK)->properties([
1465 new BoolProperty(StateNames::UPPER_BLOCK_BIT, fn(SmallDripleaf $b) => $b->isTop(), fn(SmallDripleaf $b, bool $v) => $b->setTop($v)),
1466 $commonProperties->horizontalFacingCardinal
1467 ]));
1468 $reg->mapModel(Model::create(Blocks::SMOOTH_QUARTZ(), Ids::SMOOTH_QUARTZ)->properties([
1469 $commonProperties->dummyPillarAxis
1470 ]));
1471 $reg->mapModel(Model::create(Blocks::SNOW_LAYER(), Ids::SNOW_LAYER)->properties([
1472 new DummyProperty(StateNames::COVERED_BIT, false),
1473 new IntProperty(StateNames::HEIGHT, 0, 7, fn(SnowLayer $b) => $b->getLayers(), fn(SnowLayer $b, int $v) => $b->setLayers($v), offset: 1)
1474 ]));
1475 $reg->mapModel(Model::create(Blocks::SOUL_CAMPFIRE(), Ids::SOUL_CAMPFIRE)->properties($commonProperties->campfireProperties));
1476 $reg->mapModel(Model::create(Blocks::SOUL_FIRE(), Ids::SOUL_FIRE)->properties([
1477 new DummyProperty(StateNames::AGE, 0) //this is useless for soul fire, since it doesn't have the logic associated
1478 ]));
1479 $reg->mapModel(Model::create(Blocks::SOUL_LANTERN(), Ids::SOUL_LANTERN)->properties([
1480 new BoolProperty(StateNames::HANGING, fn(Lantern $b) => $b->isHanging(), fn(Lantern $b, bool $v) => $b->setHanging($v)) //TODO: repeated
1481 ]));
1482 $reg->mapModel(Model::create(Blocks::STONE_BUTTON(), Ids::STONE_BUTTON)->properties($commonProperties->buttonProperties));
1483 $reg->mapModel(Model::create(Blocks::STONE_PRESSURE_PLATE(), Ids::STONE_PRESSURE_PLATE)->properties($commonProperties->simplePressurePlateProperties));
1484 $reg->mapModel(Model::create(Blocks::STONECUTTER(), Ids::STONECUTTER_BLOCK)->properties([
1485 $commonProperties->horizontalFacingCardinal
1486 ]));
1487 $reg->mapModel(Model::create(Blocks::SUGARCANE(), Ids::REEDS)->properties([
1488 new IntProperty(StateNames::AGE, 0, 15, fn(Sugarcane $b) => $b->getAge(), fn(Sugarcane $b, int $v) => $b->setAge($v))
1489 ]));
1490
1491 //T
1492 $reg->mapModel(Model::create(Blocks::TRAPPED_CHEST(), Ids::TRAPPED_CHEST)->properties([
1493 $commonProperties->horizontalFacingCardinal
1494 ]));
1495 $reg->mapModel(Model::create(Blocks::TRIPWIRE(), Ids::TRIP_WIRE)->properties([
1496 new BoolProperty(StateNames::ATTACHED_BIT, fn(Tripwire $b) => $b->isConnected(), fn(Tripwire $b, bool $v) => $b->setConnected($v)),
1497 new BoolProperty(StateNames::DISARMED_BIT, fn(Tripwire $b) => $b->isDisarmed(), fn(Tripwire $b, bool $v) => $b->setDisarmed($v)),
1498 new BoolProperty(StateNames::SUSPENDED_BIT, fn(Tripwire $b) => $b->isSuspended(), fn(Tripwire $b, bool $v) => $b->setSuspended($v)),
1499 new BoolProperty(StateNames::POWERED_BIT, fn(Tripwire $b) => $b->isTriggered(), fn(Tripwire $b, bool $v) => $b->setTriggered($v)),
1500 ]));
1501 $reg->mapModel(Model::create(Blocks::TRIPWIRE_HOOK(), Ids::TRIPWIRE_HOOK)->properties([
1502 new BoolProperty(StateNames::ATTACHED_BIT, fn(TripwireHook $b) => $b->isConnected(), fn(TripwireHook $b, bool $v) => $b->setConnected($v)),
1503 new BoolProperty(StateNames::POWERED_BIT, fn(TripwireHook $b) => $b->isPowered(), fn(TripwireHook $b, bool $v) => $b->setPowered($v)),
1504 $commonProperties->horizontalFacingSWNE
1505 ]));
1506
1507 $reg->mapModel(Model::create(Blocks::TWISTING_VINES(), Ids::TWISTING_VINES)->properties([
1508 new IntProperty(StateNames::TWISTING_VINES_AGE, 0, 25, fn(NetherVines $b) => $b->getAge(), fn(NetherVines $b, int $v) => $b->setAge($v))
1509 ]));
1510
1511 //W
1512 $reg->mapModel(Model::create(Blocks::WALL_BANNER(), Ids::WALL_BANNER)->properties([$commonProperties->horizontalFacingClassic]));
1513 $reg->mapModel(Model::create(Blocks::WEEPING_VINES(), Ids::WEEPING_VINES)->properties([
1514 new IntProperty(StateNames::WEEPING_VINES_AGE, 0, 25, fn(NetherVines $b) => $b->getAge(), fn(NetherVines $b, int $v) => $b->setAge($v))
1515 ]));
1516 $reg->mapModel(Model::create(Blocks::WEIGHTED_PRESSURE_PLATE_HEAVY(), Ids::HEAVY_WEIGHTED_PRESSURE_PLATE)->properties([$commonProperties->analogRedstoneSignal]));
1517 $reg->mapModel(Model::create(Blocks::WEIGHTED_PRESSURE_PLATE_LIGHT(), Ids::LIGHT_WEIGHTED_PRESSURE_PLATE)->properties([$commonProperties->analogRedstoneSignal]));
1518 }
1519
1524 private static function mapAsymmetricSerializer(BlockSerializerDeserializerRegistrar $reg, Model $model) : void{
1525 $id = $model->getId();
1526 $properties = $model->getProperties();
1527 $reg->serializer->map($model->getBlock(), function(Block $block) use ($id, $properties) : Writer{
1528 $writer = new Writer($id);
1529 foreach($properties as $property){
1530 $property->serialize($block, $writer);
1531 }
1532 return $writer;
1533 });
1534 }
1535
1541 private static function deserializeAsymmetric(Model $model, Reader $in) : Block{
1542 $block = clone $model->getBlock();
1543 foreach($model->getProperties() as $property){
1544 $property->deserialize($block, $in);
1545 }
1546 return $block;
1547 }
1548
1555 private static function registerSplitMappings(BlockSerializerDeserializerRegistrar $reg, CommonProperties $commonProperties) : void{
1556 //big dripleaf - split into head / stem variants, as stems don't have tilt or leaf state
1557 $bigDripleafHeadModel = Model::create(Blocks::BIG_DRIPLEAF_HEAD(), Ids::BIG_DRIPLEAF)->properties([
1558 $commonProperties->horizontalFacingCardinal,
1559 new ValueFromStringProperty(StateNames::BIG_DRIPLEAF_TILT, ValueMappings::getInstance()->dripleafState, fn(BigDripleafHead $b) => $b->getLeafState(), fn(BigDripleafHead $b, DripleafState $v) => $b->setLeafState($v)),
1560 new DummyProperty(StateNames::BIG_DRIPLEAF_HEAD, true)
1561 ]);
1562 $bigDripleafStemModel = Model::create(Blocks::BIG_DRIPLEAF_STEM(), Ids::BIG_DRIPLEAF)->properties([
1563 $commonProperties->horizontalFacingCardinal,
1564 new DummyProperty(StateNames::BIG_DRIPLEAF_TILT, StringValues::BIG_DRIPLEAF_TILT_NONE),
1565 new DummyProperty(StateNames::BIG_DRIPLEAF_HEAD, false)
1566 ]);
1567 self::mapAsymmetricSerializer($reg, $bigDripleafHeadModel);
1568 self::mapAsymmetricSerializer($reg, $bigDripleafStemModel);
1569 $reg->deserializer->map(Ids::BIG_DRIPLEAF, fn(Reader $in) => $in->readBool(StateNames::BIG_DRIPLEAF_HEAD) ?
1570 self::deserializeAsymmetric($bigDripleafHeadModel, $in) :
1571 self::deserializeAsymmetric($bigDripleafStemModel, $in)
1572 );
1573
1574 $fillLevelProperty = new IntProperty(StateNames::FILL_LEVEL, 1, 6, fn(FillableCauldron $b) => $b->getFillLevel(), fn(FillableCauldron $b, int $v) => $b->setFillLevel($v));
1575
1576 //this pretends to be a water cauldron on disk and stores its real information in the block actor data, therefore only a serializer is needed
1577 self::mapAsymmetricSerializer($reg, Model::create(Blocks::POTION_CAULDRON(), Ids::CAULDRON)->properties([$fillLevelProperty, new DummyProperty(StateNames::CAULDRON_LIQUID, StringValues::CAULDRON_LIQUID_WATER)]));
1578
1579 $lavaCauldronModel = Model::create(Blocks::LAVA_CAULDRON(), Ids::CAULDRON)->properties([
1580 $fillLevelProperty,
1581 new DummyProperty(StateNames::CAULDRON_LIQUID, StringValues::CAULDRON_LIQUID_LAVA)
1582 ]);
1583 $waterCauldronModel = Model::create(Blocks::WATER_CAULDRON(), Ids::CAULDRON)->properties([
1584 $fillLevelProperty,
1585 new DummyProperty(StateNames::CAULDRON_LIQUID, StringValues::CAULDRON_LIQUID_WATER)
1586 ]);
1587 $emptyCauldronModel = Model::create(Blocks::CAULDRON(), Ids::CAULDRON)->properties([
1588 new DummyProperty(StateNames::FILL_LEVEL, 0),
1589 new DummyProperty(StateNames::CAULDRON_LIQUID, StringValues::CAULDRON_LIQUID_WATER)
1590 ]);
1591 self::mapAsymmetricSerializer($reg, $lavaCauldronModel);
1592 self::mapAsymmetricSerializer($reg, $waterCauldronModel);
1593 self::mapAsymmetricSerializer($reg, $emptyCauldronModel);
1594 $reg->deserializer->map(Ids::CAULDRON, fn(Reader $in) => $in->readInt(StateNames::FILL_LEVEL) === 0 ?
1595 self::deserializeAsymmetric($emptyCauldronModel, $in) :
1596 match ($liquid = $in->readString(StateNames::CAULDRON_LIQUID)) {
1597 StringValues::CAULDRON_LIQUID_WATER => self::deserializeAsymmetric($waterCauldronModel, $in),
1598 StringValues::CAULDRON_LIQUID_LAVA => self::deserializeAsymmetric($lavaCauldronModel, $in),
1599 StringValues::CAULDRON_LIQUID_POWDER_SNOW => throw new UnsupportedBlockStateException("Powder snow is not supported yet"),
1600 default => throw $in->badValueException(StateNames::CAULDRON_LIQUID, $liquid)
1601 }
1602 );
1603
1604 //mushroom stems, split for consistency with all-sided logs vs normal logs
1605 $allSidedMushroomStemModel = Model::create(Blocks::ALL_SIDED_MUSHROOM_STEM(), Ids::MUSHROOM_STEM)->properties([new DummyProperty(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM)]);
1606 $mushroomStemModel = Model::create(Blocks::MUSHROOM_STEM(), Ids::MUSHROOM_STEM)->properties([new DummyProperty(StateNames::HUGE_MUSHROOM_BITS, BlockLegacyMetadata::MUSHROOM_BLOCK_STEM)]);
1607 self::mapAsymmetricSerializer($reg, $allSidedMushroomStemModel);
1608 self::mapAsymmetricSerializer($reg, $mushroomStemModel);
1609 $reg->deserializer->map(Ids::MUSHROOM_STEM, fn(Reader $in) : Block => match ($in->readInt(StateNames::HUGE_MUSHROOM_BITS)) {
1610 BlockLegacyMetadata::MUSHROOM_BLOCK_ALL_STEM => self::deserializeAsymmetric($allSidedMushroomStemModel, $in),
1611 BlockLegacyMetadata::MUSHROOM_BLOCK_STEM => self::deserializeAsymmetric($mushroomStemModel, $in),
1612 default => throw new BlockStateDeserializeException("This state does not exist"),
1613 });
1614
1615 //pitcher crop, split into single and double variants as double has different properties and behaviour
1616 //this will probably be the most annoying to unify
1617 $pitcherCropModel = Model::create(Blocks::PITCHER_CROP(), Ids::PITCHER_CROP)->properties([
1618 new IntProperty(StateNames::GROWTH, 0, PitcherCrop::MAX_AGE, fn(PitcherCrop $b) => $b->getAge(), fn(PitcherCrop $b, int $v) => $b->setAge($v)),
1619 new DummyProperty(StateNames::UPPER_BLOCK_BIT, false)
1620 ]);
1621 $doublePitcherCropAgeOffset = PitcherCrop::MAX_AGE + 1;
1622 $doublePitcherCropModel = Model::create(Blocks::DOUBLE_PITCHER_CROP(), Ids::PITCHER_CROP)->properties([
1623 new IntProperty(
1624 StateNames::GROWTH,
1625 $doublePitcherCropAgeOffset, //TODO: it would be a bit less awkward if the bounds applied _after_ applying the offset, instead of before
1626 7,
1627 fn(DoublePitcherCrop $b) => $b->getAge(),
1628 fn(DoublePitcherCrop $b, int $v) => $b->setAge(min($v, DoublePitcherCrop::MAX_AGE)), //state may give up to 7, but only up to 4 is valid
1629 offset: -$doublePitcherCropAgeOffset
1630 ),
1631 new BoolProperty(StateNames::UPPER_BLOCK_BIT, fn(DoublePitcherCrop $b) => $b->isTop(), fn(DoublePitcherCrop $b, bool $v) => $b->setTop($v))
1632 ]);
1633 self::mapAsymmetricSerializer($reg, $pitcherCropModel);
1634 self::mapAsymmetricSerializer($reg, $doublePitcherCropModel);
1635 $reg->deserializer->map(Ids::PITCHER_CROP, fn(Reader $in) => $in->readInt(StateNames::GROWTH) <= PitcherCrop::MAX_AGE ?
1636 ($in->readBool(StateNames::UPPER_BLOCK_BIT) ?
1637 //top pitcher crop with age 0-2 is an invalid state, only the bottom half should exist in this case
1638 Blocks::AIR() :
1639 self::deserializeAsymmetric($pitcherCropModel, $in)
1640 ) : self::deserializeAsymmetric($doublePitcherCropModel, $in)
1641 );
1642
1643 //these only exist within PM (mapped from tile properties) as they don't support the same properties as a
1644 //normal banner, therefore no deserializer is needed
1645 self::mapAsymmetricSerializer($reg, Model::create(Blocks::OMINOUS_BANNER(), Ids::STANDING_BANNER)->properties([$commonProperties->floorSignLikeRotation]));
1646 self::mapAsymmetricSerializer($reg, Model::create(Blocks::OMINOUS_WALL_BANNER(), Ids::WALL_BANNER)->properties([$commonProperties->horizontalFacingClassic]));
1647
1648 foreach([
1649 Ids::ACACIA_HANGING_SIGN => [Blocks::ACACIA_CEILING_CENTER_HANGING_SIGN(), Blocks::ACACIA_CEILING_EDGES_HANGING_SIGN(), Blocks::ACACIA_WALL_HANGING_SIGN()],
1650 Ids::BAMBOO_HANGING_SIGN => [Blocks::BAMBOO_CEILING_CENTER_HANGING_SIGN(), Blocks::BAMBOO_CEILING_EDGES_HANGING_SIGN(), Blocks::BAMBOO_WALL_HANGING_SIGN()],
1651 Ids::BIRCH_HANGING_SIGN => [Blocks::BIRCH_CEILING_CENTER_HANGING_SIGN(), Blocks::BIRCH_CEILING_EDGES_HANGING_SIGN(), Blocks::BIRCH_WALL_HANGING_SIGN()],
1652 Ids::CHERRY_HANGING_SIGN => [Blocks::CHERRY_CEILING_CENTER_HANGING_SIGN(), Blocks::CHERRY_CEILING_EDGES_HANGING_SIGN(), Blocks::CHERRY_WALL_HANGING_SIGN()],
1653 Ids::CRIMSON_HANGING_SIGN => [Blocks::CRIMSON_CEILING_CENTER_HANGING_SIGN(), Blocks::CRIMSON_CEILING_EDGES_HANGING_SIGN(), Blocks::CRIMSON_WALL_HANGING_SIGN()],
1654 Ids::DARK_OAK_HANGING_SIGN => [Blocks::DARK_OAK_CEILING_CENTER_HANGING_SIGN(), Blocks::DARK_OAK_CEILING_EDGES_HANGING_SIGN(), Blocks::DARK_OAK_WALL_HANGING_SIGN()],
1655 Ids::JUNGLE_HANGING_SIGN => [Blocks::JUNGLE_CEILING_CENTER_HANGING_SIGN(), Blocks::JUNGLE_CEILING_EDGES_HANGING_SIGN(), Blocks::JUNGLE_WALL_HANGING_SIGN()],
1656 Ids::MANGROVE_HANGING_SIGN => [Blocks::MANGROVE_CEILING_CENTER_HANGING_SIGN(), Blocks::MANGROVE_CEILING_EDGES_HANGING_SIGN(), Blocks::MANGROVE_WALL_HANGING_SIGN()],
1657 Ids::OAK_HANGING_SIGN => [Blocks::OAK_CEILING_CENTER_HANGING_SIGN(), Blocks::OAK_CEILING_EDGES_HANGING_SIGN(), Blocks::OAK_WALL_HANGING_SIGN()],
1658 Ids::PALE_OAK_HANGING_SIGN => [Blocks::PALE_OAK_CEILING_CENTER_HANGING_SIGN(), Blocks::PALE_OAK_CEILING_EDGES_HANGING_SIGN(), Blocks::PALE_OAK_WALL_HANGING_SIGN()],
1659 Ids::SPRUCE_HANGING_SIGN => [Blocks::SPRUCE_CEILING_CENTER_HANGING_SIGN(), Blocks::SPRUCE_CEILING_EDGES_HANGING_SIGN(), Blocks::SPRUCE_WALL_HANGING_SIGN()],
1660 Ids::WARPED_HANGING_SIGN => [Blocks::WARPED_CEILING_CENTER_HANGING_SIGN(), Blocks::WARPED_CEILING_EDGES_HANGING_SIGN(), Blocks::WARPED_WALL_HANGING_SIGN()],
1661 ] as $id => [$center, $edges, $wall]){
1662 //attached_bit - true for ceiling center signs, false for ceiling edges signs and wall signs
1663 //hanging - true for all ceiling signs, false for wall signs
1664 //facing_direction - used for ceiling edges signs and wall signs
1665 //ground_sign_direction - used by ceiling center signs only
1666 $centerModel = Model::create($center, $id)->properties([
1667 $commonProperties->floorSignLikeRotation,
1668 new DummyProperty(StateNames::ATTACHED_BIT, true),
1669 new DummyProperty(StateNames::HANGING, true),
1670 new DummyProperty(StateNames::FACING_DIRECTION, 2)
1671 ]);
1672 $edgesModel = Model::create($edges, $id)->properties([
1673 new DummyProperty(StateNames::GROUND_SIGN_DIRECTION, 0),
1674 new DummyProperty(StateNames::ATTACHED_BIT, false),
1675 new DummyProperty(StateNames::HANGING, true),
1676 $commonProperties->horizontalFacingClassic,
1677 ]);
1678 $wallModel = Model::create($wall, $id)->properties([
1679 new DummyProperty(StateNames::GROUND_SIGN_DIRECTION, 0),
1680 new DummyProperty(StateNames::ATTACHED_BIT, false),
1681 new DummyProperty(StateNames::HANGING, false),
1682 $commonProperties->horizontalFacingClassic
1683 ]);
1684 self::mapAsymmetricSerializer($reg, $centerModel);
1685 self::mapAsymmetricSerializer($reg, $edgesModel);
1686 self::mapAsymmetricSerializer($reg, $wallModel);
1687 $reg->deserializer->map($id, fn(Reader $in) => $in->readBool(StateNames::HANGING) ?
1688 ($in->readBool(StateNames::ATTACHED_BIT) ?
1689 self::deserializeAsymmetric($centerModel, $in) :
1690 self::deserializeAsymmetric($edgesModel, $in)
1691 ) :
1692 self::deserializeAsymmetric($wallModel, $in));
1693 }
1694 }
1695}
setLeafState(DripleafState $leafState)
setCount(int $count)
Definition Candle.php:58
setInverted(bool $inverted=true)
setNoDecay(bool $noDecay)
Definition Leaves.php:62
setCheckDecay(bool $checkDecay)
Definition Leaves.php:70
setMushroomBlockType(MushroomBlockType $mushroomBlockType)
setReady(bool $ready)
Definition Sapling.php:58
setFaces(array $faces)
Definition Vine.php:58
static create(Block $block, string $id)
Definition Model.php:69
static unused(string $name, bool $serializedValue)
static unused(string $name, int $serializedValue)