Skip to content

Added LootTableRollEvent#9666

Closed
aerulion wants to merge 1 commit into
PaperMC:masterfrom
aerulion:feature/loottable-event
Closed

Added LootTableRollEvent#9666
aerulion wants to merge 1 commit into
PaperMC:masterfrom
aerulion:feature/loottable-event

Conversation

@aerulion
Copy link
Copy Markdown
Contributor

@aerulion aerulion commented Aug 29, 2023

Adds an event that gets called whenever a LootTable rolls any loot.
There are two aspects I'm not sure about:

  • Whether this should be a ServerEvent, or a WorldEvent like the LootGenerateEvent (but just forwarding the world from the LootContext location seems a bit pointless)?
  • If this is the best way to implement / call such an event. The goal was to have a general event for all loot table rolls, but this implementation only covers loot generated via LootTable#getRandomItems method returning an ObjectArrayList of the generated items. That for example excludes the loot generated by a LivingEntity, since it calls the void method with a consumer consuming the generated items, and I couldn't think of any good way to implement the event call in the consumer method.

Nonetheless this implementation allows for modifying the loot of Brushable Blocks, which wouldn't be possible otherwise (apart from replacing the item during the BlockDropItemEvent, but that leads to the "old item" sticking out the brushable block during brushing).

@aerulion aerulion requested a review from a team as a code owner August 29, 2023 03:12
+ // Paper start - LootTableRollEvent
+ final io.papermc.paper.event.server.LootTableRollEvent lootTableRollEvent = CraftEventFactory.callLootTableRollEvent(this, context, objectarraylist);
+ return lootTableRollEvent.getLoot().stream().map(CraftItemStack::asNMSCopy).collect(ObjectArrayList.toList());
+ // Paper start - LootTableRollEvent
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to paper end

@Warriorrrr Warriorrrr moved this from Awaiting review to Waiting For Author in Paper PR Queue Mar 5, 2025
@kennytv kennytv added the pre-softspoon: never rebased Pre-hardfork pull requests that were not re-opened with the new main branch label Mar 23, 2025
@kennytv kennytv deleted the branch PaperMC:master March 23, 2025 19:15
@kennytv kennytv closed this Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pre-softspoon: never rebased Pre-hardfork pull requests that were not re-opened with the new main branch pre-softspoon

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants