Magic

Magic

190k Downloads

ChestPopulator

CJBlakey opened this issue · 6 comments

commented

Hi Nathan,

Not an issue, was just wondering how Magic plugin handles loot generated for dungeons. From what I can see you use the ChestPopulator class to check for chest entities on chunk generation and inserts the items at that point? I also saw your response to an old thread on SpigotMC suggesting that this is better than using the OnLootGenerate event.
Is this still how you'd recommend achieving this?

I only ask as I'm currently working on a plugin for my server that will distribute items in a similar way, adding to dungeon/stronghold/etc loot some custom items and some magic items.

Apologies for raising this as an issue, I couldn't PM on discord

commented

Hello!
I would actually be curious to see that thread, the LootGenerateEvent was not familiar to me. There was no such thing when I made the chest populator. It's very possible the event is a better way to go, assuming it works for all dungeon chests and not just sunken treasure- have you tested it out at all?

And feel free to ask more about this in the discord server, or send me a friend request if you'd rather keep it private.

commented

Failing that I may just write some extra loot tables, but that seems a little more complex with spigot than vanilla mc unless im misunderstanding it

commented

Hola!
Yeah, I'll pull up the thread, it's years old, someone asking about how to edit loot tables etc.
https://www.spigotmc.org/threads/edit-loot-inside-of-dungeons.263777/
I have indeed tested it, and to be honest it seems to work a lot better, when I use the block populator, the chest inventories are empty (as they've not been opened and generated from their respective tables yet) so in theory I can open the chest, adjust the loot etc, or just switch out the table.

But the lootgenerateevent seems to fire every time you open a lootable container entity which has not yet filled from its respective loot table. However through this event it seems you're able to iterate through the generated resulting loot, cancel the event all together etc. I'm trying to spice up our server by adding custom items and lore specific loot and afaik this seems to be the most promising method. But I'm also pretty new to java & spigot all together so wanted to seek the advice of a veteran such as yourself aha, especially after looking through the chestpopulator class

commented

Actually my bad, you weren't stating it was better suited than the loot generate event, was a different event. I've been reading too many threads haha. Non the less, would you think that the loot generate event would be a better way of inserting more interesting item stacks into naturally generated chests than the block populator?

commented

It does sound better to me, yes, much more efficient. I would just want to test that it works on all naturally-generated chests.

I thought it was just for sunken treasure, but I definitely could be wrong!

commented