Skip to content

Commit

Permalink
More fixes and release version
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Nov 6, 2024
1 parent 5aeca7a commit 2f06dc6
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 112 deletions.
2 changes: 1 addition & 1 deletion java/1.21.4/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mcschema/java-1.21.4",
"version": "0.0.3",
"version": "0.0.10",
"description": "Schemas for Java Edition 1.21.4",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
100 changes: 50 additions & 50 deletions java/1.21.4/src/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,71 +383,71 @@ export function initCollections(collections: CollectionRegistry) {
])

collections.register('item_model_type', [
'model',
'special',
'composite',
'condition',
'select',
'range_dispatch',
'bundle/selected_item'
'minecraft:model',
'minecraft:special',
'minecraft:composite',
'minecraft:condition',
'minecraft:select',
'minecraft:range_dispatch',
'minecraft:bundle/selected_item'
])

collections.register('tint_source_type', [
'custom_model_data',
'constant',
'dye',
'grass',
'firework',
'potion',
'map_color',
'minecraft:custom_model_data',
'minecraft:constant',
'minecraft:dye',
'minecraft:grass',
'minecraft:firework',
'minecraft:potion',
'minecraft:map_color',
])

collections.register('special_model_type', [
'bed',
'banner',
'conduit',
'chest',
'head',
'shulker_box',
'shield',
'trident',
'decorated_pot',
'minecraft:bed',
'minecraft:banner',
'minecraft:conduit',
'minecraft:chest',
'minecraft:head',
'minecraft:shulker_box',
'minecraft:shield',
'minecraft:trident',
'minecraft: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'
'minecraft:using_item',
'minecraft:broken',
'minecraft:damaged',
'minecraft:has_component',
'minecraft:fishing_rod/cast',
'minecraft:bundle/has_selected_item',
'minecraft:xmas',
'minecraft:selected',
'minecraft:carried',
'minecraft:shift_down',
'minecraft:custom_model_data'
])

collections.register('select_model_property_type', [
'main_hand',
'charge_type',
'trim_material',
'block_state',
'display_context',
'custom_model_data'
'minecraft:main_hand',
'minecraft:charge_type',
'minecraft:trim_material',
'minecraft:block_state',
'minecraft:display_context',
'minecraft: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'
'minecraft:custom_model_data',
'minecraft:bundle/fullness',
'minecraft:damage',
'minecraft:count',
'minecraft:cooldown',
'minecraft:time',
'minecraft:compass',
'minecraft:crossbow/pull',
'minecraft:use_duration',
'minecraft:use_cycle'
])

collections.register('display_position', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,72 +13,31 @@ import {
ListNode,
} from '@mcschema/core'

export function initItemModelSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) {
export function initItemDefinitionSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) {
const Reference = RawReference.bind(undefined, schemas)
const StringNode = RawStringNode.bind(undefined, collections)

schemas.register('item_model', Mod(ObjectNode({
models: ObjectNode({
schemas.register('item_definition', Mod(ObjectNode({
model: Reference('item_model'),
}, { context: 'item_definition' }), { default: () => ({
model: {
type: 'minecraft:model',
},
})}))

schemas.register('item_model', 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 }))
},
}
})))
tints: Opt(ListNode(
Reference('tint_source'),
))
},
'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' }))
},
}
})
model: Reference('special_item_model'),
},
'minecraft:composite': {
models: ListNode(Reference('item_model'))
Expand Down Expand Up @@ -150,8 +109,64 @@ export function initItemModelSchemas(schemas: SchemaRegistry, collections: Colle
fallback: Opt(Reference('item_model'))
}
}
}, { context: 'item_model' }))

schemas.register('tint_source', Mod(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')
},
'minecraft: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 }))
},
}
}, { context: 'tint_source' }), {
default: () => ({
type: 'minecraft:constant',
value: 0,
})
}), { default: () => ({
type: 'minecraft:model',
})}))
}))

schemas.register('special_item_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' }))
},
}
}, { context: 'special_item_model' }))
}
4 changes: 2 additions & 2 deletions java/1.21.4/src/schemas/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { initModelSchemas } from './Model'
import { initBlockDefinitionSchemas } from './BlockDefinition'
import { initFontSchemas } from './Font'
import { initAtlasSchemas } from './Atlas'
import { initItemModelSchemas } from './ItemModel'
import { initItemDefinitionSchemas } from './ItemDefinition'

export function initAssetsSchemas(schemas: SchemaRegistry, collections: CollectionRegistry) {
initAtlasSchemas(schemas, collections)
initBlockDefinitionSchemas(schemas, collections)
initItemModelSchemas(schemas, collections)
initItemDefinitionSchemas(schemas, collections)
initFontSchemas(schemas, collections)
initModelSchemas(schemas, collections)
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f06dc6

Please sign in to comment.