package net.minecraft.util.datafix.schemas; import com.mojang.datafixers.DSL; import com.mojang.datafixers.schemas.Schema; import com.mojang.datafixers.types.templates.TypeTemplate; import java.util.Map; import java.util.function.Supplier; import net.minecraft.util.datafix.fixes.References; public class V1458 extends NamespacedSchema { public V1458(int i, Schema schema) { super(i, schema); } @Override public void registerTypes(Schema schema, Map> map, Map> map2) { super.registerTypes(schema, map, map2); schema.registerType( true, References.ENTITY, () -> DSL.and( References.ENTITY_EQUIPMENT.in(schema), DSL.optionalFields("CustomName", References.TEXT_COMPONENT.in(schema), DSL.taggedChoiceLazy("id", namespacedString(), map)) ) ); } @Override public Map> registerBlockEntities(Schema schema) { Map> map = super.registerBlockEntities(schema); schema.register(map, "minecraft:beacon", (Supplier)(() -> nameable(schema))); schema.register(map, "minecraft:banner", (Supplier)(() -> nameable(schema))); schema.register(map, "minecraft:brewing_stand", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:chest", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:trapped_chest", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:dispenser", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:dropper", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:enchanting_table", (Supplier)(() -> nameable(schema))); schema.register(map, "minecraft:furnace", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:hopper", (Supplier)(() -> nameableInventory(schema))); schema.register(map, "minecraft:shulker_box", (Supplier)(() -> nameableInventory(schema))); return map; } public static TypeTemplate nameableInventory(Schema schema) { return DSL.optionalFields("Items", DSL.list(References.ITEM_STACK.in(schema)), "CustomName", References.TEXT_COMPONENT.in(schema)); } public static TypeTemplate nameable(Schema schema) { return DSL.optionalFields("CustomName", References.TEXT_COMPONENT.in(schema)); } }