diff --git a/java/1.20.5/src/Collections.ts b/java/1.20.5/src/Collections.ts index ae91ab4..15eea14 100644 --- a/java/1.20.5/src/Collections.ts +++ b/java/1.20.5/src/Collections.ts @@ -37,13 +37,39 @@ export function initCollections(collections: CollectionRegistry) { 'key.use' ]) - collections.register('slot', [ + collections.register('equipment_slot', [ 'mainhand', 'offhand', 'head', 'chest', 'legs', - 'feet' + 'feet', + 'body', + ]) + + collections.register('equipment_slot_group', [ + 'any', + 'mainhand', + 'offhand', + 'hand', + 'head', + 'chest', + 'legs', + 'feet', + 'armor', + ]) + + collections.register('slot_range', [ + 'container.*', + 'hotbar.*', + 'inventory.*', + 'enderchest.*', + 'villager.*', + 'horse.*', + 'weapon.*', + 'armor.*', + 'player.cursor', + 'player.crafting.*', ]) collections.register('gamemode', [ @@ -536,18 +562,6 @@ export function initCollections(collections: CollectionRegistry) { 'jp', ]) - collections.register('equipment_slot_group', [ - 'any', - 'mainhand', - 'offhand', - 'hand', - 'head', - 'chest', - 'legs', - 'feet', - 'armor', - ]) - collections.register('attribute_modifier_operation', [ 'add_value', 'add_multiplied_base', diff --git a/java/1.20.5/src/schemas/BannerPattern.ts b/java/1.20.5/src/schemas/BannerPattern.ts new file mode 100644 index 0000000..d2d6324 --- /dev/null +++ b/java/1.20.5/src/schemas/BannerPattern.ts @@ -0,0 +1,21 @@ +import { + StringNode as RawStringNode, + Mod, + ObjectNode, + SchemaRegistry, + CollectionRegistry +} from '@mcschema/core' + +export function initBannerPatternSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) { + const StringNode = RawStringNode.bind(undefined, collections) + + schemas.register('banner_pattern', Mod(ObjectNode({ + asset_id: StringNode(), + translation_key: StringNode(), + }, { context: 'banner_pattern' }), { + default: () => ({ + asset_id: 'minecraft:globe', + translation_key: 'block.minecraft.banner.globe' + }) + })) +} diff --git a/java/1.20.5/src/schemas/Components.ts b/java/1.20.5/src/schemas/Components.ts index c2343b0..95c7c86 100644 --- a/java/1.20.5/src/schemas/Components.ts +++ b/java/1.20.5/src/schemas/Components.ts @@ -19,13 +19,30 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll const Reference = RawReference.bind(undefined, schemas) const StringNode = RawStringNode.bind(undefined, collections) - schemas.register('enchantments_component', ObjectNode({ - levels: MapNode( - StringNode({ validator: 'resource', params: { pool: 'enchantment' } }), - NumberNode({ integer: true, min: 0, max: 255 }), - ), - show_in_tooltip: Opt(BooleanNode()), - }, { context: 'enchantments' })) + schemas.register('enchantments_component', ChoiceNode([ + { + type: 'simple', + match: () => true, + node: MapNode( + StringNode({ validator: 'resource', params: { pool: 'enchantment' } }), + NumberNode({ integer: true, min: 0, max: 255 }), + ), + change: v => v.levels ?? {} + }, + { + type: 'full', + match: v => typeof v === 'object' && typeof v?.levels === 'object', + node: ObjectNode({ + levels: MapNode( + StringNode({ validator: 'resource', params: { pool: 'enchantment' } }), + NumberNode({ integer: true, min: 0, max: 255 }), + ), + show_in_tooltip: Opt(BooleanNode()), + }), + change: v => ({ levels: v ?? {} }), + priority: 1, + } + ], { context: 'enchantments' })) schemas.register('adventure_mode_predicate', ChoiceNode([ { @@ -51,6 +68,15 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll }, ], { context: 'adventure_mode_predicate' })) + schemas.register('attribute_modifiers_entry', ObjectNode({ + type: StringNode({ validator: 'resource', params: { pool: 'attribute' } }), + uuid: StringNode({ validator: 'uuid' }), + name: StringNode(), + amount: NumberNode(), + operation: StringNode({ enum: 'attribute_modifier_operation' }), + slot: Opt(StringNode({ enum: 'equipment_slot_group' })), + }, { context: 'attribute_modifier' })) + schemas.register('map_decoration', ObjectNode({ type: StringNode({ enum: 'map_decoration' }), x: NumberNode(), @@ -142,6 +168,16 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll has_twinkle: Opt(BooleanNode()), }, { context: 'firework_explosion' })) + schemas.register('player_name', Mod(SizeLimitedString({ maxLength: 16 }), node => ({ + validate: (path, value, errors, options) => { + value = node.validate(path, value, errors, options) + if (typeof value === 'string' && !value.split('').map(c => c.charCodeAt(0)).some(c => c <= 32 || c >= 127)) { + errors.add(path, 'error.invalid_player_name') + } + return value + } + }))) + const Components: Record = { 'minecraft:damage': NumberNode({ integer: true, min: 0 }), 'minecraft:unbreakable': ObjectNode({ @@ -150,34 +186,51 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll 'minecraft:custom_name': StringNode(), // text component 'minecraft:lore': ListNode( StringNode(), // text component - { context: 'data_component.lore', maxLength: 64 }, + { context: 'data_component.lore', maxLength: 256 }, ), 'minecraft:enchantments': Reference('enchantments_component'), 'minecraft:can_place_on': Reference('adventure_mode_predicate'), 'minecraft:can_break': Reference('adventure_mode_predicate'), - 'minecraft:attribute_modifiers': ObjectNode({ - modifiers: ListNode( - ObjectNode({ - type: StringNode({ validator: 'resource', params: { pool: 'attribute' } }), - uuid: StringNode({ validator: 'uuid' }), - name: StringNode(), - amount: NumberNode(), - operation: StringNode({ enum: 'attribute_modifier_operation' }), - slot: Opt(StringNode({ enum: 'equipment_slot_group' })), - }, { context: 'attribute_modifier' }), - ), - show_in_tooltip: Opt(BooleanNode()), - }, { context: 'data_component.attribute_modifiers' }), + 'minecraft:attribute_modifiers': ChoiceNode([ + { + type: 'list', + node: ListNode( + Reference('attribute_modifiers_entry'), + ), + change: v => v.modifiers + }, + { + type: 'object', + node: ObjectNode({ + modifiers: ListNode( + Reference('attribute_modifiers_entry'), + ), + show_in_tooltip: Opt(BooleanNode()), + }), + change: v => ({ modifiers: v }) + } + ], { context: 'data_component.attribute_modifiers' }), 'minecraft:custom_model_data': NumberNode({ integer: true }), 'minecraft:hide_additional_tooltip': ObjectNode({}), 'minecraft:repair_cost': NumberNode({ integer: true, min: 0 }), 'minecraft:enchantment_glint_override': BooleanNode(), 'minecraft:intangible_projectile': ObjectNode({}), 'minecraft:stored_enchantments': Reference('enchantments_component'), - 'minecraft:dyed_color': ObjectNode({ - rgb: NumberNode({ color: true }), - show_in_tooltip: Opt(BooleanNode()), - }, { context: 'data_component.dyed_color' }), + 'minecraft:dyed_color': ChoiceNode([ + { + type: 'number', + node: NumberNode({ color: true }), + change: v => v.rgb + }, + { + type: 'object', + node: ObjectNode({ + rgb: NumberNode({ color: true }), + show_in_tooltip: Opt(BooleanNode()), + }), + change: v => ({ rgb: v }) + } + ], { context: 'data_component.dyed_color' }), 'minecraft:map_color': NumberNode({ color: true }), 'minecraft:map_id': NumberNode({ integer: true }), 'minecraft:map_decorations': MapNode( @@ -193,13 +246,24 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll Reference('item_stack'), { context: 'data_component.bundle_contents', maxLength: 64 }, ), - 'minecraft:potion_contents': ObjectNode({ - potion: Opt(StringNode({ validator: 'resource', params: { pool: 'potion' } })), - custom_color: Opt(NumberNode({ color: true })), - custom_effects: Opt(ListNode( - Reference('mob_effect_instance'), - )), - }, { context: 'data_component.potion_contents' }), + 'minecraft:potion_contents': ChoiceNode([ + { + type: 'string', + node: StringNode({ validator: 'resource', params: { pool: 'potion' } }), + change: v => v.potion + }, + { + type: 'object', + node: ObjectNode({ + potion: Opt(StringNode({ validator: 'resource', params: { pool: 'potion' } })), + custom_color: Opt(NumberNode({ color: true })), + custom_effects: Opt(ListNode( + Reference('mob_effect_instance'), + )), + }), + change: v => ({ potion: v}) + } + ], { context: 'data_component.potion_contents' }), 'minecraft:suspicious_stew_effects': ListNode( Reference('suspicious_stew_effect_instance'), { context: 'data_component.suspicious_stew_effects' }, @@ -264,38 +328,43 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll StringNode({ validator: 'resource', params: { pool: '$recipe' } }), { context: 'data_component.recipes' }, ), - 'minecraft:lodestone_target': ObjectNode({ - dimension: StringNode({ validator: 'resource', params: { pool: '$dimension' } }), - pos: Reference('block_pos'), + 'minecraft:lodestone_tracker': ObjectNode({ + tracker: Opt(ObjectNode({ + dimension: StringNode({ validator: 'resource', params: { pool: '$dimension' } }), + pos: Reference('block_pos'), + })), tracked: Opt(BooleanNode()), - }, { context: 'data_component.lodestone_target' }), + }, { context: 'data_component.lodestone_tracker' }), 'minecraft:firework_explosion': Reference('firework_explosion'), 'minecraft:fireworks': ObjectNode({ flight_duration: Opt(NumberNode({ integer: true, min: 0, max: 255 })), explosions: ListNode( Reference('firework_explosion'), - { maxLength: 16 }, + { maxLength: 256 }, ), }, { context: 'data_component.fireworks' }), - 'minecraft:profile': ObjectNode({ - name: Mod(SizeLimitedString({ maxLength: 16 }), node => ({ - validate: (path, value, errors, options) => { - value = node.validate(path, value, errors, options) - if (typeof value === 'string' && !value.split('').map(c => c.charCodeAt(0)).some(c => c <= 32 || c >= 127)) { - errors.add(path, 'error.invalid_player_name') - } - return value - } - })), - id: ListNode( - NumberNode({ integer: true }), - { minLength: 4, maxLength: 4 }, - ), - properties: MapNode( // TODO - StringNode(), - StringNode(), - ), - }, { context: 'data_component.profile' }), + 'minecraft:profile': ChoiceNode([ + { + type: 'string', + node: Reference('player_name'), + change: v => v.name + }, + { + type: 'object', + node: ObjectNode({ + name: Opt(Reference('player_name')), + id: ListNode( + NumberNode({ integer: true }), + { minLength: 4, maxLength: 4 }, + ), + properties: MapNode( // TODO + StringNode(), + StringNode(), + ), + }), + change: v => ({ name: v }) + } + ], { context: 'data_component.profile' }), 'minecraft:note_block_sound': StringNode({ validator: 'resource', params: { pool: [], allowUnknown: true } }), 'minecraft:banner_patterns': ListNode( ObjectNode({ diff --git a/java/1.20.5/src/schemas/Predicates.ts b/java/1.20.5/src/schemas/Predicates.ts index f08b681..5056d79 100644 --- a/java/1.20.5/src/schemas/Predicates.ts +++ b/java/1.20.5/src/schemas/Predicates.ts @@ -212,6 +212,10 @@ export function initPredicatesSchemas(schemas: SchemaRegistry, collections: Coll location: Opt(Reference('location_predicate')), stepping_on: Opt(Reference('location_predicate')), distance: Opt(Reference('distance_predicate')), + slots: Opt(MapNode( + StringNode({ enum: 'slot_range', additional: true }), + Reference('item_predicate') + )), flags: Opt(ObjectNode({ is_on_fire: Opt(BooleanNode()), is_sneaking: Opt(BooleanNode()), @@ -220,7 +224,7 @@ export function initPredicatesSchemas(schemas: SchemaRegistry, collections: Coll is_baby: Opt(BooleanNode()) })), equipment: Opt(MapNode( - StringNode({ enum: 'slot' }), + StringNode({ enum: 'equipment_slot' }), Reference('item_predicate') )), vehicle: Opt(Reference('entity_predicate')), diff --git a/java/1.20.5/src/schemas/Recipe.ts b/java/1.20.5/src/schemas/Recipe.ts index 19f0dfb..dc332ad 100644 --- a/java/1.20.5/src/schemas/Recipe.ts +++ b/java/1.20.5/src/schemas/Recipe.ts @@ -30,57 +30,51 @@ export function initRecipeSchemas(schemas: SchemaRegistry, collections: Collecti StringNode(), // TODO: add validation Reference('recipe_ingredient') ), - result: Reference('recipe_result') + result: Reference('item_stack') }, 'minecraft:crafting_shapeless': { group: Opt(StringNode()), ingredients: ListNode(Reference('recipe_ingredient')), - result: Reference('recipe_result') + result: Reference('item_stack') }, 'minecraft:smelting': { group: Opt(StringNode()), ingredient: Reference('recipe_ingredient'), - result: StringNode({ validator: 'resource', params: { pool: 'item' } }), + result: Reference('cooking_recipe_result'), experience: Opt(NumberNode()), cookingtime: Opt(Mod(NumberNode({ integer: true }), { default: () => 200 })) }, 'minecraft:blasting': { group: Opt(StringNode()), ingredient: Reference('recipe_ingredient'), - result: StringNode({ validator: 'resource', params: { pool: 'item' } }), + result: Reference('cooking_recipe_result'), experience: Opt(NumberNode()), cookingtime: Opt(Mod(NumberNode({ integer: true }), { default: () => 100 })) }, 'minecraft:smoking': { group: Opt(StringNode()), ingredient: Reference('recipe_ingredient'), - result: StringNode({ validator: 'resource', params: { pool: 'item' } }), + result: Reference('cooking_recipe_result'), experience: Opt(NumberNode()), cookingtime: Opt(Mod(NumberNode({ integer: true }), { default: () => 100 })) }, 'minecraft:campfire_cooking': { group: Opt(StringNode()), ingredient: Reference('recipe_ingredient'), - result: StringNode({ validator: 'resource', params: { pool: 'item' } }), + result: Reference('cooking_recipe_result'), experience: Opt(NumberNode()), cookingtime: Opt(Mod(NumberNode({ integer: true }), { default: () => 100 })) }, 'minecraft:stonecutting': { group: Opt(StringNode()), ingredient: Reference('recipe_ingredient'), - result: Reference('recipe_result') - }, - 'minecraft:smithing': { - group: Opt(StringNode()), - base: Reference('recipe_ingredient_object'), - addition: Reference('recipe_ingredient_object'), - result: Reference('recipe_result') + result: Reference('item_stack') }, 'minecraft:smithing_transform': { template: Reference('recipe_ingredient_object'), base: Reference('recipe_ingredient_object'), addition: Reference('recipe_ingredient_object'), - result: Reference('recipe_result') + result: Reference('item_stack') }, 'minecraft:smithing_trim': { template: Reference('recipe_ingredient_object'), @@ -120,9 +114,9 @@ export function initRecipeSchemas(schemas: SchemaRegistry, collections: Collecti }) })) - schemas.register('recipe_result', Mod(ObjectNode({ + schemas.register('cooking_recipe_result', Mod(ObjectNode({ id: StringNode({ validator: 'resource', params: { pool: 'item' } }), - count: Opt(Mod(NumberNode({ integer: true }), { default: () => 1 })) + components: Opt(Reference('data_component_predicate')) }), { default: () => ({ id: 'minecraft:stone' diff --git a/java/1.20.5/src/schemas/WolfVariant.ts b/java/1.20.5/src/schemas/WolfVariant.ts new file mode 100644 index 0000000..4c0f3be --- /dev/null +++ b/java/1.20.5/src/schemas/WolfVariant.ts @@ -0,0 +1,27 @@ +import { + StringNode as RawStringNode, + Mod, + ObjectNode, + Opt, + SchemaRegistry, + CollectionRegistry +} from '@mcschema/core' +import { Tag } from './Common' + +export function initWolfVariantSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) { + const StringNode = RawStringNode.bind(undefined, collections) + + schemas.register('wolf_variant', Mod(ObjectNode({ + texture: StringNode(), + angry_texture: StringNode(), + tame_texture: StringNode(), + biomes: Tag({ resource: '$worldgen/biome' }), + }, { context: 'banner_pattern' }), { + default: () => ({ + texture: 'minecraft:textures/entity/wolf/wolf.png', + tame_texture: 'minecraft:textures/entity/wolf/wolf_tame.png', + angry_texture: 'minecraft:textures/entity/wolf/wolf_angry.png', + biomes: 'minecraft:taiga' + }) + })) +} diff --git a/java/1.20.5/src/schemas/index.ts b/java/1.20.5/src/schemas/index.ts index 610bee3..2b46ee9 100644 --- a/java/1.20.5/src/schemas/index.ts +++ b/java/1.20.5/src/schemas/index.ts @@ -1,6 +1,7 @@ import { CollectionRegistry, SchemaRegistry } from '@mcschema/core' import { initAdvancementSchemas } from './Advancement' import { initAssetsSchemas } from './assets' +import { initBannerPatternSchemas } from './BannerPattern' import { initChatTypeSchemas } from './ChatType' import { initCommonSchemas } from './Common' import { initConditionSchemas } from './Condition' @@ -15,6 +16,7 @@ import { initRecipeSchemas } from './Recipe' import { initTagsSchemas } from './Tags' import { initTextComponentSchemas } from './TextComponent' import { initTrimsSchemas } from './Trims' +import { initWolfVariantSchemas } from './WolfVariant' import { initWorldgenSchemas } from './worldgen' import { initWorldSettingsSchemas } from './WorldSettings' import { initComponentsSchemas } from './Components' @@ -26,6 +28,7 @@ export function initSchemas(schemas: SchemaRegistry, collections: CollectionRegi initChatTypeSchemas(schemas, collections) initAdvancementSchemas(schemas, collections) initAssetsSchemas(schemas, collections) + initBannerPatternSchemas(schemas, collections) initConditionSchemas(schemas, collections) initDamageTypeSchemas(schemas, collections) initDimensionTypeSchemas(schemas, collections) @@ -38,6 +41,7 @@ export function initSchemas(schemas: SchemaRegistry, collections: CollectionRegi initTagsSchemas(schemas, collections) initTextComponentSchemas(schemas, collections) initTrimsSchemas(schemas, collections) + initWolfVariantSchemas(schemas, collections) initWorldgenSchemas(schemas, collections) initWorldSettingsSchemas(schemas, collections) }