npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prismarine-loottable

v1.0.0

Published

A small utility package to help in parsing Minecraft loot tables.

Downloads

28

Readme

prismarine-loottable

NPM version Build Status Discord Gitter Irc Try it on gitpod

A utility package for parsing Minecraft loot table files.

Based on Loot Table format: https://minecraft.gamepedia.com/Loot_table

Usage

const getPotentialDrops = require("prismarine-loottable").getPotentialDrops;
const lootTable = require('./path/to/table.json')

const drops = getPotentialDrops(lootTable)

const itemType = drops[0].itemType
const silkTouch = drops[0].requiresSilkTouch()

API

Global Functions

getPotentialDrops(lootTable: MinecaftLootTable): LootItemDrop[]

This function can be used to directly parse a raw Minecraft loot table to pull out all potential drops as well as conditions required for that item to drop and functions that applied to the item (or user) in order. It returns a list of potential item drops.

Classes

LootItemDrop

This object is the main object returned from the getPotentialDrops function. It contains information about the details involved in getting this item to drop from the table.

  • lootItemDrop.itemType: string Gets the name of the item type which is dropped. This is a namespaced value.

  • lootItemDrop.minCount: number The smallest number of this item type which can be dropped, assuming all conditions are met. This does not take functions into consideration, which may change this value.

  • lootItemDrop.maxCount: number The maximum number of this item type which can be dropped assuming all conditions are met. This does not take functions into consideration, which may change this value.

  • lootItemDrop.functions: LootFunction[] The list of all functions that should be applied to this item drop, in order. Some functions may contain additional conditions required for them to occur.

  • lootItemDrop.conditions: LootCondition[] The list of all conditions which are required for this item drop to occur. This list contain conditions from both the item drop entry as well as the pool the item drop is in. These conditions do not have to be applied in any other but all conditions must be true.

  • lootItemDrop.weight: number The randomness weight of this item drop within the pool, relative to other entries in the pool. Items with a higher weight are more likely to be dropped than items with a lower weight compared to other entries in the same pool.

  • lootItemDrop.quality: number The bonus weight to add for each point of luck being used. The new weight value is calculated via the formula: floor(weight + (quality * generic.luck)) More information can be found on the Minecraft wiki page.

  • lootItemDrop.poolIndex: number The index of the loot table pool this item drop is located in.

  • lootItemDrop.entryType: string This value contains the entry type of the parent entry this item drop occurs from. For item drops not being nested, this is equal to minecraft:item. For item drops which are nested inside another entry, this value contains the parent entry's group type. group, alternatives, or sequence. This can be used to calculate more information about how item drops are calculated compared to the siblings

  • lootItemDrop.sibling: LootItemDrop[] A list of all other item drops that come from the same pool as this item drop. The list also contains this item.

  • lootItemDrop.requiresSilkTouch(): boolean Checks if any of the drop conditions is a silk touch requirement.

  • lootItemDrop.requiresNoSilkTouch(): boolean Checks if the item drop requires the tool to not have silk touch.

  • lootItemDrop.requiresPlayerKill(): boolean Checks if the item drop requires the entity to be killed by a player directly.

  • lootItemDrop.estimateDropChance(looting?: number, luck?: number): number Estimates the drop chance of the item with the given luck potion effect, looting enchantment level and all relevant functions and conditions applied to the item drop. If the looting parameter is not defined, it is defaulted to 0. If the luck parameter is not defined, it is defaulted to 0.

  • lootItemDrop.getRequiredBlockAge(): number Gets the required age of the block (for plant based blocks) in order for this item drop to occur.

  • lootItemDrop.getStackSizeRange(fortune?: number, looting?: number): [number, number] Gets the range of potential stack sizes for this item drop. This value may exceed the actual size of a Minecraft stack. If looting or fortune enchantments are used, the level can be specified to produce a more accurate range.

LootFunction

Contains information about a function to be applied to an item drop. The properties within this class match the properties of the given type as defined within the Minecraft Loot Table format.

  • lootFunction.type: string The namespaced type of function that is being applied.

  • lootFunction.onPool: boolean True if this function is applied to the entire pool. False if this function is only applied to the item.

LootCondition

Contains information about a condition required for an item drop to occur. The properties within this class match the properties of the given type as defined within the Minecraft Loot Table format.

  • lootCondition.type: string The namespaced type of condition that is being applied.

  • lootCondition.onPool: boolean True if this condition is applied to the entire pool. False if this condition is only applied to the item.

  • lootCondition.isSilkTouch(): boolean Checks if the condition is a silk touch check.