diff --git a/packages/core/src/symbol/Symbol.ts b/packages/core/src/symbol/Symbol.ts index 291ede24b..09e514036 100644 --- a/packages/core/src/symbol/Symbol.ts +++ b/packages/core/src/symbol/Symbol.ts @@ -141,7 +141,9 @@ export const MiscCategories = Object.freeze( [ 'attribute_modifier_uuid', 'bossbar', + 'jigsaw_block_name', 'objective', + 'random_sequence', 'score_holder', 'storage', 'tag', @@ -171,6 +173,8 @@ export type AllCategory = (typeof AllCategories)[number] export const ResourceLocationCategories = Object.freeze( [ 'bossbar', + 'jigsaw_block_name', + 'random_sequence', 'storage', 'mcdoc/dispatcher', ...FileCategories, diff --git a/packages/java-edition/src/dependency/common.ts b/packages/java-edition/src/dependency/common.ts index 8dd9a5421..a6d887428 100644 --- a/packages/java-edition/src/dependency/common.ts +++ b/packages/java-edition/src/dependency/common.ts @@ -9,6 +9,18 @@ export namespace ReleaseVersion { export function cmp(a: ReleaseVersion, b: ReleaseVersion): number { return Math.sign(Number(a.slice(2)) - Number(b.slice(2))) } + + /** + * @returns `true` if `version` is newer than `since` (inclusive) and older + * than `until` (exclusive) + */ + export function isBetween( + version: ReleaseVersion, + since: ReleaseVersion, + until: ReleaseVersion, + ): boolean { + return cmp(version, since) >= 0 && cmp(version, until) < 0 + } } export interface VersionInfo { diff --git a/packages/java-edition/src/mcfunction/tree/patch.ts b/packages/java-edition/src/mcfunction/tree/patch.ts index 580fb9b81..6e30d87cf 100644 --- a/packages/java-edition/src/mcfunction/tree/patch.ts +++ b/packages/java-edition/src/mcfunction/tree/patch.ts @@ -180,8 +180,23 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { unless: ExecuteCondition, }, }, + function: { + children: { + name: { + ...(ReleaseVersion.cmp(release, '1.20.2') >= 0 + ? { + children: { + // Added in 23w31a (1.20.2, pack format 16) + with: DataSource, + }, + } + : {}), + }, + }, + }, ...(ReleaseVersion.cmp(release, '1.17') >= 0 ? { + // Added in 20w46a (1.17, pack format 7) item: { children: { replace: { @@ -335,6 +350,7 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { }, ...(ReleaseVersion.cmp(release, '1.18') >= 0 ? { + // Added in 21w37a (1.18, pack format 8) jfr: { permission: 4, }, @@ -346,13 +362,16 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { list: { permission: 0, }, - ...(ReleaseVersion.cmp(release, '1.16') >= 0 + ...(ReleaseVersion.isBetween(release, '1.16', '1.19') ? { + // Added in 20w06a (1.16, pack format 5) + // Removed in 22w19a (1.19, pack format 10) locatebiome: { children: { biome: { properties: { category: 'worldgen/biome', + allowTag: true, }, }, }, @@ -427,6 +446,7 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { }, ...(ReleaseVersion.cmp(release, '1.17') >= 0 ? { + // Added in 1.17 Pre-release 1 (1.17, pack format 7) perf: { permission: 4, }, @@ -434,18 +454,33 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { : {}), ...(ReleaseVersion.cmp(release, '1.19') >= 0 ? { + // Added in 22w18a (1.19, pack format 10) place: { children: { + jigsaw: { + children: { + pool: { + children: { + target: { + properties: { + category: 'jigsaw_block_name', + allowUnknown: true, + }, + }, + }, + }, + }, + }, template: { children: { template: { properties: { - category: 'structure' - } - } - } - } - } + category: 'structure', + }, + }, + }, + }, + }, }, } : {}), @@ -453,6 +488,53 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { publish: { permission: 4, }, + ...(ReleaseVersion.cmp(release, '1.20.2') >= 0 + ? { + // Added in 23w31a (1.20.2, pack format 16) + random: { + children: { + reset: { + children: { + sequence: { + properties: { + category: 'random_sequence', + allowUnknown: true, + }, + }, + }, + }, + roll: { + children: { + range: { + children: { + sequence: { + properties: { + category: 'random_sequence', + allowUnknown: true, + }, + }, + }, + }, + }, + }, + value: { + children: { + range: { + children: { + sequence: { + properties: { + category: 'random_sequence', + allowUnknown: true, + }, + }, + }, + }, + }, + }, + }, + }, + } + : {}), recipe: { children: { give: RecipeTargets, @@ -590,8 +672,9 @@ export function getPatch(release: ReleaseVersion): PartialRootTreeNode { tell: { permission: 0, }, - ...(ReleaseVersion.cmp(release, '1.20.2') >= 0 + ...(ReleaseVersion.cmp(release, '1.20.3') >= 0 ? { + // Added in 23w43a (1.20.3, pack format 22) tick: { permission: 3, },