setToItemSlot() 调用中抛出 NPE
Closed this issue · 1 comments
RisingInIris2017 commented
ZenUtils 版本
1.16.1
复现涉及到的模组
- https://www.curseforge.com/minecraft/mc-mods/slashblade/files/3039993
- https://www.curseforge.com/minecraft/mc-mods/the-last-smith/files/3314856
- https://www.curseforge.com/minecraft/mc-mods/corpse-complex/files/3176964
各模组的前置省略。
复现所需的配置文件
https://gist.github.com/RisingInIris2017/d6aa354eccb0d7a68d35ac885f1fbe39
问题脚本
报错
复现报错方式
- 获取名为 item.custom_newbie.name 的拔刀剑(即为问题脚本 L9 所匹配的目标物品),把它放在快捷栏除左起第一格以外的栏位。
- 设法让玩家在消耗其耐久的过程中被杀。已尝试过可行的方式包括:
- 和怪物战斗的过程中被怪物杀死
- 先触发一个接到写有
kill @p
命令的命令方块的延时电路,然后用这把拔刀剑挖掘事先放好的方块
- 如果重生后快捷栏中出现了一把耐久不满的拔刀剑,那么滚动鼠标滚轮或按数字 1-9,将主手切换到这把拔刀剑上,上述报错即出现,复现即成功。
预期行为
该脚本除了报错以外的行为都是预期要实现的行为,只要能有避免上述报错的方法就好了。
friendlyhj commented
在 client side,player.activeHand 会返回 null,考虑 !world.remote 判断或者只替换主手的物品(毕竟你也只判断了主手的物品)