xiaozheng666QQ
监听击杀了非玩家实体生物
监听击杀了玩家实体生物


这2个监听事件是什么事件,谢谢了

3222577979
public void onPlayerDeadEvent(PlayerDeathEvent e) { //玩家pvp击杀事件
                                   Player p = e.getEntity(); //死者玩家
                                Player k = e.getEntity().getKiller();  //凶手
                       if (k!=null) {
                                         //确定凶手是玩家
                                        }

}

                public void onEntitydeadevent(EntityDeathEvent e) {//玩家pve击杀事件
                                Entity en = e.getEntity();//死者实体
                                Player k = e.getEntity().getKiller();//凶手
                       if (k!=null) {
                                         //确定凶手是玩家
                                        }
                        }

森林蝙蝠
你如果说的是forge,那就是LivingDeathEvent。

xiaozheng666QQ
3222577979 发表于 2019-4-28 17:18
public void onPlayerDeadEvent(PlayerDeathEvent e) { //玩家pvp击杀事件
                                   Player p = e.getEntity( ...

非常感谢

qq1458132898
xiaozheng666QQ 发表于 2019-4-29 15:02
非常感谢

我知道。但是不告诉你

William_Shi
3222577979 发表于 2019-4-28 17:18
public void onPlayerDeadEvent(PlayerDeathEvent e) { //玩家pvp击杀事件
                                   Player p = e.getEntity( ...

getKiller()不一定是玩家

要判断instance of Player吧

炽热未来
3222577979 发表于 2019-4-28 17:18
public void onPlayerDeadEvent(PlayerDeathEvent e) { //玩家pvp击杀事件
                                   Player p = e.getEntity( ...

看不懂      

3222577979
William_Shi 发表于 2019-5-1 12:17
getKiller()不一定是玩家

要判断instance of Player吧

getkiller() 一定是玩家 返回的是玩家对象




2425701120
6666666666666

2425701120
sssssssssssssss

William_Shi
3222577979 发表于 2019-5-8 08:24
getkiller() 一定是玩家 返回的是玩家对象
  1. @Nullable
  2. Player getKiller?()
  3. Gets the player identified as the killer of the living entity.
  4. May be null.

  5. Returns:
  6. killer player, or null if none found
复制代码


抱歉是我记错了,这个好像不只是局限于事件监听的,对不起