Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autolighter.sc no longer works as of 1.21 #395

Open
ChickenNdWaffles opened this issue Jun 25, 2024 · 5 comments
Open

Autolighter.sc no longer works as of 1.21 #395

ChickenNdWaffles opened this issue Jun 25, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@ChickenNdWaffles
Copy link

Describe the bug

I've used the Autolighter script for many years. Suddenly in the 1.21 update it doesn't seem to work. What happens when I right click with a torch is the entire stack of torches disappears from my inventory immediately instead of changing to the enchanted torch and starting to send the falling block entities flying towards their destinations like normal. I'm not sure if I'm doing something wrong here, or if it's just broken.

To Reproduce

Steps to reproduce the behavior:

  1. Ensure you have Fabric Loader installed for 1.21
  2. Open Mods folder for Minecraft
  3. Remove everything except FabricAPI and Carpet
  4. Launch Minecraft through Fabric Loader 1.21
  5. Make a new creative world
  6. Add a torch to selected slot of player hotbar
  7. Use the command /script download survival/auto_lighter.sc
  8. Look at air and right click while the torch is in your main hand

Expected behavior

When you right click the torch while looking at air (not a block) the torches should start flying outwards from you to their destinations. The torch in your hand gets toggled on and off when you right click, if toggled on, it has an enchantment on it.

Environment

Additional context
To ensure scripts work still, I did "/script download survival/sneak_grow_overpowered.sc" then planted some seeds into tilled soil, and crouched. They started to grow immediately, verifying that the script works. Even though you do get an error when you use it. For reference, the error you get from the sneak_grow_overpowered script is "App 'sneak_grow_overpowered' uses 'material (...)' which is deprecated for removal. Check the docs for a replacement" It's done that for a long time though and works regardless. The issue here is AutoLigher.sc doesn't do what it normally does anymore for some reason. Any help would be appreciated. Thank you! <3

@ChickenNdWaffles ChickenNdWaffles added the bug Something isn't working label Jun 25, 2024
@isbest
Copy link

isbest commented Jul 8, 2024

Hi, I have the same problem. so i just make some fix by delete:

			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);

which look like that give the Enchantments to the torch.

then it work well

@duggum
Copy link

duggum commented Jul 10, 2024

+1

@isbest
Copy link

isbest commented Jul 17, 2024

Hi, I have the same problem. so i just make some fix by delete:

			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);

which look like that give the Enchantments to the torch.

then it work well

I have studied the component system in version 1.21 and made the following changes. Note that this only applies to version 1.21

__on_player_uses_item(player, item, hand) ->
(
        if (hand != 'mainhand', return());
        if (item:0 == 'torch',
                ench = has(item:2:'components');
                global_spread_love = 0;
                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');
                );
                inventory_set(player, player~'selected_slot', item:1, item:0, item:2);
        ) 
);

@ChickenNdWaffles
Copy link
Author

ChickenNdWaffles commented Jul 24, 2024

Hi, I have the same problem. so i just make some fix by delete:

			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);

which look like that give the Enchantments to the torch.
then it work well

I have studied the component system in version 1.21 and made the following changes. Note that this only applies to version 1.21

__on_player_uses_item(player, item, hand) ->
(
        if (hand != 'mainhand', return());
        if (item:0 == 'torch',
                ench = has(item:2:'components');
                global_spread_love = 0;
                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');
                );
                inventory_set(player, player~'selected_slot', item:1, item:0, item:2);
        ) 
);

Ok, so how do I make that change and use it? I think I figured it out, sort of. My method was to replace the original code with your modification, then I saved the file as "autolighterfix.sc and put it into my scripts folder inside my world folder inside my saves folder. Then I did /script load autolighterfix.sc and tried it. That seems to have worked for me.

@isbest
Copy link

isbest commented Jul 25, 2024

Hi, I have the same problem. so i just make some fix by delete:

			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);

which look like that give the Enchantments to the torch.
then it work well

I have studied the component system in version 1.21 and made the following changes. Note that this only applies to version 1.21

__on_player_uses_item(player, item, hand) ->
(
        if (hand != 'mainhand', return());
        if (item:0 == 'torch',
                ench = has(item:2:'components');
                global_spread_love = 0;
                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');
                );
                inventory_set(player, player~'selected_slot', item:1, item:0, item:2);
        ) 
);

Ok, so how do I make that change and use it? I think I figured it out, sort of. My method was to replace the original code with your modification, then I saved the file as "autolighterfix.sc and put it into my scripts folder inside my world folder inside my saves folder. Then I did /script load autolighterfix.sc and tried it. That seems to have worked for me.

you should just change the you world direction/scripts/auto_light.sc then change the function __on_player_uses_item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants