1

run function

1 emeralds4 replies31 views
panchuel started 06/22/2020 8:44 pm
One_Nose replied 06/24/2020 2:36 am
I seek to make a function that when the player has a bedrock block in the inventory the game eliminates it and after that it gives me an effect for example speed
How could I do it?
Posted by avatar
panchuel
Level 1 : New Miner
0

comment Login or register to post a reply.

4 replies

1
06/24/2020 2:36 am
Level 30 : Artisan Loremaster
One_Nose
Use scoreboards and execute store. After creating a dummy scoreboard (named speedrock for example):
execute as @a store success score @s speedrock run clear @s minecraft:bedrock 1This will clear 1 bedrock, and stores 1 if the player had bedrock (that now one disappeared) and 0 if the player didn't have bedrock. Then, check the scoreboard using target selectors and do stuff.
effect give @a[scores={speedrock=1}] minecraft:speedAnd reset the scoreboard to all players at the end of the function. Run this function on tick.

Maby you will want to add more conditions to the execute store function, for example if you want it to work only if the player doesn't have speed effect.

Hope it helped. If you have any questions or issues, feel free to comment them.
2
06/23/2020 2:28 pm
Level 1 : New Crafter
DMan16
/execute as @a[nbt={Inventory:[{id:"minecraft:bedrock"}]}] run effect give @s <effect_name> <seconds> <amplifier> <hide_particles>

What to change:
<effect_name>: The name of the effect - starts with minecraft: (write the command in the command line and use TAB to fill it in properly)
<seconds>: For how many seconds should the effect last - in seconds (minimum: 1)
<amplifier>: How strong should the effect be - number (range: 0-255, 255 is max strength)
<hide_particles>: Should the particles be visible (true/false)

If you want to do more than 1 command, make a function and replace everything after run with function <function_name> (again, use TAB to properly replace everything)
1
06/23/2020 7:12 pm
Level 1 : New Miner
panchuel
Is it possible that instead of an effect when removing the bedrock block, a mod command is executed [for example / slash give @p exp (quantity)] which is a command from mine and slash?
1
06/24/2020 2:22 am
Level 1 : New Crafter
DMan16
You have no idea how I wish that was was possible... But no. The execute function does not support any commands that are not Minecraft native...

BUT I do have a solution - command blocks.
Make a 2-chain command blocks structure, where the first one is the execute function but rubs nothing (only checks) or does a dummy run, and the the 2nd one is a chain+conditional command blocks with your mod's command.
Planet Minecraft Logo

Website

© 2010 - 2020
www.planetminecraft.com

Welcome