How to use the minecraft-data.itemsByName 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 1b8 / schematic / lib / block-entity.js View on Github external
module.exports = function (version) {
  var Block = require('./block')(version);
  var Item = require('prismarine-item')(version);
  var itemsByName = require('minecraft-data')(version).itemsByName;

  function container(self, raw) {
    if (raw.CustomName) self.customName = raw.CustomName.value;
    self.lockKey = raw.Lock.value;
    self.items = [];
    raw.Items.value.value.forEach(function (item) {
      var data = itemsByName[item.id.value.split(':')[1]];
      self.items.push(new Item(data ? data.id : 1,
        item.Count.value, item.Damage.value, item.tag ? item.tag.value : {}));
    });
  }

  function BlockEntity(schem, raw) {
    Block.apply(this, schem._blockArgs(vec3(raw.x.value, raw.y.value, raw.z.value)));
    this.raw = raw;