LegacyScriptEngine icon indicating copy to clipboard operation
LegacyScriptEngine copied to clipboard

[Bug]: 命令回调与getStructure相关bug

Open cvxz8 opened this issue 8 months ago • 2 comments

Describe the bug

运行环境:lse-nodejs v0.10.3,Levilamina v1.1.1

描述:

  1. getStructure坐标不正确。
  2. 命令回调中,涉及到方块的子命令,参数赋值错误

下面是测试用例:

function structureTest() {
    // 不使用AABB坐标,报错:C++ Exception: std::length_error, from <MSVCP140>: vector too long
    // 可能是故意设计,但文档中似乎没有强调
    // 本次报告的点并不是这里,而是在下面
    // https://lse.levimc.org/zh/apis/GameAPI/Basic/#nbt
    // const component = mc.getStructure(
    //     mc.newIntPos(-100, 70, -50, 0),
    //     mc.newIntPos(-100, 65, -45, 0)
    // )

    const component = mc.getStructure(
        mc.newIntPos(-100, 65, -50, 0),
        mc.newIntPos(-100, 70, -45, 0)
    )
    
    if(component == null) {
        console.error("component is null")
        return;
    }
    
    // 实际输出:[-100,64,-50]
    // 预期:[-100,65,-50]
    console.debug("coordinate", component.getData("structure_world_origin").toString())
}

function commandTest() {
    // 该段代码无法复现效果,只是大概框架
    // 只有部分插件在某些情况才会出现bug,暂时找不到复现方法
    // 具体表现为 result.action 变为 Block 类型
    // 不能给出出错的插件代码,因为是商用插件。但是可以大概率确定不是插件本身问题,插件在前几个版本可以正常运行
    // 只有更新到1.21.60后才会出现这个错误

    const cmd = mc.newCommand("t2", "command test", PermType.Any)

    cmd.setEnum("TestEnum", ["test", "t"])

    cmd.mandatory("action", ParamType.Enum, "TestEnum", "TestArgment", 1)
    cmd.mandatory("block", ParamType.Block, "", "BlockArgment")
    cmd.optional("states", ParamType.String, "", "StateArgment")

    cmd.overload(["TestArgment", "BlockArgment", "StateArgment"])

    // 输入 t2 test grass "" 触发回调
    cmd.setCallback((cmd, origin, output, result)=>{
        // 该段代码工作正常,输出 test
        // 部分出问题的插件得到的输出结果是: Block
        // 猜测:可能需要多注册一些action的参数才会复现bug,或许和命令的结构,命名也有关
        console.debug("command result:", result.action)
    })
}

(() => {
    // bug1
    mc.regPlayerCmd("t1", "structure test", structureTest);

    // bug2
    commandTest()
})()

To Reproduce

参考用例,但是命令回调部分暂时找不到复现方法

Expected behavior

none

Screenshots

No response

Platform

No response

BDS Version

No response

LeviLamina Version

No response

LegacyScriptEngine Version

No response

Additional context

No response

cvxz8 avatar Apr 07 '25 05:04 cvxz8

LL的bug,已修复 https://github.com/LiteLDev/LeviLamina/commit/03547a0058fdd3d63d768b095a89f49e28883caf

xiaoqch avatar May 07 '25 13:05 xiaoqch

getStructure bug已修,命令回调bug未确认

xiaoqch avatar May 10 '25 15:05 xiaoqch