PrismarineJS / mineflayer-pvp

Adds support for basic PVP and PVE to Mineflayer bots.
MIT License
51 stars 19 forks source link

Bot can attack through blocks #52

Open AidenRaaphorst opened 2 years ago

AidenRaaphorst commented 2 years ago

The bot can still hit me when encased in blocks like this. image

Even when adding another layer on the sides and on top and closing the hole, the bot still hits me through the blocks. image

This is the code, it's the same as the example in the readme, but I added semicolons and changed bot to this.bot because it's in a class.

this.bot.on('chat', (username, message) => {
  if (message === 'fight me') {
    const player = this.bot.players[username];

    if (!player) {
      this.bot.chat("I can't see you.");
      return;
    }

    this.bot.pvp.attack(player.entity);
  }

  if (message === 'stop') {
    this.bot.pvp.stop();
  }
});