From f478813a468c3e4eb1a5050f1506bc3c443ccd3e Mon Sep 17 00:00:00 2001 From: Apollo <102649729+Apollounknowndev@users.noreply.github.com> Date: Thu, 13 Jun 2024 23:54:10 -0400 Subject: [PATCH] Update Lithostitched partner (#539) * Add enchantment tag generator * Update Lithostitched partner * fix config.json * Refactor a bit --------- Co-authored-by: Misode --- src/app/partners/Lithostitched.ts | 14 ++++++++++++-- src/app/partners/index.ts | 5 +++-- src/app/partners/locales/en.json | 1 + src/app/services/Schemas.ts | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/app/partners/Lithostitched.ts b/src/app/partners/Lithostitched.ts index 01b14f6f..675ee272 100644 --- a/src/app/partners/Lithostitched.ts +++ b/src/app/partners/Lithostitched.ts @@ -1,10 +1,11 @@ import type { CollectionRegistry, ResourceType, SchemaRegistry } from '@mcschema/core' import { BooleanNode, Case, ChoiceNode, ListNode, Mod, NumberNode, ObjectNode, Opt, Reference as RawReference, StringNode as RawStringNode, Switch } from '@mcschema/core' +import type { VersionId } from '../services/Schemas.js' const ID = 'lithostitched' -export function initLithostitched(schemas: SchemaRegistry, collections: CollectionRegistry) { +export function initLithostitched(schemas: SchemaRegistry, collections: CollectionRegistry, version: VersionId) { const Reference = RawReference.bind(undefined, schemas) const StringNode = RawStringNode.bind(undefined, collections) @@ -69,6 +70,9 @@ export function initLithostitched(schemas: SchemaRegistry, collections: Collecti collections.register(`${ID}:modifier_type`, [ 'lithostitched:add_biome_spawns', 'lithostitched:add_features', + ...(version === '1.20.5' || version === '1.21') + ? ['lithostitched:add_pool_aliases'] + : [], 'lithostitched:add_structure_set_entries', 'lithostitched:add_surface_rule', 'lithostitched:add_template_pool_elements', @@ -91,7 +95,9 @@ export function initLithostitched(schemas: SchemaRegistry, collections: Collecti schemas.register(`${ID}:worldgen_modifier`, Mod(ObjectNode({ type: StringNode({ validator: 'resource', params: { pool: `${ID}:modifier_type` as any } }), - predicate: Opt(Reference(`${ID}:modifier_predicate`)), + predicate: Mod(Opt(Reference(`${ID}:modifier_predicate`)), { + enabled: () => version !== '1.21', + }), [Switch]: [{ push: 'type' }], [Case]: { 'lithostitched:add_biome_spawns': { @@ -114,6 +120,10 @@ export function initLithostitched(schemas: SchemaRegistry, collections: Collecti features: Tag('$worldgen/configured_feature'), step: StringNode({ enum: 'decoration_step' }), }, + 'lithostitched:add_pool_aliases': { + structure: StringNode({ validator: 'resource', params: { pool: '$worldgen/structure' } }), + pool_aliases: Reference('pool_alias_binding'), + }, 'lithostitched:add_structure_set_entries': { structure_set: StringNode({ validator: 'resource', params: { pool: '$worldgen/structure_set' } }), entries: ListNode( diff --git a/src/app/partners/index.ts b/src/app/partners/index.ts index 71ac72c8..f4dee4d7 100644 --- a/src/app/partners/index.ts +++ b/src/app/partners/index.ts @@ -1,4 +1,5 @@ import type { CollectionRegistry, SchemaRegistry } from '@mcschema/core' +import type { VersionId } from '../services/Schemas.js' import { initImmersiveWeathering } from './ImmersiveWeathering.js' import { initLithostitched } from './Lithostitched.js' import { initObsidian } from './Obsidian.js' @@ -7,9 +8,9 @@ import { initOhTheTreesYoullGrow } from './OhTheTreesYoullGrow.js' export * from './ImmersiveWeathering.js' export * from './Lithostitched.js' -export function initPartners(schemas: SchemaRegistry, collections: CollectionRegistry) { +export function initPartners(schemas: SchemaRegistry, collections: CollectionRegistry, version: VersionId) { initImmersiveWeathering(schemas, collections) - initLithostitched(schemas, collections) + initLithostitched(schemas, collections, version) initObsidian(schemas, collections) initOhTheTreesYoullGrow(schemas, collections) } diff --git a/src/app/partners/locales/en.json b/src/app/partners/locales/en.json index 0fac55f0..2c25112a 100644 --- a/src/app/partners/locales/en.json +++ b/src/app/partners/locales/en.json @@ -58,6 +58,7 @@ "lithostitched:modifier_type.lithostitched:add_biome_spawns": "Add biome spawns", "lithostitched:modifier_type.lithostitched:add_features": "Add features", + "lithostitched:modifier_type.lithostitched:add_pool_aliases": "Add pool aliases", "lithostitched:modifier_type.lithostitched:add_structure_set_entries": "Add structure set entries", "lithostitched:modifier_type.lithostitched:add_surface_rule": "Add surface rule", "lithostitched:modifier_type.lithostitched:add_template_pool_elements": "Add template pool elements", diff --git a/src/app/services/Schemas.ts b/src/app/services/Schemas.ts index 46aec40e..206414c1 100644 --- a/src/app/services/Schemas.ts +++ b/src/app/services/Schemas.ts @@ -1,8 +1,8 @@ import type { CollectionRegistry, INode, SchemaRegistry } from '@mcschema/core' import { ChoiceNode, DataModel, Reference, StringNode } from '@mcschema/core' import config from '../Config.js' -import { initPartners } from '../partners/index.js' import { message } from '../Utils.js' +import { initPartners } from '../partners/index.js' import { fetchData } from './DataFetcher.js' export const VersionIds = ['1.15', '1.16', '1.17', '1.18', '1.18.2', '1.19', '1.19.3', '1.19.4', '1.20', '1.20.2', '1.20.3', '1.20.5', '1.21'] as const @@ -69,7 +69,7 @@ async function getVersion(id: VersionId): Promise { const blockStates: BlockStateRegistry = {} await fetchData(id, collections, blockStates) const schemas = mcschema.getSchemas(collections) - initPartners(schemas, collections) + initPartners(schemas, collections, id) Versions[id] = { collections, schemas, blockStates } return Versions[id] } catch (e) {