Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
687 B
2
Indexable
Never
const mineflayer = require('mineflayer');
const pathfinder = require('mineflayer-pathfinder').pathfinder;
const mcData = require('minecraft-data')(mineflayer.version);

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25565,
  username: 'Autosleeper'
});

bot.loadPlugin(pathfinder);

const bedType = mcData.blocksByName['bed'].name; // Bed block type

bot.on('spawn', () => {
  const bedBlock = bot.findBlock({
    matching: (block) => block.name === bedType
  });

  if (bedBlock && bot.time.timeOfDay >= 12541 && bot.time.timeOfDay <= 23458) {
    bot.pathfinder.setGoal(new pathfinder.GoalBlock(bedBlock.position.x, bedBlock.position.y, bedBlock.position.z));
  }
});
Leave a Comment