How to use the minecraft-data.entitiesByName function in minecraft-data

To help you get started, we’ve selected a few minecraft-data 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 / spawn.js View on Github external
module.exports.player = function (player, serv, options) {
  const version = options.version
  const entitiesByName = require('minecraft-data')(version).entitiesByName
  const Item = require('prismarine-item')(version)

  player.commands.add({
    base: 'summon',
    info: 'Summon an entity',
    usage: '/summon ',
    op: true,
    action (name) {
      if (Object.keys(serv.entities).length > options['max-entities']) { throw new UserError('Too many mobs !') }
      const entity = entitiesByName[name]
      if (!entity) {
        player.chat('No entity named ' + name)
        return
      }
      if (entity.type === 'mob') {
        serv.spawnMob(entity.id, player.world, player.position, {