From 5aeca7ab3a58288562caab75a90ecea60071745c Mon Sep 17 00:00:00 2001 From: Apollo <102649729+Apollounknowndev@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:43:13 -0500 Subject: [PATCH] 24w45a (#59) * Datapack changes * The rest * Pack format bump * Small fixes --------- Co-authored-by: Misode --- java/1.21.4/src/Collections.ts | 78 ++++++++++ java/1.21.4/src/schemas/Common.ts | 45 +++++- java/1.21.4/src/schemas/Components.ts | 15 +- java/1.21.4/src/schemas/PackMcmeta.ts | 2 +- java/1.21.4/src/schemas/assets/ItemModel.ts | 157 ++++++++++++++++++++ java/1.21.4/src/schemas/assets/index.ts | 2 + 6 files changed, 296 insertions(+), 3 deletions(-) create mode 100644 java/1.21.4/src/schemas/assets/ItemModel.ts diff --git a/java/1.21.4/src/Collections.ts b/java/1.21.4/src/Collections.ts index 9fc58c3..9255e17 100644 --- a/java/1.21.4/src/Collections.ts +++ b/java/1.21.4/src/Collections.ts @@ -372,6 +372,84 @@ export function initCollections(collections: CollectionRegistry) { 'z' ]) + collections.register('skull_kind', [ + 'skeleton', + 'wither_skeleton', + 'player', + 'zombie', + 'creeper', + 'piglin', + 'dragon' + ]) + + collections.register('item_model_type', [ + 'model', + 'special', + 'composite', + 'condition', + 'select', + 'range_dispatch', + 'bundle/selected_item' + ]) + + collections.register('tint_source_type', [ + 'custom_model_data', + 'constant', + 'dye', + 'grass', + 'firework', + 'potion', + 'map_color', + ]) + + collections.register('special_model_type', [ + 'bed', + 'banner', + 'conduit', + 'chest', + 'head', + 'shulker_box', + 'shield', + 'trident', + 'decorated_pot', + ]) + + collections.register('model_condition_type', [ + 'using_item', + 'broken', + 'damaged', + 'has_component', + 'fishing_rod/cast', + 'bundle/has_selected_item', + 'xmas', + 'selected', + 'carried', + 'shift_down', + 'custom_model_data' + ]) + + collections.register('select_model_property_type', [ + 'main_hand', + 'charge_type', + 'trim_material', + 'block_state', + 'display_context', + 'custom_model_data' + ]) + + collections.register('numeric_model_property_type', [ + 'custom_model_data', + 'bundle/fullness', + 'damage', + 'count', + 'cooldown', + 'time', + 'compass', + 'crossbow/pull', + 'use_duration', + 'use_cycle' + ]) + collections.register('display_position', [ 'firstperson_righthand', 'firstperson_lefthand', diff --git a/java/1.21.4/src/schemas/Common.ts b/java/1.21.4/src/schemas/Common.ts index 9180aa6..a9566e2 100644 --- a/java/1.21.4/src/schemas/Common.ts +++ b/java/1.21.4/src/schemas/Common.ts @@ -207,6 +207,34 @@ export function initCommonSchemas(schemas: SchemaRegistry, collections: Collecti ]) } + schemas.register('color_rgb', ChoiceNode([ + { + type: 'number', + node: NumberNode({ integer: true, color: true }) + }, + { + type: 'list', + node: ListNode( + NumberNode({ min: 0, max: 1 }), + { minLength: 4, maxLength: 4 }, + ) + } + ])) + + schemas.register('color_argb', ChoiceNode([ + { + type: 'number', + node: NumberNode({ integer: true }) + }, + { + type: 'list', + node: ListNode( + NumberNode({ min: 0, max: 1 }), + { minLength: 4, maxLength: 4 }, + ) + } + ])) + schemas.register('particle', ObjectNode({ type: StringNode({ validator: 'resource', params: { pool: 'particle_type' }}), [Switch]: [{ push: 'type' }], @@ -889,7 +917,22 @@ export function initCommonSchemas(schemas: SchemaRegistry, collections: Collecti tag: Reference('custom_data_component'), }, 'minecraft:set_custom_model_data': { - value: Reference('number_provider'), + floats: Opt(ListOperation({ + node: Reference('number_provider'), + maxLength: 2147483647, + })), + flags: Opt(ListOperation({ + node: BooleanNode(), + maxLength: 2147483647, + })), + strings: Opt(ListOperation({ + node: StringNode(), + maxLength: 2147483647, + })), + colors: Opt(ListOperation({ + node: Reference('color_rgb'), + maxLength: 2147483647, + })), }, 'minecraft:set_damage': { damage: Reference('number_provider'), diff --git a/java/1.21.4/src/schemas/Components.ts b/java/1.21.4/src/schemas/Components.ts index 4ac2450..e57748f 100644 --- a/java/1.21.4/src/schemas/Components.ts +++ b/java/1.21.4/src/schemas/Components.ts @@ -251,7 +251,20 @@ export function initComponentsSchemas(schemas: SchemaRegistry, collections: Coll seed: Opt(NumberNode({ integer: true })), }, { context: 'data_component.container_loot' }), 'minecraft:custom_data': Reference('custom_data_component'), - 'minecraft:custom_model_data': NumberNode({ integer: true }), + 'minecraft:custom_model_data': ObjectNode({ + floats: Opt(ListNode( + NumberNode() + )), + flags: Opt(ListNode( + BooleanNode() + )), + strings: Opt(ListNode( + StringNode() + )), + colors: Opt(ListNode( + Reference('color_rgb') + )), + }), 'minecraft:custom_name': StringNode(), // text component 'minecraft:damage': NumberNode({ integer: true, min: 0 }), 'minecraft:damage_resistant': ObjectNode({ diff --git a/java/1.21.4/src/schemas/PackMcmeta.ts b/java/1.21.4/src/schemas/PackMcmeta.ts index 212d5eb..9bbc4c3 100644 --- a/java/1.21.4/src/schemas/PackMcmeta.ts +++ b/java/1.21.4/src/schemas/PackMcmeta.ts @@ -12,7 +12,7 @@ import { } from '@mcschema/core' import { InclusiveRange } from './Common' -const CURRENT_PACK_FORMAT = 58 +const CURRENT_PACK_FORMAT = 59 export function initPackMcmetaSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) { const Reference = RawReference.bind(undefined, schemas) diff --git a/java/1.21.4/src/schemas/assets/ItemModel.ts b/java/1.21.4/src/schemas/assets/ItemModel.ts new file mode 100644 index 0000000..58791c7 --- /dev/null +++ b/java/1.21.4/src/schemas/assets/ItemModel.ts @@ -0,0 +1,157 @@ +import { + StringNode as RawStringNode, + Mod, + NumberNode, + ObjectNode, + SchemaRegistry, + CollectionRegistry, + Switch, + Case, + Opt, + BooleanNode, + Reference as RawReference, + ListNode, +} from '@mcschema/core' + +export function initItemModelSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) { + const Reference = RawReference.bind(undefined, schemas) + const StringNode = RawStringNode.bind(undefined, collections) + + schemas.register('item_model', Mod(ObjectNode({ + models: ObjectNode({ + type: StringNode({ enum: 'item_model_type' }), + [Switch]: [{ push: 'type' }], + [Case]: { + 'minecraft:model': { + model: StringNode({ validator: 'resource', params: { pool: '$model' } }), + tints: Opt(ListNode(ObjectNode({ + type: StringNode({ validator: 'resource', params: { pool: collections.get('tint_source_type') } }), + [Switch]: [{ push: 'type' }], + [Case]: { + 'minecraft:constant': { + value: Reference('color_rgb') + }, + 'minecraft:dye': { + default: Reference('color_rgb') + }, + 'minecraft:firework': { + default: Reference('color_rgb') + }, + 'minecrat:grass': { + temperature: NumberNode({ min: 0, max: 1}), + downfall : NumberNode({ min: 0, max: 1}), + }, + 'minecraft:potion': { + default: Reference('color_rgb') + }, + 'minecraft:map_color': { + default: Reference('color_rgb') + }, + 'minecraft:custom_model_data': { + index: Opt(NumberNode({ integer: true })) + }, + } + }))) + }, + 'minecraft:special': { + base: StringNode({ validator: 'resource', params: { pool: '$model' } }), + model: ObjectNode({ + type: StringNode({ validator: 'resource', params: { pool: collections.get('special_model_type') } }), + [Switch]: [{ push: 'type' }], + [Case]: { + 'minecraft:bed': { + texture: StringNode() + }, + 'minecraft:banner': { + color: StringNode({ enum: 'dye_color' }) + }, + 'minecraft:chest': { + texture: StringNode(), + openness: Opt(NumberNode({ min: 0, max: 1})) + }, + 'minecraft:head': { + color: StringNode({ enum: 'skull_kind' }) + }, + 'minecraft:shulker_box': { + texture: StringNode(), + openness: Opt(NumberNode({ min: 0, max: 1})), + orientation: Opt(StringNode({ enum: 'direction' })) + }, + } + }) + }, + 'minecraft:composite': { + models: ListNode(Reference('item_model')) + }, + 'minecraft:condition': { + property: StringNode({ validator: 'resource', params: { pool: collections.get('model_condition_type') } }), + [Switch]: [{ push: 'property' }], + [Case]: { + 'minecraft:has_component': { + component: StringNode({ validator: 'resource', params: { pool: 'data_component_type' } }) + }, + 'minecraft:custom_model_data': { + index: Opt(NumberNode({ integer: true })) + } + }, + on_true: Reference('item_model'), + on_false: Reference('item_model') + }, + 'minecraft:select': { + property: StringNode({ validator: 'resource', params: { pool: collections.get('select_model_property_type') } }), + [Switch]: [{ push: 'property' }], + [Case]: { + 'minecraft:block_state': { + 'block_state_property': StringNode() + }, + 'minecraft:custom_model_data': { + index: Opt(NumberNode({ integer: true })) + } + }, + cases: ObjectNode({ + when: StringNode(), + model: Reference('item_model') + }), + fallback: Opt(Reference('item_model')) + }, + 'minecraft:range_dispatch': { + property: StringNode({ validator: 'resource', params: { pool: collections.get('numeric_model_property_type') } }), + [Switch]: [{ push: 'property' }], + [Case]: { + 'minecraft:custom_model_data': { + index: Opt(NumberNode({ integer: true })) + }, + 'minecraft:damage': { + normalize: Opt(BooleanNode()) + }, + 'minecraft:count': { + normalize: Opt(BooleanNode()) + }, + 'minecraft:time': { + wobble: Opt(BooleanNode()), + natural_only: Opt(BooleanNode()) + }, + 'minecraft:compass': { + target: StringNode({ enum: ['spawn', 'lodestone', 'recovery'] }), + wobble: Opt(BooleanNode()) + }, + 'minecraft:use_duration': { + remaining: Opt(BooleanNode()) + }, + 'minecraft:use_cycle': { + period: Opt(NumberNode()) + } + }, + scale: Opt(NumberNode()), + entries: ObjectNode({ + threshold: NumberNode(), + model: Reference('item_model') + }), + fallback: Opt(Reference('item_model')) + } + } + }) + }), { default: () => ({ + type: 'minecraft:model', + })})) +} diff --git a/java/1.21.4/src/schemas/assets/index.ts b/java/1.21.4/src/schemas/assets/index.ts index 962e561..bd2430d 100644 --- a/java/1.21.4/src/schemas/assets/index.ts +++ b/java/1.21.4/src/schemas/assets/index.ts @@ -3,10 +3,12 @@ import { initModelSchemas } from './Model' import { initBlockDefinitionSchemas } from './BlockDefinition' import { initFontSchemas } from './Font' import { initAtlasSchemas } from './Atlas' +import { initItemModelSchemas } from './ItemModel' export function initAssetsSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) { initAtlasSchemas(schemas, collections) initBlockDefinitionSchemas(schemas, collections) + initItemModelSchemas(schemas, collections) initFontSchemas(schemas, collections) initModelSchemas(schemas, collections) }