Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function inject (bot, { version }) {
const Item = require('prismarine-item')(version)
const windows = require('prismarine-windows')(version).windows
let nextActionNumber = 0
const windowClickQueue = []
let lastEating
let lastFishing
let lastFloat
let windowItems
// 0-8, null = uninitialized
// which quick bar slot is selected
bot.quickBarSlot = null
bot.inventory = new windows.InventoryWindow(0, 'Inventory', 44)
bot.currentWindow = null
bot.heldItem = null
bot._client.on('entity_status', (packet) => {
function inject (bot, { version }) {
const Item = require('prismarine-item')(version)
const Recipe = require('prismarine-recipe')(version).Recipe
const windows = require('prismarine-windows')(version).windows
function craft (recipe, count, craftingTable, cb) {
assert.ok(recipe)
cb = cb || noop
count = count == null ? 1 : parseInt(count, 10)
if (recipe.requiresTable && !craftingTable) {
cb(new Error('recipe requires craftingTable'))
return
}
next()
function next (err) {
if (err) {
cb(err)
} else if (count > 0) {
count -= 1
craftOnce(recipe, craftingTable, next)
function inject (bot, { version }) {
const windows = require('prismarine-windows')(version).windows
function openChest (chestToOpen) {
let chest
if (chestToOpen.constructor.name === 'Block') {
assert.ok(chestToOpen.type === 54 || chestToOpen.type === 130 || chestToOpen.type === 146)
chest = bot.openBlock(chestToOpen, Chest)
} else if (chestToOpen.constructor.name === 'Entity') {
assert.strictEqual(chestToOpen.entityType, 10)
assert.strictEqual(chestToOpen.objectData.intField, 1)
chest = bot.openEntity(chestToOpen, Chest)
} else {
assert.ok(false, 'chestToOpen is neither block nor entity')
}
chest.withdraw = withdraw
chest.deposit = deposit
return chest
function inject (bot, { version }) {
const Item = require('prismarine-item')(version)
const windows = require('prismarine-windows')(version).windows
bot._client.registerChannel('MC|TrSel', 'i32')
bot._client.registerChannel('MC|TrList', [
'container',
[
{ type: 'i32', name: 'windowId' },
{
name: 'trades',
type: [
'array',
{
countType: 'i8',
type: [
'container',
[
{ type: 'slot', name: 'firstInput' },
function inject (bot, { version }) {
const windows = require('prismarine-windows')(version).windows
let nextQuickBarSlot = 0
function tossStack (item, cb = noop) {
assert.ok(item)
bot.clickWindow(item.slot, 0, 0, (err) => {
if (err) return cb(err)
bot.clickWindow(-999, 0, 0, cb)
bot.closeWindow(bot.currentWindow || bot.inventory)
})
}
function toss (itemType, metadata, count, cb) {
const window = bot.currentWindow || bot.inventory
const options = {
window,
function inject (bot, { version }) {
const windows = require('prismarine-windows')(version).windows
function openDispenser (dispenserBlock) {
assert.strictEqual(dispenserBlock.type, 23)
const dispenser = bot.openBlock(dispenserBlock, Dispenser)
dispenser.deposit = deposit
dispenser.withdraw = withdraw
return dispenser
function deposit (itemType, metadata, count, cb) {
const options = {
window: dispenser.window,
itemType,
metadata,
count,
sourceStart: dispenser.window.inventorySlotStart,
sourceEnd: dispenser.window.inventorySlotStart + windows.INVENTORY_SLOT_COUNT,
destStart: 0,
module.exports.player = function (player, serv, { version }) {
const Item = require('prismarine-item')(version)
const windows = require('prismarine-windows')(version).windows
player.heldItemSlot = 0
player.heldItem = new Item(256, 1)
player.inventory = new windows.InventoryWindow(0, 'Inventory', 44)
player._client.on('held_item_slot', ({ slotId } = {}) => {
player.heldItemSlot = slotId
player.setEquipment(0, player.inventory.slots[36 + player.heldItemSlot])
player._writeOthersNearby('entity_equipment', {
entityId: player.id,
slot: 0,
item: Item.toNotch(player.heldItem)
})
})
function inject (bot, { version }) {
const windows = require('prismarine-windows')(version).windows
function openFurnace (furnaceBlock) {
assert.ok(furnaceBlock.type === 61 || furnaceBlock.type === 62)
const furnace = bot.openBlock(furnaceBlock, Furnace)
furnace.takeInput = takeInput
furnace.takeFuel = takeFuel
furnace.takeOutput = takeOutput
furnace.putInput = putInput
furnace.putFuel = putFuel
bot._client.on('craft_progress_bar', onUpdateWindowProperty)
furnace.once('close', onClose)
return furnace
function onClose () {
bot._client.removeListener('craft_progress_bar', onUpdateWindowProperty)
}
function onUpdateWindowProperty (packet) {