Skip to content

Commit

Permalink
Update auto_lighter.sc for v1.21
Browse files Browse the repository at this point in the history
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 gnembon#395 

Fixes gnembon#395 
Fixes gnembon#405 
Fixes gnembon#406
  • Loading branch information
jnovack authored Jan 11, 2025
1 parent 4c289a8 commit 75ca7c2
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions programs/survival/auto_lighter.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 75ca7c2

Please sign in to comment.