LeviLamina icon indicating copy to clipboard operation
LeviLamina copied to clipboard

玩家穿戴事件无限触发

Open FBQingYi opened this issue 3 years ago • 2 comments

异常模块

ScriptEngine(脚本引擎)

操作系统

Windows 10

LiteLoader版本

2.6.2

BDS版本

1.19.22.01

发生了什么?

往穿戴装备nbt的tag里面原版以外的内容然后穿戴会一直触发穿戴事件

复现此问题的步骤

let nbt1 = new NbtCompound({ "addon": new NbtCompound({ "type": new NbtString(type), "lvl": new NbtInt(lvl) }) }) let NItem = mc.newItem("minecraft:leather_helmet", 1); let nbt = NItem.getNbt(); nbt.setTag("tag", nbt1) Item = mc.newItem(nbt); let pos = player.pos; mc.spawnItem(Item, pos.x, pos.y + 1, pos.z, pos.dimid);

有关的日志/输出

No response

插件列表

No response

FBQingYi avatar Sep 18 '22 14:09 FBQingYi

@FBQingYi 能否提供简单的复现代码,以及用到的Addon。另外请自查是否在事件内部使用了会触发事件的函数

Jasonzyt avatar Sep 18 '22 14:09 Jasonzyt

mc.listen("onPlayerCmd", (player, _cmd) => { let nbt1 = new NbtCompound({ "addon": new NbtCompound({ "type": new NbtString("additional"), "lvl": new NbtInt(1) }) }) let NewItem = mc.newItem("minecraft:leather_helmet", 1); let nbt = NewItem.getNbt(); nbt.setTag("tag", nbt1); log(nbt.toString()); player.giveItem(mc.newItem(nbt)); player.refreshItems(); });

mc.listen("onSetArmor",(player,slotNum,item)=>{ log(slotNum) log(item.name) })

//今天没出现无限回调,但还是会把所有格子触发一遍。 //无addon,无其他触发函数。测试原版物品不会出问题。但是往nbt加料就会出问题。

FBQingYi avatar Sep 19 '22 01:09 FBQingYi