From 9c553dcd0b97cdac585c56425d4018b24a2f7edd Mon Sep 17 00:00:00 2001 From: Nico314159 Date: Sat, 18 May 2024 19:57:29 -0700 Subject: [PATCH] Use `ReleaseVersion.cmp` as requested --- package-lock.json | 2 +- .../src/mcfunction/common/index.ts | 49 +++++++++++-------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 02d002f76..75dbf5b5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10981,7 +10981,7 @@ }, "packages/mcdoc-cli": { "name": "@spyglassmc/mcdoc-cli", - "version": "0.1.3", + "version": "0.1.5", "license": "MIT", "dependencies": { "fs-extra": "^11.1.1", diff --git a/packages/java-edition/src/mcfunction/common/index.ts b/packages/java-edition/src/mcfunction/common/index.ts index c349a0658..e3052d5d3 100644 --- a/packages/java-edition/src/mcfunction/common/index.ts +++ b/packages/java-edition/src/mcfunction/common/index.ts @@ -1,4 +1,5 @@ import * as core from '@spyglassmc/core' +import { ReleaseVersion } from '../../dependency' export const ColorArgumentValues = [...core.Color.ColorNames, 'reset'] @@ -11,27 +12,33 @@ export const GamemodeArgumentValues = [ 'spectator', ] -export const ItemSlotArgumentValues = [ - ...[...Array(54).keys()].map((n) => `container.${n}`), - ...[...Array(27).keys()].map((n) => `enderchest.${n}`), - ...[...Array(15).keys()].map((n) => `horse.${n}`), - ...[...Array(9).keys()].map((n) => `hotbar.${n}`), - ...[...Array(27).keys()].map((n) => `inventory.${n}`), - ...[...Array(4).keys()].map((n) => `player.crafting.${n}`), - ...[...Array(8).keys()].map((n) => `villager.${n}`), - 'armor.chest', - 'armor.feet', - 'armor.head', - 'armor.legs', - 'armor.body', - 'contents', - 'horse.chest', - 'horse.saddle', - 'player.cursor', - 'weapon', - 'weapon.mainhand', - 'weapon.offhand', -] +export function getItemSlotArgumentValues(release: ReleaseVersion) { + const output = [ + ...[...Array(54).keys()].map((n) => `container.${n}`), + ...[...Array(27).keys()].map((n) => `enderchest.${n}`), + ...[...Array(15).keys()].map((n) => `horse.${n}`), + ...[...Array(9).keys()].map((n) => `hotbar.${n}`), + ...[...Array(27).keys()].map((n) => `inventory.${n}`), + ...[...Array(8).keys()].map((n) => `villager.${n}`), + 'armor.chest', + 'armor.feet', + 'armor.head', + 'armor.legs', + 'horse.chest', + 'horse.saddle', + 'weapon', + 'weapon.mainhand', + 'weapon.offhand', + ] + if (ReleaseVersion.cmp(release, '1.20.5') >= 0) { + output.push(...[...Array(4).keys()].map((n) => `player.crafting.${n}`), + 'armor.body', + 'contents', + 'player.cursor') + } + else { output.push('horse.armor') } + return output +} export const OperationArgumentValues = [ '=',