Files
node-minecraft-data/lib/indexes.js
T
TheDudeFromCIandRomain Beaumont 78d5266a27 Added Loot Data (#39)
* Added loot loaders.

Signed-off-by: TheDudeFromCI <thedudefromci@gmail.com>

* Added loot typings

Signed-off-by: TheDudeFromCI <thedudefromci@gmail.com>

* Added loot to api docs

Signed-off-by: TheDudeFromCI <thedudefromci@gmail.com>

* better integration

* update to mcdata 2.67.0

Co-authored-by: Romain Beaumont <romain.rom1@gmail.com>
2020-08-23 13:42:33 +02:00

43 lines
2.0 KiB
JavaScript

const indexer = require('./indexer.js')
module.exports = function (mcData) {
return {
biomesById: indexer.buildIndexFromArray(mcData.biomes, 'id'),
blocksById: indexer.buildIndexFromArray(mcData.blocks, 'id'),
blocksByName: indexer.buildIndexFromArray(mcData.blocks, 'name'),
blocksByStateId: indexer.buildIndexFromArrayWithRanges(mcData.blocks, 'minStateId', 'maxStateId'),
enchantmentsById: indexer.buildIndexFromArray(mcData.enchantments, 'id'),
enchantmentsByName: indexer.buildIndexFromArray(mcData.enchantments, 'name'),
entitiesByName: indexer.buildIndexFromArray(mcData.entities, 'name'),
mobsById: mcData.entities === undefined ? undefined
: indexer.buildIndexFromArray(mcData.entities.filter(e => e.type === 'mob'), 'id'),
objectsById: mcData.entities === undefined ? undefined
: indexer.buildIndexFromArray(mcData.entities.filter(e => e.type === 'object'), 'id'),
instrumentsById: indexer.buildIndexFromArray(mcData.instruments, 'id'),
itemsById: indexer.buildIndexFromArray(mcData.items, 'id'),
itemsByName: indexer.buildIndexFromArray(mcData.items, 'name'),
foodsById: indexer.buildIndexFromArray(mcData.foods, 'id'),
foodsByName: indexer.buildIndexFromArray(mcData.foods, 'name'),
foodsByFoodPoints: indexer.buildIndexFromArray(mcData.foods, 'foodPoints'),
foodsBySaturation: indexer.buildIndexFromArray(mcData.foods, 'saturation'),
windowsById: indexer.buildIndexFromArray(mcData.windows, 'id'),
windowsByName: indexer.buildIndexFromArray(mcData.windows, 'name'),
effectsById: indexer.buildIndexFromArray(mcData.effects, 'id'),
effectsByName: indexer.buildIndexFromArray(mcData.effects, 'name'),
particlesById: indexer.buildIndexFromArray(mcData.particles, 'id'),
particlesByName: indexer.buildIndexFromArray(mcData.particles, 'name'),
blockLootByName: indexer.buildIndexFromArray(mcData.blockLoot, 'block'),
entityLootByName: indexer.buildIndexFromArray(mcData.entityLoot, 'entity')
}
}