So I have a consumable item which is linked to an advancement which then calls a function but if you have a stack there is no cooldown so im trying to add one by scheduling a function to run a reenable function which then revokes the advancement, but the scheduling is being really weird ive realised i cant schedule a function as @s so i made the function tag the player, then when the cooldown is over it untags the player, but the scheduling in the function just plainly doesnt work
#Scheduling working weird
1 messages · Page 1 of 1 (latest)
execute if data entity @s SelectedItem.components.minecraft:custom_data run item modify entity @s weapon trimeffect:remove_one
execute if data entity @s equipment.offhand.components.minecraft:custom_data run item modify entity @s weapon.offhand trimeffect:remove_one
tag @s add disabled
execute as @s run schedule function trimeffect:reenable 10t append```
tag @s[tag=disabled] remove disabled```
schedules cannot be run as or at something/somewhere else
they always run as the server and at spawn
but why isnt it working even with the tag system
or is there an alternative way to cooldown something
you target @s in your schedule, so it only checks the tag on the executor (the server)
you have to change it to @a
You can also change this line: execute as @s run schedule function trimeffect:reenable 10t append to this: schedule function trimeffect:reenable 10t append
ok it works thanks
your way of doing it causes issues in multiplayer though
is there another way i can do it
yes
ok how
execute store result score @s cooldown_timestamp run schedule function trimeffect:reenable 10t append
and in the reenable function you do this:
[35mexecute [34mstore result score [36m$time_now [0mtemp [34mrun [35mtime [0mquerry [34mgametime
[35mexecute [34mas [36m@a [34mif score [36m@s [0mcooldown_timestamp [34m= [36m$time_now [0mtemp [34mrun [35madvancement [34mrevoke [36m@s [34monly [33mtrimeffect:click
you don't need the disabled tags anymore
you can use execute if items to more efficently check item data btw
raw nbt checks are expensive
is cooldown_timestamp a scoreboard?
yes, a dummy scoreboard
ok
it also lets you combine your two commands that check main and offhand into only a single one
is temp a scoreboard as well
ok ill do that
yes, temp is also a dummy scoreboard. I always use a scoreboard called temp for scores that are only needed in a single tick to avoid having to create new ones for every little thing I do.
it doesnt seem to be working
execute if data entity @s SelectedItem.components.minecraft:custom_data run item modify entity @s weapon trimeffect:remove_one
execute if data entity @s equipment.offhand.components.minecraft:custom_data run item modify entity @s weapon.offhand trimeffect:remove_one
execute store result score @s trimeffect.cooldown_timestamp run schedule function trimeffect:reenable 10t append```
i added prefixes to the scoreboards and added them
```execute store result score $time_now trimeffect.temp run time query gametime
execute as @a if score @s trimeffect.cooldown_timestamp = $time_now temp run advancement revoke @s only trimeffect:click```
does the log say anything?
game logs?
Logs
When making or debugging Minecraft datapacks, it is useful to have the Minecraft logs open in order to view errors quickly.
To open the logs:
- Enable the logs in the Minecraft Launcher (see image)
- Start Minecraft
The logs should open in a separate window. Datapack errors are shown in the when you /reload and are almost always in red text or yellow text.
nothing showing up in logs
both of them are running
/valid
because i did function <>
works for me
I assume you have an error in one of your remove_one functions or have referenced a wrong advancement
If you want to make cooldown items, I have a system you can use,
in my project Aspects, look into Focuses, Best example is Merling.
aspects/item_modifier/focus/merling.json
aspects/enchantment/focus/generic/
aspects/function/focus/generic/
aspects/function/focus/merling/
aspects/advancement/focus/merling.json
I am not sure if I am allowed to send the link, but like shouldnt be a problem