2

Is it possible to convert a command block into a datapack?

Silam's Avatar Silam5/14/24 10:38 am
5/15/2024 12:19 pm
Silam's Avatar Silam
Hi !
I have been making spells, potions, and other add-ons with command blocks for some time, I wanted to know if it was possible to convert this into a datapack?
is it “easy”?



scoreboard objectives add tp minecraft.used:minecraft.carrot_on_a_stick
tag @a[nbt={Inventory:[{Slot:-106b,components:{"minecraft:custom_data":{rightClick:14b}}}]}] add tp1
execute at @a[tag=tp1,scores={tp=1..}] run particle minecraft:angry_villager ^ ^ ^-1 0.3 0.3 0.3 0 50 normal
execute at @a[tag=tp1,scores={tp=1..}] run teleport @p[tag=tp1] ^ ^ ^3
execute at @a[tag=tp1,scores={tp=1..}] run effect give @p[tag=tp1] minecraft:weakness 4 2 true
execute at @a[tag=tp1,scores={tp=1..}] run playsound minecraft:entity.enderman.teleport player @p[tag=tp1]
execute at @a[tag=tp1,scores={tp=1..},nbt={Inventory:[{components:{"minecraft:custom_data":{rightClick:14b}}}]}] run clear @a[tag=tp1,scores={tp=1..}] carrot_on_a_stick[custom_data={rightClick:14b}] 1
tag @a remove tp1
scoreboard players set @a tp 0
For example for these commands, do you have an example? a Tutorial? I only ask to learn.

Thank you :)

----------------------------------------------------------------------

Salut !
Je fais depuis un certain temps des sorts, des potions, et autres add on avec des command block, je voulais savoir si il était possible de convertir cela en datapack ?
est-ce "facile" ?

scoreboard objectives add tp minecraft.used:minecraft.carrot_on_a_stick
tag @a[nbt={Inventory:[{Slot:-106b,components:{"minecraft:custom_data":{rightClick:14b}}}]}] add tp1
execute at @a[tag=tp1,scores={tp=1..}] run particle minecraft:angry_villager ^ ^ ^-1 0.3 0.3 0.3 0 50 normal
execute at @a[tag=tp1,scores={tp=1..}] run teleport @p[tag=tp1] ^ ^ ^3
execute at @a[tag=tp1,scores={tp=1..}] run effect give @p[tag=tp1] minecraft:weakness 4 2 true
execute at @a[tag=tp1,scores={tp=1..}] run playsound minecraft:entity.enderman.teleport player @p[tag=tp1]
execute at @a[tag=tp1,scores={tp=1..},nbt={Inventory:[{components:{"minecraft:custom_data":{rightClick:14b}}}]}] run clear @a[tag=tp1,scores={tp=1..}] carrot_on_a_stick[custom_data={rightClick:14b}] 1
tag @a remove tp1
scoreboard players set @a tp 0

Par exemple pour ces commandes là, avez vous un exemple ? un Tutoriel ? Je ne demande qu'a apprendre.

Je vous remercie :)
Posted by Silam's Avatar
Silam
Level 1 : New Miner
0

Create an account or sign in to comment.

2

imalittlhigh
05/15/2024 5:07 am
Level 62 : High Grandmaster Sweetheart
history
imalittlhigh's Avatar
yes, its very easy.
There is a good guide on datapacks here
If youre starting out from commandblocks, you can just use the tick.mcfunction for now (not good practice, but fine for starting)
You can think of that as every line of code being a repeating commandblock. The first line executes first, then second, third...

You technically could just copy the commandblocks commands into the function and it should work.
If youre using relative coordinates, datapacks execute from 0 0 0 iirc (might be worldspawn)

Also creating objectives and similar, that only need to be done once can be executed in the load.mcfunction.
3
Silam
05/15/2024 12:19 pm
Level 1 : New Miner
Silam's Avatar
Thank you so much !

I worked all afternoon on the datapacks and I managed to have something that suits me!
Again, thank you very much !!!
2
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome