From 75ca7c2d9b99a99ee0099870fd4643a73bd21443 Mon Sep 17 00:00:00 2001 From: "Justin J. Novack" Date: Sat, 11 Jan 2025 10:46:03 -0500 Subject: [PATCH] Update auto_lighter.sc for v1.21 Updates auto_lighter to check for version, and appropriately use Enchantments (<1.21) vs components (v1.21+) depending on version. Corrective snipped merged from @YageGeng in #395 Fixes #395 Fixes #405 Fixes #406 --- programs/survival/auto_lighter.sc | 32 +++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) 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);