I'm not sure why it isn't working for you. I just tested it, worked for me. What's your treasure table look like? I just modified the luck tables (at the very bottom) to always give 6 legendaries. This means you have to have a point in luck, but that's not much of a cost for infinite legendaries, and you could even put a rabbit's belt or amulet at the start.

Screw it, here's a link to a modified version of my artifacts mod, which also includes a few changes to the number and type of boosts you can find on legendaries, and a few locked, indestructible chests lying around, but you won't have to mess with those since you'll have all the gear you need anyway. There will be a lucky rabbit's belt lying right there as well so you don't even have to put a point in lucky charm if you don't want. There will probably be some things I've accidentally left around from testing, but they shouldn't be any more immersion breaking than finding six legendaries in every barrel.

https://www.dropbox.com/s/ij285veze8ow3b4/Infinite%20Legendaries.rar?dl=0

new treasuretable "_Luck"
new treasuretable "Luck1"
new subtable "-3"
object category "Scroll",25,100,0,0,0,0,0,0
object category "Arrow",30,100,0,0,0,0,0,0
object category "Gold",30,100,0,0,0,0,0,0
object category "Precious",15,100,0,0,0,0,0,0
new subtable "-6"
object category "T_ST_SecGearLegendary",100,100,0,0,0,0,0,0
object category "T_ST_WeaponLegendary",100,100,0,0,0,0,0,0
object category "T_ST_ArmorLegendary",100,100,0,0,0,0,0,0
object category "ST_RingOrAmuletLegendary",100,100,0,0,0,0,0,0
new treasuretable "Luck2"
new subtable "0,96;1,4"
object category "Scroll",25,100,0,0,0,0,0,0
object category "Arrow",25,100,0,0,0,0,0,0
object category "T_ST_SecGearNormal",25,100,0,0,0,0,0,0
object category "Precious",25,100,0,0,0,0,0,0
new subtable "-6"
object category "T_ST_SecGearLegendary",100,100,0,0,0,0,0,0
object category "T_ST_WeaponLegendary",100,100,0,0,0,0,0,0
object category "T_ST_ArmorLegendary",100,100,0,0,0,0,0,0
object category "ST_RingOrAmuletLegendary",100,100,0,0,0,0,0,0
new treasuretable "Luck3"
new subtable "0,95;1,2;2;3"
object category "Scroll",20,100,0,0,0,0,0,0
object category "Arrow",20,100,0,0,0,0,0,0
object category "T_ST_SecGearNormal",20,100,0,0,0,0,0,0
object category "T_ST_ArmorNormal",20,100,0,0,0,0,0,0
object category "Precious",20,100,0,0,0,0,0,0
new subtable "-6"
object category "T_ST_SecGearLegendary",100,100,0,0,0,0,0,0
object category "T_ST_WeaponLegendary",100,100,0,0,0,0,0,0
object category "T_ST_ArmorLegendary",100,100,0,0,0,0,0,0
object category "ST_RingOrAmuletLegendary",100,100,0,0,0,0,0,0
new treasuretable "Luck4"
new subtable "0,93;1,3;2,4"
object category "Scroll",20,100,0,0,0,0,0,0
object category "Arrow",20,100,0,0,0,0,0,0
object category "GoldBig",10,100,0,0,0,0,0,0
object category "T_ST_SecGearMagic",10,100,0,0,0,0,0,0
object category "T_ST_ArmorMagic",10,100,0,0,0,0,0,0
object category "Precious",20,100,0,0,0,0,0,0
new subtable "-6"
object category "T_ST_SecGearLegendary",100,100,0,0,0,0,0,0
object category "T_ST_WeaponLegendary",100,100,0,0,0,0,0,0
object category "T_ST_ArmorLegendary",100,100,0,0,0,0,0,0
object category "ST_RingOrAmuletLegendary",100,100,0,0,0,0,0,0
new treasuretable "Luck5"
new subtable "0,92;1,3;2,5"
object category "Scroll",10,100,0,0,0,0,0,0
object category "Arrow",10,100,0,0,0,0,0,0
object category "GoldBig",10,100,0,0,0,0,0,0t
object category "T_ST_SecGearMagic",10,100,0,0,0,0,0,0
object category "T_ST_ArmorMagic",10,100,0,0,0,0,0,0
object category "T_ST_WeaponMagic",10,100,0,0,0,0,0,0
object category "Precious",10,100,0,0,0,0,0,0
new subtable "-6"
object category "T_ST_SecGearLegendary",100,100,0,0,0,0,0,0
object category "T_ST_WeaponLegendary",100,100,0,0,0,0,0,0
object category "T_ST_ArmorLegendary",100,100,0,0,0,0,0,0
object category "ST_RingOrAmuletLegendary",100,100,0,0,0,0,0,0
new treasuretable "Luck6"
new subtable "0,90;1,5;2,5"
object category "Scroll",15,100,0,0,0,0,0,0
object category "Arrow",15,100,0,0,0,0,0,0
object category "GoldBig",15,100,0,0,0,0,0,0
object category "T_ST_SecGearMagic",5,100,0,0,0,0,0,0
object category "T_ST_ArmorMagic",5,100,0,0,0,0,0,0
object category "T_ST_WeaponMagic",5,100,0,0,0,0,0,0
object category "Precious",10,100,0,0,0,0,0,0
new subtable "-6"
object category "T_ST_SecGearLegendary",100,100,0,0,0,0,0,0
object category "T_ST_WeaponLegendary",100,100,0,0,0,0,0,0
object category "T_ST_ArmorLegendary",100,100,0,0,0,0,0,0
object category "ST_RingOrAmuletLegendary",100,100,0,0,0,0,0,0