How to use the flying-squid.portal_detector function in flying-squid

To help you get started, we’ve selected a few flying-squid 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 / flying-squid / src / lib / plugins / portal.js View on Github external
module.exports.player = function (player, serv, { version }) {
  const { detectFrame, generatePortal, addPortalToWorld } = require('flying-squid').portal_detector(version)

  player.use_flint_and_steel = async (referencePosition, direction, position) => {
    let block = await player.world.getBlock(referencePosition)
    if (block.name === 'obsidian') {
      const frames = await detectFrame(player.world, referencePosition, direction)
      if (frames.length !== 0) {
        const air = frames[0].air
        air.forEach(pos => player.setBlock(pos, 90, (frames[0].bottom[0].x - frames[0].bottom[1].x) !== 0 ? 1 : 2))
        player.world.portals.push(frames[0])
        return
      }
    }
    player.changeBlock(position, 51, 0)
  }

  player.on('dug', ({ position, block }) => {