From fdf960e019dc4c5a1f96246e66d8f2ce56197294 Mon Sep 17 00:00:00 2001 From: PuppyOne Date: Wed, 6 Nov 2024 19:37:55 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(chatSpawn):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E9=9D=9E=E6=B3=95=E5=AF=BC=E8=87=B4=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=94=99=E8=AF=AF=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复由于输入非数字字符(包括 Infinity)导致的假人生成在边境,且无法再通过命令与之交互的问题 --- tscripts/lib/xboyPackage/xyz_dododo.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tscripts/lib/xboyPackage/xyz_dododo.ts b/tscripts/lib/xboyPackage/xyz_dododo.ts index 5228753..d147662 100644 --- a/tscripts/lib/xboyPackage/xyz_dododo.ts +++ b/tscripts/lib/xboyPackage/xyz_dododo.ts @@ -14,8 +14,12 @@ export function xyz_dododo(xyz:string[],playerLocation=[0,0,0]) : number[] { // 遍历分割后的数组 xyz.forEach((part, index) => { // 否则直接解析为数字 - if (!part.startsWith('~')) - return new_xyz[index] = Number(part); + if (!part.startsWith('~')) { + const data = Number(part); + if (Number.isFinite(data)) + return new_xyz[index] = data; + throw new Error(['x', 'y', 'z'][index] + ' not a number'); + } let data: number|string = part.slice(1) // 去掉~ let op = ops[data[0]] // 存在风险 @@ -27,7 +31,7 @@ export function xyz_dododo(xyz:string[],playerLocation=[0,0,0]) : number[] { } data = Number(data) - if(isNaN(data)) + if(!Number.isFinite(data)) throw new Error(['x','y','z'][index] + ' not a number') From e78b383108fa50dcde7398a8621d9fe525da387a Mon Sep 17 00:00:00 2001 From: PuppyOne Date: Wed, 6 Nov 2024 19:42:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20`xyz=5Fdododo`=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=94=B9=E4=B8=BA=E6=95=B0=E7=BB=84=20map=20=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tscripts/lib/xboyPackage/xyz_dododo.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/tscripts/lib/xboyPackage/xyz_dododo.ts b/tscripts/lib/xboyPackage/xyz_dododo.ts index d147662..c2e2791 100644 --- a/tscripts/lib/xboyPackage/xyz_dododo.ts +++ b/tscripts/lib/xboyPackage/xyz_dododo.ts @@ -8,16 +8,13 @@ ops['+'] = '+' ops['-'] = '-' export function xyz_dododo(xyz:string[],playerLocation=[0,0,0]) : number[] { - // 初始化x, y, z - let new_xyz = [0,0,0] - // 遍历分割后的数组 - xyz.forEach((part, index) => { + return xyz.map((part, index) => { // 否则直接解析为数字 if (!part.startsWith('~')) { const data = Number(part); if (Number.isFinite(data)) - return new_xyz[index] = data; + return data; throw new Error(['x', 'y', 'z'][index] + ' not a number'); } @@ -40,10 +37,8 @@ export function xyz_dododo(xyz:string[],playerLocation=[0,0,0]) : number[] { if(op === '-') data -= playerLocation[index] - new_xyz[index] = data + return data }); - - return new_xyz; } function xyz_dododo_test() { From ad51898ba44a7e81f915db31bfc803b0d4c17959 Mon Sep 17 00:00:00 2001 From: PuppyOne Date: Wed, 6 Nov 2024 19:45:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?build:=20=E6=9B=B4=E6=96=B0=E4=BA=86?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新版本号到 v17 --- manifest.json | 6 +++--- packer.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index b674462..81504f4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,13 @@ { "format_version": 2, "header": { - "name": "§t1.21.30 v16 §e§lFlash§fFakePlayerPack", + "name": "§t1.21.30 v17 §e§lFlash§fFakePlayerPack", "description": "【指定生成坐标-构建于1.21.30-支持1.21.2x-1.21.5x】1.21.30 \n开启实验性游戏内容(测试版 API)-游戏内输入“假人帮助”或“假人创建” 对着假人右键(蹲或不蹲是两个不同的菜单) 无关QQ群:122957051:", "uuid": "aa101e99-abb4-448d-b58f-71e9da43064e", "version": [ 1, 21, - 316 + 317 ], "min_engine_version": [ 1, @@ -20,7 +20,7 @@ "version": [ 1, 21, - 316 + 317 ], "type": "script", "uuid": "10101e99-abc1-5488-ba76-71e9da441300", diff --git a/packer.js b/packer.js index 73a0aa2..cebef30 100644 --- a/packer.js +++ b/packer.js @@ -4,7 +4,7 @@ const archiver = require('archiver'); const pack_name = '指定生成坐标-构建于1.21.30-支持1.21.2x-1.21.5x' const pack_version = [1,21,30]; -const fix_pack_version = 16 +const fix_pack_version = 17 const min_engine_version = [1,21,20] // https://www.npmjs.com/package/@minecraft/server?activeTab=versions