Simply Swords [Fabric & Forge]

Simply Swords [Fabric & Forge]

16M Downloads

[Suggestion] Refactor Loot Modification To Use Your Tags

fzzyhmstrs opened this issue ยท 2 comments

commented

Hi Sweeney!

I noticed a couple weeks ago you've added a set of tags for diamond_gear, iron_gear, uniques, etc.

My suggestion is to refactor your current Loot Table MODIFY event to use TagEntry instead of plain item entries. Here's the Wiki page where you can see them explained: Entry Providers

With the expand boolean selected, the tag entry should act just like a list of item entries, but would allow other weapons that are added to the tag to appear in the loot table automagically.

I bring this up, because I'm adding my very own "unique" hammer item that I would love to have appear effectively as one of the possible list of unique Simply Swords (and if SS isn't present, just in a separate event with the same chances all by itself). If I can just pop the hammer into an item tag, that would make things super easy, instead of having a separate loot pool all the time just for it. I also would prefer to avoid having the separate loot pool if possible so "multiple uniques" (the hammer + a unique SS) can't appear together at the same time.

commented

Thanks for the suggestion, Fzzy!

Do you have a working example of this KeyEntry usage that I can reference?

commented

Hi Sweeney, I tested this myself to make sure it works, and it does.

Here's a code snippet from my testing:

else if (LootTables.VILLAGE_TEMPLE_CHEST.equals(id)) {
            val poolBuilder = LootPool.builder()
                .rolls(UniformLootNumberProvider.create(1.0F,3.0F))
                //.conditionally(RandomChanceLootCondition.builder(0.5f))
                .with(TagEntry.expandBuilder(RegisterTag.ASPECT_GEMS_TAG).weight(5))
                .with(ItemEntry.builder(RegisterItem.BOOK_OF_LORE).weight(5))
                .with(ItemEntry.builder(RegisterItem.GLOWING_FRAGMENT).weight(5))
                .with(ItemEntry.builder(RegisterItem.EMPTY_SPELL_SCROLL).weight(3))
            table.pool(poolBuilder)
            val poolBuilder2 = RegisterLoot.tierOneGemPool(3.0F, 0.25F)
            table.pool(poolBuilder2)
            return true
        }

You can see in line 5 I inserted a TagEntry.expandBuilder with one of my tags. That makes a separate item entry for each item in the tag, so the stacks don't all appear together in one lumped drop. I then tested with the items explicitly defined in ItemEntries to check for equality:
image

Both ways did yield identical results.

If you want to take a look for yourself, here's the little 1.20.1 modpack I tested with, with the tag entry version of AI included.
Test Modpack

Here's an example loot table using the above TagEntry implementation:
image