Any match_location conditions will fail in bartering loot tables. This makes it very difficult to make biome-based piglin barter drops.
I doubt it's intentional, probably just an oversight.
Code Analysis
Code analysis by @unknown can be found in this comment.
Attachments
Comments 7
I created a small datapack to demonstrate the issue. I've attached three screenshots. One shows the source code for the barter loot table, one shows the result of bartering with piglins in a warped forest (where warped planks should drop 80% of the time in my example datapack), and one shows the result of using the /loot command in a warped forest, where you can see warped planks dropping.
If there's anything else I can provide, let me know!
(Edit) I just noticed in the screenshot with the /loot command the biome information is covered up by previous command results. It was in the same location as the bartering screenshot, a warped forest, and I can probably go back and provide any information which is covered up.
I've attached the datapack I used to demonstrate the issue. All of the interesting stuff is in data/minecraft/loot_tables/gameplay/piglin_bartering.json.
I made sure to add one item which should always have a chance of dropping (diamond), one which should in a warped forest (warped planks), and one which never have a chance of dropping in an unmodified nether (bamboo). This ensures that:
The datapack is working and the loot table is being overridden, as none of those are normal drops
The conditions are valid and not being ignored, as no bamboo is ever dropped
The conditions do what they are supposed to with other means of using the loot table, as /loot works as expected
The conditions are always negative when used for piglin bartering, as diamonds are the only item that ever drops
Thanks! I can confirm now. Also, I made a slightly updated loot table to make testing a bit easier
{
"type": "minecraft:barter",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:diamond"
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:emerald"
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:warped_planks",
"conditions": [
{
"condition": "minecraft:location_check",
"predicate": {
"biome": "minecraft:warped_forest"
}
}
]
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:bamboo",
"conditions": [
{
"condition": "minecraft:location_check",
"predicate": {
"biome": "minecraft:jungle"
}
}
]
}
]
}
]
}
Now it always drops one diamond, one emerald (to prove that piglins can drop more than one item, i.e. MC-180407 is fixed). When using /loot
to simulate the table while in a warped forest, you get the extra plank, but when trading you don't.
Also code analysis: PiglinAi#getBarterResponseItems
needs to add withParameter(LootContextParams.ORIGIN, this.position())
to the loot context builder, like e.g. fishing hooks do
Hey there!
Please could you provide some screenshots or recordings of this issue occurring whilst the F3 Debug Screen is enabled. This would help myself, along with others, determine what the problem is. Thanks!