How to use the prismarine-windows.windows function in prismarine-windows

To help you get started, we’ve selected a few prismarine-windows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PrismarineJS / mineflayer / lib / plugins / inventory.js View on Github external
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) => {
github PrismarineJS / mineflayer / lib / plugins / craft.js View on Github external
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)
github PrismarineJS / mineflayer / lib / plugins / chest.js View on Github external
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
github PrismarineJS / mineflayer / lib / plugins / villager.js View on Github external
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' },
github PrismarineJS / mineflayer / lib / plugins / simple_inventory.js View on Github external
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,
github PrismarineJS / mineflayer / lib / plugins / dispenser.js View on Github external
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,
github PrismarineJS / flying-squid / src / lib / plugins / inventory.js View on Github external
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)
    })
  })
github PrismarineJS / mineflayer / lib / plugins / furnace.js View on Github external
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) {

prismarine-windows

Represent minecraft windows

MIT
Latest version published 10 months ago

Package Health Score

61 / 100
Full package analysis

Popular prismarine-windows functions