Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

24w45a #59

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions java/1.21.4/src/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
45 changes: 44 additions & 1 deletion java/1.21.4/src/schemas/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' }],
Expand Down Expand Up @@ -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'),
Expand Down
15 changes: 14 additions & 1 deletion java/1.21.4/src/schemas/Components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion java/1.21.4/src/schemas/PackMcmeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
157 changes: 157 additions & 0 deletions java/1.21.4/src/schemas/assets/ItemModel.ts
Original file line number Diff line number Diff line change
@@ -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',
})}))
}
2 changes: 2 additions & 0 deletions java/1.21.4/src/schemas/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading