我怎样才能得到当你点击一个npc时执行的命令?

问题描述 投票:0回答:1

我试图获取在我单击服务器上的 npc 时执行的命令。我怎样才能得到这个命令?

我尝试使用一些修改过的客户端来获取它,但没有帮助。

minecraft spigot
1个回答
0
投票

没有直接事件,但您可以使用“PlayerInteractEntity”并比较点击的实体是村民还是您想要的任何 NPC。

像这样的东西:

@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent e) {
    Entity ent = e.getRightClicked();
    
    if (ent instanceof NPC){
    // Do whatever
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.