Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24w10a #52

Merged
merged 10 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion java/1.20.5/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mcschema/java-1.20.5",
"version": "0.0.6",
"version": "0.0.7",
Apollounknowndev marked this conversation as resolved.
Show resolved Hide resolved
"description": "Schemas for Java Edition 1.20.5",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
21 changes: 21 additions & 0 deletions java/1.20.5/src/schemas/BannerPattern.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
StringNode as RawStringNode,
Mod,
ObjectNode,
SchemaRegistry,
CollectionRegistry
} from '@mcschema/core'

export function initBannerPatternSchema(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'
})
}))
}
18 changes: 10 additions & 8 deletions java/1.20.5/src/schemas/Components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ 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'),
Expand Down Expand Up @@ -264,29 +264,31 @@ 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 => ({
name: Opt(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 },
Expand Down
20 changes: 15 additions & 5 deletions java/1.20.5/src/schemas/Recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ export function initRecipeSchemas(schemas: SchemaRegistry, collections: Collecti
'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 }))
},
Expand Down Expand Up @@ -120,9 +120,19 @@ export function initRecipeSchemas(schemas: SchemaRegistry, collections: Collecti
})
}))

schemas.register('cooking_recipe_result', Mod(ObjectNode({
id: StringNode({ validator: 'resource', params: { pool: 'item' } }),
components: Opt(Reference('data_component_predicate'))
}), {
default: () => ({
id: 'minecraft:stone'
})
}))

schemas.register('recipe_result', Mod(ObjectNode({
id: StringNode({ validator: 'resource', params: { pool: 'item' } }),
count: Opt(Mod(NumberNode({ integer: true }), { default: () => 1 }))
count: Opt(Mod(NumberNode({ integer: true }), { default: () => 1 })),
components: Opt(Reference('data_component_predicate'))
Apollounknowndev marked this conversation as resolved.
Show resolved Hide resolved
}), {
default: () => ({
id: 'minecraft:stone'
Expand Down
27 changes: 27 additions & 0 deletions java/1.20.5/src/schemas/WolfVariant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
StringNode as RawStringNode,
Mod,
ObjectNode,
Opt,
SchemaRegistry,
CollectionRegistry
} from '@mcschema/core'
import { Tag } from './Common'

export function initWolfVariantSchema(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: Opt(Tag({ resource: '$worldgen/biome' })),
Apollounknowndev marked this conversation as resolved.
Show resolved Hide resolved
}, { 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'
})
}))
}
4 changes: 4 additions & 0 deletions java/1.20.5/src/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CollectionRegistry, SchemaRegistry } from '@mcschema/core'
import { initAdvancementSchemas } from './Advancement'
import { initAssetsSchemas } from './assets'
import { initBannerPatternSchema } from './BannerPattern'
import { initChatTypeSchemas } from './ChatType'
import { initCommonSchemas } from './Common'
import { initConditionSchemas } from './Condition'
Expand All @@ -15,6 +16,7 @@ import { initRecipeSchemas } from './Recipe'
import { initTagsSchemas } from './Tags'
import { initTextComponentSchemas } from './TextComponent'
import { initTrimsSchemas } from './Trims'
import { initWolfVariantSchema } from './WolfVariant'
import { initWorldgenSchemas } from './worldgen'
import { initWorldSettingsSchemas } from './WorldSettings'
import { initComponentsSchemas } from './Components'
Expand All @@ -26,6 +28,7 @@ export function initSchemas(schemas: SchemaRegistry, collections: CollectionRegi
initChatTypeSchemas(schemas, collections)
initAdvancementSchemas(schemas, collections)
initAssetsSchemas(schemas, collections)
initBannerPatternSchema(schemas, collections)
Apollounknowndev marked this conversation as resolved.
Show resolved Hide resolved
initConditionSchemas(schemas, collections)
initDamageTypeSchemas(schemas, collections)
initDimensionTypeSchemas(schemas, collections)
Expand All @@ -38,6 +41,7 @@ export function initSchemas(schemas: SchemaRegistry, collections: CollectionRegi
initTagsSchemas(schemas, collections)
initTextComponentSchemas(schemas, collections)
initTrimsSchemas(schemas, collections)
initWolfVariantSchema(schemas, collections)
initWorldgenSchemas(schemas, collections)
initWorldSettingsSchemas(schemas, collections)
}
Loading