@jsprismarine/features 0.23.0-unstable-20261121073620 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @jsprismarine/features
2
2
 
3
- ## 0.23.0-unstable-20261121073620
3
+ ## 0.23.0
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -15,9 +15,9 @@
15
15
  - [#3288](https://github.com/JSPrismarine/JSPrismarine/pull/3288) [`1a1f7f2`](https://github.com/JSPrismarine/JSPrismarine/commit/1a1f7f2d9272a3b73dc61fe0d3d79feade306650) Thanks [@filiphsps](https://github.com/filiphsps)! - `@jsprismarine/features` reads two Java 26.4 types: the `large_speleothem` feature, which builds `large_dripstone`'s cones out of the `base_block` it names, and the `below_heightmap` block predicate. 26.4's `crevasse` feature type is not read yet.
16
16
 
17
17
  - [#3288](https://github.com/JSPrismarine/JSPrismarine/pull/3288) [`9b75d40`](https://github.com/JSPrismarine/JSPrismarine/commit/9b75d4022d8e73fa450dd179e5ef686279e846b1) Thanks [@filiphsps](https://github.com/filiphsps)! - Add the `unhandledJavaTypes` module, the reviewed lists of Java registry types the package has no reader for. A test checks them against the pinned Java registry report.
18
- - Updated dependencies [[`60edd7a`](https://github.com/JSPrismarine/JSPrismarine/commit/60edd7a1234650367fe5c2406ee402641be33ed9), [`bf419b8`](https://github.com/JSPrismarine/JSPrismarine/commit/bf419b82bfea52c095ca09b02c1c4ac955ac1d0a), [`c8e1685`](https://github.com/JSPrismarine/JSPrismarine/commit/c8e1685ae8316255d39674af9d00ac8d778f674d), [`bd06d38`](https://github.com/JSPrismarine/JSPrismarine/commit/bd06d385bf9cfa9de40703ef4a7ca218253a3f23), [`b41035b`](https://github.com/JSPrismarine/JSPrismarine/commit/b41035be9b61570008b3405aa169418b19081915), [`b41035b`](https://github.com/JSPrismarine/JSPrismarine/commit/b41035be9b61570008b3405aa169418b19081915), [`4bda824`](https://github.com/JSPrismarine/JSPrismarine/commit/4bda8241a8631da2d205133c85fd361871d6cf61), [`7e2e6f3`](https://github.com/JSPrismarine/JSPrismarine/commit/7e2e6f3cff1f20a11a3f59aac94c68a33fa71a35), [`3e71a8d`](https://github.com/JSPrismarine/JSPrismarine/commit/3e71a8dd75bd0a97e0f8587666f60f160844ff0b), [`586269e`](https://github.com/JSPrismarine/JSPrismarine/commit/586269e324cddfe57caf4206f387895cda6d479f), [`5d2fb0e`](https://github.com/JSPrismarine/JSPrismarine/commit/5d2fb0eb3730e59260a09e60c130e57e5fdb099c), [`936970c`](https://github.com/JSPrismarine/JSPrismarine/commit/936970c04f98b392e4b753f3c89224da3d03cb49), [`57caf26`](https://github.com/JSPrismarine/JSPrismarine/commit/57caf2632f92e5da55ce6eedc4eb0be3d66190d4), [`4b590cf`](https://github.com/JSPrismarine/JSPrismarine/commit/4b590cf6c529d17d8df20d8eab9b2157dc213a19), [`349a814`](https://github.com/JSPrismarine/JSPrismarine/commit/349a81448bfc8be2f901efe14527b8c9334f11eb), [`8876fae`](https://github.com/JSPrismarine/JSPrismarine/commit/8876faec0d0cbd4232446e5081338461e420450e), [`56200a6`](https://github.com/JSPrismarine/JSPrismarine/commit/56200a61535d916f0c41a11d077752b194e4c08b), [`f8843ce`](https://github.com/JSPrismarine/JSPrismarine/commit/f8843ce726b96032631a15efbc2dea76e743b68a), [`c500335`](https://github.com/JSPrismarine/JSPrismarine/commit/c5003358e3a7199593c6ddcdbe4bdf63f8c29fac), [`e090dd7`](https://github.com/JSPrismarine/JSPrismarine/commit/e090dd75379edbfc415d84925e48af29aaa4864e), [`6e758f9`](https://github.com/JSPrismarine/JSPrismarine/commit/6e758f9de80c357c12d992bf473f1bdac86fb274), [`93a1b61`](https://github.com/JSPrismarine/JSPrismarine/commit/93a1b610493f401c4ac62881f70b3dee8c882f33), [`e1c982e`](https://github.com/JSPrismarine/JSPrismarine/commit/e1c982eeed0dfd682b5680c45c69159e21fd9ec0), [`9579362`](https://github.com/JSPrismarine/JSPrismarine/commit/9579362b4070e246d6300d2f4e2dca2ab4715124), [`f18ef7c`](https://github.com/JSPrismarine/JSPrismarine/commit/f18ef7c595f58a267b5371baab96390d0282616d), [`cf88d2f`](https://github.com/JSPrismarine/JSPrismarine/commit/cf88d2f8c2184bd4e116db888d4528fa27f5338d), [`d6c69e4`](https://github.com/JSPrismarine/JSPrismarine/commit/d6c69e43051eb091f0b4a17c0f33799f5944caf3), [`0792e2a`](https://github.com/JSPrismarine/JSPrismarine/commit/0792e2a7e6e5e98729b80df412262fd549ea3cb9), [`9878bb1`](https://github.com/JSPrismarine/JSPrismarine/commit/9878bb1b6fa05000787138b077db166e2f17f47e), [`1c3be54`](https://github.com/JSPrismarine/JSPrismarine/commit/1c3be5465a2865072ac0f16b4848ee0cd9b6b13a), [`db04d85`](https://github.com/JSPrismarine/JSPrismarine/commit/db04d8520c1d43b88196c14229f36f5c8e71f3c1), [`6afe243`](https://github.com/JSPrismarine/JSPrismarine/commit/6afe2434c34f74ce16494876b4722365b416388f), [`823a321`](https://github.com/JSPrismarine/JSPrismarine/commit/823a32166248e10f8be45f45e9cf9f8ef17861de), [`8e72453`](https://github.com/JSPrismarine/JSPrismarine/commit/8e7245335a09057151d7e1af70398fa32d1a93c5), [`2682079`](https://github.com/JSPrismarine/JSPrismarine/commit/26820792b905fd8b0da34e3058c9e64ae4c14be4)]:
19
- - @jsprismarine/errors@0.23.0-unstable-20261121073620
20
- - @jsprismarine/worldgen@0.23.0-unstable-20261121073620
18
+ - Updated dependencies [[`60edd7a`](https://github.com/JSPrismarine/JSPrismarine/commit/60edd7a1234650367fe5c2406ee402641be33ed9), [`bf419b8`](https://github.com/JSPrismarine/JSPrismarine/commit/bf419b82bfea52c095ca09b02c1c4ac955ac1d0a), [`c8e1685`](https://github.com/JSPrismarine/JSPrismarine/commit/c8e1685ae8316255d39674af9d00ac8d778f674d), [`bd06d38`](https://github.com/JSPrismarine/JSPrismarine/commit/bd06d385bf9cfa9de40703ef4a7ca218253a3f23), [`b41035b`](https://github.com/JSPrismarine/JSPrismarine/commit/b41035be9b61570008b3405aa169418b19081915), [`b41035b`](https://github.com/JSPrismarine/JSPrismarine/commit/b41035be9b61570008b3405aa169418b19081915), [`4bda824`](https://github.com/JSPrismarine/JSPrismarine/commit/4bda8241a8631da2d205133c85fd361871d6cf61), [`7e2e6f3`](https://github.com/JSPrismarine/JSPrismarine/commit/7e2e6f3cff1f20a11a3f59aac94c68a33fa71a35), [`3e71a8d`](https://github.com/JSPrismarine/JSPrismarine/commit/3e71a8dd75bd0a97e0f8587666f60f160844ff0b), [`586269e`](https://github.com/JSPrismarine/JSPrismarine/commit/586269e324cddfe57caf4206f387895cda6d479f), [`5d2fb0e`](https://github.com/JSPrismarine/JSPrismarine/commit/5d2fb0eb3730e59260a09e60c130e57e5fdb099c), [`936970c`](https://github.com/JSPrismarine/JSPrismarine/commit/936970c04f98b392e4b753f3c89224da3d03cb49), [`57caf26`](https://github.com/JSPrismarine/JSPrismarine/commit/57caf2632f92e5da55ce6eedc4eb0be3d66190d4), [`4b590cf`](https://github.com/JSPrismarine/JSPrismarine/commit/4b590cf6c529d17d8df20d8eab9b2157dc213a19), [`349a814`](https://github.com/JSPrismarine/JSPrismarine/commit/349a81448bfc8be2f901efe14527b8c9334f11eb), [`56200a6`](https://github.com/JSPrismarine/JSPrismarine/commit/56200a61535d916f0c41a11d077752b194e4c08b), [`f8843ce`](https://github.com/JSPrismarine/JSPrismarine/commit/f8843ce726b96032631a15efbc2dea76e743b68a), [`c500335`](https://github.com/JSPrismarine/JSPrismarine/commit/c5003358e3a7199593c6ddcdbe4bdf63f8c29fac), [`e090dd7`](https://github.com/JSPrismarine/JSPrismarine/commit/e090dd75379edbfc415d84925e48af29aaa4864e), [`6e758f9`](https://github.com/JSPrismarine/JSPrismarine/commit/6e758f9de80c357c12d992bf473f1bdac86fb274), [`93a1b61`](https://github.com/JSPrismarine/JSPrismarine/commit/93a1b610493f401c4ac62881f70b3dee8c882f33), [`e1c982e`](https://github.com/JSPrismarine/JSPrismarine/commit/e1c982eeed0dfd682b5680c45c69159e21fd9ec0), [`9579362`](https://github.com/JSPrismarine/JSPrismarine/commit/9579362b4070e246d6300d2f4e2dca2ab4715124), [`f18ef7c`](https://github.com/JSPrismarine/JSPrismarine/commit/f18ef7c595f58a267b5371baab96390d0282616d), [`cf88d2f`](https://github.com/JSPrismarine/JSPrismarine/commit/cf88d2f8c2184bd4e116db888d4528fa27f5338d), [`d6c69e4`](https://github.com/JSPrismarine/JSPrismarine/commit/d6c69e43051eb091f0b4a17c0f33799f5944caf3), [`0792e2a`](https://github.com/JSPrismarine/JSPrismarine/commit/0792e2a7e6e5e98729b80df412262fd549ea3cb9), [`9878bb1`](https://github.com/JSPrismarine/JSPrismarine/commit/9878bb1b6fa05000787138b077db166e2f17f47e), [`1c3be54`](https://github.com/JSPrismarine/JSPrismarine/commit/1c3be5465a2865072ac0f16b4848ee0cd9b6b13a), [`db04d85`](https://github.com/JSPrismarine/JSPrismarine/commit/db04d8520c1d43b88196c14229f36f5c8e71f3c1), [`823a321`](https://github.com/JSPrismarine/JSPrismarine/commit/823a32166248e10f8be45f45e9cf9f8ef17861de), [`8e72453`](https://github.com/JSPrismarine/JSPrismarine/commit/8e7245335a09057151d7e1af70398fa32d1a93c5), [`2682079`](https://github.com/JSPrismarine/JSPrismarine/commit/26820792b905fd8b0da34e3058c9e64ae4c14be4)]:
19
+ - @jsprismarine/errors@0.23.0
20
+ - @jsprismarine/worldgen@0.23.0
21
21
 
22
22
  ## 0.22.0
23
23
 
@@ -6,7 +6,7 @@ import type { BlockOracle, BlockPos } from '../world/FeatureWorld.js';
6
6
  *
7
7
  * Ores use these to decide what they may cut through, which is why `ore_diamond` can place
8
8
  * deepslate diamond below y 8 and ordinary diamond above it from one feature. Unlike a
9
- * {@link import('../providers/blockPredicate').BlockPredicate} it never reads the world: it is
9
+ * {@link BlockPredicate} it never reads the world: it is
10
10
  * handed the state it is judging, and two of the ten types draw from the random stream.
11
11
  */
12
12
  export type RuleTest = (blocks: BlockOracle, state: BlockState, position: BlockPos, random: RandomSource) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ruleTest.js","names":[],"sources":["../../src/features/ruleTest.ts"],"sourcesContent":["import type { RandomSource } from '@jsprismarine/worldgen';\n\nimport { asArray, asInteger, asNumber, asObject, fail } from '../json';\nimport { normalizeIdentifier, predicateTypeNameOf } from '../registry';\nimport type { BlockState } from '../world/BlockState';\nimport { blockStateKey } from '../world/BlockState';\nimport type { BlockOracle, BlockPos } from '../world/FeatureWorld';\nimport { parseBlockState } from '../providers/blockStateProvider';\nimport { FeaturesErrors } from '@jsprismarine/errors/features';\n\n/**\n * A test on a block state and its position, Java's `RuleTest`.\n *\n * Ores use these to decide what they may cut through, which is why `ore_diamond` can place\n * deepslate diamond below y 8 and ordinary diamond above it from one feature. Unlike a\n * {@link import('../providers/blockPredicate').BlockPredicate} it never reads the world: it is\n * handed the state it is judging, and two of the ten types draw from the random stream.\n */\nexport type RuleTest = (blocks: BlockOracle, state: BlockState, position: BlockPos, random: RandomSource) => boolean;\n\n/** The ten types Java 26.3 registers in `rule_test`. */\nexport type RuleTestTypeName =\n | 'always_true'\n | 'block_match'\n | 'blockstate_match'\n | 'tag_match'\n | 'random_block_match'\n | 'random_blockstate_match'\n | 'height_match'\n | 'not'\n | 'any_of'\n | 'all_of';\n\n/** Reads a `rule_test` document. The dispatch key is `predicate_type`, not `type`. */\nexport const parseRuleTest = (source: unknown, path: string): RuleTest => {\n const raw = asObject(source, path);\n const type = predicateTypeNameOf(raw['predicate_type'], path);\n switch (type) {\n case 'always_true':\n return () => true;\n\n case 'block_match': {\n const block = normalizeIdentifier(raw['block'], `${path}.block`);\n return (_blocks, state) => state.name === block;\n }\n\n case 'blockstate_match': {\n const wanted = blockStateKey(parseBlockState(raw['block_state'], `${path}.block_state`));\n return (_blocks, state) => blockStateKey(state) === wanted;\n }\n\n case 'tag_match': {\n const tag = normalizeIdentifier(raw['tag'], `${path}.tag`);\n return (blocks, state) => blocks.hasTag(state, tag);\n }\n\n case 'random_block_match': {\n const block = normalizeIdentifier(raw['block'], `${path}.block`);\n const probability = asNumber(raw['probability'], `${path}.probability`);\n return (_blocks, state, _position, random) => state.name === block && random.nextFloat() < probability;\n }\n\n case 'random_blockstate_match': {\n const wanted = blockStateKey(parseBlockState(raw['block_state'], `${path}.block_state`));\n const probability = asNumber(raw['probability'], `${path}.probability`);\n return (_blocks, state, _position, random) =>\n blockStateKey(state) === wanted && random.nextFloat() < probability;\n }\n\n case 'height_match': {\n const min = asInteger(raw['min_inclusive'], `${path}.min_inclusive`);\n const max = asInteger(raw['max_inclusive'], `${path}.max_inclusive`);\n return (_blocks, _state, position) => min <= position.y && position.y <= max;\n }\n\n case 'not': {\n const inner = parseRuleTest(raw['rule'], `${path}.rule`);\n return (blocks, state, position, random) => !inner(blocks, state, position, random);\n }\n\n case 'any_of': {\n const rules = parseRuleList(raw['rules'], `${path}.rules`);\n return (blocks, state, position, random) => rules.some((rule) => rule(blocks, state, position, random));\n }\n\n case 'all_of': {\n const rules = parseRuleList(raw['rules'], `${path}.rules`);\n return (blocks, state, position, random) => rules.every((rule) => rule(blocks, state, position, random));\n }\n\n default:\n return fail(new FeaturesErrors.UnknownRuleTestType({ path, type: JSON.stringify(type) }));\n }\n};\n\nconst parseRuleList = (source: unknown, path: string): RuleTest[] =>\n asArray(source, path).map((entry, index) => parseRuleTest(entry, `${path}[${index}]`));\n\n/** A rule test paired with the state to write when it holds, Java's `BlockReplacement`. */\nexport interface BlockReplacement {\n /** What the block already there has to be. */\n readonly target: RuleTest;\n /** What to write in its place. */\n readonly state: BlockState;\n}\n\n/** Reads a `{\"target\": ..., \"state\": ...}` replacement. */\nexport const parseBlockReplacement = (source: unknown, path: string): BlockReplacement => {\n const raw = asObject(source, path);\n return {\n target: parseRuleTest(raw['target'], `${path}.target`),\n state: parseBlockState(raw['state'], `${path}.state`)\n };\n};\n\n/** Reads the list of replacements an ore or a `replace_single_block` carries. */\nexport const parseBlockReplacements = (source: unknown, path: string): BlockReplacement[] =>\n asArray(source, path).map((entry, index) => parseBlockReplacement(entry, `${path}[${index}]`));\n"],"mappings":";;;;;;;AAkCA,IAAa,iBAAiB,QAAiB,SAA2B;CACtE,MAAM,MAAM,SAAS,QAAQ,IAAI;CACjC,MAAM,OAAO,oBAAoB,IAAI,mBAAmB,IAAI;CAC5D,QAAQ,MAAR;EACI,KAAK,eACD,aAAa;EAEjB,KAAK,eAAe;GAChB,MAAM,QAAQ,oBAAoB,IAAI,UAAU,GAAG,KAAK,OAAO;GAC/D,QAAQ,SAAS,UAAU,MAAM,SAAS;EAC9C;EAEA,KAAK,oBAAoB;GACrB,MAAM,SAAS,cAAc,gBAAgB,IAAI,gBAAgB,GAAG,KAAK,aAAa,CAAC;GACvF,QAAQ,SAAS,UAAU,cAAc,KAAK,MAAM;EACxD;EAEA,KAAK,aAAa;GACd,MAAM,MAAM,oBAAoB,IAAI,QAAQ,GAAG,KAAK,KAAK;GACzD,QAAQ,QAAQ,UAAU,OAAO,OAAO,OAAO,GAAG;EACtD;EAEA,KAAK,sBAAsB;GACvB,MAAM,QAAQ,oBAAoB,IAAI,UAAU,GAAG,KAAK,OAAO;GAC/D,MAAM,cAAc,SAAS,IAAI,gBAAgB,GAAG,KAAK,aAAa;GACtE,QAAQ,SAAS,OAAO,WAAW,WAAW,MAAM,SAAS,SAAS,OAAO,UAAU,IAAI;EAC/F;EAEA,KAAK,2BAA2B;GAC5B,MAAM,SAAS,cAAc,gBAAgB,IAAI,gBAAgB,GAAG,KAAK,aAAa,CAAC;GACvF,MAAM,cAAc,SAAS,IAAI,gBAAgB,GAAG,KAAK,aAAa;GACtE,QAAQ,SAAS,OAAO,WAAW,WAC/B,cAAc,KAAK,MAAM,UAAU,OAAO,UAAU,IAAI;EAChE;EAEA,KAAK,gBAAgB;GACjB,MAAM,MAAM,UAAU,IAAI,kBAAkB,GAAG,KAAK,eAAe;GACnE,MAAM,MAAM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/ruleTest.ts"],"sourcesContent":["import type { RandomSource } from '@jsprismarine/worldgen';\n\nimport { asArray, asInteger, asNumber, asObject, fail } from '../json';\nimport { normalizeIdentifier, predicateTypeNameOf } from '../registry';\nimport type { BlockState } from '../world/BlockState';\nimport { blockStateKey } from '../world/BlockState';\nimport type { BlockOracle, BlockPos } from '../world/FeatureWorld';\nimport { parseBlockState } from '../providers/blockStateProvider';\nimport { FeaturesErrors } from '@jsprismarine/errors/features';\n\n/**\n * A test on a block state and its position, Java's `RuleTest`.\n *\n * Ores use these to decide what they may cut through, which is why `ore_diamond` can place\n * deepslate diamond below y 8 and ordinary diamond above it from one feature. Unlike a\n * {@link BlockPredicate} it never reads the world: it is\n * handed the state it is judging, and two of the ten types draw from the random stream.\n */\nexport type RuleTest = (blocks: BlockOracle, state: BlockState, position: BlockPos, random: RandomSource) => boolean;\n\n/** The ten types Java 26.3 registers in `rule_test`. */\nexport type RuleTestTypeName =\n | 'always_true'\n | 'block_match'\n | 'blockstate_match'\n | 'tag_match'\n | 'random_block_match'\n | 'random_blockstate_match'\n | 'height_match'\n | 'not'\n | 'any_of'\n | 'all_of';\n\n/** Reads a `rule_test` document. The dispatch key is `predicate_type`, not `type`. */\nexport const parseRuleTest = (source: unknown, path: string): RuleTest => {\n const raw = asObject(source, path);\n const type = predicateTypeNameOf(raw['predicate_type'], path);\n switch (type) {\n case 'always_true':\n return () => true;\n\n case 'block_match': {\n const block = normalizeIdentifier(raw['block'], `${path}.block`);\n return (_blocks, state) => state.name === block;\n }\n\n case 'blockstate_match': {\n const wanted = blockStateKey(parseBlockState(raw['block_state'], `${path}.block_state`));\n return (_blocks, state) => blockStateKey(state) === wanted;\n }\n\n case 'tag_match': {\n const tag = normalizeIdentifier(raw['tag'], `${path}.tag`);\n return (blocks, state) => blocks.hasTag(state, tag);\n }\n\n case 'random_block_match': {\n const block = normalizeIdentifier(raw['block'], `${path}.block`);\n const probability = asNumber(raw['probability'], `${path}.probability`);\n return (_blocks, state, _position, random) => state.name === block && random.nextFloat() < probability;\n }\n\n case 'random_blockstate_match': {\n const wanted = blockStateKey(parseBlockState(raw['block_state'], `${path}.block_state`));\n const probability = asNumber(raw['probability'], `${path}.probability`);\n return (_blocks, state, _position, random) =>\n blockStateKey(state) === wanted && random.nextFloat() < probability;\n }\n\n case 'height_match': {\n const min = asInteger(raw['min_inclusive'], `${path}.min_inclusive`);\n const max = asInteger(raw['max_inclusive'], `${path}.max_inclusive`);\n return (_blocks, _state, position) => min <= position.y && position.y <= max;\n }\n\n case 'not': {\n const inner = parseRuleTest(raw['rule'], `${path}.rule`);\n return (blocks, state, position, random) => !inner(blocks, state, position, random);\n }\n\n case 'any_of': {\n const rules = parseRuleList(raw['rules'], `${path}.rules`);\n return (blocks, state, position, random) => rules.some((rule) => rule(blocks, state, position, random));\n }\n\n case 'all_of': {\n const rules = parseRuleList(raw['rules'], `${path}.rules`);\n return (blocks, state, position, random) => rules.every((rule) => rule(blocks, state, position, random));\n }\n\n default:\n return fail(new FeaturesErrors.UnknownRuleTestType({ path, type: JSON.stringify(type) }));\n }\n};\n\nconst parseRuleList = (source: unknown, path: string): RuleTest[] =>\n asArray(source, path).map((entry, index) => parseRuleTest(entry, `${path}[${index}]`));\n\n/** A rule test paired with the state to write when it holds, Java's `BlockReplacement`. */\nexport interface BlockReplacement {\n /** What the block already there has to be. */\n readonly target: RuleTest;\n /** What to write in its place. */\n readonly state: BlockState;\n}\n\n/** Reads a `{\"target\": ..., \"state\": ...}` replacement. */\nexport const parseBlockReplacement = (source: unknown, path: string): BlockReplacement => {\n const raw = asObject(source, path);\n return {\n target: parseRuleTest(raw['target'], `${path}.target`),\n state: parseBlockState(raw['state'], `${path}.state`)\n };\n};\n\n/** Reads the list of replacements an ore or a `replace_single_block` carries. */\nexport const parseBlockReplacements = (source: unknown, path: string): BlockReplacement[] =>\n asArray(source, path).map((entry, index) => parseBlockReplacement(entry, `${path}[${index}]`));\n"],"mappings":";;;;;;;AAkCA,IAAa,iBAAiB,QA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AAI,SAAS,GAAG,KAAK,MAAM;GACvD,QAAQ,QAAQ,OAAO,UAAU,WAAW,CAAC,MAAM,QAAQ,OAAO,UAAU,MAAM;EACtF;EAEA,KAAK,UAAU;GACX,MAAM,QAAQ,cAAc,IAAI,UAAU,GAAG,KAAK,OAAO;GACzD,QAAQ,QAAQ,OAAO,UAAU,WAAW,MAAM,MAAM,SAAS,KAAK,QAAQ,OAAO,UAAU,MAAM,CAAC;EAC1G;EAEA,KAAK,UAAU;GACX,MAAM,QAAQ,cAAc,IAAI,UAAU,GAAG,KAAK,OAAO;GACzD,QAAQ,QAAQ,OAAO,UAAU,WAAW,MAAM,OAAO,SAAS,KAAK,QAAQ,OAAO,UAAU,MAAM,CAAC;EAC3G;EAEA,SACI,OAAO,KAAK,IAAI,eAAe,oBAAoB;GAAE;GAAM,MAAM,KAAK,UAAU,IAAI;EAAE,CAAC,CAAC;CAChG;AACJ;AAEA,IAAM,iBAAiB,QAAiB,SACpC,QAAQ,QAAQ,IAAI,CAAC,CAAC,KAAK,OAAO,UAAU,cAAc,OAAO,GAAG,KAAK,GAAG,MAAM,EAAE,CAAC;;AAWzF,IAAa,yBAAyB,QAAiB,SAAmC;CACtF,MAAM,MAAM,SAAS,QAAQ,IAAI;CACjC,OAAO;EACH,QAAQ,cAAc,IAAI,WAAW,GAAG,KAAK,QAAQ;EACrD,OAAO,gBAAgB,IAAI,UAAU,GAAG,KAAK,OAAO;CACxD;AACJ;;AAGA,IAAa,0BAA0B,QAAiB,SACpD,QAAQ,QAAQ,IAAI,CAAC,CAAC,KAAK,OAAO,UAAU,sBAAsB,OAAO,GAAG,KAAK,GAAG,MAAM,EAAE,CAAC"}
@@ -69,7 +69,7 @@ export declare const randomNeighborSpread: (block: BlockStateProvider, acceptedN
69
69
  * Freezes exposed water and lays a snow layer across the chunk.
70
70
  *
71
71
  * Java decides both from the biome's temperature at the position and from the block light there.
72
- * Temperature comes through {@link import('../world/FeatureWorld').FeatureWorld.isColdEnoughToSnow}
72
+ * Temperature comes through {@link FeatureWorld.isColdEnoughToSnow}
73
73
  * and light is taken as dark, which is what a chunk being generated has everywhere but under a
74
74
  * light-emitting block.
75
75
  */
@@ -222,7 +222,7 @@ var SNOW = blockState("minecraft:snow");
222
222
  * Freezes exposed water and lays a snow layer across the chunk.
223
223
  *
224
224
  * Java decides both from the biome's temperature at the position and from the block light there.
225
- * Temperature comes through {@link import('../world/FeatureWorld').FeatureWorld.isColdEnoughToSnow}
225
+ * Temperature comes through {@link FeatureWorld.isColdEnoughToSnow}
226
226
  * and light is taken as dark, which is what a chunk being generated has everywhere but under a
227
227
  * light-emitting block.
228
228
  */
@@ -1 +1 @@
1
- {"version":3,"file":"simple.js","names":[],"sources":["../../src/features/simple.ts"],"sourcesContent":["import { asArray, asBoolean, asInteger, asNumber, asObject } from '../json';\nimport type { PlacedFeature } from '../placement/pipeline';\nimport { placeFeature } from '../placement/pipeline';\nimport { randomWeighted } from '../placement/WorldgenRandom';\nimport type { BlockPredicate } from '../providers/blockPredicate';\nimport { parseBlockPredicate } from '../providers/blockPredicate';\nimport type { BlockStateProvider } from '../providers/blockStateProvider';\nimport { parseBlockState } from '../providers/blockStateProvider';\nimport type { IntProvider } from '../providers/valueProviders';\nimport { parseIntProvider, parseWeightedList } from '../providers/valueProviders';\nimport type { BlockSet } from '../registry';\nimport { parseBlockSet } from '../registry';\nimport type { BlockState, Direction } from '../world/BlockState';\nimport {\n ALL_DIRECTIONS,\n blockState,\n HORIZONTAL_DIRECTIONS,\n oppositeDirection,\n withProperty\n} from '../world/BlockState';\nimport type { BlockPos } from '../world/FeatureWorld';\nimport { atY, offset } from '../world/FeatureWorld';\nimport type { ConfiguredFeature } from './Feature';\nimport { feature } from './Feature';\nimport type { BlockReplacement } from './ruleTest';\nimport { parseBlockReplacements } from './ruleTest';\nimport {\n above,\n below,\n betweenClosed,\n distanceSquared,\n inBlockSet,\n isEmptyBlock,\n manhattan,\n outsideBuildHeight,\n relative,\n shuffledCopy,\n withinManhattan\n} from './support';\nimport type { FeatureParsers } from './parseContext';\n\n/**\n * The features whose whole implementation is a few dozen lines: the five selectors, the two\n * sequencers and the small block writers.\n *\n * They are grouped because they share one property that matters for the seed: each decides what\n * to do with the random stream before it touches the world, so a selector that picks a branch\n * costs exactly one draw whichever branch wins.\n */\n\n/** Builds the `no_op` feature, which Java reports as a successful placement that wrote nothing. */\nexport const noOp = (): ConfiguredFeature => feature('no_op', () => true);\n\n/** Runs one of several placed features, drawn uniformly. Costs one draw. */\nexport const simpleRandomSelector = (features: readonly PlacedFeature[]): ConfiguredFeature =>\n feature(\n 'simple_random_selector',\n (world, random, origin) => {\n const chosen = features[random.nextIntBounded(features.length)];\n return chosen === undefined ? false : placeFeature(chosen, { world }, random, origin);\n },\n features.map((entry) => entry.feature)\n );\n\n/** Runs one of two placed features on a coin flip. */\nexport const randomBooleanSelector = (whenTrue: PlacedFeature, whenFalse: PlacedFeature): ConfiguredFeature =>\n feature(\n 'random_boolean_selector',\n (world, random, origin) => placeFeature(random.nextBoolean() ? whenTrue : whenFalse, { world }, random, origin),\n [whenTrue.feature, whenFalse.feature]\n );\n\n/** Runs one placed feature drawn by weight. */\nexport const weightedRandomSelector = (\n features: readonly { readonly value: PlacedFeature; readonly weight: number }[]\n): ConfiguredFeature =>\n feature(\n 'weighted_random_selector',\n (world, random, origin) => placeFeature(randomWeighted(features, random), { world }, random, origin),\n features.map((entry) => entry.value.feature)\n );\n\n/**\n * Walks a list of chance-weighted features, taking the first whose roll succeeds.\n *\n * Java marks this deprecated in favor of `weighted_random_selector`, but 21 vanilla features\n * still use it, and the draw pattern differs: this rolls once per entry until one passes, so the\n * number of draws depends on where the winner sits.\n */\nexport const randomSelector = (\n features: readonly { readonly feature: PlacedFeature; readonly chance: number }[],\n fallback: PlacedFeature\n): ConfiguredFeature =>\n feature(\n 'random_selector',\n (world, random, origin) => {\n for (const entry of features) {\n if (random.nextFloat() < entry.chance) {\n return placeFeature(entry.feature, { world }, random, origin);\n }\n }\n return placeFeature(fallback, { world }, random, origin);\n },\n [...features.map((entry) => entry.feature.feature), fallback.feature]\n );\n\n/** Runs every placed feature at the same origin, reporting whether any placed. */\nexport const overlay = (features: readonly PlacedFeature[]): ConfiguredFeature =>\n feature(\n 'overlay',\n (world, random, origin) => {\n let placedAny = false;\n for (const entry of features) placedAny = placeFeature(entry, { world }, random, origin) || placedAny;\n return placedAny;\n },\n features.map((entry) => entry.feature)\n );\n\n/** Runs every placed feature in order and stops at the first failure. */\nexport const sequence = (features: readonly PlacedFeature[]): ConfiguredFeature =>\n feature(\n 'sequence',\n (world, random, origin) => {\n for (const entry of features) {\n if (!placeFeature(entry, { world }, random, origin)) return false;\n }\n return true;\n },\n features.map((entry) => entry.feature)\n );\n\n/**\n * Places one block, if it would survive there.\n *\n * Java has two special cases this cannot reproduce without a block registry: a double plant\n * places both halves, and a mossy carpet spreads onto its neighbors. Both are recorded in the\n * README as the places where a server's own block behavior has to finish the job.\n */\nexport const simpleBlock = (toPlace: BlockStateProvider, scheduleTick: boolean): ConfiguredFeature =>\n feature('simple_block', (world, random, origin) => {\n const state = toPlace.getOptionalState(world, random, origin);\n if (state === undefined) return false;\n if (!world.blocks.canSurvive(world, origin, state)) return false;\n world.setBlock(origin, state);\n void scheduleTick;\n return true;\n });\n\n/** Replaces the block at the origin with the first replacement whose rule test matches. */\nexport const replaceSingleBlock = (replacements: readonly BlockReplacement[]): ConfiguredFeature =>\n feature('replace_single_block', (world, random, origin) => {\n for (const replacement of replacements) {\n if (replacement.target(world.blocks, world.getBlock(origin), origin, random)) {\n world.setBlock(origin, replacement.state);\n break;\n }\n }\n return true;\n });\n\n/** Fills one y level of the chunk with a state, wherever that level is air. */\nexport const fillLayer = (height: number, state: BlockState): ConfiguredFeature =>\n feature('fill_layer', (world, _random, origin) => {\n const y = world.minY + height;\n for (let dx = 0; dx < 16; dx++) {\n for (let dz = 0; dz < 16; dz++) {\n const position = { x: origin.x + dx, y, z: origin.z + dz };\n if (world.blocks.isAir(world.getBlock(position))) world.setBlock(position, state);\n }\n }\n return true;\n });\n\nconst BLUE_ICE = blockState('minecraft:blue_ice');\n\n/** Grows a patch of blue ice underwater beside packed ice. */\nexport const blueIce = (): ConfiguredFeature =>\n feature('blue_ice', (world, random, origin) => {\n if (origin.y > world.seaLevel - 1) return false;\n if (\n world.getBlock(origin).name !== 'minecraft:water' &&\n world.getBlock(below(origin)).name !== 'minecraft:water'\n ) {\n return false;\n }\n\n let foundPackedIce = false;\n for (const direction of ALL_DIRECTIONS) {\n if (direction === 'down') continue;\n if (world.getBlock(relative(origin, direction)).name === 'minecraft:packed_ice') {\n foundPackedIce = true;\n break;\n }\n }\n if (!foundPackedIce) return false;\n\n world.setBlock(origin, BLUE_ICE);\n for (let attempt = 0; attempt < 200; attempt++) {\n const yOffset = random.nextIntBounded(5) - random.nextIntBounded(6);\n // Java narrows the horizontal spread as the attempt reaches below the start.\n let spread = 3;\n if (yOffset < 2) spread += Math.trunc(yOffset / 2);\n if (spread < 1) continue;\n\n const position = offset(\n origin,\n random.nextIntBounded(spread) - random.nextIntBounded(spread),\n yOffset,\n random.nextIntBounded(spread) - random.nextIntBounded(spread)\n );\n const existing = world.getBlock(position);\n const replaceable =\n world.blocks.isAir(existing) ||\n existing.name === 'minecraft:water' ||\n existing.name === 'minecraft:packed_ice' ||\n existing.name === 'minecraft:ice';\n if (!replaceable) continue;\n\n for (const direction of ALL_DIRECTIONS) {\n if (world.getBlock(relative(position, direction)).name !== 'minecraft:blue_ice') continue;\n world.setBlock(position, BLUE_ICE);\n break;\n }\n }\n return true;\n });\n\nconst COBBLESTONE = blockState('minecraft:cobblestone');\nconst STONE = blockState('minecraft:stone');\n\n/** Builds the stone platform a player spawns on in a void world. */\nexport const voidStartPlatform = (): ConfiguredFeature =>\n feature('void_start_platform', (world, _random, origin) => {\n const chunkX = origin.x >> 4;\n const chunkZ = origin.z >> 4;\n const checkerboard = (ax: number, az: number, bx: number, bz: number) =>\n Math.max(Math.abs(ax - bx), Math.abs(az - bz));\n if (checkerboard(chunkX, chunkZ, 0, 0) > 1) return true;\n\n const platform = { x: 8, y: origin.y + 3, z: 8 };\n for (let z = chunkZ * 16; z <= chunkZ * 16 + 15; z++) {\n for (let x = chunkX * 16; x <= chunkX * 16 + 15; x++) {\n if (checkerboard(platform.x, platform.z, x, z) > 16) continue;\n const position = { x, y: platform.y, z };\n const isCenter = x === platform.x && z === platform.z;\n world.setBlock(position, isCenter ? COBBLESTONE : STONE);\n }\n }\n return true;\n });\n\nconst OBSIDIAN = blockState('minecraft:obsidian');\nconst AIR = blockState('minecraft:air');\n\n/** Builds the five by five obsidian platform an arrival in the end lands on. */\nexport const endPlatform = (): ConfiguredFeature =>\n feature('end_platform', (world, _random, origin) => {\n for (let dz = -2; dz <= 2; dz++) {\n for (let dx = -2; dx <= 2; dx++) {\n for (let dy = -1; dy < 3; dy++) {\n const position = offset(origin, dx, dy, dz);\n const wanted = dy === -1 ? OBSIDIAN : AIR;\n if (world.getBlock(position).name !== wanted.name) world.setBlock(position, wanted);\n }\n }\n }\n return true;\n });\n\n/** Stacks one block upward or downward while a predicate and a per-block chance both hold. */\nexport const singleBlockPillar = (\n block: BlockStateProvider,\n canReplace: BlockPredicate,\n direction: Direction,\n chanceToContinue: number,\n capFeature?: PlacedFeature\n): ConfiguredFeature =>\n feature(\n 'single_block_pillar',\n (world, random, origin) => {\n let position = origin;\n while (\n canReplace(world, position) &&\n random.nextFloat() < chanceToContinue &&\n !outsideBuildHeight(world, position.y)\n ) {\n world.setBlock(position, block.getState(world, random, position));\n position = relative(position, direction);\n }\n position = relative(position, oppositeDirection(direction));\n if (capFeature !== undefined) placeFeature(capFeature, { world }, random, position);\n return true;\n },\n capFeature === undefined ? undefined : [capFeature.feature]\n );\n\nconst MAGMA_BLOCK = blockState('minecraft:magma_block');\n\n/** Scatters magma blocks on an underwater floor, avoiding any that would be visible from the side. */\nexport const underwaterMagma = (\n floorSearchRange: number,\n placementRadiusAroundFloor: number,\n placementProbabilityPerValidPosition: number\n): ConfiguredFeature =>\n feature('underwater_magma', (world, random, origin) => {\n const floorY = findWaterFloor(world, origin, floorSearchRange);\n if (floorY === undefined) return false;\n\n const floor = atY(origin, floorY);\n const radius = placementRadiusAroundFloor;\n let placed = 0;\n for (const position of betweenClosed(\n offset(floor, -radius, -radius, -radius),\n offset(floor, radius, radius, radius)\n )) {\n if (random.nextFloat() >= placementProbabilityPerValidPosition) continue;\n if (!isValidMagmaPlacement(world, position)) continue;\n world.setBlock(position, MAGMA_BLOCK);\n placed++;\n }\n return placed > 0;\n });\n\n/**\n * Walks down through water and returns the y of the first block that is not water.\n *\n * This is Java's `Column.scan` with water inside and anything else as the edge, so the value is\n * the floor block itself rather than the water above it.\n */\nconst findWaterFloor = (\n world: Parameters<ConfiguredFeature['place']>[0],\n origin: BlockPos,\n range: number\n): number | undefined => {\n if (world.getBlock(origin).name !== 'minecraft:water') return undefined;\n let y = origin.y;\n for (let step = 1; step < range && world.getBlock(atY(origin, y)).name === 'minecraft:water'; step++) y--;\n return world.getBlock(atY(origin, y)).name === 'minecraft:water' ? undefined : y;\n};\n\nconst isValidMagmaPlacement = (world: Parameters<ConfiguredFeature['place']>[0], position: BlockPos): boolean => {\n const state = world.getBlock(position);\n const isWaterOrAir = state.name === 'minecraft:water' || world.blocks.isAir(state);\n if (isWaterOrAir) return false;\n if (!world.blocks.isSolid(world.getBlock(below(position)))) return false;\n for (const direction of HORIZONTAL_DIRECTIONS) {\n if (!world.blocks.isSolid(world.getBlock(relative(position, direction)))) return false;\n }\n return true;\n};\n\n/** Places a block at the origin and scatters more wherever exactly one accepted neighbor sits. */\nexport const randomNeighborSpread = (\n block: BlockStateProvider,\n acceptedNeighbors: BlockSet,\n canReplace: BlockPredicate,\n attempts: IntProvider,\n xzOffset: IntProvider,\n yOffset: IntProvider\n): ConfiguredFeature =>\n feature('random_neighbor_spread', (world, random, origin) => {\n world.setBlock(origin, block.getState(world, random, origin));\n const tries = attempts.sample(random);\n for (let attempt = 0; attempt < tries; attempt++) {\n const position = offset(origin, xzOffset.sample(random), yOffset.sample(random), xzOffset.sample(random));\n if (!canReplace(world, position)) continue;\n\n let neighbors = 0;\n for (const direction of ALL_DIRECTIONS) {\n if (inBlockSet(world.blocks, world.getBlock(relative(position, direction)), acceptedNeighbors)) {\n neighbors++;\n }\n if (neighbors > 1) break;\n }\n if (neighbors === 1) world.setBlock(position, block.getState(world, random, position));\n }\n return true;\n });\n\nconst ICE = blockState('minecraft:ice');\nconst SNOW = blockState('minecraft:snow');\n\n/**\n * Freezes exposed water and lays a snow layer across the chunk.\n *\n * Java decides both from the biome's temperature at the position and from the block light there.\n * Temperature comes through {@link import('../world/FeatureWorld').FeatureWorld.isColdEnoughToSnow}\n * and light is taken as dark, which is what a chunk being generated has everywhere but under a\n * light-emitting block.\n */\nexport const freezeTopLayer = (): ConfiguredFeature =>\n feature('freeze_top_layer', (world, _random, origin) => {\n for (let dx = 0; dx < 16; dx++) {\n for (let dz = 0; dz < 16; dz++) {\n const x = origin.x + dx;\n const z = origin.z + dz;\n const y = world.getHeight('MOTION_BLOCKING', x, z);\n const top = { x, y, z };\n const under = { x, y: y - 1, z };\n if (world.isColdEnoughToSnow?.(top) !== true) continue;\n\n if (world.getBlock(under).name === 'minecraft:water') world.setBlock(under, ICE);\n const topState = world.getBlock(top);\n if (world.blocks.isAir(topState) && world.blocks.canSurvive(world, top, SNOW)) {\n world.setBlock(top, SNOW);\n const belowState = world.getBlock(under);\n if ('snowy' in belowState.properties)\n world.setBlock(under, withProperty(belowState, 'snowy', 'true'));\n }\n }\n }\n return true;\n });\n\n/** Scatters blocks over a small disc of ground, thinning toward the edge. */\nexport const blockPile = (stateProvider: BlockStateProvider): ConfiguredFeature =>\n feature('block_pile', (world, random, origin) => {\n if (origin.y < world.minY + 5) return false;\n const spreadX = 2 + random.nextIntBounded(2);\n const spreadZ = 2 + random.nextIntBounded(2);\n\n for (const position of betweenClosed(\n offset(origin, -spreadX, 0, -spreadZ),\n offset(origin, spreadX, 1, spreadZ)\n )) {\n const dx = origin.x - position.x;\n const dz = origin.z - position.z;\n const withinBlob = dx * dx + dz * dz <= random.nextFloat() * 10 - random.nextFloat() * 6;\n if (withinBlob || random.nextFloat() < 0.031) {\n if (!isEmptyBlock(world, position)) continue;\n const under = below(position);\n const underState = world.getBlock(under);\n const mayPlace =\n underState.name === 'minecraft:dirt_path'\n ? random.nextBoolean()\n : world.blocks.isSturdy(underState, 'up');\n if (mayPlace) world.setBlock(position, stateProvider.getState(world, random, position));\n }\n }\n return true;\n });\n\n/** Drops three overlapping blobs of one state onto the first block that passes a predicate. */\nexport const blockBlob = (state: BlockState, canPlaceOn: BlockPredicate): ConfiguredFeature =>\n feature('block_blob', (world, random, origin) => {\n let center = origin;\n while (center.y > world.minY + 3 && !canPlaceOn(world, below(center))) center = below(center);\n if (center.y <= world.minY + 3) return false;\n\n for (let blob = 0; blob < 3; blob++) {\n const rx = random.nextIntBounded(2);\n const ry = random.nextIntBounded(2);\n const rz = random.nextIntBounded(2);\n const radius = Math.fround((rx + ry + rz) * 0.333 + 0.5);\n for (const position of betweenClosed(offset(center, -rx, -ry, -rz), offset(center, rx, ry, rz))) {\n if (distanceSquared(position, center) <= radius * radius) world.setBlock(position, state);\n }\n center = offset(\n center,\n -1 + random.nextIntBounded(2),\n -random.nextIntBounded(2),\n -1 + random.nextIntBounded(2)\n );\n }\n return true;\n });\n\n/** Finds the nearest target block below and replaces a Manhattan blob of it. */\nexport const netherrackReplaceBlobs = (\n target: BlockState,\n replacement: BlockState,\n radius: IntProvider\n): ConfiguredFeature =>\n feature('netherrack_replace_blobs', (world, random, origin) => {\n const start = atY(origin, Math.min(Math.max(origin.y, world.minY + 1), world.minY + world.height - 1));\n let center: BlockPos | undefined;\n for (let y = start.y; y > world.minY + 1; y--) {\n const position = atY(start, y);\n if (world.getBlock(position).name === target.name) {\n center = position;\n break;\n }\n }\n if (center === undefined) return false;\n\n const radiusX = radius.sample(random);\n const radiusY = radius.sample(random);\n const radiusZ = radius.sample(random);\n const maximumRadius = Math.max(radiusX, Math.max(radiusY, radiusZ));\n let replacedAny = false;\n for (const position of withinManhattan(center, radiusX, radiusY, radiusZ)) {\n if (manhattan(position, center) > maximumRadius) break;\n if (world.getBlock(position).name !== target.name) continue;\n world.setBlock(position, replacement);\n replacedAny = true;\n }\n return replacedAny;\n });\n\nconst DELTA_CANNOT_REPLACE = new Set([\n 'minecraft:bedrock',\n 'minecraft:nether_bricks',\n 'minecraft:nether_brick_fence',\n 'minecraft:nether_brick_stairs',\n 'minecraft:nether_wart',\n 'minecraft:chest',\n 'minecraft:spawner'\n]);\n\n/** Pours a lava delta with an offset rim over the basalt deltas floor. */\nexport const deltaFeature = (\n contents: BlockState,\n rim: BlockState,\n size: IntProvider,\n rimSize: IntProvider\n): ConfiguredFeature =>\n feature('delta_feature', (world, random, origin) => {\n let anyPlaced = false;\n const spawnRim = random.nextDouble() < 0.9;\n const rimX = spawnRim ? rimSize.sample(random) : 0;\n const rimZ = spawnRim ? rimSize.sample(random) : 0;\n const hasRim = spawnRim && rimX !== 0 && rimZ !== 0;\n const radiusX = size.sample(random);\n const radiusZ = size.sample(random);\n const radiusLimit = Math.max(radiusX, radiusZ);\n\n const isClear = (position: BlockPos): boolean => {\n const state = world.getBlock(position);\n if (state.name === contents.name) return false;\n if (DELTA_CANNOT_REPLACE.has(state.name)) return false;\n for (const direction of ALL_DIRECTIONS) {\n const isAir = world.blocks.isAir(world.getBlock(relative(position, direction)));\n if ((isAir && direction !== 'up') || (!isAir && direction === 'up')) return false;\n }\n return true;\n };\n\n for (const position of withinManhattan(origin, radiusX, 0, radiusZ)) {\n if (manhattan(position, origin) > radiusLimit) break;\n if (!isClear(position)) continue;\n if (hasRim) {\n anyPlaced = true;\n world.setBlock(position, rim);\n }\n const shifted = offset(position, rimX, 0, rimZ);\n if (isClear(shifted)) {\n anyPlaced = true;\n world.setBlock(shifted, contents);\n }\n }\n return anyPlaced;\n });\n\n/** Lays a flat disc of blocks wherever a target predicate holds, within a drawn radius. */\nexport const disk = (\n stateProvider: BlockStateProvider,\n target: BlockPredicate,\n radius: IntProvider,\n halfHeight: number\n): ConfiguredFeature =>\n feature('disk', (world, random, origin) => {\n let placedAny = false;\n const top = origin.y + halfHeight;\n const bottom = origin.y - halfHeight - 1;\n const drawn = radius.sample(random);\n\n for (const column of betweenClosed(offset(origin, -drawn, 0, -drawn), offset(origin, drawn, 0, drawn))) {\n const dx = column.x - origin.x;\n const dz = column.z - origin.z;\n if (dx * dx + dz * dz > drawn * drawn) continue;\n for (let y = top; y > bottom; y--) {\n const position = { x: column.x, y, z: column.z };\n if (!target(world, position)) continue;\n const state = stateProvider.getOptionalState(world, random, position);\n if (state === undefined) continue;\n world.setBlock(position, state);\n placedAny = true;\n }\n }\n return placedAny;\n });\n\n/** Opens a one-block fluid spring in a wall with exactly the declared rock and hole counts. */\nexport const springFeature = (\n fluid: BlockState,\n requiresBlockBelow: boolean,\n rockCount: number,\n holeCount: number,\n validBlocks: BlockSet\n): ConfiguredFeature =>\n feature('spring_feature', (world, _random, origin) => {\n const isValid = (position: BlockPos) => inBlockSet(world.blocks, world.getBlock(position), validBlocks);\n if (!isValid(above(origin))) return false;\n if (requiresBlockBelow && !isValid(below(origin))) return false;\n\n const current = world.getBlock(origin);\n if (!world.blocks.isAir(current) && !inBlockSet(world.blocks, current, validBlocks)) return false;\n\n const sides = [\n relative(origin, 'west'),\n relative(origin, 'east'),\n relative(origin, 'north'),\n relative(origin, 'south'),\n below(origin)\n ];\n let rocks = 0;\n for (const side of sides) if (isValid(side)) rocks++;\n let holes = 0;\n for (const side of sides) if (isEmptyBlock(world, side)) holes++;\n\n if (rocks !== rockCount || holes !== holeCount) return false;\n world.setBlock(origin, fluid);\n // Java's `SpringFeature` ticks the fluid it placed at once, which is what starts the stream.\n world.scheduleFluidTick?.(origin);\n return true;\n });\n\n/**\n * The vine state property for the face a vine attaches to.\n *\n * A vine names the direction of the block it hangs on, so `north=true` means the support is to\n * the north. There is no `down`, which is why the feature skips that direction.\n */\nconst VINE_FACE_PROPERTIES: Readonly<Record<Direction, string | undefined>> = {\n up: 'up',\n down: undefined,\n north: 'north',\n south: 'south',\n west: 'west',\n east: 'east'\n};\n\n/** Hangs a vine on the first face of the origin that has a block behind it. */\nexport const vines = (): ConfiguredFeature =>\n feature('vines', (world, _random, origin) => {\n if (!isEmptyBlock(world, origin)) return false;\n for (const direction of ALL_DIRECTIONS) {\n if (direction === 'down') continue;\n const property = VINE_FACE_PROPERTIES[direction];\n if (property === undefined) continue;\n const neighbor = world.getBlock(relative(origin, direction));\n if (!world.blocks.isSturdy(neighbor, oppositeDirection(direction))) continue;\n world.setBlock(origin, blockState('minecraft:vine', { [property]: 'true' }));\n return true;\n }\n return false;\n });\n\n/**\n * Grows a face-attached block such as glow lichen or sculk vein onto a nearby surface.\n *\n * Java then rolls `chance_of_spreading` and, when it passes, asks the block's own spreader to\n * continue from the placed face. The spreader is block behavior rather than world generation, so\n * this places the first face and stops; the README records the spread pass as the caller's job.\n * The roll is still drawn, because it costs one float whichever way it lands, and the chance\n * itself therefore does not reach this function.\n */\nexport const multifaceGrowth = (\n placeBlock: string,\n searchRange: number,\n canPlaceOnFloor: boolean,\n canPlaceOnCeiling: boolean,\n canPlaceOnWall: boolean,\n canBePlacedOn: BlockSet\n): ConfiguredFeature =>\n feature('multiface_growth', (world, random, origin) => {\n const isAirOrWater = (position: BlockPos) => {\n const state = world.getBlock(position);\n return world.blocks.isAir(state) || state.name === 'minecraft:water';\n };\n if (!isAirOrWater(origin)) return false;\n\n const valid: Direction[] = [];\n if (canPlaceOnCeiling) valid.push('up');\n if (canPlaceOnFloor) valid.push('down');\n if (canPlaceOnWall) valid.push(...HORIZONTAL_DIRECTIONS);\n if (valid.length === 0) return false;\n\n const tryPlace = (position: BlockPos, directions: readonly Direction[]): boolean => {\n for (const direction of directions) {\n const neighbor = world.getBlock(relative(position, direction));\n if (!inBlockSet(world.blocks, neighbor, canBePlacedOn)) continue;\n // A multiface block names the face it sits on, including `down`, which vines lack.\n const existing = world.getBlock(position);\n const base = existing.name === placeBlock ? existing : blockState(placeBlock);\n world.setBlock(position, withProperty(base, direction, 'true'));\n // Java's `placeGrowthIfPossible` marks every face it places for post-processing.\n world.markForPostProcessing?.(position);\n random.nextFloat();\n return true;\n }\n return false;\n };\n\n const searchDirections = shuffledCopy(valid, random);\n if (tryPlace(origin, searchDirections)) return true;\n\n for (const searchDirection of searchDirections) {\n const opposite = oppositeDirection(searchDirection);\n const placementDirections = shuffledCopy(\n valid.filter((direction) => direction !== opposite),\n random\n );\n // Java resets the cursor to one step from the origin on every iteration rather than\n // walking outward, so the scan tests the same position `search_range` times.\n let position = origin;\n for (let step = 0; step < searchRange; step++) {\n position = relative(origin, searchDirection);\n const state = world.getBlock(position);\n if (!isAirOrWater(position) && state.name !== placeBlock) break;\n if (tryPlace(position, placementDirections)) return true;\n }\n }\n return false;\n });\n\n/** One band of a `block_column`: how many blocks and which state they take. */\nexport interface BlockColumnLayer {\n /** How tall the band is. */\n readonly height: IntProvider;\n /** What the band is made of. */\n readonly provider: BlockStateProvider;\n}\n\n/**\n * Stacks several bands of blocks in one direction, trimming them when the column runs into\n * something.\n *\n * Which end gets trimmed is `prioritize_tip`: a twisting vine keeps its tip and loses its stem,\n * while a kelp column keeps its stem and loses its tip.\n */\nexport const blockColumn = (\n layers: readonly BlockColumnLayer[],\n direction: Direction,\n allowedPlacement: BlockPredicate,\n prioritizeTip: boolean\n): ConfiguredFeature =>\n feature('block_column', (world, random, origin) => {\n const heights = layers.map((layer) => layer.height.sample(random));\n let totalHeight = 0;\n for (const height of heights) totalHeight += height;\n if (totalHeight === 0) return false;\n\n let probe = relative(origin, direction);\n for (let step = 0; step < totalHeight; step++) {\n if (!allowedPlacement(world, probe)) {\n truncateColumn(heights, totalHeight, step, prioritizeTip);\n break;\n }\n probe = relative(probe, direction);\n }\n\n let position = origin;\n for (const [index, layer] of layers.entries()) {\n const count = heights[index] ?? 0;\n for (let step = 0; step < count; step++) {\n world.setBlock(position, layer.provider.getState(world, random, position));\n position = relative(position, direction);\n }\n }\n return true;\n });\n\nconst truncateColumn = (heights: number[], totalHeight: number, newHeight: number, prioritizeTip: boolean): void => {\n let toRemove = totalHeight - newHeight;\n const step = prioritizeTip ? 1 : -1;\n const start = prioritizeTip ? 0 : heights.length - 1;\n const end = prioritizeTip ? heights.length : -1;\n for (let index = start; index !== end && toRemove > 0; index += step) {\n const held = heights[index] ?? 0;\n const removed = Math.min(held, toRemove);\n toRemove -= removed;\n heights[index] = held - removed;\n }\n};\n\n/**\n * Scatters blocks over a square, thinning toward the corners, dropping each one onto the surface\n * below it.\n *\n * 26.3 added this and removed `random_patch`. The corner thinning is the whole difference: a\n * position's chance of being used falls with the product of its two offsets, so the patch comes\n * out round rather than square.\n */\nexport const projectedRandomPatchySquare = (\n block: BlockStateProvider,\n projectThrough: BlockPredicate,\n size: IntProvider,\n maxProjectionHeight: number\n): ConfiguredFeature =>\n feature('projected_random_patchy_square', (world, random, origin) => {\n const drawn = size.sample(random);\n const bound = drawn * drawn + 1;\n\n for (let dx = -drawn; dx <= drawn; dx++) {\n for (let dz = -drawn; dz <= drawn; dz++) {\n const probability = Math.abs(dx) * Math.abs(dz);\n if (random.nextIntBounded(bound) >= bound - probability) continue;\n\n let position = offset(origin, dx, 0, dz);\n let drop = maxProjectionHeight;\n while (projectThrough(world, below(position))) {\n position = below(position);\n if (--drop <= 0) break;\n }\n\n const state = block.getOptionalState(world, random, position);\n if (state !== undefined) world.setBlock(position, state);\n }\n }\n return true;\n });\n\n/** Reads the simple feature types, given the parsers for the nested documents they carry. */\nexport const parseSimpleFeature = (\n type: string,\n raw: Record<string, unknown>,\n path: string,\n parsers: FeatureParsers\n): ConfiguredFeature | undefined => {\n switch (type) {\n case 'no_op':\n return noOp();\n case 'simple_random_selector':\n return simpleRandomSelector(parsers.placedFeatureList(raw['features'], `${path}.features`));\n case 'random_boolean_selector':\n return randomBooleanSelector(\n parsers.placedFeature(raw['feature_true'], `${path}.feature_true`),\n parsers.placedFeature(raw['feature_false'], `${path}.feature_false`)\n );\n case 'weighted_random_selector':\n return weightedRandomSelector(\n parseWeightedList(raw['features'], `${path}.features`, (value, entryPath) =>\n parsers.placedFeature(value, entryPath)\n )\n );\n case 'random_selector':\n return randomSelector(\n asArray(raw['features'], `${path}.features`).map((entry, index) => {\n const entryPath = `${path}.features[${index}]`;\n const item = asObject(entry, entryPath);\n return {\n feature: parsers.placedFeature(item['feature'], `${entryPath}.feature`),\n chance: asNumber(item['chance'], `${entryPath}.chance`)\n };\n }),\n parsers.placedFeature(raw['default'], `${path}.default`)\n );\n case 'overlay':\n return overlay(parsers.placedFeatureList(raw['features'], `${path}.features`));\n case 'sequence':\n return sequence(parsers.placedFeatureList(raw['features'], `${path}.features`));\n case 'simple_block':\n return simpleBlock(\n parsers.blockStateProvider(raw['to_place'], `${path}.to_place`),\n asBoolean(raw['schedule_tick'], `${path}.schedule_tick`, false)\n );\n case 'replace_single_block':\n return replaceSingleBlock(parseBlockReplacements(raw['replacements'], `${path}.replacements`));\n case 'fill_layer':\n return fillLayer(\n asInteger(raw['height'], `${path}.height`),\n parseBlockState(raw['state'], `${path}.state`)\n );\n case 'blue_ice':\n return blueIce();\n case 'void_start_platform':\n return voidStartPlatform();\n case 'end_platform':\n return endPlatform();\n case 'single_block_pillar': {\n const cap = raw['cap_feature'];\n return singleBlockPillar(\n parsers.blockStateProvider(raw['block'], `${path}.block`),\n raw['can_replace'] === undefined\n ? () => true\n : parseBlockPredicate(raw['can_replace'], `${path}.can_replace`),\n parsers.verticalDirection(raw['direction'], `${path}.direction`),\n asNumber(raw['chance_to_continue'], `${path}.chance_to_continue`, 1),\n cap === undefined ? undefined : parsers.placedFeature(cap, `${path}.cap_feature`)\n );\n }\n case 'underwater_magma':\n return underwaterMagma(\n asInteger(raw['floor_search_range'], `${path}.floor_search_range`),\n asInteger(raw['placement_radius_around_floor'], `${path}.placement_radius_around_floor`),\n asNumber(\n raw['placement_probability_per_valid_position'],\n `${path}.placement_probability_per_valid_position`\n )\n );\n case 'random_neighbor_spread':\n return randomNeighborSpread(\n parsers.blockStateProvider(raw['block'], `${path}.block`),\n parseBlockSet(raw['accepted_neighbors'], `${path}.accepted_neighbors`),\n parseBlockPredicate(raw['can_replace'], `${path}.can_replace`),\n parseIntProvider(raw['attempts'], `${path}.attempts`),\n parseIntProvider(raw['xz_offset'], `${path}.xz_offset`),\n parseIntProvider(raw['y_offset'], `${path}.y_offset`)\n );\n case 'freeze_top_layer':\n return freezeTopLayer();\n case 'block_pile':\n return blockPile(parsers.blockStateProvider(raw['state_provider'], `${path}.state_provider`));\n case 'block_blob':\n return blockBlob(\n parseBlockState(raw['state'], `${path}.state`),\n parseBlockPredicate(raw['can_place_on'], `${path}.can_place_on`)\n );\n case 'netherrack_replace_blobs':\n return netherrackReplaceBlobs(\n parseBlockState(raw['target'], `${path}.target`),\n parseBlockState(raw['state'], `${path}.state`),\n parseIntProvider(raw['radius'], `${path}.radius`)\n );\n case 'delta_feature':\n return deltaFeature(\n parseBlockState(raw['contents'], `${path}.contents`),\n parseBlockState(raw['rim'], `${path}.rim`),\n parseIntProvider(raw['size'], `${path}.size`),\n parseIntProvider(raw['rim_size'], `${path}.rim_size`)\n );\n case 'disk':\n return disk(\n parsers.blockStateProvider(raw['state_provider'], `${path}.state_provider`),\n parseBlockPredicate(raw['target'], `${path}.target`),\n parseIntProvider(raw['radius'], `${path}.radius`),\n asInteger(raw['half_height'], `${path}.half_height`)\n );\n case 'spring_feature':\n return springFeature(\n parsers.fluidState(raw['state'], `${path}.state`),\n asBoolean(raw['requires_block_below'], `${path}.requires_block_below`, true),\n asInteger(raw['rock_count'], `${path}.rock_count`, 4),\n asInteger(raw['hole_count'], `${path}.hole_count`, 1),\n parseBlockSet(raw['valid_blocks'], `${path}.valid_blocks`)\n );\n case 'vines':\n return vines();\n case 'multiface_growth':\n return multifaceGrowth(\n parsers.identifier(raw['block'], `${path}.block`),\n asInteger(raw['search_range'], `${path}.search_range`, 10),\n asBoolean(raw['can_place_on_floor'], `${path}.can_place_on_floor`, false),\n asBoolean(raw['can_place_on_ceiling'], `${path}.can_place_on_ceiling`, false),\n asBoolean(raw['can_place_on_wall'], `${path}.can_place_on_wall`, false),\n parseBlockSet(raw['can_be_placed_on'], `${path}.can_be_placed_on`)\n );\n case 'block_column':\n return blockColumn(\n asArray(raw['layers'], `${path}.layers`).map((entry, index) => {\n const layerPath = `${path}.layers[${index}]`;\n const layer = asObject(entry, layerPath);\n return {\n height: parseIntProvider(layer['height'], `${layerPath}.height`),\n provider: parsers.blockStateProvider(layer['provider'], `${layerPath}.provider`)\n };\n }),\n parsers.direction(raw['direction'], `${path}.direction`),\n parseBlockPredicate(raw['allowed_placement'], `${path}.allowed_placement`),\n asBoolean(raw['prioritize_tip'], `${path}.prioritize_tip`, false)\n );\n case 'projected_random_patchy_square':\n return projectedRandomPatchySquare(\n parsers.blockStateProvider(raw['block'], `${path}.block`),\n parseBlockPredicate(raw['project_through'], `${path}.project_through`),\n parseIntProvider(raw['size'], `${path}.size`),\n asInteger(raw['max_projection_height'], `${path}.max_projection_height`)\n );\n default:\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,aAAgC,QAAQ,eAAe,IAAI;;AAGxE,IAAa,wBAAwB,aACjC,QACI,2BACC,OAAO,QAAQ,WAAW;CACvB,MAAM,SAAS,SAAS,OAAO,eAAe,SAAS,MAAM;CAC7D,OAAO,WAAW,KAAA,IAAY,QAAQ,aAAa,QAAQ,EAAE,MAAM,GAAG,QAAQ,MAAM;AACxF,GACA,SAAS,KAAK,UAAU,MAAM,OAAO,CACzC;;AAGJ,IAAa,yBAAyB,UAAyB,cAC3D,QACI,4BACC,OAAO,QAAQ,WAAW,aAAa,OAAO,YAAY,IAAI,WAAW,WAAW,EAAE,MAAM,GAAG,QAAQ,MAAM,GAC9G,CAAC,SAAS,SAAS,UAAU,OAAO,CACxC;;AAGJ,IAAa,0BACT,aAEA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":"simple.js","names":[],"sources":["../../src/features/simple.ts"],"sourcesContent":["import { asArray, asBoolean, asInteger, asNumber, asObject } from '../json';\nimport type { PlacedFeature } from '../placement/pipeline';\nimport { placeFeature } from '../placement/pipeline';\nimport { randomWeighted } from '../placement/WorldgenRandom';\nimport type { BlockPredicate } from '../providers/blockPredicate';\nimport { parseBlockPredicate } from '../providers/blockPredicate';\nimport type { BlockStateProvider } from '../providers/blockStateProvider';\nimport { parseBlockState } from '../providers/blockStateProvider';\nimport type { IntProvider } from '../providers/valueProviders';\nimport { parseIntProvider, parseWeightedList } from '../providers/valueProviders';\nimport type { BlockSet } from '../registry';\nimport { parseBlockSet } from '../registry';\nimport type { BlockState, Direction } from '../world/BlockState';\nimport {\n ALL_DIRECTIONS,\n blockState,\n HORIZONTAL_DIRECTIONS,\n oppositeDirection,\n withProperty\n} from '../world/BlockState';\nimport type { BlockPos } from '../world/FeatureWorld';\nimport { atY, offset } from '../world/FeatureWorld';\nimport type { ConfiguredFeature } from './Feature';\nimport { feature } from './Feature';\nimport type { BlockReplacement } from './ruleTest';\nimport { parseBlockReplacements } from './ruleTest';\nimport {\n above,\n below,\n betweenClosed,\n distanceSquared,\n inBlockSet,\n isEmptyBlock,\n manhattan,\n outsideBuildHeight,\n relative,\n shuffledCopy,\n withinManhattan\n} from './support';\nimport type { FeatureParsers } from './parseContext';\n\n/**\n * The features whose whole implementation is a few dozen lines: the five selectors, the two\n * sequencers and the small block writers.\n *\n * They are grouped because they share one property that matters for the seed: each decides what\n * to do with the random stream before it touches the world, so a selector that picks a branch\n * costs exactly one draw whichever branch wins.\n */\n\n/** Builds the `no_op` feature, which Java reports as a successful placement that wrote nothing. */\nexport const noOp = (): ConfiguredFeature => feature('no_op', () => true);\n\n/** Runs one of several placed features, drawn uniformly. Costs one draw. */\nexport const simpleRandomSelector = (features: readonly PlacedFeature[]): ConfiguredFeature =>\n feature(\n 'simple_random_selector',\n (world, random, origin) => {\n const chosen = features[random.nextIntBounded(features.length)];\n return chosen === undefined ? false : placeFeature(chosen, { world }, random, origin);\n },\n features.map((entry) => entry.feature)\n );\n\n/** Runs one of two placed features on a coin flip. */\nexport const randomBooleanSelector = (whenTrue: PlacedFeature, whenFalse: PlacedFeature): ConfiguredFeature =>\n feature(\n 'random_boolean_selector',\n (world, random, origin) => placeFeature(random.nextBoolean() ? whenTrue : whenFalse, { world }, random, origin),\n [whenTrue.feature, whenFalse.feature]\n );\n\n/** Runs one placed feature drawn by weight. */\nexport const weightedRandomSelector = (\n features: readonly { readonly value: PlacedFeature; readonly weight: number }[]\n): ConfiguredFeature =>\n feature(\n 'weighted_random_selector',\n (world, random, origin) => placeFeature(randomWeighted(features, random), { world }, random, origin),\n features.map((entry) => entry.value.feature)\n );\n\n/**\n * Walks a list of chance-weighted features, taking the first whose roll succeeds.\n *\n * Java marks this deprecated in favor of `weighted_random_selector`, but 21 vanilla features\n * still use it, and the draw pattern differs: this rolls once per entry until one passes, so the\n * number of draws depends on where the winner sits.\n */\nexport const randomSelector = (\n features: readonly { readonly feature: PlacedFeature; readonly chance: number }[],\n fallback: PlacedFeature\n): ConfiguredFeature =>\n feature(\n 'random_selector',\n (world, random, origin) => {\n for (const entry of features) {\n if (random.nextFloat() < entry.chance) {\n return placeFeature(entry.feature, { world }, random, origin);\n }\n }\n return placeFeature(fallback, { world }, random, origin);\n },\n [...features.map((entry) => entry.feature.feature), fallback.feature]\n );\n\n/** Runs every placed feature at the same origin, reporting whether any placed. */\nexport const overlay = (features: readonly PlacedFeature[]): ConfiguredFeature =>\n feature(\n 'overlay',\n (world, random, origin) => {\n let placedAny = false;\n for (const entry of features) placedAny = placeFeature(entry, { world }, random, origin) || placedAny;\n return placedAny;\n },\n features.map((entry) => entry.feature)\n );\n\n/** Runs every placed feature in order and stops at the first failure. */\nexport const sequence = (features: readonly PlacedFeature[]): ConfiguredFeature =>\n feature(\n 'sequence',\n (world, random, origin) => {\n for (const entry of features) {\n if (!placeFeature(entry, { world }, random, origin)) return false;\n }\n return true;\n },\n features.map((entry) => entry.feature)\n );\n\n/**\n * Places one block, if it would survive there.\n *\n * Java has two special cases this cannot reproduce without a block registry: a double plant\n * places both halves, and a mossy carpet spreads onto its neighbors. Both are recorded in the\n * README as the places where a server's own block behavior has to finish the job.\n */\nexport const simpleBlock = (toPlace: BlockStateProvider, scheduleTick: boolean): ConfiguredFeature =>\n feature('simple_block', (world, random, origin) => {\n const state = toPlace.getOptionalState(world, random, origin);\n if (state === undefined) return false;\n if (!world.blocks.canSurvive(world, origin, state)) return false;\n world.setBlock(origin, state);\n void scheduleTick;\n return true;\n });\n\n/** Replaces the block at the origin with the first replacement whose rule test matches. */\nexport const replaceSingleBlock = (replacements: readonly BlockReplacement[]): ConfiguredFeature =>\n feature('replace_single_block', (world, random, origin) => {\n for (const replacement of replacements) {\n if (replacement.target(world.blocks, world.getBlock(origin), origin, random)) {\n world.setBlock(origin, replacement.state);\n break;\n }\n }\n return true;\n });\n\n/** Fills one y level of the chunk with a state, wherever that level is air. */\nexport const fillLayer = (height: number, state: BlockState): ConfiguredFeature =>\n feature('fill_layer', (world, _random, origin) => {\n const y = world.minY + height;\n for (let dx = 0; dx < 16; dx++) {\n for (let dz = 0; dz < 16; dz++) {\n const position = { x: origin.x + dx, y, z: origin.z + dz };\n if (world.blocks.isAir(world.getBlock(position))) world.setBlock(position, state);\n }\n }\n return true;\n });\n\nconst BLUE_ICE = blockState('minecraft:blue_ice');\n\n/** Grows a patch of blue ice underwater beside packed ice. */\nexport const blueIce = (): ConfiguredFeature =>\n feature('blue_ice', (world, random, origin) => {\n if (origin.y > world.seaLevel - 1) return false;\n if (\n world.getBlock(origin).name !== 'minecraft:water' &&\n world.getBlock(below(origin)).name !== 'minecraft:water'\n ) {\n return false;\n }\n\n let foundPackedIce = false;\n for (const direction of ALL_DIRECTIONS) {\n if (direction === 'down') continue;\n if (world.getBlock(relative(origin, direction)).name === 'minecraft:packed_ice') {\n foundPackedIce = true;\n break;\n }\n }\n if (!foundPackedIce) return false;\n\n world.setBlock(origin, BLUE_ICE);\n for (let attempt = 0; attempt < 200; attempt++) {\n const yOffset = random.nextIntBounded(5) - random.nextIntBounded(6);\n // Java narrows the horizontal spread as the attempt reaches below the start.\n let spread = 3;\n if (yOffset < 2) spread += Math.trunc(yOffset / 2);\n if (spread < 1) continue;\n\n const position = offset(\n origin,\n random.nextIntBounded(spread) - random.nextIntBounded(spread),\n yOffset,\n random.nextIntBounded(spread) - random.nextIntBounded(spread)\n );\n const existing = world.getBlock(position);\n const replaceable =\n world.blocks.isAir(existing) ||\n existing.name === 'minecraft:water' ||\n existing.name === 'minecraft:packed_ice' ||\n existing.name === 'minecraft:ice';\n if (!replaceable) continue;\n\n for (const direction of ALL_DIRECTIONS) {\n if (world.getBlock(relative(position, direction)).name !== 'minecraft:blue_ice') continue;\n world.setBlock(position, BLUE_ICE);\n break;\n }\n }\n return true;\n });\n\nconst COBBLESTONE = blockState('minecraft:cobblestone');\nconst STONE = blockState('minecraft:stone');\n\n/** Builds the stone platform a player spawns on in a void world. */\nexport const voidStartPlatform = (): ConfiguredFeature =>\n feature('void_start_platform', (world, _random, origin) => {\n const chunkX = origin.x >> 4;\n const chunkZ = origin.z >> 4;\n const checkerboard = (ax: number, az: number, bx: number, bz: number) =>\n Math.max(Math.abs(ax - bx), Math.abs(az - bz));\n if (checkerboard(chunkX, chunkZ, 0, 0) > 1) return true;\n\n const platform = { x: 8, y: origin.y + 3, z: 8 };\n for (let z = chunkZ * 16; z <= chunkZ * 16 + 15; z++) {\n for (let x = chunkX * 16; x <= chunkX * 16 + 15; x++) {\n if (checkerboard(platform.x, platform.z, x, z) > 16) continue;\n const position = { x, y: platform.y, z };\n const isCenter = x === platform.x && z === platform.z;\n world.setBlock(position, isCenter ? COBBLESTONE : STONE);\n }\n }\n return true;\n });\n\nconst OBSIDIAN = blockState('minecraft:obsidian');\nconst AIR = blockState('minecraft:air');\n\n/** Builds the five by five obsidian platform an arrival in the end lands on. */\nexport const endPlatform = (): ConfiguredFeature =>\n feature('end_platform', (world, _random, origin) => {\n for (let dz = -2; dz <= 2; dz++) {\n for (let dx = -2; dx <= 2; dx++) {\n for (let dy = -1; dy < 3; dy++) {\n const position = offset(origin, dx, dy, dz);\n const wanted = dy === -1 ? OBSIDIAN : AIR;\n if (world.getBlock(position).name !== wanted.name) world.setBlock(position, wanted);\n }\n }\n }\n return true;\n });\n\n/** Stacks one block upward or downward while a predicate and a per-block chance both hold. */\nexport const singleBlockPillar = (\n block: BlockStateProvider,\n canReplace: BlockPredicate,\n direction: Direction,\n chanceToContinue: number,\n capFeature?: PlacedFeature\n): ConfiguredFeature =>\n feature(\n 'single_block_pillar',\n (world, random, origin) => {\n let position = origin;\n while (\n canReplace(world, position) &&\n random.nextFloat() < chanceToContinue &&\n !outsideBuildHeight(world, position.y)\n ) {\n world.setBlock(position, block.getState(world, random, position));\n position = relative(position, direction);\n }\n position = relative(position, oppositeDirection(direction));\n if (capFeature !== undefined) placeFeature(capFeature, { world }, random, position);\n return true;\n },\n capFeature === undefined ? undefined : [capFeature.feature]\n );\n\nconst MAGMA_BLOCK = blockState('minecraft:magma_block');\n\n/** Scatters magma blocks on an underwater floor, avoiding any that would be visible from the side. */\nexport const underwaterMagma = (\n floorSearchRange: number,\n placementRadiusAroundFloor: number,\n placementProbabilityPerValidPosition: number\n): ConfiguredFeature =>\n feature('underwater_magma', (world, random, origin) => {\n const floorY = findWaterFloor(world, origin, floorSearchRange);\n if (floorY === undefined) return false;\n\n const floor = atY(origin, floorY);\n const radius = placementRadiusAroundFloor;\n let placed = 0;\n for (const position of betweenClosed(\n offset(floor, -radius, -radius, -radius),\n offset(floor, radius, radius, radius)\n )) {\n if (random.nextFloat() >= placementProbabilityPerValidPosition) continue;\n if (!isValidMagmaPlacement(world, position)) continue;\n world.setBlock(position, MAGMA_BLOCK);\n placed++;\n }\n return placed > 0;\n });\n\n/**\n * Walks down through water and returns the y of the first block that is not water.\n *\n * This is Java's `Column.scan` with water inside and anything else as the edge, so the value is\n * the floor block itself rather than the water above it.\n */\nconst findWaterFloor = (\n world: Parameters<ConfiguredFeature['place']>[0],\n origin: BlockPos,\n range: number\n): number | undefined => {\n if (world.getBlock(origin).name !== 'minecraft:water') return undefined;\n let y = origin.y;\n for (let step = 1; step < range && world.getBlock(atY(origin, y)).name === 'minecraft:water'; step++) y--;\n return world.getBlock(atY(origin, y)).name === 'minecraft:water' ? undefined : y;\n};\n\nconst isValidMagmaPlacement = (world: Parameters<ConfiguredFeature['place']>[0], position: BlockPos): boolean => {\n const state = world.getBlock(position);\n const isWaterOrAir = state.name === 'minecraft:water' || world.blocks.isAir(state);\n if (isWaterOrAir) return false;\n if (!world.blocks.isSolid(world.getBlock(below(position)))) return false;\n for (const direction of HORIZONTAL_DIRECTIONS) {\n if (!world.blocks.isSolid(world.getBlock(relative(position, direction)))) return false;\n }\n return true;\n};\n\n/** Places a block at the origin and scatters more wherever exactly one accepted neighbor sits. */\nexport const randomNeighborSpread = (\n block: BlockStateProvider,\n acceptedNeighbors: BlockSet,\n canReplace: BlockPredicate,\n attempts: IntProvider,\n xzOffset: IntProvider,\n yOffset: IntProvider\n): ConfiguredFeature =>\n feature('random_neighbor_spread', (world, random, origin) => {\n world.setBlock(origin, block.getState(world, random, origin));\n const tries = attempts.sample(random);\n for (let attempt = 0; attempt < tries; attempt++) {\n const position = offset(origin, xzOffset.sample(random), yOffset.sample(random), xzOffset.sample(random));\n if (!canReplace(world, position)) continue;\n\n let neighbors = 0;\n for (const direction of ALL_DIRECTIONS) {\n if (inBlockSet(world.blocks, world.getBlock(relative(position, direction)), acceptedNeighbors)) {\n neighbors++;\n }\n if (neighbors > 1) break;\n }\n if (neighbors === 1) world.setBlock(position, block.getState(world, random, position));\n }\n return true;\n });\n\nconst ICE = blockState('minecraft:ice');\nconst SNOW = blockState('minecraft:snow');\n\n/**\n * Freezes exposed water and lays a snow layer across the chunk.\n *\n * Java decides both from the biome's temperature at the position and from the block light there.\n * Temperature comes through {@link FeatureWorld.isColdEnoughToSnow}\n * and light is taken as dark, which is what a chunk being generated has everywhere but under a\n * light-emitting block.\n */\nexport const freezeTopLayer = (): ConfiguredFeature =>\n feature('freeze_top_layer', (world, _random, origin) => {\n for (let dx = 0; dx < 16; dx++) {\n for (let dz = 0; dz < 16; dz++) {\n const x = origin.x + dx;\n const z = origin.z + dz;\n const y = world.getHeight('MOTION_BLOCKING', x, z);\n const top = { x, y, z };\n const under = { x, y: y - 1, z };\n if (world.isColdEnoughToSnow?.(top) !== true) continue;\n\n if (world.getBlock(under).name === 'minecraft:water') world.setBlock(under, ICE);\n const topState = world.getBlock(top);\n if (world.blocks.isAir(topState) && world.blocks.canSurvive(world, top, SNOW)) {\n world.setBlock(top, SNOW);\n const belowState = world.getBlock(under);\n if ('snowy' in belowState.properties)\n world.setBlock(under, withProperty(belowState, 'snowy', 'true'));\n }\n }\n }\n return true;\n });\n\n/** Scatters blocks over a small disc of ground, thinning toward the edge. */\nexport const blockPile = (stateProvider: BlockStateProvider): ConfiguredFeature =>\n feature('block_pile', (world, random, origin) => {\n if (origin.y < world.minY + 5) return false;\n const spreadX = 2 + random.nextIntBounded(2);\n const spreadZ = 2 + random.nextIntBounded(2);\n\n for (const position of betweenClosed(\n offset(origin, -spreadX, 0, -spreadZ),\n offset(origin, spreadX, 1, spreadZ)\n )) {\n const dx = origin.x - position.x;\n const dz = origin.z - position.z;\n const withinBlob = dx * dx + dz * dz <= random.nextFloat() * 10 - random.nextFloat() * 6;\n if (withinBlob || random.nextFloat() < 0.031) {\n if (!isEmptyBlock(world, position)) continue;\n const under = below(position);\n const underState = world.getBlock(under);\n const mayPlace =\n underState.name === 'minecraft:dirt_path'\n ? random.nextBoolean()\n : world.blocks.isSturdy(underState, 'up');\n if (mayPlace) world.setBlock(position, stateProvider.getState(world, random, position));\n }\n }\n return true;\n });\n\n/** Drops three overlapping blobs of one state onto the first block that passes a predicate. */\nexport const blockBlob = (state: BlockState, canPlaceOn: BlockPredicate): ConfiguredFeature =>\n feature('block_blob', (world, random, origin) => {\n let center = origin;\n while (center.y > world.minY + 3 && !canPlaceOn(world, below(center))) center = below(center);\n if (center.y <= world.minY + 3) return false;\n\n for (let blob = 0; blob < 3; blob++) {\n const rx = random.nextIntBounded(2);\n const ry = random.nextIntBounded(2);\n const rz = random.nextIntBounded(2);\n const radius = Math.fround((rx + ry + rz) * 0.333 + 0.5);\n for (const position of betweenClosed(offset(center, -rx, -ry, -rz), offset(center, rx, ry, rz))) {\n if (distanceSquared(position, center) <= radius * radius) world.setBlock(position, state);\n }\n center = offset(\n center,\n -1 + random.nextIntBounded(2),\n -random.nextIntBounded(2),\n -1 + random.nextIntBounded(2)\n );\n }\n return true;\n });\n\n/** Finds the nearest target block below and replaces a Manhattan blob of it. */\nexport const netherrackReplaceBlobs = (\n target: BlockState,\n replacement: BlockState,\n radius: IntProvider\n): ConfiguredFeature =>\n feature('netherrack_replace_blobs', (world, random, origin) => {\n const start = atY(origin, Math.min(Math.max(origin.y, world.minY + 1), world.minY + world.height - 1));\n let center: BlockPos | undefined;\n for (let y = start.y; y > world.minY + 1; y--) {\n const position = atY(start, y);\n if (world.getBlock(position).name === target.name) {\n center = position;\n break;\n }\n }\n if (center === undefined) return false;\n\n const radiusX = radius.sample(random);\n const radiusY = radius.sample(random);\n const radiusZ = radius.sample(random);\n const maximumRadius = Math.max(radiusX, Math.max(radiusY, radiusZ));\n let replacedAny = false;\n for (const position of withinManhattan(center, radiusX, radiusY, radiusZ)) {\n if (manhattan(position, center) > maximumRadius) break;\n if (world.getBlock(position).name !== target.name) continue;\n world.setBlock(position, replacement);\n replacedAny = true;\n }\n return replacedAny;\n });\n\nconst DELTA_CANNOT_REPLACE = new Set([\n 'minecraft:bedrock',\n 'minecraft:nether_bricks',\n 'minecraft:nether_brick_fence',\n 'minecraft:nether_brick_stairs',\n 'minecraft:nether_wart',\n 'minecraft:chest',\n 'minecraft:spawner'\n]);\n\n/** Pours a lava delta with an offset rim over the basalt deltas floor. */\nexport const deltaFeature = (\n contents: BlockState,\n rim: BlockState,\n size: IntProvider,\n rimSize: IntProvider\n): ConfiguredFeature =>\n feature('delta_feature', (world, random, origin) => {\n let anyPlaced = false;\n const spawnRim = random.nextDouble() < 0.9;\n const rimX = spawnRim ? rimSize.sample(random) : 0;\n const rimZ = spawnRim ? rimSize.sample(random) : 0;\n const hasRim = spawnRim && rimX !== 0 && rimZ !== 0;\n const radiusX = size.sample(random);\n const radiusZ = size.sample(random);\n const radiusLimit = Math.max(radiusX, radiusZ);\n\n const isClear = (position: BlockPos): boolean => {\n const state = world.getBlock(position);\n if (state.name === contents.name) return false;\n if (DELTA_CANNOT_REPLACE.has(state.name)) return false;\n for (const direction of ALL_DIRECTIONS) {\n const isAir = world.blocks.isAir(world.getBlock(relative(position, direction)));\n if ((isAir && direction !== 'up') || (!isAir && direction === 'up')) return false;\n }\n return true;\n };\n\n for (const position of withinManhattan(origin, radiusX, 0, radiusZ)) {\n if (manhattan(position, origin) > radiusLimit) break;\n if (!isClear(position)) continue;\n if (hasRim) {\n anyPlaced = true;\n world.setBlock(position, rim);\n }\n const shifted = offset(position, rimX, 0, rimZ);\n if (isClear(shifted)) {\n anyPlaced = true;\n world.setBlock(shifted, contents);\n }\n }\n return anyPlaced;\n });\n\n/** Lays a flat disc of blocks wherever a target predicate holds, within a drawn radius. */\nexport const disk = (\n stateProvider: BlockStateProvider,\n target: BlockPredicate,\n radius: IntProvider,\n halfHeight: number\n): ConfiguredFeature =>\n feature('disk', (world, random, origin) => {\n let placedAny = false;\n const top = origin.y + halfHeight;\n const bottom = origin.y - halfHeight - 1;\n const drawn = radius.sample(random);\n\n for (const column of betweenClosed(offset(origin, -drawn, 0, -drawn), offset(origin, drawn, 0, drawn))) {\n const dx = column.x - origin.x;\n const dz = column.z - origin.z;\n if (dx * dx + dz * dz > drawn * drawn) continue;\n for (let y = top; y > bottom; y--) {\n const position = { x: column.x, y, z: column.z };\n if (!target(world, position)) continue;\n const state = stateProvider.getOptionalState(world, random, position);\n if (state === undefined) continue;\n world.setBlock(position, state);\n placedAny = true;\n }\n }\n return placedAny;\n });\n\n/** Opens a one-block fluid spring in a wall with exactly the declared rock and hole counts. */\nexport const springFeature = (\n fluid: BlockState,\n requiresBlockBelow: boolean,\n rockCount: number,\n holeCount: number,\n validBlocks: BlockSet\n): ConfiguredFeature =>\n feature('spring_feature', (world, _random, origin) => {\n const isValid = (position: BlockPos) => inBlockSet(world.blocks, world.getBlock(position), validBlocks);\n if (!isValid(above(origin))) return false;\n if (requiresBlockBelow && !isValid(below(origin))) return false;\n\n const current = world.getBlock(origin);\n if (!world.blocks.isAir(current) && !inBlockSet(world.blocks, current, validBlocks)) return false;\n\n const sides = [\n relative(origin, 'west'),\n relative(origin, 'east'),\n relative(origin, 'north'),\n relative(origin, 'south'),\n below(origin)\n ];\n let rocks = 0;\n for (const side of sides) if (isValid(side)) rocks++;\n let holes = 0;\n for (const side of sides) if (isEmptyBlock(world, side)) holes++;\n\n if (rocks !== rockCount || holes !== holeCount) return false;\n world.setBlock(origin, fluid);\n // Java's `SpringFeature` ticks the fluid it placed at once, which is what starts the stream.\n world.scheduleFluidTick?.(origin);\n return true;\n });\n\n/**\n * The vine state property for the face a vine attaches to.\n *\n * A vine names the direction of the block it hangs on, so `north=true` means the support is to\n * the north. There is no `down`, which is why the feature skips that direction.\n */\nconst VINE_FACE_PROPERTIES: Readonly<Record<Direction, string | undefined>> = {\n up: 'up',\n down: undefined,\n north: 'north',\n south: 'south',\n west: 'west',\n east: 'east'\n};\n\n/** Hangs a vine on the first face of the origin that has a block behind it. */\nexport const vines = (): ConfiguredFeature =>\n feature('vines', (world, _random, origin) => {\n if (!isEmptyBlock(world, origin)) return false;\n for (const direction of ALL_DIRECTIONS) {\n if (direction === 'down') continue;\n const property = VINE_FACE_PROPERTIES[direction];\n if (property === undefined) continue;\n const neighbor = world.getBlock(relative(origin, direction));\n if (!world.blocks.isSturdy(neighbor, oppositeDirection(direction))) continue;\n world.setBlock(origin, blockState('minecraft:vine', { [property]: 'true' }));\n return true;\n }\n return false;\n });\n\n/**\n * Grows a face-attached block such as glow lichen or sculk vein onto a nearby surface.\n *\n * Java then rolls `chance_of_spreading` and, when it passes, asks the block's own spreader to\n * continue from the placed face. The spreader is block behavior rather than world generation, so\n * this places the first face and stops; the README records the spread pass as the caller's job.\n * The roll is still drawn, because it costs one float whichever way it lands, and the chance\n * itself therefore does not reach this function.\n */\nexport const multifaceGrowth = (\n placeBlock: string,\n searchRange: number,\n canPlaceOnFloor: boolean,\n canPlaceOnCeiling: boolean,\n canPlaceOnWall: boolean,\n canBePlacedOn: BlockSet\n): ConfiguredFeature =>\n feature('multiface_growth', (world, random, origin) => {\n const isAirOrWater = (position: BlockPos) => {\n const state = world.getBlock(position);\n return world.blocks.isAir(state) || state.name === 'minecraft:water';\n };\n if (!isAirOrWater(origin)) return false;\n\n const valid: Direction[] = [];\n if (canPlaceOnCeiling) valid.push('up');\n if (canPlaceOnFloor) valid.push('down');\n if (canPlaceOnWall) valid.push(...HORIZONTAL_DIRECTIONS);\n if (valid.length === 0) return false;\n\n const tryPlace = (position: BlockPos, directions: readonly Direction[]): boolean => {\n for (const direction of directions) {\n const neighbor = world.getBlock(relative(position, direction));\n if (!inBlockSet(world.blocks, neighbor, canBePlacedOn)) continue;\n // A multiface block names the face it sits on, including `down`, which vines lack.\n const existing = world.getBlock(position);\n const base = existing.name === placeBlock ? existing : blockState(placeBlock);\n world.setBlock(position, withProperty(base, direction, 'true'));\n // Java's `placeGrowthIfPossible` marks every face it places for post-processing.\n world.markForPostProcessing?.(position);\n random.nextFloat();\n return true;\n }\n return false;\n };\n\n const searchDirections = shuffledCopy(valid, random);\n if (tryPlace(origin, searchDirections)) return true;\n\n for (const searchDirection of searchDirections) {\n const opposite = oppositeDirection(searchDirection);\n const placementDirections = shuffledCopy(\n valid.filter((direction) => direction !== opposite),\n random\n );\n // Java resets the cursor to one step from the origin on every iteration rather than\n // walking outward, so the scan tests the same position `search_range` times.\n let position = origin;\n for (let step = 0; step < searchRange; step++) {\n position = relative(origin, searchDirection);\n const state = world.getBlock(position);\n if (!isAirOrWater(position) && state.name !== placeBlock) break;\n if (tryPlace(position, placementDirections)) return true;\n }\n }\n return false;\n });\n\n/** One band of a `block_column`: how many blocks and which state they take. */\nexport interface BlockColumnLayer {\n /** How tall the band is. */\n readonly height: IntProvider;\n /** What the band is made of. */\n readonly provider: BlockStateProvider;\n}\n\n/**\n * Stacks several bands of blocks in one direction, trimming them when the column runs into\n * something.\n *\n * Which end gets trimmed is `prioritize_tip`: a twisting vine keeps its tip and loses its stem,\n * while a kelp column keeps its stem and loses its tip.\n */\nexport const blockColumn = (\n layers: readonly BlockColumnLayer[],\n direction: Direction,\n allowedPlacement: BlockPredicate,\n prioritizeTip: boolean\n): ConfiguredFeature =>\n feature('block_column', (world, random, origin) => {\n const heights = layers.map((layer) => layer.height.sample(random));\n let totalHeight = 0;\n for (const height of heights) totalHeight += height;\n if (totalHeight === 0) return false;\n\n let probe = relative(origin, direction);\n for (let step = 0; step < totalHeight; step++) {\n if (!allowedPlacement(world, probe)) {\n truncateColumn(heights, totalHeight, step, prioritizeTip);\n break;\n }\n probe = relative(probe, direction);\n }\n\n let position = origin;\n for (const [index, layer] of layers.entries()) {\n const count = heights[index] ?? 0;\n for (let step = 0; step < count; step++) {\n world.setBlock(position, layer.provider.getState(world, random, position));\n position = relative(position, direction);\n }\n }\n return true;\n });\n\nconst truncateColumn = (heights: number[], totalHeight: number, newHeight: number, prioritizeTip: boolean): void => {\n let toRemove = totalHeight - newHeight;\n const step = prioritizeTip ? 1 : -1;\n const start = prioritizeTip ? 0 : heights.length - 1;\n const end = prioritizeTip ? heights.length : -1;\n for (let index = start; index !== end && toRemove > 0; index += step) {\n const held = heights[index] ?? 0;\n const removed = Math.min(held, toRemove);\n toRemove -= removed;\n heights[index] = held - removed;\n }\n};\n\n/**\n * Scatters blocks over a square, thinning toward the corners, dropping each one onto the surface\n * below it.\n *\n * 26.3 added this and removed `random_patch`. The corner thinning is the whole difference: a\n * position's chance of being used falls with the product of its two offsets, so the patch comes\n * out round rather than square.\n */\nexport const projectedRandomPatchySquare = (\n block: BlockStateProvider,\n projectThrough: BlockPredicate,\n size: IntProvider,\n maxProjectionHeight: number\n): ConfiguredFeature =>\n feature('projected_random_patchy_square', (world, random, origin) => {\n const drawn = size.sample(random);\n const bound = drawn * drawn + 1;\n\n for (let dx = -drawn; dx <= drawn; dx++) {\n for (let dz = -drawn; dz <= drawn; dz++) {\n const probability = Math.abs(dx) * Math.abs(dz);\n if (random.nextIntBounded(bound) >= bound - probability) continue;\n\n let position = offset(origin, dx, 0, dz);\n let drop = maxProjectionHeight;\n while (projectThrough(world, below(position))) {\n position = below(position);\n if (--drop <= 0) break;\n }\n\n const state = block.getOptionalState(world, random, position);\n if (state !== undefined) world.setBlock(position, state);\n }\n }\n return true;\n });\n\n/** Reads the simple feature types, given the parsers for the nested documents they carry. */\nexport const parseSimpleFeature = (\n type: string,\n raw: Record<string, unknown>,\n path: string,\n parsers: FeatureParsers\n): ConfiguredFeature | undefined => {\n switch (type) {\n case 'no_op':\n return noOp();\n case 'simple_random_selector':\n return simpleRandomSelector(parsers.placedFeatureList(raw['features'], `${path}.features`));\n case 'random_boolean_selector':\n return randomBooleanSelector(\n parsers.placedFeature(raw['feature_true'], `${path}.feature_true`),\n parsers.placedFeature(raw['feature_false'], `${path}.feature_false`)\n );\n case 'weighted_random_selector':\n return weightedRandomSelector(\n parseWeightedList(raw['features'], `${path}.features`, (value, entryPath) =>\n parsers.placedFeature(value, entryPath)\n )\n );\n case 'random_selector':\n return randomSelector(\n asArray(raw['features'], `${path}.features`).map((entry, index) => {\n const entryPath = `${path}.features[${index}]`;\n const item = asObject(entry, entryPath);\n return {\n feature: parsers.placedFeature(item['feature'], `${entryPath}.feature`),\n chance: asNumber(item['chance'], `${entryPath}.chance`)\n };\n }),\n parsers.placedFeature(raw['default'], `${path}.default`)\n );\n case 'overlay':\n return overlay(parsers.placedFeatureList(raw['features'], `${path}.features`));\n case 'sequence':\n return sequence(parsers.placedFeatureList(raw['features'], `${path}.features`));\n case 'simple_block':\n return simpleBlock(\n parsers.blockStateProvider(raw['to_place'], `${path}.to_place`),\n asBoolean(raw['schedule_tick'], `${path}.schedule_tick`, false)\n );\n case 'replace_single_block':\n return replaceSingleBlock(parseBlockReplacements(raw['replacements'], `${path}.replacements`));\n case 'fill_layer':\n return fillLayer(\n asInteger(raw['height'], `${path}.height`),\n parseBlockState(raw['state'], `${path}.state`)\n );\n case 'blue_ice':\n return blueIce();\n case 'void_start_platform':\n return voidStartPlatform();\n case 'end_platform':\n return endPlatform();\n case 'single_block_pillar': {\n const cap = raw['cap_feature'];\n return singleBlockPillar(\n parsers.blockStateProvider(raw['block'], `${path}.block`),\n raw['can_replace'] === undefined\n ? () => true\n : parseBlockPredicate(raw['can_replace'], `${path}.can_replace`),\n parsers.verticalDirection(raw['direction'], `${path}.direction`),\n asNumber(raw['chance_to_continue'], `${path}.chance_to_continue`, 1),\n cap === undefined ? undefined : parsers.placedFeature(cap, `${path}.cap_feature`)\n );\n }\n case 'underwater_magma':\n return underwaterMagma(\n asInteger(raw['floor_search_range'], `${path}.floor_search_range`),\n asInteger(raw['placement_radius_around_floor'], `${path}.placement_radius_around_floor`),\n asNumber(\n raw['placement_probability_per_valid_position'],\n `${path}.placement_probability_per_valid_position`\n )\n );\n case 'random_neighbor_spread':\n return randomNeighborSpread(\n parsers.blockStateProvider(raw['block'], `${path}.block`),\n parseBlockSet(raw['accepted_neighbors'], `${path}.accepted_neighbors`),\n parseBlockPredicate(raw['can_replace'], `${path}.can_replace`),\n parseIntProvider(raw['attempts'], `${path}.attempts`),\n parseIntProvider(raw['xz_offset'], `${path}.xz_offset`),\n parseIntProvider(raw['y_offset'], `${path}.y_offset`)\n );\n case 'freeze_top_layer':\n return freezeTopLayer();\n case 'block_pile':\n return blockPile(parsers.blockStateProvider(raw['state_provider'], `${path}.state_provider`));\n case 'block_blob':\n return blockBlob(\n parseBlockState(raw['state'], `${path}.state`),\n parseBlockPredicate(raw['can_place_on'], `${path}.can_place_on`)\n );\n case 'netherrack_replace_blobs':\n return netherrackReplaceBlobs(\n parseBlockState(raw['target'], `${path}.target`),\n parseBlockState(raw['state'], `${path}.state`),\n parseIntProvider(raw['radius'], `${path}.radius`)\n );\n case 'delta_feature':\n return deltaFeature(\n parseBlockState(raw['contents'], `${path}.contents`),\n parseBlockState(raw['rim'], `${path}.rim`),\n parseIntProvider(raw['size'], `${path}.size`),\n parseIntProvider(raw['rim_size'], `${path}.rim_size`)\n );\n case 'disk':\n return disk(\n parsers.blockStateProvider(raw['state_provider'], `${path}.state_provider`),\n parseBlockPredicate(raw['target'], `${path}.target`),\n parseIntProvider(raw['radius'], `${path}.radius`),\n asInteger(raw['half_height'], `${path}.half_height`)\n );\n case 'spring_feature':\n return springFeature(\n parsers.fluidState(raw['state'], `${path}.state`),\n asBoolean(raw['requires_block_below'], `${path}.requires_block_below`, true),\n asInteger(raw['rock_count'], `${path}.rock_count`, 4),\n asInteger(raw['hole_count'], `${path}.hole_count`, 1),\n parseBlockSet(raw['valid_blocks'], `${path}.valid_blocks`)\n );\n case 'vines':\n return vines();\n case 'multiface_growth':\n return multifaceGrowth(\n parsers.identifier(raw['block'], `${path}.block`),\n asInteger(raw['search_range'], `${path}.search_range`, 10),\n asBoolean(raw['can_place_on_floor'], `${path}.can_place_on_floor`, false),\n asBoolean(raw['can_place_on_ceiling'], `${path}.can_place_on_ceiling`, false),\n asBoolean(raw['can_place_on_wall'], `${path}.can_place_on_wall`, false),\n parseBlockSet(raw['can_be_placed_on'], `${path}.can_be_placed_on`)\n );\n case 'block_column':\n return blockColumn(\n asArray(raw['layers'], `${path}.layers`).map((entry, index) => {\n const layerPath = `${path}.layers[${index}]`;\n const layer = asObject(entry, layerPath);\n return {\n height: parseIntProvider(layer['height'], `${layerPath}.height`),\n provider: parsers.blockStateProvider(layer['provider'], `${layerPath}.provider`)\n };\n }),\n parsers.direction(raw['direction'], `${path}.direction`),\n parseBlockPredicate(raw['allowed_placement'], `${path}.allowed_placement`),\n asBoolean(raw['prioritize_tip'], `${path}.prioritize_tip`, false)\n );\n case 'projected_random_patchy_square':\n return projectedRandomPatchySquare(\n parsers.blockStateProvider(raw['block'], `${path}.block`),\n parseBlockPredicate(raw['project_through'], `${path}.project_through`),\n parseIntProvider(raw['size'], `${path}.size`),\n asInteger(raw['max_projection_height'], `${path}.max_projection_height`)\n );\n default:\n return undefined;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAa,aAAgC,QAAQ,eAAe,IAAI;;AAGxE,IAAa,wBAAwB,aACjC,QACI,2BACC,OAAO,QAAQ,WAAW;CACvB,MAAM,SAAS,SAAS,OAAO,eAAe,SAAS,MAAM;CAC7D,OAAO,WAAW,KAAA,IAAY,QAAQ,aAAa,QAAQ,EAAE,MAAM,GAAG,QAAQ,MAAM;AACxF,GACA,SAAS,KAAK,UAAU,MAAM,OAAO,CACzC;;AAGJ,IAAa,yBAAyB,UAAyB,cAC3D,QACI,4BACC,OAAO,QAAQ,WAAW,aAAa,OAAO,YAAY,IAAI,WAAW,WAAW,EAAE,MAAM,GAAG,QAAQ,MAAM,GAC9G,CAAC,SAAS,SAAS,UAAU,OAAO,CACxC;;AAGJ,IAAa,0BACT,aAEA,QACI,6BACC,OAAO,QAAQ,WAAW,aAAa,eAAe,UAAU,MAAM,GAAG,EAAE,MAAM,GAAG,QAAQ,MAAM,GACnG,SAAS,KAAK,UAAU,MAAM,MAAM,OAAO,CAC/C;;;;;;;;AASJ,IAAa,kBACT,UACA,aAEA,QACI,oBACC,OAAO,QAAQ,WAAW;CACvB,KAAK,MAAM,SAAS,UAChB,IAAI,OAAO,UAAU,IAAI,MAAM,QAC3B,OAAO,aAAa,MAAM,SAAS,EAAE,MAAM,GAAG,QAAQ,MAAM;CAGpE,OAAO,aAAa,UAAU,EAAE,MAAM,GAAG,QAAQ,MAAM;AAC3D,GACA,CAAC,GAAG,SAAS,KAAK,UAAU,MAAM,QAA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ACtE,cAAc,IAAI,qBAAqB,GAAG,KAAK,kBAAkB,CACrE;EACJ,KAAK,gBACD,OAAO,YACH,QAAQ,IAAI,WAAW,GAAG,KAAK,QAAQ,CAAC,CAAC,KAAK,OAAO,UAAU;GAC3D,MAAM,YAAY,GAAG,KAAK,UAAU,MAAM;GAC1C,MAAM,QAAQ,SAAS,OAAO,SAAS;GACvC,OAAO;IACH,QAAQ,iBAAiB,MAAM,WAAW,GAAG,UAAU,QAAQ;IAC/D,UAAU,QAAQ,mBAAmB,MAAM,aAAa,GAAG,UAAU,UAAU;GACnF;EACJ,CAAC,GACD,QAAQ,UAAU,IAAI,cAAc,GAAG,KAAK,WAAW,GACvD,oBAAoB,IAAI,sBAAsB,GAAG,KAAK,mBAAmB,GACzE,UAAU,IAAI,mBAAmB,GAAG,KAAK,kBAAkB,KAAK,CACpE;EACJ,KAAK,kCACD,OAAO,4BACH,QAAQ,mBAAmB,IAAI,UAAU,GAAG,KAAK,OAAO,GACxD,oBAAoB,IAAI,oBAAoB,GAAG,KAAK,iBAAiB,GACrE,iBAAiB,IAAI,SAAS,GAAG,KAAK,MAAM,GAC5C,UAAU,IAAI,0BAA0B,GAAG,KAAK,uBAAuB,CAC3E;EACJ,SACI;CACR;AACJ"}
@@ -40,7 +40,7 @@ export declare const parseVerticalAnchor: (source: unknown, path: string) => Ver
40
40
  /**
41
41
  * A draw of one y, Java's `HeightProvider`.
42
42
  *
43
- * It differs from an {@link import('./valueProviders').IntProvider} in taking a
43
+ * It differs from an {@link IntProvider} in taking a
44
44
  * {@link VerticalContext}, because its bounds are anchors rather than numbers.
45
45
  */
46
46
  export interface HeightProvider {
@@ -1 +1 @@
1
- {"version":3,"file":"heightProvider.js","names":[],"sources":["../../src/providers/heightProvider.ts"],"sourcesContent":["import type { RandomSource } from '@jsprismarine/worldgen';\n\nimport { asInteger, asObject, fail } from '../json';\nimport type { Weighted } from '../placement/WorldgenRandom';\nimport { nextIntBetween, randomBetweenInclusive, randomWeighted } from '../placement/WorldgenRandom';\nimport { typeNameOf } from '../registry';\nimport { parseWeightedList } from './valueProviders';\nimport { FeaturesErrors } from '@jsprismarine/errors/features';\n\n/**\n * What a height provider needs from the dimension to turn an anchor into a y.\n *\n * It is the three numbers of Java's `WorldGenerationContext`, so a caller can resolve a height\n * without a world.\n */\nexport interface VerticalContext {\n /** The lowest generated y. */\n readonly minY: number;\n /** The number of generated y levels. */\n readonly height: number;\n /** The dimension's sea level. */\n readonly seaLevel: number;\n}\n\n/**\n * One end of a vertical range, Java's `VerticalAnchor`.\n *\n * The four forms exist so a datapack can express \"eight above the bottom of whatever dimension\n * this is\" without knowing the dimension's height.\n */\nexport type VerticalAnchor =\n | { readonly kind: 'absolute'; readonly y: number }\n | { readonly kind: 'above_bottom'; readonly offset: number }\n | { readonly kind: 'below_top'; readonly offset: number }\n | { readonly kind: 'relative_to_sea_level'; readonly offset: number };\n\n/** Resolves an anchor to a y in the given dimension. */\nexport const resolveAnchor = (anchor: VerticalAnchor, context: VerticalContext): number => {\n switch (anchor.kind) {\n case 'absolute':\n return anchor.y;\n case 'above_bottom':\n return context.minY + anchor.offset;\n case 'below_top':\n return context.height - 1 + context.minY - anchor.offset;\n case 'relative_to_sea_level':\n return context.seaLevel + anchor.offset;\n }\n};\n\n/** Reads a `VerticalAnchor`, which is an object with exactly one of the four keys. */\nexport const parseVerticalAnchor = (source: unknown, path: string): VerticalAnchor => {\n const raw = asObject(source, path);\n if ('absolute' in raw) return { kind: 'absolute', y: asInteger(raw['absolute'], `${path}.absolute`) };\n if ('above_bottom' in raw) {\n return { kind: 'above_bottom', offset: asInteger(raw['above_bottom'], `${path}.above_bottom`) };\n }\n if ('below_top' in raw) return { kind: 'below_top', offset: asInteger(raw['below_top'], `${path}.below_top`) };\n if ('relative_to_sea_level' in raw) {\n return {\n kind: 'relative_to_sea_level',\n offset: asInteger(raw['relative_to_sea_level'], `${path}.relative_to_sea_level`)\n };\n }\n return fail(new FeaturesErrors.ExpectedVerticalAnchor({ path }));\n};\n\n/**\n * A draw of one y, Java's `HeightProvider`.\n *\n * It differs from an {@link import('./valueProviders').IntProvider} in taking a\n * {@link VerticalContext}, because its bounds are anchors rather than numbers.\n */\nexport interface HeightProvider {\n /** The provider's registry name. */\n readonly type: HeightProviderType;\n /** Draws one y. */\n sample(random: RandomSource, context: VerticalContext): number;\n}\n\n/** The six types Java 26.3 registers in `height_provider_type`. */\nexport type HeightProviderType =\n 'constant' | 'uniform' | 'biased_to_bottom' | 'very_biased_to_bottom' | 'trapezoid' | 'weighted_list';\n\n/** A fixed anchor. Costs no draws. */\nexport const constantHeight = (value: VerticalAnchor): HeightProvider => ({\n type: 'constant',\n sample: (_random, context) => resolveAnchor(value, context)\n});\n\n/**\n * A uniform y in `[min, max]`. Costs one draw.\n *\n * Java collapses an inverted range to `min` with a warning rather than failing, because the range\n * depends on the dimension and a datapack cannot always know it is valid. Reproduced here.\n */\nexport const uniformHeight = (min: VerticalAnchor, max: VerticalAnchor): HeightProvider => ({\n type: 'uniform',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n return low > high ? low : randomBetweenInclusive(random, low, high);\n }\n});\n\n/** A y weighted toward the bottom of `[min + inner, max]`. Costs two draws. */\nexport const biasedToBottomHeight = (min: VerticalAnchor, max: VerticalAnchor, inner: number): HeightProvider => ({\n type: 'biased_to_bottom',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n if (high - low - inner + 1 <= 0) return low;\n const limit = random.nextIntBounded(high - low - inner + 1);\n return random.nextIntBounded(limit + inner) + low;\n }\n});\n\n/** A y weighted hard toward the bottom. Costs three draws. */\nexport const veryBiasedToBottomHeight = (min: VerticalAnchor, max: VerticalAnchor, inner: number): HeightProvider => ({\n type: 'very_biased_to_bottom',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n if (high - low - inner + 1 <= 0) return low;\n const upper = nextIntBetween(random, low + inner, high);\n const biasedUpper = nextIntBetween(random, low, upper - 1);\n return nextIntBetween(random, low, biasedUpper - 1 + inner);\n }\n});\n\n/** A trapezoidal y distribution with a flat top `plateau` wide. Costs one or two draws. */\nexport const trapezoidHeight = (min: VerticalAnchor, max: VerticalAnchor, plateau: number): HeightProvider => ({\n type: 'trapezoid',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n if (low > high) return low;\n const range = high - low;\n if (plateau >= range) return randomBetweenInclusive(random, low, high);\n const plateauStart = Math.trunc((range - plateau) / 2);\n const plateauEnd = range - plateauStart;\n return low + randomBetweenInclusive(random, 0, plateauEnd) + randomBetweenInclusive(random, 0, plateauStart);\n }\n});\n\n/** Picks a nested provider by weight, then draws from it. */\nexport const weightedListHeight = (entries: readonly Weighted<HeightProvider>[]): HeightProvider => ({\n type: 'weighted_list',\n sample: (random, context) => randomWeighted(entries, random).sample(random, context)\n});\n\n/** Reads a `HeightProvider`. A bare anchor object is a constant. */\nexport const parseHeightProvider = (source: unknown, path: string): HeightProvider => {\n if (typeof source === 'number') {\n return constantHeight({ kind: 'absolute', y: asInteger(source, path) });\n }\n const raw = asObject(source, path);\n if (!('type' in raw)) return constantHeight(parseVerticalAnchor(raw, path));\n\n const type = typeNameOf(raw['type'], path);\n switch (type) {\n case 'constant':\n return constantHeight(parseVerticalAnchor(raw['value'], `${path}.value`));\n case 'uniform':\n return uniformHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`)\n );\n case 'biased_to_bottom':\n return biasedToBottomHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`),\n asInteger(raw['inner'], `${path}.inner`, 1)\n );\n case 'very_biased_to_bottom':\n return veryBiasedToBottomHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`),\n asInteger(raw['inner'], `${path}.inner`, 1)\n );\n case 'trapezoid':\n return trapezoidHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`),\n asInteger(raw['plateau'], `${path}.plateau`, 0)\n );\n case 'weighted_list':\n return weightedListHeight(\n parseWeightedList(raw['distribution'], `${path}.distribution`, (value, entryPath) =>\n parseHeightProvider(value, entryPath)\n )\n );\n default:\n return fail(new FeaturesErrors.UnknownHeightProviderType({ path, type: JSON.stringify(type) }));\n }\n};\n"],"mappings":";;;;;;;AAqCA,IAAa,iBAAiB,QAAwB,YAAqC;CACvF,QAAQ,OAAO,MAAf;EACI,KAAK,YACD,OAAO,OAAO;EAClB,KAAK,gBACD,OAAO,QAAQ,OAAO,OAAO;EACjC,KAAK,aACD,OAAO,QAAQ,SAAS,IAAI,QAAQ,OAAO,OAAO;EACtD,KAAK,yBACD,OAAO,QAAQ,WAAW,OAAO;CACzC;AACJ;;AAGA,IAAa,uBAAuB,QAAiB,SAAiC;CAClF,MAAM,MAAM,SAAS,QAAQ,IAAI;CACjC,IAAI,cAAc,KAAK,OAAO;EAAE,MAAM;EAAY,GAAG,UAAU,IAAI,aAAa,GAAG,KAAK,UAAU;CAAE;CACpG,IAAI,kBAAkB,KAClB,OAAO;EAAE,MAAM;EAAgB,QAAQ,UAAU,IAAI,iBAAiB,GAAG,KAAK,cAAc;CAAE;CAElG,IAAI,eAAe,KAAK,OAAO;EAAE,MAAM;EAAa,QAAQ,UAAU,IAAI,cAAc,GAAG,KAAK,WAAW;CAAE;CAC7G,IAAI,2BAA2B,KAC3B,OAAO;EACH,MAAM;EACN,QAAQ,UAAU,IAAI,0BAA0B,GAAG,KAAK,uBAAuB;CACnF;CAEJ,OAAO,KAAK,IAAI,eAAe,uBAAuB,EAAE,KAAK,CAAC,CAAC;AACnE;;AAoBA,IAAa,kBAAkB,WAA2C;CACtE,MAAM;CAC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jE,UAAU,IAAI,YAAY,GAAG,KAAK,WAAW,CAAC,CAClD;EACJ,KAAK,iBACD,OAAO,mBACH,kBAAkB,IAAI,iBAAiB,GAAG,KAAK,iBAAiB,OAAO,cACnE,oBAAoB,OAAO,SAAS,CACxC,CACJ;EACJ,SACI,OAAO,KAAK,IAAI,eAAe,0BAA0B;GAAE;GAAM,MAAM,KAAK,UAAU,IAAI;EAAE,CAAC,CAAC;CACtG;AACJ"}
1
+ {"version":3,"file":"heightProvider.js","names":[],"sources":["../../src/providers/heightProvider.ts"],"sourcesContent":["import type { RandomSource } from '@jsprismarine/worldgen';\n\nimport { asInteger, asObject, fail } from '../json';\nimport type { Weighted } from '../placement/WorldgenRandom';\nimport { nextIntBetween, randomBetweenInclusive, randomWeighted } from '../placement/WorldgenRandom';\nimport { typeNameOf } from '../registry';\nimport { parseWeightedList } from './valueProviders';\nimport { FeaturesErrors } from '@jsprismarine/errors/features';\n\n/**\n * What a height provider needs from the dimension to turn an anchor into a y.\n *\n * It is the three numbers of Java's `WorldGenerationContext`, so a caller can resolve a height\n * without a world.\n */\nexport interface VerticalContext {\n /** The lowest generated y. */\n readonly minY: number;\n /** The number of generated y levels. */\n readonly height: number;\n /** The dimension's sea level. */\n readonly seaLevel: number;\n}\n\n/**\n * One end of a vertical range, Java's `VerticalAnchor`.\n *\n * The four forms exist so a datapack can express \"eight above the bottom of whatever dimension\n * this is\" without knowing the dimension's height.\n */\nexport type VerticalAnchor =\n | { readonly kind: 'absolute'; readonly y: number }\n | { readonly kind: 'above_bottom'; readonly offset: number }\n | { readonly kind: 'below_top'; readonly offset: number }\n | { readonly kind: 'relative_to_sea_level'; readonly offset: number };\n\n/** Resolves an anchor to a y in the given dimension. */\nexport const resolveAnchor = (anchor: VerticalAnchor, context: VerticalContext): number => {\n switch (anchor.kind) {\n case 'absolute':\n return anchor.y;\n case 'above_bottom':\n return context.minY + anchor.offset;\n case 'below_top':\n return context.height - 1 + context.minY - anchor.offset;\n case 'relative_to_sea_level':\n return context.seaLevel + anchor.offset;\n }\n};\n\n/** Reads a `VerticalAnchor`, which is an object with exactly one of the four keys. */\nexport const parseVerticalAnchor = (source: unknown, path: string): VerticalAnchor => {\n const raw = asObject(source, path);\n if ('absolute' in raw) return { kind: 'absolute', y: asInteger(raw['absolute'], `${path}.absolute`) };\n if ('above_bottom' in raw) {\n return { kind: 'above_bottom', offset: asInteger(raw['above_bottom'], `${path}.above_bottom`) };\n }\n if ('below_top' in raw) return { kind: 'below_top', offset: asInteger(raw['below_top'], `${path}.below_top`) };\n if ('relative_to_sea_level' in raw) {\n return {\n kind: 'relative_to_sea_level',\n offset: asInteger(raw['relative_to_sea_level'], `${path}.relative_to_sea_level`)\n };\n }\n return fail(new FeaturesErrors.ExpectedVerticalAnchor({ path }));\n};\n\n/**\n * A draw of one y, Java's `HeightProvider`.\n *\n * It differs from an {@link IntProvider} in taking a\n * {@link VerticalContext}, because its bounds are anchors rather than numbers.\n */\nexport interface HeightProvider {\n /** The provider's registry name. */\n readonly type: HeightProviderType;\n /** Draws one y. */\n sample(random: RandomSource, context: VerticalContext): number;\n}\n\n/** The six types Java 26.3 registers in `height_provider_type`. */\nexport type HeightProviderType =\n 'constant' | 'uniform' | 'biased_to_bottom' | 'very_biased_to_bottom' | 'trapezoid' | 'weighted_list';\n\n/** A fixed anchor. Costs no draws. */\nexport const constantHeight = (value: VerticalAnchor): HeightProvider => ({\n type: 'constant',\n sample: (_random, context) => resolveAnchor(value, context)\n});\n\n/**\n * A uniform y in `[min, max]`. Costs one draw.\n *\n * Java collapses an inverted range to `min` with a warning rather than failing, because the range\n * depends on the dimension and a datapack cannot always know it is valid. Reproduced here.\n */\nexport const uniformHeight = (min: VerticalAnchor, max: VerticalAnchor): HeightProvider => ({\n type: 'uniform',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n return low > high ? low : randomBetweenInclusive(random, low, high);\n }\n});\n\n/** A y weighted toward the bottom of `[min + inner, max]`. Costs two draws. */\nexport const biasedToBottomHeight = (min: VerticalAnchor, max: VerticalAnchor, inner: number): HeightProvider => ({\n type: 'biased_to_bottom',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n if (high - low - inner + 1 <= 0) return low;\n const limit = random.nextIntBounded(high - low - inner + 1);\n return random.nextIntBounded(limit + inner) + low;\n }\n});\n\n/** A y weighted hard toward the bottom. Costs three draws. */\nexport const veryBiasedToBottomHeight = (min: VerticalAnchor, max: VerticalAnchor, inner: number): HeightProvider => ({\n type: 'very_biased_to_bottom',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n if (high - low - inner + 1 <= 0) return low;\n const upper = nextIntBetween(random, low + inner, high);\n const biasedUpper = nextIntBetween(random, low, upper - 1);\n return nextIntBetween(random, low, biasedUpper - 1 + inner);\n }\n});\n\n/** A trapezoidal y distribution with a flat top `plateau` wide. Costs one or two draws. */\nexport const trapezoidHeight = (min: VerticalAnchor, max: VerticalAnchor, plateau: number): HeightProvider => ({\n type: 'trapezoid',\n sample: (random, context) => {\n const low = resolveAnchor(min, context);\n const high = resolveAnchor(max, context);\n if (low > high) return low;\n const range = high - low;\n if (plateau >= range) return randomBetweenInclusive(random, low, high);\n const plateauStart = Math.trunc((range - plateau) / 2);\n const plateauEnd = range - plateauStart;\n return low + randomBetweenInclusive(random, 0, plateauEnd) + randomBetweenInclusive(random, 0, plateauStart);\n }\n});\n\n/** Picks a nested provider by weight, then draws from it. */\nexport const weightedListHeight = (entries: readonly Weighted<HeightProvider>[]): HeightProvider => ({\n type: 'weighted_list',\n sample: (random, context) => randomWeighted(entries, random).sample(random, context)\n});\n\n/** Reads a `HeightProvider`. A bare anchor object is a constant. */\nexport const parseHeightProvider = (source: unknown, path: string): HeightProvider => {\n if (typeof source === 'number') {\n return constantHeight({ kind: 'absolute', y: asInteger(source, path) });\n }\n const raw = asObject(source, path);\n if (!('type' in raw)) return constantHeight(parseVerticalAnchor(raw, path));\n\n const type = typeNameOf(raw['type'], path);\n switch (type) {\n case 'constant':\n return constantHeight(parseVerticalAnchor(raw['value'], `${path}.value`));\n case 'uniform':\n return uniformHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`)\n );\n case 'biased_to_bottom':\n return biasedToBottomHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`),\n asInteger(raw['inner'], `${path}.inner`, 1)\n );\n case 'very_biased_to_bottom':\n return veryBiasedToBottomHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`),\n asInteger(raw['inner'], `${path}.inner`, 1)\n );\n case 'trapezoid':\n return trapezoidHeight(\n parseVerticalAnchor(raw['min_inclusive'], `${path}.min_inclusive`),\n parseVerticalAnchor(raw['max_inclusive'], `${path}.max_inclusive`),\n asInteger(raw['plateau'], `${path}.plateau`, 0)\n );\n case 'weighted_list':\n return weightedListHeight(\n parseWeightedList(raw['distribution'], `${path}.distribution`, (value, entryPath) =>\n parseHeightProvider(value, entryPath)\n )\n );\n default:\n return fail(new FeaturesErrors.UnknownHeightProviderType({ path, type: JSON.stringify(type) }));\n }\n};\n"],"mappings":";;;;;;;AAqCA,IAAa,iBAAiB,QAAwB,YAAqC;CACvF,QAAQ,OAAO,MAAf;EACI,KAAK,YACD,OAAO,OAAO;EAClB,KAAK,gBACD,OAAO,QAAQ,OAAO,OAAO;EACjC,KAAK,aACD,OAAO,QAAQ,SAAS,IAAI,QAAQ,OAAO,OAAO;EACtD,KAAK,yBACD,OAAO,QAAQ,WAAW,OAAO;CACzC;AACJ;;AAGA,IAAa,uBAAuB,QAAiB,SAAiC;CAClF,MAAM,MAAM,SAAS,QAAQ,IAAI;CACjC,IAAI,cAAc,KAAK,OAAO;EAAE,MAAM;EAA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ACrE;EACJ,KAAK,oBACD,OAAO,qBACH,oBAAoB,IAAI,kBAAkB,GAAG,KAAK,eAAe,GACjE,oBAAoB,IAAI,kBAAkB,GAAG,KAAK,eAAe,GACjE,UAAU,IAAI,UAAU,GAAG,KAAK,SAAS,CAAC,CAC9C;EACJ,KAAK,yBACD,OAAO,yBACH,oBAAoB,IAAI,kBAAkB,GAAG,KAAK,eAAe,GACjE,oBAAoB,IAAI,kBAAkB,GAAG,KAAK,eAAe,GACjE,UAAU,IAAI,UAAU,GAAG,KAAK,SAAS,CAAC,CAC9C;EACJ,KAAK,aACD,OAAO,gBACH,oBAAoB,IAAI,kBAAkB,GAAG,KAAK,eAAe,GACjE,oBAAoB,IAAI,kBAAkB,GAAG,KAAK,eAAe,GACjE,UAAU,IAAI,YAAY,GAAG,KAAK,WAAW,CAAC,CAClD;EACJ,KAAK,iBACD,OAAO,mBACH,kBAAkB,IAAI,iBAAiB,GAAG,KAAK,iBAAiB,OAAO,cACnE,oBAAoB,OAAO,SAAS,CACxC,CACJ;EACJ,SACI,OAAO,KAAK,IAAI,eAAe,0BAA0B;GAAE;GAAM,MAAM,KAAK,UAAU,IAAI;EAAE,CAAC,CAAC;CACtG;AACJ"}
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Everything this package produces is Java-shaped. Turning a state into the Bedrock palette entry
6
6
  * the server stores is `@jsprismarine/mapping`'s job, reached through the
7
- * {@link import('./FeatureWorld').FeatureWorld} adapter rather than from inside a feature.
7
+ * {@link FeatureWorld} adapter rather than from inside a feature.
8
8
  */
9
9
  export interface BlockState {
10
10
  /** The namespaced block identifier, for example `minecraft:oak_log`. */
@@ -1 +1 @@
1
- {"version":3,"file":"BlockState.js","names":[],"sources":["../../src/world/BlockState.ts"],"sourcesContent":["/**\n * A Java Edition block state: an identifier and the property values that distinguish it from the\n * other states of the same block.\n *\n * Everything this package produces is Java-shaped. Turning a state into the Bedrock palette entry\n * the server stores is `@jsprismarine/mapping`'s job, reached through the\n * {@link import('./FeatureWorld').FeatureWorld} adapter rather than from inside a feature.\n */\nexport interface BlockState {\n /** The namespaced block identifier, for example `minecraft:oak_log`. */\n readonly name: string;\n /** Property values keyed by name, as strings, exactly as the JSON spells them. */\n readonly properties: Readonly<Record<string, string>>;\n}\n\n/** The three fluids a block state can hold, which is all the feature code distinguishes. */\nexport type FluidKind = 'empty' | 'water' | 'lava';\n\n/** The six block faces, spelled as Java spells a `Direction`. */\nexport type Direction = 'down' | 'up' | 'north' | 'south' | 'west' | 'east';\n\n/** The two vertical directions, which `environment_scan` and the speleothem features search along. */\nexport type VerticalDirection = 'down' | 'up';\n\n/** The unit step of each direction, in Java's axis order. */\nexport const DIRECTION_STEPS: Readonly<Record<Direction, readonly [number, number, number]>> = {\n down: [0, -1, 0],\n up: [0, 1, 0],\n north: [0, 0, -1],\n south: [0, 0, 1],\n west: [-1, 0, 0],\n east: [1, 0, 0]\n};\n\n/**\n * The four compass directions in Java's `Direction.Plane.HORIZONTAL` order.\n *\n * This is north, east, south, west, which is not the order of `Direction.values()`. Anything\n * that draws a random horizontal direction indexes into this array, so the order is part of the\n * seed contract rather than a presentation detail.\n */\nexport const HORIZONTAL_DIRECTIONS = ['north', 'east', 'south', 'west'] as const satisfies readonly Direction[];\n\n/** Every direction in Java's declaration order, which decides iteration order in several features. */\nexport const ALL_DIRECTIONS = ['down', 'up', 'north', 'south', 'west', 'east'] as const satisfies readonly Direction[];\n\nconst OPPOSITES = {\n down: 'up',\n up: 'down',\n north: 'south',\n south: 'north',\n west: 'east',\n east: 'west'\n} as const satisfies Record<Direction, Direction>;\n\n/** Returns the direction facing the other way. */\nexport const oppositeDirection = <D extends Direction>(direction: D): (typeof OPPOSITES)[D] => OPPOSITES[direction];\n\nconst EMPTY_PROPERTIES: Readonly<Record<string, string>> = Object.freeze({});\n\n/** Builds a block state, sharing one frozen object for the common property-free case. */\nexport const blockState = (name: string, properties?: Readonly<Record<string, string>>): BlockState => ({\n name,\n properties: properties ?? EMPTY_PROPERTIES\n});\n\n/** Returns a copy of `state` with one property set, leaving the original untouched. */\nexport const withProperty = (state: BlockState, key: string, value: string): BlockState =>\n state.properties[key] === value ? state : blockState(state.name, { ...state.properties, [key]: value });\n\n/** Returns a copy of `state` with several properties set at once. */\nexport const withProperties = (state: BlockState, values: Readonly<Record<string, string>>): BlockState =>\n blockState(state.name, { ...state.properties, ...values });\n\n/**\n * Returns the canonical text form, `minecraft:oak_log[axis=y]`, with properties in sorted order.\n *\n * Two states are the same state when their keys are equal, which is what the feature code compares\n * instead of walking property maps.\n */\nexport const blockStateKey = (state: BlockState): string => {\n const keys = Object.keys(state.properties).sort();\n if (keys.length === 0) return state.name;\n return `${state.name}[${keys.map((key) => `${key}=${state.properties[key]}`).join(',')}]`;\n};\n\n/** Answers whether two states name the same block, ignoring their properties. */\nexport const isBlock = (state: BlockState, name: string): boolean => state.name === name;\n\n/** Answers whether two states are identical, properties included. */\nexport const sameState = (a: BlockState, b: BlockState): boolean => blockStateKey(a) === blockStateKey(b);\n"],"mappings":";;AAyBA,IAAa,kBAAkF;CAC3F,MAAM;EAAC;EAAG;EAAI;CAAC;CACf,IAAI;EAAC;EAAG;EAAG;CAAC;CACZ,OAAO;EAAC;EAAG;EAAG;CAAE;CAChB,OAAO;EAAC;EAAG;EAAG;CAAC;CACf,MAAM;EAAC;EAAI;EAAG;CAAC;CACf,MAAM;EAAC;EAAG;EAAG;CAAC;AAClB;;;;;;;;AASA,IAAa,wBAAwB;CAAC;CAAS;CAAQ;CAAS;AAAM;;AAGtE,IAAa,iBAAiB;CAAC;CAAQ;CAAM;CAAS;CAAS;CAAQ;AAAM;AAE7E,IAAM,YAAY;CACd,MAAM;CACN,IAAI;CACJ,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;AACV;;AAGA,IAAa,qBAA0C,cAAwC,UAAU;AAEzG,IAAM,mBAAqD,OAAO,OAAO,CAAC,CAAC;;AAG3E,IAAa,cAAc,MAAc,gBAA+D;CACpG;CACA,YAAY,cAAc;AAC9B;;AAGA,IAAa,gBAAgB,OAAmB,KAAa,UACzD,MAAM,WAAW,SAAS,QAAQ,QAAQ,WAAW,MAAM,MAAM;CAAE,GAAG,MAAM;EAAa,MAAM;AAAM,CAAC;;AAG1G,IAAa,kBAAkB,OAAmB,WAC9C,WAAW,MAAM,MAAM;CAAE,GAAG,MAAM;CAAY,GAAG;AAAO,CAAC;;;;;;;AAQ7D,IAAa,iBAAiB,UAA8B;CACxD,MAAM,OAAO,OAAO,KAAK,MAAM,UAAU,CAAC,CAAC,KAAK;CAChD,IAAI,KAAK,WAAW,GAAG,OAAO,MAAM;CACpC,OAAO,GAAG,MAAM,KAAK,GAAG,KAAK,KAAK,QAAQ,GAAG,IAAI,GAAG,MAAM,WAAW,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE;AAC3F;;AAGA,IAAa,WAAW,OAAmB,SAA0B,MAAM,SAAS;;AAGpF,IAAa,aAAa,GAAe,MAA2B,cAAc,CAAC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"BlockState.js","names":[],"sources":["../../src/world/BlockState.ts"],"sourcesContent":["/**\n * A Java Edition block state: an identifier and the property values that distinguish it from the\n * other states of the same block.\n *\n * Everything this package produces is Java-shaped. Turning a state into the Bedrock palette entry\n * the server stores is `@jsprismarine/mapping`'s job, reached through the\n * {@link FeatureWorld} adapter rather than from inside a feature.\n */\nexport interface BlockState {\n /** The namespaced block identifier, for example `minecraft:oak_log`. */\n readonly name: string;\n /** Property values keyed by name, as strings, exactly as the JSON spells them. */\n readonly properties: Readonly<Record<string, string>>;\n}\n\n/** The three fluids a block state can hold, which is all the feature code distinguishes. */\nexport type FluidKind = 'empty' | 'water' | 'lava';\n\n/** The six block faces, spelled as Java spells a `Direction`. */\nexport type Direction = 'down' | 'up' | 'north' | 'south' | 'west' | 'east';\n\n/** The two vertical directions, which `environment_scan` and the speleothem features search along. */\nexport type VerticalDirection = 'down' | 'up';\n\n/** The unit step of each direction, in Java's axis order. */\nexport const DIRECTION_STEPS: Readonly<Record<Direction, readonly [number, number, number]>> = {\n down: [0, -1, 0],\n up: [0, 1, 0],\n north: [0, 0, -1],\n south: [0, 0, 1],\n west: [-1, 0, 0],\n east: [1, 0, 0]\n};\n\n/**\n * The four compass directions in Java's `Direction.Plane.HORIZONTAL` order.\n *\n * This is north, east, south, west, which is not the order of `Direction.values()`. Anything\n * that draws a random horizontal direction indexes into this array, so the order is part of the\n * seed contract rather than a presentation detail.\n */\nexport const HORIZONTAL_DIRECTIONS = ['north', 'east', 'south', 'west'] as const satisfies readonly Direction[];\n\n/** Every direction in Java's declaration order, which decides iteration order in several features. */\nexport const ALL_DIRECTIONS = ['down', 'up', 'north', 'south', 'west', 'east'] as const satisfies readonly Direction[];\n\nconst OPPOSITES = {\n down: 'up',\n up: 'down',\n north: 'south',\n south: 'north',\n west: 'east',\n east: 'west'\n} as const satisfies Record<Direction, Direction>;\n\n/** Returns the direction facing the other way. */\nexport const oppositeDirection = <D extends Direction>(direction: D): (typeof OPPOSITES)[D] => OPPOSITES[direction];\n\nconst EMPTY_PROPERTIES: Readonly<Record<string, string>> = Object.freeze({});\n\n/** Builds a block state, sharing one frozen object for the common property-free case. */\nexport const blockState = (name: string, properties?: Readonly<Record<string, string>>): BlockState => ({\n name,\n properties: properties ?? EMPTY_PROPERTIES\n});\n\n/** Returns a copy of `state` with one property set, leaving the original untouched. */\nexport const withProperty = (state: BlockState, key: string, value: string): BlockState =>\n state.properties[key] === value ? state : blockState(state.name, { ...state.properties, [key]: value });\n\n/** Returns a copy of `state` with several properties set at once. */\nexport const withProperties = (state: BlockState, values: Readonly<Record<string, string>>): BlockState =>\n blockState(state.name, { ...state.properties, ...values });\n\n/**\n * Returns the canonical text form, `minecraft:oak_log[axis=y]`, with properties in sorted order.\n *\n * Two states are the same state when their keys are equal, which is what the feature code compares\n * instead of walking property maps.\n */\nexport const blockStateKey = (state: BlockState): string => {\n const keys = Object.keys(state.properties).sort();\n if (keys.length === 0) return state.name;\n return `${state.name}[${keys.map((key) => `${key}=${state.properties[key]}`).join(',')}]`;\n};\n\n/** Answers whether two states name the same block, ignoring their properties. */\nexport const isBlock = (state: BlockState, name: string): boolean => state.name === name;\n\n/** Answers whether two states are identical, properties included. */\nexport const sameState = (a: BlockState, b: BlockState): boolean => blockStateKey(a) === blockStateKey(b);\n"],"mappings":";;AAyBA,IAAa,kBAAkF;CAC3F,MAAM;EAAC;EAAG;EAAI;CAAC;CACf,IAAI;EAAC;EAAG;EAAG;CAAC;CACZ,OAAO;EAAC;EAAG;EAAG;CAAE;CAChB,OAAO;EAAC;EAAG;EAAG;CAAC;CACf,MAAM;EAAC;EAAI;EAAG;CAAC;CACf,MAAM;EAAC;EAAG;EAAG;CAAC;AAClB;;;;;;;;AASA,IAAa,wBAAwB;CAAC;CAAS;CAAQ;CAAS;AAAM;;AAGtE,IAAa,iBAAiB;CAAC;CAAQ;CAAM;CAAS;CAAS;CAAQ;AAAM;AAE7E,IAAM,YAAY;CACd,MAAM;CACN,IAAI;CACJ,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;AACV;;AAGA,IAAa,qBAA0C,cAAwC,UAAU;AAEzG,IAAM,mBAAqD,OAAO,OAAO,CAAC,CAAC;;AAG3E,IAAa,cAAc,MAAc,gBAA+D;CACpG;CACA,YAAY,cAAc;AAC9B;;AAGA,IAAa,gBAAgB,OAAmB,KAAa,UACzD,MAAM,WAAW,SAAS,QAAQ,QAAQ,WAAW,MAAM,MAAM;CAAE,GAAG,MAAM;EAAa,MAAM;AAAM,CAAC;;AAG1G,IAAa,kBAAkB,OAAmB,WAC9C,WAAW,MAAM,MAAM;CAAE,GAAG,MAAM;CAAY,GAAG;AAAO,CAAC;;;;;;;AAQ7D,IAAa,iBAAiB,UAA8B;CACxD,MAAM,OAAO,OAAO,KAAK,MAAM,UAAU,CAAC,CAAC,KAAK;CAChD,IAAI,KAAK,WAAW,GAAG,OAAO,MAAM;CACpC,OAAO,GAAG,MAAM,KAAK,GAAG,KAAK,KAAK,QAAQ,GAAG,IAAI,GAAG,MAAM,WAAW,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE;AAC3F;;AAGA,IAAa,WAAW,OAAmB,SAA0B,MAAM,SAAS;;AAGpF,IAAa,aAAa,GAAe,MAA2B,cAAc,CAAC,MAAM,cAAc,CAAC"}
@@ -68,7 +68,7 @@ export interface BlockOracle {
68
68
  * This is the package's only outward seam. Features never see a chunk, a section, a palette or a
69
69
  * Bedrock identifier: they read and write Java block states through these seven members, so the
70
70
  * server's storage, its Java-to-Bedrock mapping and its chunk lifetime stay on the other side.
71
- * {@link import('./TestFeatureWorld').TestFeatureWorld} is the in-memory adapter the tests use.
71
+ * {@link TestFeatureWorld} is the in-memory adapter the tests use.
72
72
  *
73
73
  * Writes are expected to succeed or be dropped silently, as Java's `WorldGenLevel.setBlock` does
74
74
  * outside the region being generated; a feature treats {@link setBlock} as advisory and reads back
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureWorld.js","names":[],"sources":["../../src/world/FeatureWorld.ts"],"sourcesContent":["import type { BlockState, Direction, FluidKind } from './BlockState';\n\n/** A block position in world coordinates. */\nexport interface BlockPos {\n readonly x: number;\n readonly y: number;\n readonly z: number;\n}\n\n/** Builds a position. */\nexport const pos = (x: number, y: number, z: number): BlockPos => ({ x, y, z });\n\n/** Returns `origin` moved by a delta. */\nexport const offset = (origin: BlockPos, dx: number, dy: number, dz: number): BlockPos => ({\n x: origin.x + dx,\n y: origin.y + dy,\n z: origin.z + dz\n});\n\n/** Returns `origin` with a different y. */\nexport const atY = (origin: BlockPos, y: number): BlockPos => ({ x: origin.x, y, z: origin.z });\n\n/** The canonical text key for a position, which the test world uses to index its store. */\nexport const posKey = (position: BlockPos): string => `${position.x},${position.y},${position.z}`;\n\n/**\n * The six heightmaps Java Edition keeps, named as the placement JSON spells them.\n *\n * The three `_WG` and `OCEAN_FLOOR`/`WORLD_SURFACE` pairs differ only in when they are computed,\n * so a generator that decorates a chunk once can answer both from the same column scan.\n */\nexport type HeightmapType =\n | 'WORLD_SURFACE_WG'\n | 'WORLD_SURFACE'\n | 'OCEAN_FLOOR_WG'\n | 'OCEAN_FLOOR'\n | 'MOTION_BLOCKING'\n | 'MOTION_BLOCKING_NO_LEAVES';\n\n/** Every {@link HeightmapType}, for reading one out of a document. */\nexport const HEIGHTMAPS = [\n 'WORLD_SURFACE_WG',\n 'WORLD_SURFACE',\n 'OCEAN_FLOOR_WG',\n 'OCEAN_FLOOR',\n 'MOTION_BLOCKING',\n 'MOTION_BLOCKING_NO_LEAVES'\n] as const satisfies readonly HeightmapType[];\n\n/**\n * The facts about a block state that do not depend on where it sits.\n *\n * This is a separate seam from {@link FeatureWorld} because the answers are pure and shared: a\n * server builds one oracle from its block registry and tag tables and reuses it for every chunk,\n * while a world adapter is created per decorated region. A feature reaches it through\n * {@link FeatureWorld.blocks}, so a feature still takes one object.\n */\nexport interface BlockOracle {\n /** Answers Java's `BlockState.isAir()`. */\n isAir(state: BlockState): boolean;\n /** Answers Java's `BlockState.isSolid()`: the block occupies its whole cell and blocks motion. */\n isSolid(state: BlockState): boolean;\n /** Answers Java's `BlockState.isFaceSturdy(level, pos, direction)` for a full face. */\n isSturdy(state: BlockState, direction: Direction): boolean;\n /** Answers Java's `BlockState.canBeReplaced()`, which decides whether a feature may overwrite it. */\n isReplaceable(state: BlockState): boolean;\n /** Returns the fluid the state holds, counting both source blocks and waterlogging. */\n fluid(state: BlockState): FluidKind;\n /**\n * Answers whether the state is in a block tag.\n *\n * @param tag - The tag identifier with no leading `#`, for example `minecraft:logs`.\n */\n hasTag(state: BlockState, tag: string): boolean;\n /** Answers Java's `BlockState.canSurvive(level, pos)` for the `would_survive` predicate. */\n canSurvive(world: FeatureWorld, position: BlockPos, state: BlockState): boolean;\n /**\n * Answers Java's `isUnobstructed`: whether a block-shaped box at the position collides with\n * no entity. Optional, because decoration has no entity list and no vanilla feature asks.\n * When absent the `unobstructed` predicate passes.\n */\n isUnobstructed?(world: FeatureWorld, position: BlockPos): boolean;\n /**\n * Lists the blocks in a tag. Optional, because only the `random_block` state provider needs\n * to enumerate rather than test, and a server that cannot answer gets Java's empty-set\n * behavior: the provider places nothing.\n */\n tagMembers?(tag: string): readonly string[];\n}\n\n/**\n * Everything a feature may do to the world it decorates.\n *\n * This is the package's only outward seam. Features never see a chunk, a section, a palette or a\n * Bedrock identifier: they read and write Java block states through these seven members, so the\n * server's storage, its Java-to-Bedrock mapping and its chunk lifetime stay on the other side.\n * {@link import('./TestFeatureWorld').TestFeatureWorld} is the in-memory adapter the tests use.\n *\n * Writes are expected to succeed or be dropped silently, as Java's `WorldGenLevel.setBlock` does\n * outside the region being generated; a feature treats {@link setBlock} as advisory and reads back\n * when it needs to know.\n */\nexport interface FeatureWorld {\n /** The lowest y the dimension generates, Java's `getMinY()`. */\n readonly minY: number;\n /** The number of y levels the dimension generates, Java's `getHeight()`. */\n readonly height: number;\n /** The dimension's sea level, which `relative_to_sea_level` anchors resolve against. */\n readonly seaLevel: number;\n /**\n * The world seed.\n *\n * Only the geode reads it, to build a noise field that is the same everywhere in one world\n * and different between worlds.\n */\n readonly seed: bigint;\n /** The static block facts, shared across worlds. */\n readonly blocks: BlockOracle;\n /** Returns the state at a position, or air outside the generated region. */\n getBlock(position: BlockPos): BlockState;\n /** Writes a state. Returns whether the write landed. */\n setBlock(position: BlockPos, state: BlockState, options?: SetBlockOptions): boolean;\n /** Returns the first y above the topmost block matching the heightmap's predicate. */\n getHeight(heightmap: HeightmapType, x: number, z: number): number;\n /** Returns the biome identifier at a position. */\n getBiome(position: BlockPos): string;\n /**\n * Answers Java's `Biome.getTemperature(pos) < 0.15`, which is the whole of what decides\n * whether `freeze_top_layer` acts.\n *\n * Optional, because biome climate lives in the biome source rather than here. When absent\n * nothing freezes, which is the right answer for a warm world and a visible one for a cold\n * world rather than a silent miss.\n */\n isColdEnoughToSnow?(position: BlockPos): boolean;\n /**\n * Attaches block entity data to a block this package just wrote.\n *\n * Optional, because only six features need it: the two chests, the spawner, the two end\n * gateway kinds and the end podium. A world that cannot store it loses the contents rather\n * than the block.\n */\n setBlockEntity?(position: BlockPos, data: BlockEntityRequest): void;\n /**\n * Places a structure template, which `template` and `fossil` delegate to.\n *\n * Optional, and the seam to `@jsprismarine/structures`: this package names a template and a\n * processor list and does not read NBT. A world that cannot place one reports failure, which\n * propagates through the pipeline the same way an obstructed placement does.\n */\n placeTemplate?(request: TemplateRequest): boolean;\n /**\n * Spawns an entity a feature builds around, which is only the end spike's crystal.\n *\n * Optional, because entities belong to the server rather than to world generation.\n */\n spawnEntity?(identifier: string, position: BlockPos, options?: EntitySpawnOptions): void;\n /**\n * Asks for the fluid at a position to be ticked as soon as the world runs, Java's\n * `WorldGenLevel.scheduleTick` with a fluid and no delay. A spring starts its stream this way,\n * and a geode's crack lets the fluid beside it in.\n *\n * Optional, because ticks belong to the server rather than to world generation. A world that\n * cannot schedule one leaves the fluid standing until something else disturbs it.\n */\n scheduleFluidTick?(position: BlockPos): void;\n /**\n * Marks a position for the work Java's `LevelChunk.postProcessGeneration` does once the chunk\n * is full: tick the fluid standing there, and settle the block against its neighbors. Java's\n * `ChunkAccess.markPosForPostProcessing`, which a multiface growth calls for every face it\n * places.\n *\n * Optional, for the same reason as {@link scheduleFluidTick}.\n */\n markForPostProcessing?(position: BlockPos): void;\n}\n\n/** How a feature writes one block, beyond the state it writes. */\nexport interface SetBlockOptions {\n /**\n * Whether the write marks the position its block asks for post-processing, as Java's\n * `WorldGenRegion.setBlock` does for a block with a post-process position: a mushroom marks\n * itself, and soul sand and magma mark the block above for the bubble column. Defaults to\n * true. False is a write Java makes past `WorldGenRegion.setBlock`, which is how the ore\n * feature writes through `BulkSectionAccess`.\n */\n readonly postProcess?: boolean;\n}\n\n/**\n * What a feature declares about an entity it spawns beyond its type and position.\n *\n * The three crystal fields carry Java's `EndSpikeFeature` configuration and the end crystal's\n * synced data to the server, which projects them onto the spawned entity.\n */\nexport interface EntitySpawnOptions {\n /** The spawn yaw in degrees. Defaults to 0. */\n readonly yaw?: number;\n /** The block an end crystal's beam points at, Java's `crystal_beam_target`. */\n readonly beamTarget?: BlockPos;\n /** Whether an end crystal renders its bedrock base plate. Java's default is true. */\n readonly showBottom?: boolean;\n /** Whether the entity ignores damage, Java's `crystal_invulnerable`. */\n readonly invulnerable?: boolean;\n}\n\n/** What a feature asks a world to record on a block it just placed. */\nexport interface BlockEntityRequest {\n /** The block entity type, for example `minecraft:chest`. */\n readonly id: string;\n /** The loot table to roll when the block is first opened, when there is one. */\n readonly lootTable?: string;\n /** The entity a spawner produces, when the block is a spawner. */\n readonly spawnEntity?: string;\n /** Where an end gateway sends a traveller, when the block is one. */\n readonly exitPortal?: BlockPos;\n /** Whether an end gateway places its own exit platform. */\n readonly exactTeleport?: boolean;\n /**\n * The whole block entity as a structure template saved it, when a template saved one.\n *\n * Typed as `unknown` because this package does not model NBT and depends on no library that\n * does. The server narrows it before reading it.\n */\n readonly saved?: unknown;\n /** The Java block the block entity sits in, which is where Java keeps a banner's color. */\n readonly javaBlock?: string;\n}\n\n/**\n * The processors a feature runs its template through.\n *\n * Java's field is either an identifier naming a `worldgen/processor_list` or the list itself,\n * written where the feature stands. The inline form stays `unknown` here, because this package\n * names a chain and does not read one. The world parses whichever form arrives.\n */\nexport type TemplateProcessors = string | { readonly processors: readonly unknown[] };\n\n/** What a feature asks a world to stamp out of a structure template. */\nexport interface TemplateRequest {\n /** The template identifier, for example `minecraft:trail_ruins/tower/tower_top`. */\n readonly template: string;\n /** Where the template's origin corner lands. */\n readonly origin: BlockPos;\n /** The quarter turns to apply, 0 through 3. */\n readonly rotation: number;\n /** The mirror to apply before the rotation. */\n readonly mirror: 'none' | 'left_right' | 'front_back';\n /** The processors to run over the template, when the feature carries any. */\n readonly processors?: TemplateProcessors;\n /** The template's own offset, which `template` carries as `offset`. */\n readonly offset?: BlockPos;\n /** Whether the template's project-to-heightmap mode is set, and to which heightmap. */\n readonly projectToHeightmap?: HeightmapType;\n /** Whether air in the template overwrites the world. */\n readonly overwrite?: boolean;\n}\n\n/** Answers whether `y` is outside the dimension's generated range. */\nexport const isOutsideBuildHeight = (world: FeatureWorld, y: number): boolean =>\n y < world.minY || y >= world.minY + world.height;\n\n/**\n * Translates the Java block states a feature writes into whatever the target world stores.\n *\n * A server supplies `@jsprismarine/mapping`'s Java-to-Bedrock function here. Nothing in this\n * package knows that two editions exist.\n */\nexport type BlockStateMapper<Target> = {\n /** Converts a Java state into the target world's state type. */\n toTarget(state: BlockState): Target;\n /** Converts a target state back into Java, so predicates and reads keep working. */\n toJava(state: Target): BlockState;\n};\n\n/** A world that stores some other state type, which {@link translatingWorld} adapts. */\nexport interface TargetWorld<Target> extends Omit<FeatureWorld, 'getBlock' | 'setBlock' | 'blocks'> {\n getBlock(position: BlockPos): Target;\n setBlock(position: BlockPos, state: Target, options?: SetBlockOptions): boolean;\n}\n\n/**\n * Wraps a world that stores non-Java states so features can write Java states into it.\n *\n * This is the injection point the plan's section 5 asks for: the mapping table is applied once, at\n * the seam, rather than inside every feature.\n */\nexport const translatingWorld = <Target>(\n target: TargetWorld<Target>,\n mapper: BlockStateMapper<Target>,\n blocks: BlockOracle\n): FeatureWorld => ({\n minY: target.minY,\n height: target.height,\n seaLevel: target.seaLevel,\n seed: target.seed,\n blocks,\n getBlock: (position) => mapper.toJava(target.getBlock(position)),\n setBlock: (position, state, options) => target.setBlock(position, mapper.toTarget(state), options),\n getHeight: (heightmap, x, z) => target.getHeight(heightmap, x, z),\n getBiome: (position) => target.getBiome(position)\n});\n"],"mappings":";;AAUA,IAAa,OAAO,GAAW,GAAW,OAAyB;CAAE;CAAG;CAAG;AAAE;;AAG7E,IAAa,UAAU,QAAkB,IAAY,IAAY,QAA0B;CACvF,GAAG,OAAO,IAAI;CACd,GAAG,OAAO,IAAI;CACd,GAAG,OAAO,IAAI;AAClB;;AAGA,IAAa,OAAO,QAAkB,OAAyB;CAAE,GAAG,OAAO;CAAG;CAAG,GAAG,OAAO;AAAE;;AAG7F,IAAa,UAAU,aAA+B,GAAG,SAAS,EAAE,GAAG,SAAS,EAAE,GAAG,SAAS;;AAiB9F,IAAa,aAAa;CACtB;CACA;CACA;CACA;CACA;CACA;AACJ;;AAoNA,IAAa,wBAAwB,OAAqB,MACtD,IAAI,MAAM,QAAQ,KAAK,MAAM,OAAO,MAAM;;;;;;;AA2B9C,IAAa,oBACT,QACA,QACA,YACgB;CAChB,MAAM,OAAO;CACb,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,MAAM,OAAO;CACb;CACA,WAAW,aAAa,OAAO,OAAO,OAAO,SAAS,QAAQ,CAAC;CAC/D,WAAW,UAAU,OAAO,YAAY,OAAO,SAAS,UAAU,OAAO,SAAS,KAAK,GAAG,OAAO;CACjG,YAAY,WAAW,GAAG,MAAM,OAAO,UAAU,WAAW,GAAG,CAAC;CAChE,WAAW,aAAa,OAAO,SAAS,QAAQ;AACpD"}
1
+ {"version":3,"file":"FeatureWorld.js","names":[],"sources":["../../src/world/FeatureWorld.ts"],"sourcesContent":["import type { BlockState, Direction, FluidKind } from './BlockState';\n\n/** A block position in world coordinates. */\nexport interface BlockPos {\n readonly x: number;\n readonly y: number;\n readonly z: number;\n}\n\n/** Builds a position. */\nexport const pos = (x: number, y: number, z: number): BlockPos => ({ x, y, z });\n\n/** Returns `origin` moved by a delta. */\nexport const offset = (origin: BlockPos, dx: number, dy: number, dz: number): BlockPos => ({\n x: origin.x + dx,\n y: origin.y + dy,\n z: origin.z + dz\n});\n\n/** Returns `origin` with a different y. */\nexport const atY = (origin: BlockPos, y: number): BlockPos => ({ x: origin.x, y, z: origin.z });\n\n/** The canonical text key for a position, which the test world uses to index its store. */\nexport const posKey = (position: BlockPos): string => `${position.x},${position.y},${position.z}`;\n\n/**\n * The six heightmaps Java Edition keeps, named as the placement JSON spells them.\n *\n * The three `_WG` and `OCEAN_FLOOR`/`WORLD_SURFACE` pairs differ only in when they are computed,\n * so a generator that decorates a chunk once can answer both from the same column scan.\n */\nexport type HeightmapType =\n | 'WORLD_SURFACE_WG'\n | 'WORLD_SURFACE'\n | 'OCEAN_FLOOR_WG'\n | 'OCEAN_FLOOR'\n | 'MOTION_BLOCKING'\n | 'MOTION_BLOCKING_NO_LEAVES';\n\n/** Every {@link HeightmapType}, for reading one out of a document. */\nexport const HEIGHTMAPS = [\n 'WORLD_SURFACE_WG',\n 'WORLD_SURFACE',\n 'OCEAN_FLOOR_WG',\n 'OCEAN_FLOOR',\n 'MOTION_BLOCKING',\n 'MOTION_BLOCKING_NO_LEAVES'\n] as const satisfies readonly HeightmapType[];\n\n/**\n * The facts about a block state that do not depend on where it sits.\n *\n * This is a separate seam from {@link FeatureWorld} because the answers are pure and shared: a\n * server builds one oracle from its block registry and tag tables and reuses it for every chunk,\n * while a world adapter is created per decorated region. A feature reaches it through\n * {@link FeatureWorld.blocks}, so a feature still takes one object.\n */\nexport interface BlockOracle {\n /** Answers Java's `BlockState.isAir()`. */\n isAir(state: BlockState): boolean;\n /** Answers Java's `BlockState.isSolid()`: the block occupies its whole cell and blocks motion. */\n isSolid(state: BlockState): boolean;\n /** Answers Java's `BlockState.isFaceSturdy(level, pos, direction)` for a full face. */\n isSturdy(state: BlockState, direction: Direction): boolean;\n /** Answers Java's `BlockState.canBeReplaced()`, which decides whether a feature may overwrite it. */\n isReplaceable(state: BlockState): boolean;\n /** Returns the fluid the state holds, counting both source blocks and waterlogging. */\n fluid(state: BlockState): FluidKind;\n /**\n * Answers whether the state is in a block tag.\n *\n * @param tag - The tag identifier with no leading `#`, for example `minecraft:logs`.\n */\n hasTag(state: BlockState, tag: string): boolean;\n /** Answers Java's `BlockState.canSurvive(level, pos)` for the `would_survive` predicate. */\n canSurvive(world: FeatureWorld, position: BlockPos, state: BlockState): boolean;\n /**\n * Answers Java's `isUnobstructed`: whether a block-shaped box at the position collides with\n * no entity. Optional, because decoration has no entity list and no vanilla feature asks.\n * When absent the `unobstructed` predicate passes.\n */\n isUnobstructed?(world: FeatureWorld, position: BlockPos): boolean;\n /**\n * Lists the blocks in a tag. Optional, because only the `random_block` state provider needs\n * to enumerate rather than test, and a server that cannot answer gets Java's empty-set\n * behavior: the provider places nothing.\n */\n tagMembers?(tag: string): readonly string[];\n}\n\n/**\n * Everything a feature may do to the world it decorates.\n *\n * This is the package's only outward seam. Features never see a chunk, a section, a palette or a\n * Bedrock identifier: they read and write Java block states through these seven members, so the\n * server's storage, its Java-to-Bedrock mapping and its chunk lifetime stay on the other side.\n * {@link TestFeatureWorld} is the in-memory adapter the tests use.\n *\n * Writes are expected to succeed or be dropped silently, as Java's `WorldGenLevel.setBlock` does\n * outside the region being generated; a feature treats {@link setBlock} as advisory and reads back\n * when it needs to know.\n */\nexport interface FeatureWorld {\n /** The lowest y the dimension generates, Java's `getMinY()`. */\n readonly minY: number;\n /** The number of y levels the dimension generates, Java's `getHeight()`. */\n readonly height: number;\n /** The dimension's sea level, which `relative_to_sea_level` anchors resolve against. */\n readonly seaLevel: number;\n /**\n * The world seed.\n *\n * Only the geode reads it, to build a noise field that is the same everywhere in one world\n * and different between worlds.\n */\n readonly seed: bigint;\n /** The static block facts, shared across worlds. */\n readonly blocks: BlockOracle;\n /** Returns the state at a position, or air outside the generated region. */\n getBlock(position: BlockPos): BlockState;\n /** Writes a state. Returns whether the write landed. */\n setBlock(position: BlockPos, state: BlockState, options?: SetBlockOptions): boolean;\n /** Returns the first y above the topmost block matching the heightmap's predicate. */\n getHeight(heightmap: HeightmapType, x: number, z: number): number;\n /** Returns the biome identifier at a position. */\n getBiome(position: BlockPos): string;\n /**\n * Answers Java's `Biome.getTemperature(pos) < 0.15`, which is the whole of what decides\n * whether `freeze_top_layer` acts.\n *\n * Optional, because biome climate lives in the biome source rather than here. When absent\n * nothing freezes, which is the right answer for a warm world and a visible one for a cold\n * world rather than a silent miss.\n */\n isColdEnoughToSnow?(position: BlockPos): boolean;\n /**\n * Attaches block entity data to a block this package just wrote.\n *\n * Optional, because only six features need it: the two chests, the spawner, the two end\n * gateway kinds and the end podium. A world that cannot store it loses the contents rather\n * than the block.\n */\n setBlockEntity?(position: BlockPos, data: BlockEntityRequest): void;\n /**\n * Places a structure template, which `template` and `fossil` delegate to.\n *\n * Optional, and the seam to `@jsprismarine/structures`: this package names a template and a\n * processor list and does not read NBT. A world that cannot place one reports failure, which\n * propagates through the pipeline the same way an obstructed placement does.\n */\n placeTemplate?(request: TemplateRequest): boolean;\n /**\n * Spawns an entity a feature builds around, which is only the end spike's crystal.\n *\n * Optional, because entities belong to the server rather than to world generation.\n */\n spawnEntity?(identifier: string, position: BlockPos, options?: EntitySpawnOptions): void;\n /**\n * Asks for the fluid at a position to be ticked as soon as the world runs, Java's\n * `WorldGenLevel.scheduleTick` with a fluid and no delay. A spring starts its stream this way,\n * and a geode's crack lets the fluid beside it in.\n *\n * Optional, because ticks belong to the server rather than to world generation. A world that\n * cannot schedule one leaves the fluid standing until something else disturbs it.\n */\n scheduleFluidTick?(position: BlockPos): void;\n /**\n * Marks a position for the work Java's `LevelChunk.postProcessGeneration` does once the chunk\n * is full: tick the fluid standing there, and settle the block against its neighbors. Java's\n * `ChunkAccess.markPosForPostProcessing`, which a multiface growth calls for every face it\n * places.\n *\n * Optional, for the same reason as {@link scheduleFluidTick}.\n */\n markForPostProcessing?(position: BlockPos): void;\n}\n\n/** How a feature writes one block, beyond the state it writes. */\nexport interface SetBlockOptions {\n /**\n * Whether the write marks the position its block asks for post-processing, as Java's\n * `WorldGenRegion.setBlock` does for a block with a post-process position: a mushroom marks\n * itself, and soul sand and magma mark the block above for the bubble column. Defaults to\n * true. False is a write Java makes past `WorldGenRegion.setBlock`, which is how the ore\n * feature writes through `BulkSectionAccess`.\n */\n readonly postProcess?: boolean;\n}\n\n/**\n * What a feature declares about an entity it spawns beyond its type and position.\n *\n * The three crystal fields carry Java's `EndSpikeFeature` configuration and the end crystal's\n * synced data to the server, which projects them onto the spawned entity.\n */\nexport interface EntitySpawnOptions {\n /** The spawn yaw in degrees. Defaults to 0. */\n readonly yaw?: number;\n /** The block an end crystal's beam points at, Java's `crystal_beam_target`. */\n readonly beamTarget?: BlockPos;\n /** Whether an end crystal renders its bedrock base plate. Java's default is true. */\n readonly showBottom?: boolean;\n /** Whether the entity ignores damage, Java's `crystal_invulnerable`. */\n readonly invulnerable?: boolean;\n}\n\n/** What a feature asks a world to record on a block it just placed. */\nexport interface BlockEntityRequest {\n /** The block entity type, for example `minecraft:chest`. */\n readonly id: string;\n /** The loot table to roll when the block is first opened, when there is one. */\n readonly lootTable?: string;\n /** The entity a spawner produces, when the block is a spawner. */\n readonly spawnEntity?: string;\n /** Where an end gateway sends a traveller, when the block is one. */\n readonly exitPortal?: BlockPos;\n /** Whether an end gateway places its own exit platform. */\n readonly exactTeleport?: boolean;\n /**\n * The whole block entity as a structure template saved it, when a template saved one.\n *\n * Typed as `unknown` because this package does not model NBT and depends on no library that\n * does. The server narrows it before reading it.\n */\n readonly saved?: unknown;\n /** The Java block the block entity sits in, which is where Java keeps a banner's color. */\n readonly javaBlock?: string;\n}\n\n/**\n * The processors a feature runs its template through.\n *\n * Java's field is either an identifier naming a `worldgen/processor_list` or the list itself,\n * written where the feature stands. The inline form stays `unknown` here, because this package\n * names a chain and does not read one. The world parses whichever form arrives.\n */\nexport type TemplateProcessors = string | { readonly processors: readonly unknown[] };\n\n/** What a feature asks a world to stamp out of a structure template. */\nexport interface TemplateRequest {\n /** The template identifier, for example `minecraft:trail_ruins/tower/tower_top`. */\n readonly template: string;\n /** Where the template's origin corner lands. */\n readonly origin: BlockPos;\n /** The quarter turns to apply, 0 through 3. */\n readonly rotation: number;\n /** The mirror to apply before the rotation. */\n readonly mirror: 'none' | 'left_right' | 'front_back';\n /** The processors to run over the template, when the feature carries any. */\n readonly processors?: TemplateProcessors;\n /** The template's own offset, which `template` carries as `offset`. */\n readonly offset?: BlockPos;\n /** Whether the template's project-to-heightmap mode is set, and to which heightmap. */\n readonly projectToHeightmap?: HeightmapType;\n /** Whether air in the template overwrites the world. */\n readonly overwrite?: boolean;\n}\n\n/** Answers whether `y` is outside the dimension's generated range. */\nexport const isOutsideBuildHeight = (world: FeatureWorld, y: number): boolean =>\n y < world.minY || y >= world.minY + world.height;\n\n/**\n * Translates the Java block states a feature writes into whatever the target world stores.\n *\n * A server supplies `@jsprismarine/mapping`'s Java-to-Bedrock function here. Nothing in this\n * package knows that two editions exist.\n */\nexport type BlockStateMapper<Target> = {\n /** Converts a Java state into the target world's state type. */\n toTarget(state: BlockState): Target;\n /** Converts a target state back into Java, so predicates and reads keep working. */\n toJava(state: Target): BlockState;\n};\n\n/** A world that stores some other state type, which {@link translatingWorld} adapts. */\nexport interface TargetWorld<Target> extends Omit<FeatureWorld, 'getBlock' | 'setBlock' | 'blocks'> {\n getBlock(position: BlockPos): Target;\n setBlock(position: BlockPos, state: Target, options?: SetBlockOptions): boolean;\n}\n\n/**\n * Wraps a world that stores non-Java states so features can write Java states into it.\n *\n * This is the injection point the plan's section 5 asks for: the mapping table is applied once, at\n * the seam, rather than inside every feature.\n */\nexport const translatingWorld = <Target>(\n target: TargetWorld<Target>,\n mapper: BlockStateMapper<Target>,\n blocks: BlockOracle\n): FeatureWorld => ({\n minY: target.minY,\n height: target.height,\n seaLevel: target.seaLevel,\n seed: target.seed,\n blocks,\n getBlock: (position) => mapper.toJava(target.getBlock(position)),\n setBlock: (position, state, options) => target.setBlock(position, mapper.toTarget(state), options),\n getHeight: (heightmap, x, z) => target.getHeight(heightmap, x, z),\n getBiome: (position) => target.getBiome(position)\n});\n"],"mappings":";;AAUA,IAAa,OAAO,GAAW,GAAW,OAAyB;CAAE;CAAG;CAAG;AAAE;;AAG7E,IAAa,UAAU,QAAkB,IAAY,IAAY,QAA0B;CACvF,GAAG,OAAO,IAAI;CACd,GAAG,OAAO,IAAI;CACd,GAAG,OAAO,IAAI;AAClB;;AAGA,IAAa,OAAO,QAAkB,OAAyB;CAAE,GAAG,OAAO;CAAG;CAAG,GAAG,OAAO;AAAE;;AAG7F,IAAa,UAAU,aAA+B,GAAG,SAAS,EAAE,GAAG,SAAS,EAAE,GAAG,SAAS;;AAiB9F,IAAa,aAAa;CACtB;CACA;CACA;CACA;CACA;CACA;AACJ;;AAoNA,IAAa,wBAAwB,OAAqB,MACtD,IAAI,MAAM,QAAQ,KAAK,MAAM,OAAO,MAAM;;;;;;;AA2B9C,IAAa,oBACT,QACA,QACA,YACgB;CAChB,MAAM,OAAO;CACb,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,MAAM,OAAO;CACb;CACA,WAAW,aAAa,OAAO,OAAO,OAAO,SAAS,QAAQ,CAAC;CAC/D,WAAW,UAAU,OAAO,YAAY,OAAO,SAAS,UAAU,OAAO,SAAS,KAAK,GAAG,OAAO;CACjG,YAAY,WAAW,GAAG,MAAM,OAAO,UAAU,WAAW,GAAG,CAAC;CAChE,WAAW,aAAa,OAAO,SAAS,QAAQ;AACpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsprismarine/features",
3
- "version": "0.23.0-unstable-20261121073620",
3
+ "version": "0.23.0",
4
4
  "description": "Java Edition world decoration: feature types, block state and value providers, placement modifiers and the seeded placement pipeline",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -53,8 +53,8 @@
53
53
  "vitest": "5.1.1"
54
54
  },
55
55
  "dependencies": {
56
- "@jsprismarine/errors": "0.23.0-unstable-20261121073620",
57
- "@jsprismarine/worldgen": "0.23.0-unstable-20261121073620"
56
+ "@jsprismarine/errors": "0.23.0",
57
+ "@jsprismarine/worldgen": "0.23.0"
58
58
  },
59
59
  "scripts": {
60
60
  "clean": "rimraf dist jsp *.tsbuildinfo vite.config.ts.timestamp-* .tsup .turbo",