PHPackages                             j1b1x/loottables - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. j1b1x/loottables

ActiveLibrary

j1b1x/loottables
================

34[1 issues](https://github.com/J1b1x/LootTables/issues)PHP

Since Aug 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/J1b1x/LootTables)[ Packagist](https://packagist.org/packages/j1b1x/loottables)[ RSS](/packages/j1b1x-loottables/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

LootTables
==========

[](#loottables)

[![php](https://camo.githubusercontent.com/6e2ca56a2d75d2d6d8bdbcea333f3f9bf4576c0229affc2b32fbc3ce47fe62f5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312d696e666f726d6174696f6e616c)](https://camo.githubusercontent.com/6e2ca56a2d75d2d6d8bdbcea333f3f9bf4576c0229affc2b32fbc3ce47fe62f5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312d696e666f726d6174696f6e616c)[![api](https://camo.githubusercontent.com/09f5789e63311cafb26c8af7e2f3f9f5fd29d49b678e18edad26402ee7abb73c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706f636b65746d696e652d352e302d696e666f726d6174696f6e616c)](https://camo.githubusercontent.com/09f5789e63311cafb26c8af7e2f3f9f5fd29d49b678e18edad26402ee7abb73c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706f636b65746d696e652d352e302d696e666f726d6174696f6e616c)

LootTables is a PocketMine-MP library for spreading certain loots in inventories. This can be used for mini-games, such as SkyWars, JumpLeague etc.

Categories
----------

[](#categories)

- [Loot](#loot)
    - [Construction](#loot-construction)
    - [Compatibilities](#compatibilities)
- [LootTable](#item-registration)
    - [Construction](#loottable-construction)
    - [Loot generation](#loot-generating)
- [LootTableMap](#functional-item)
    - [Construction](#loottablemap-construction)
    - [Spreading](#spreading)
- [Use example](#use-example)

Loot
----

[](#loot)

### Loot construction

[](#loot-construction)

```
public function __construct(
    Item $item, //The loots item
    int $chance, //The loots chance of being generated
    int $minCount = 1, //The min count of the item
    int $maxCount = 1, //The max count of the item
    ?Closure $isCompatible = null, //Compatibility with other items
){}
```

### Compatibilities

[](#compatibilities)

```
Loot::equalsSelf() //Checks if the generated item does not equal the loot item (so the loot can't be generated twice)
Loot::equalsArmor() //Checks if the generated item does not have the same armor slot as the loot item (so it won't generate multiple armor pieces with the same slot, like chestplates for example)

//You can also make your own compatibility function, just like this
function (Item $generated, Item $lootItem): bool{
    return true; //Put your own check in here
}
```

LootTable
---------

[](#loottable)

### LootTable construction

[](#loottable-construction)

```
public function __construct(
    int $minLootAmount, //The min amount of loots this table can generate
    int $maxLootAmount, //The max amount of loots this table can generate
    bool $generateOnce, //Weather the table can generate loots multiple times
    array $loots //The array of Loot objects for this table
){}
```

### Loot generating

[](#loot-generating)

This is actually supposed to be used by the LootTableMap only

```
//$loots is the array of loots that got generated already
//$amount is the amount of loots that get generated, use null to make it a random amount between $minLootAmount and $maxLootAmount
public function generateLoots(array &$loots = [], ?int $amount = null): Generator{}
```

LootTableMap
------------

[](#loottablemap)

### LootTableMap construction

[](#loottablemap-construction)

```
public function __construct(
    string $name, //The name of the loot table map (for example "easy", "medium", "hard")
    array $lootTables //The array of LootTables
){}
```

### Spreading

[](#spreading)

```
//$fillMultiplier is a percentage value of how much the inventory is gonna get filled
//$inventories is the array of inventory objects where the loots get put in
//$shuffle is weather the inventory contents gonna get shuffled (use this when you fill the invs for the first time to make the loots look more randomized)
public function spread(float $fillMultiplier, array $inventories, bool $shuffle = false): void{}
```

Use example
-----------

[](#use-example)

### This is an example of how to use this library for mini-games like SkyWars

[](#this-is-an-example-of-how-to-use-this-library-for-mini-games-like-skywars)

```
class Example{

    private const FILL_MULTIPLIER = 0.4;
    private const MULTIPLIER_RANDOMIZER = 0.2;

    private LootTable $table;

    public function initialize(): void{
        $this->table = new LootTable(
            new Loot(VanillaBlocks::OAK_PLANKS()->asItem(), 70, 20, 50),
            new Loot(VanillaBlocks::STONE()->asItem(), 70, 20, 50),
            new Loot(VanillaBlocks::BRICKS()->asItem(), 65, 20, 50),

            new Loot(VanillaItems::APPLE(), 55, 1, 3),
            new Loot(VanillaItems::BREAD(), 55, 1, 4),
            new Loot(VanillaBlocks::CAKE()->asItem(), 30),
            new Loot(VanillaItems::RAW_FISH(), 55, 1, 3),
            new Loot(VanillaItems::COOKED_FISH(), 50, 1, 3),
            new Loot(VanillaItems::RAW_CHICKEN(), 55, 1, 3),
            new Loot(VanillaItems::COOKED_CHICKEN(), 50, 1, 3),

            new Loot(VanillaItems::GOLDEN_APPLE(), 2, 1, 2),

            new Loot(VanillaItems::EGG(), 40, 1, 16),
            new Loot(VanillaItems::SNOWBALL(), 40, 1, 16),

            new Loot(VanillaItems::STONE_SWORD(), 27, 1, 1, Loot::equalsSelf()), //Only one stone sword per "island".
            new Loot(VanillaItems::IRON_HELMET(), 20, 1, 1, Loot::equalsArmor()), //Only one helmet per "island".
        );
    }

    /**
     * Function spread
     * @param Inventory[] $inventories
     * @param bool $shuffle
     * @return void
     */
    public function spread(array $inventories, bool $shuffle = true): void{
        $this->table->spread(
            self::FILL_MULTIPLIER + random_float(-self::MULTIPLIER_RANDOMOIZER, self::MULTIPLIER_RANDOMOIZER,
            $inventories,
            $shuffle
        ),
    }
}
```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/17a7e8099b8d2fdc6597c376d6367f3fa04b1e64f9ae07cc408cc3386d71537c?d=identicon)[J1b1x](/maintainers/J1b1x)

---

Top Contributors

[![J1b1x](https://avatars.githubusercontent.com/u/64813399?v=4)](https://github.com/J1b1x "J1b1x (4 commits)")

### Embed Badge

![Health badge](/badges/j1b1x-loottables/health.svg)

```
[![Health](https://phpackages.com/badges/j1b1x-loottables/health.svg)](https://phpackages.com/packages/j1b1x-loottables)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
