diff --git a/programs/survival/auto_lighter.sc b/programs/survival/auto_lighter.sc index ede31568..1092cac9 100644 --- a/programs/survival/auto_lighter.sc +++ b/programs/survival/auto_lighter.sc @@ -26,19 +26,31 @@ __on_player_uses_item(player, item, hand) -> ( if (hand != 'mainhand', return()); if (item:0 == 'torch', - ench = item:2:'Enchantments[]'; global_spread_love = 0; - delete(item:2:'Enchantments'); - if (!ench && player~'gamemode_id'!=3, - global_spread_love = 1; - if (ench==null, item:2 = nbt('{}')); - put(item:2:'Enchantments','[]'); - put(item:2:'Enchantments', '{lvl:1s,id:"minecraft:protection"}', 0); - global_survival=!(player~'gamemode_id' % 2); - schedule(0, 'spread_torches', player, player~'gamemode_id'); + if (system_info('game_major_target')>=21, + ench = has(item:2:'components'); + item:2:'components' = null; + if (!ench && player~'gamemode_id'!=3, + global_spread_love = 1; + if (ench==null, put(item:2:'components', '{}')); + put(item:2:'components', '{enchantments:{levels:{"protection":1}}}'); + global_survival=!(player~'gamemode_id' % 2); + schedule(0, 'spread_torches', player, player~'gamemode_id'); + ); + , //else + ench = item:2:'Enchantments[]'; + delete(item:2:'Enchantments'); + if (!ench && player~'gamemode_id'!=3, + global_spread_love = 1; + if (ench==null, item:2 = nbt('{}')); + put(item:2:'Enchantments','[]'); + put(item:2:'Enchantments', '{lvl:1s,id:"minecraft:protection"}', 0); + global_survival=!(player~'gamemode_id' % 2); + schedule(0, 'spread_torches', player, player~'gamemode_id'); + ); ); inventory_set(player, player~'selected_slot', item:1, item:0, item:2); - ) + ) ); __distance_sq(vec1, vec2) -> reduce(vec1 - vec2, _a + _*_, 0);