mojira.dev
MC-272561

'random_chance_with_enchanted_bonus' always uses 'unenchanted_chance' outside of loot tables

Tinkered around a bit right after the pre-release dropped and discovered that the newly added predicate isn't fully functional outside of loot tables.

Steps to reproduce

1. Put the following command into a repeating always active Command Block:

execute as @p if predicate {"condition":"minecraft:random_chance_with_enchanted_bonus","enchanted_chance":{"type":"minecraft:linear","base":0.33333334,"per_level_above_first":0.33333333},"enchantment":"minecraft:looting","unenchanted_chance":0} run say passed!

2. Give yourself 3 swords - each with a different level of Looting.

3. First, hold nothing. Then switch to the enchanted swords.
4. Notice how the amount of chat messages saying 'passed!' doesn't increase despite the fact that the predicate should have a 100% chance of passing with Looting III. 

Comments 4

This condition does work, but must be used in a loot table with an attacker context

updated title and description accordingly, thank you @tryashtar

Can confirm in 1.21 Pre-release 2.

I believe this is intended since merely holding an item does not constitute an attacker context

kohara

(Unassigned)

Community Consensus

Platform

Low

Enchantments

function, predicate

1.21 Pre-Release 1, 1.21 Pre-Release 2, 1.21 Pre-Release 3, 1.21, 1.21 Release Candidate 1, 1.21.4, 25w02a, 25w04a

Retrieved