Skip to content

Commit

Permalink
Update Lithostitched partner (#539)
Browse files Browse the repository at this point in the history
* Add enchantment tag generator

* Update Lithostitched partner

* fix config.json

* Refactor a bit

---------

Co-authored-by: Misode <misoloo64@gmail.com>
  • Loading branch information
Apollounknowndev and misode authored Jun 14, 2024
1 parent 86b3bed commit f478813
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/app/partners/Lithostitched.ts
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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',
Expand All @@ -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': {
Expand All @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions src/app/partners/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)
}
1 change: 1 addition & 0 deletions src/app/partners/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/app/services/Schemas.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -69,7 +69,7 @@ async function getVersion(id: VersionId): Promise<VersionData> {
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) {
Expand Down

0 comments on commit f478813

Please sign in to comment.