mojira.dev
MC-276413

Shearing loot tables cannot have looting or fortune applied

Expected: adding 

"function": "minecraft:enchanted_count_increase"

would allow for looting to be applied to the loot table

What happened instead: There is an error validating the loot table,

Found loot table element validation problem in {minecraft:loot_table/minecraft:shearing/mooshroom}.pools[0].entries[0].entry[1]->{minecraft:shearing/mooshroom/brown}.pools[0].entries[0].functions[1]: Parameters [<parameter minecraft:attacking_entity>] are not provided in this context

Attempts to fix this issue: I have also attempted to use the fortune "apply_bonus", adding:

{
  "function": "minecraft:apply_bonus",
  "enchantment": "minecraft:fortune",
  "formula": "uniform_bonus_count",
  "parameters": {
     "bonusMultiplier": 1
   }
}

And got this error:

Found loot table element validation problem in {minecraft:loot_table/minecraft:shearing/mooshroom}.pools[0].entries[0].entry[1]->{minecraft:shearing/mooshroom/brown}.pools[0].entries[0].functions[1]: Parameters [<parameter minecraft:tool>] are not provided in this context

 

 

Attachments

Comments 8

Can you please provide more information? You can do so by attaching a video showcasing the bug and providing the How to Reproduce steps.

@BugTracker
I am not able to add a video, as it would only show the default behavior. The issue here is that the loot table is not functioning as expected, and thus it does not load. I have provided the datapack that I used. "How to reproduce" would literally just be "make a datapack that attempts to use the "minecraft:enchanted_count_increase" function on the shearing loot tables"

The enchanted_count_increase function, just like your error suggests, requires an attacking entity in its loot context in order to be evaluated, which means that it only applies to killing an entity. Likewise, the apply_bonus function requires a tool to be evaluated, which means it only applies to mining a block.

@ManosSef

Yes, this is the issue I am attempting to report. I would expect that looting or fortune would work with shearing, or that there would be an alternative function that would work similarly. I am assuming that it is unintended behavior that there is no option with these loot tables for enchanted loot increasing, since each of the other loot tables have a way to do this.

In that case this would be a feature request.

I am assuming that it is unintended behavior that there is no option with these loot tables for enchanted loot increasing, since each of the other loot tables have a way to do this.

Do you have any source to back up this assumption?

I think this issue is valid considering a similar loot context issue, MC-262347, was triaged.

Code analysis (Yarn mappings)

The LootContextParameterSet constructed in the LivingEntity#forEachShearedItem method is not passed the tool loot context parameter, as the method itself does not take a tool item stack as a parameter. This is despite the shearing player interactions and dispenser interactions for bogged, mooshrooms, sheep, and snow golems all requiring a shears item stack to occur.

A proposed fix for this issue is to pass the item stack through all necessary methods and be consumed in a parameterSet.add(LootContextParameters.TOOL, shears builder call.

According to the 24w37a changelog, this "issue" should now be fixed.

  • Tool value (used for functions like match_tool) is now available for some additional loot table types

    • archaeology - used brush

    • vault - inserted key (not available when displaying items)

    • shearing - shears

Yes, the issue is resolved in 24w37a, thank you.

IllogicalSong

(Unassigned)

Unconfirmed

(Unassigned)

24w36a

Retrieved