UNPKG

@throw-out-error/minecraft-datapack

Version:

A module for making minecraft datapacks with node to cut down on the repetition.

215 lines (214 loc) 8.6 kB
import { Condition } from "./predicate"; export declare class LootTable { path: string; pools: LootPool[]; /** * Creates a LootTable * @param {string} path The path of the loot table file relative to namespace/loot_tables (excluding the file extension) */ constructor(path: string); /** * Outputs the loot table file * @param {string} path The root path for the loot table to compile to */ compile(path: string): void; /** * Appends a pool to the table * @param {LootPool} lootPool the loot pool to be added * @returns {LootPool} a reference to the added pool */ addPool(lootPool: LootPool): LootPool; /** * Remove one of the loot pools from the table * @param {number} index The index of the pool to be deleted */ deletePool(index: number): void; /** * Creates a loot pool and adds it to the loot table * @param {object} options The configuration for the pool * @param {(object|number)} options.rolls The range of the amount of entries the pool will choose * @param {number} options.rolls.min The minimum amount of entries chosen * @param {number} options.rolls.max The maximum amount of entries chosen * @param {(object|number)} options.bonusRolls The range of the amount of bonus rolls due to luck (it get's multiplied by the players generic.luck attribute) * @param {number} options.bonusRolls.min The minimum amount of bonus rolls (it get's multiplied by the players generic.luck attribute) * @param {number} options.bonusRolls.max The maximum amount of bonus rolls (it get's multiplied by the players generic.luck attribute) * @returns {LootPool} a reference to the added loot pool */ createPool(options: { rolls: { min: number; max: number; } | number; bonusRolls: { min: number; max: number; } | number; }): LootPool; /** * Creates a copy of the loot table * @param {LootTable} lootTable */ static copy(lootTable: LootTable): LootTable; } export declare class LootPool { rolls: { min: number; max: number; } | number; bonusRolls: { min: number; max: number; } | number; entries: LootEntry[]; conditions: Condition[]; /** * Creates a LootPool * @param {object} options The configuration for the pool * @param {number} options.rolls The range of the amount of entries the pool will choose * @param {object} options.rolls A range of entries the pool will choose * @param {number} options.rolls.min The minimum amount of entries chosen * @param {number} options.rolls.max The maximum amount of entries chosen * @param {number} options.bonusRolls The amount of bonus rolls due to luck (it get's multiplied by the players generic.luck attribute) * @param {object} options.bonusRolls The range of bonus rolls due to luck (it get's multiplied by the players generic.luck attribute) * @param {number} options.bonusRolls.min The minimum amount of bonus rolls (it get's multiplied by the players generic.luck attribute) * @param {number} options.bonusRolls.max The maximum amount of bonus rolls (it get's multiplied by the players generic.luck attribute) */ constructor(options: any); /** * Generates the data associated with the pool * @returns {object|array} the generated json */ compile(): { rolls: number | { min: number; max: number; }; bonus_rolls: number | { min: number; max: number; }; entries: object[]; conditions: object[]; }; /** * Adds an entry to the loot pool * @param {LootEntry} entry the entry to be added to the pool * @returns {LootEntry} returns a reference to the added loot entry */ addEntry(entry: LootEntry): LootEntry; /** * Adds a condition to the loot pool * @param {Condition} condition the condition to be added to the pool * @returns {Condition} returns a reference to the added condition */ addCondition(condition: Condition): Condition; /** * Creates a copy of the loot pool * @param {LootPool} lootPool * @returns {LootPool} a copy of the loot pool */ static copy(lootPool: LootPool): LootPool; } export declare class LootEntry { type: "minecraft:item" | "minecraft:loot_table" | "minecraft:empty"; conditions: Condition[]; /** * Creates a LootEntry * @param {('minecraft:item'|'minecraft:loot_table'|'minecraft:empty')} type the type of loot entry */ constructor(type: any); /** * Generates the data associated with the entry * @returns {object|array} the generated json */ compile(): object; /** * Adds a condition to the loot pool * @param {Condition} condition the condition to be added to the pool * @returns {Condition} returns a reference to the added condition */ addCondition(condition: Condition): Condition; /** * Creates a copy of the loot entry * @param {LootEntry} lootEntry * @returns {LootEntry} a copy of the loot entry */ static copy(lootEntry: LootEntry): LootEntry; } export declare class ItemEntry extends LootEntry { output: object; functions: LootFunction[]; /** * Creates an ItemEntry * @param {object} options the configuration for the item entry * @param {string} options.name the name of the item in the entry * @param {number} [options.weight=1] the chance of this entry being picked from the pool proportional to the sum of all the entries weights in the pool * @param {number} [options.quality=1.0] the quality of the entry, the final weight of the entry = weight+quality*generic.luck */ constructor(options: any); /** * Adds a function to the item entry * @param {LootFunction} lootFunction the function to be added */ addFunction(lootFunction: LootFunction): void; /** * Creates a function and adds it to the item entry * @param {object} options the configuration of the function to be added * @returns {LootFunction} the loot function created */ createFunction(options: object): LootFunction; /** * Generates the data associated with the item entry * @returns {object|array} the generated json */ compile(): object; } export declare class EmptyEntry extends LootEntry { output: object; /** * Creates an EmptyEntry * @param {object} options the configuration for the empty entry * @param {number} [options.weight=1] the chance of this entry being picked from the pool proportional to the sum of all the entries weights in the pool * @param {number} [options.quality=1.0] the quality of the entry, the final weight of the entry = weight+quality*generic.luck */ constructor(options: any); } export declare class LootTableEntry extends LootEntry { output: object; /** * Creates a LootTableEntry * @param {object} options the configuration of the loot table entry * @param {string} options.name the name of the loot table the entry will use. recursion will be blocked(if a loot table points to it's self then the loot table is selected it won't generate items) * @param {number} [options.weight=1] the chance of this entry being picked from the pool proportional to the sum of all the entries weights in the pool * @param {number} [options.quality=1.0] the quality of the entry, the final weight of the entry = weight+quality*generic.luck */ constructor(options: any); } export declare class LootFunction { options: object; conditions: Condition[]; /** * Creates a LootFunction * @param {object} options the configuration of the loot function */ constructor(options: object); /** * Generates the data associated with the function * @returns {object|array} the generated json */ compile(): { condition: object[]; }; /** * Adds a condition to the loot pool * @param {Condition} condition the condition to be added to the pool * @returns {Condition} returns a reference to the added condition */ addCondition(condition: Condition): Condition; /** * Creates a copy of the loot function * @param {LootFunction} lootFunction * @returns {LootFunction} a copy of the loot function */ static copy(lootFunction: any): any; }