#Unbreakable Tools
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
🙇 If nobody has answered you by <t:1723903120:t>, feel free to use the Summon Helpers button to ping our helper team.
✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve
what minecraft version are you in?
1.20.1
okay, then that command should already do something
to give yourself an unbreakable age with damage of 1 you just run a simple give command, you can even add a unique tag if you ever plan to do anything else with that item
give <player> iron_axe{Damage:1,is_my_custom_axe:1b,Unbreakable:1b}
and when clearing you can specify data of the item you want to clear, so if you only want to clear iron axes with damage of 0, you can simply
clear <player> iron_axe{Damage:0}
when do you want it to happen?
every tick
i want it to be so when you craft an item it removes the original and gives you the modified version
you can either do it every tick - that may lag if there are a lot of players or you do this with more items/data packs/mods
or only when a player crafts something, but that won't work if they drop the item from the crafting table
i suggest doing it every tick for now, it's a lot easier to set up aswell
okay
then the idea would be to
- check if someone has the unmodified axe -> then give the custom axe
- check if someone has the unmodified axe -> then clear all unmodified axes
you can do it a little bit more fancy, by only checking the condition once but these 2 commands should do it
the checking is what you already did in your original post and the other stuff is what i send in the message earlier
with command blocks i did that a repeater does the execute command and then conditional chain command will give the modified axe
yea, in data packs it works a little differently, you either check the condition twice, where stuff may change - like checking for a cleared axe isn't possible
or, the data pack way
execute if <condition> run function other:function
# other:function
clear ...
give ...
okay, i made an simple function with this code
execute as @a[nbt={Inventory:[{id:"minecraft:iron_axe",Count:1b,tag:{Damage:0}}]}]
give @a iron_axe{Unbreakable:1b,Damage:1}
but the give command runs even if i dont have and axe, how can i make it only give the axe when the execute is succesful?
You need to put the execute command in your tick function, and run that function in the execute command
like you did in your original command, execute works like this:
execute <condition> run <command>
then the command is only ran if the condition succeeds
if you run a whole other function using execute and the condition you only need to check that once
can you explain how to do that please?
okay
i made it work but now the axe appers in the second slot like i will make the axe and it will be for a split second in the first slot of hotbar but then the unbreakable version will be in the second
what way did you decide to do it? if you did it in just 2 commands thats not fixable - if you did it in the function way just swap the order of the commands
well i did it in the two commands
execute as @a[nbt={Inventory:[{id:"minecraft:iron_axe",Count:1b,tag:{Damage:0}}]}] run give @a iron_axe{Unbreakable:1b,Damage:1}
execute as @a[nbt={Inventory:[{id:"minecraft:iron_axe",Count:1b,tag:{Damage:0}}]}] run clear @a iron_axe{Damage:0}
could you show me how to fix it?
sure
in tick:
execute as ... run function some:other/function
in some:other/function:
clear ...
give ...
to add a function just add another mcfunction file in the functions folder
could you tell me whats tick?
your ticking function
that does the command?
it's id is your namespace and the path to the function
some:other/function would be located at
data/some/functions/other/function.mcfunction
where are your commands currently?
tomitom/functions
in what file? how is it ran?
in the data file and is run by the tick.json in minecraft/tags/functions
not quite sure what "the data file" means but if it's ran by the tick.json function tag, it's a ticking function - it runs every tick