Skip to content

Commit

Permalink
Merge pull request #65 from PuppyOne/main
Browse files Browse the repository at this point in the history
fix(chatSpawn): 修复输入非法导致生成错误的 bug
  • Loading branch information
xBoyMinemc authored Nov 6, 2024
2 parents 61477af + ad51898 commit 9b97474
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -20,7 +20,7 @@
"version": [
1,
21,
316
317
],
"type": "script",
"uuid": "10101e99-abc1-5488-ba76-71e9da441300",
Expand Down
2 changes: 1 addition & 1 deletion packer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions tscripts/lib/xboyPackage/xyz_dododo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ 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('~'))
return new_xyz[index] = Number(part);
if (!part.startsWith('~')) {
const data = Number(part);
if (Number.isFinite(data))
return data;
throw new Error(['x', 'y', 'z'][index] + ' not a number');
}

let data: number|string = part.slice(1) // 去掉~
let op = ops[data[0]] // 存在风险
Expand All @@ -27,7 +28,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')


Expand All @@ -36,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() {
Expand Down

0 comments on commit 9b97474

Please sign in to comment.