Binary-only library for loot generation.
ā ļø This is an early-stage API (v0.1.1). The API may change and backward compatibility is not guaranteed.
This library provides a loot table service with support for:
It is intended to be used as a dependency by other server plugins or mods.
Mods folder.ā ļø Important The LootGenerator mod must be installed in the Mods folder and enabled in the world. Otherwise, the loot service will not be available.
Add the dependency to your mod configuration files.
manifest.json
"Dependencies": {
"nofrfa.vectome.loot:LootGenerator": "*"
}pom.xml
<dependency>
<groupId>nofrfa.vectome.loot</groupId>
<artifactId>LootGenerator</artifactId>
<version>0.1.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/LootGenerator-0.1.1.jar</systemPath>
</dependency>š¦ Local library <your-mod>/libs/LootGenerator-0.1.1.jar
**Notes for developers** āļø
systemPath must match the actual JAR versionThe loot service is registered automatically on startup and can be accessed globally.
ā ļø Important PreferLootTableServices.getOrThrow()overget()to ensure the loot service is available.
LootTableService lootService = LootTableServices.getOrThrow();
List<ItemStack> items = lootService.roll(
"Default", // mode
"Basic", // tier
3 // rolls
);Returns a list of generated ItemStack.
LootInsertResult result = LootTableServices.getOrThrow().roll(
"Default",
"Rare",
2,
playerInventory
);
List<ItemStack> inserted = result.inserted();
List<ItemStack> remainder = result.remainder();inserted ā items successfully placed into the inventoryremainder ā items that did not fitThe configuration file is automatically created on first launch and can be safely edited afterward.
{
"Modes": {
"Default": {
"Tiers": {
"Basic": [
{
"Item": "Item_Id",
"Name": "CustomName",
"Guaranteed": true,
"Rarity": 5,
"Weight": 10,
"Min": 1,
"Max": 5
}
]
}
}
}
}| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| <code>Item</code> | string | Yes | ā | Item identifier |
| <code>Weight</code> | integer | No | 0 | Weight for random selection |
| <code>Guaranteed</code> | boolean | No | false | Always drops once; if <code>Weight &amp;gt; 0</code>, also participates in weighted rolls |
| <code>Min</code> | integer | No | 1 | Minimum amount |
| <code>Max</code> | integer | No | 1 | Maximum amount |
| <code>Name</code> | string | No | ā | Optional custom name |
| <code>Rarity</code> | integer | No | ā | Optional rarity metadata |
Notes:
Weight > 0 participate in weighted rolls regardless of GuaranteedGuaranteed and Weight are setWeight <= 0 do not participate in weighted rollsThese commands are intended for server administrators and developers. They do not add any gameplay features.
/lt reload ā Reloads the loot configuration at runtime. Permission: loottables.reload
Not published.
0 Comments