| 1 | package net.minecraft.util.datafix.schemas;
|
| 2 |
|
| 3 | import com.mojang.datafixers.DSL;
|
| 4 | import com.mojang.datafixers.schemas.Schema;
|
| 5 | import com.mojang.datafixers.types.templates.TypeTemplate;
|
| 6 | import java.util.LinkedHashMap;
|
| 7 | import java.util.Map;
|
| 8 | import java.util.SequencedMap;
|
| 9 | import java.util.function.Supplier;
|
| 10 | import net.minecraft.util.datafix.fixes.References;
|
| 11 |
|
| 12 | public class V3818_3 extends NamespacedSchema {
|
| 13 | public V3818_3(final int versionKey, final Schema parent) {
|
| 14 | super(versionKey, parent);
|
| 15 | }
|
| 16 |
|
| 17 | public static SequencedMap<String, Supplier<TypeTemplate>> components(final Schema schema) {
|
| 18 | SequencedMap<String, Supplier<TypeTemplate>> components = new LinkedHashMap<>();
|
| 19 | components.put("minecraft:bees", () -> DSL.list(DSL.optionalFields("entity_data", References.ENTITY_TREE.in(schema))));
|
| 20 | components.put("minecraft:block_entity_data", () -> References.BLOCK_ENTITY.in(schema));
|
| 21 | components.put("minecraft:bundle_contents", () -> DSL.list(References.ITEM_STACK.in(schema)));
|
| 22 | components.put(
|
| 23 | "minecraft:can_break",
|
| 24 | () -> DSL.optionalFields(
|
| 25 | "predicates", DSL.list(DSL.optionalFields("blocks", DSL.or(References.BLOCK_NAME.in(schema), DSL.list(References.BLOCK_NAME.in(schema)))))
|
| 26 | )
|
| 27 | );
|
| 28 | components.put(
|
| 29 | "minecraft:can_place_on",
|
| 30 | () -> DSL.optionalFields(
|
| 31 | "predicates", DSL.list(DSL.optionalFields("blocks", DSL.or(References.BLOCK_NAME.in(schema), DSL.list(References.BLOCK_NAME.in(schema)))))
|
| 32 | )
|
| 33 | );
|
| 34 | components.put("minecraft:charged_projectiles", () -> DSL.list(References.ITEM_STACK.in(schema)));
|
| 35 | components.put("minecraft:container", () -> DSL.list(DSL.optionalFields("item", References.ITEM_STACK.in(schema))));
|
| 36 | components.put("minecraft:entity_data", () -> References.ENTITY_TREE.in(schema));
|
| 37 | components.put("minecraft:pot_decorations", () -> DSL.list(References.ITEM_NAME.in(schema)));
|
| 38 | components.put("minecraft:food", () -> DSL.optionalFields("using_converts_to", References.ITEM_STACK.in(schema)));
|
| 39 | components.put("minecraft:custom_name", () -> References.TEXT_COMPONENT.in(schema));
|
| 40 | components.put("minecraft:item_name", () -> References.TEXT_COMPONENT.in(schema));
|
| 41 | components.put("minecraft:lore", () -> DSL.list(References.TEXT_COMPONENT.in(schema)));
|
| 42 | components.put(
|
| 43 | "minecraft:written_book_content",
|
| 44 | () -> DSL.optionalFields(
|
| 45 | "pages",
|
| 46 | DSL.list(
|
| 47 | DSL.or(
|
| 48 | DSL.optionalFields("raw", References.TEXT_COMPONENT.in(schema), "filtered", References.TEXT_COMPONENT.in(schema)), References.TEXT_COMPONENT.in(schema)
|
| 49 | )
|
| 50 | )
|
| 51 | )
|
| 52 | );
|
| 53 | return components;
|
| 54 | }
|
| 55 |
|
| 56 | @Override
|
| 57 | public void registerTypes(
|
| 58 | final Schema schema, final Map<String, Supplier<TypeTemplate>> entityTypes, final Map<String, Supplier<TypeTemplate>> blockEntityTypes
|
| 59 | ) {
|
| 60 | super.registerTypes(schema, entityTypes, blockEntityTypes);
|
| 61 | schema.registerType(true, References.DATA_COMPONENTS, () -> DSL.optionalFieldsLazy(components(schema)));
|
| 62 | }
|
| 63 | }
|
| 64 |
|