#Scheduling working weird

1 messages · Page 1 of 1 (latest)

hazy magnet
#

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

hazy magnet
#
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```
wicked siren
#

schedules cannot be run as or at something/somewhere else

#

they always run as the server and at spawn

hazy magnet
#

but why isnt it working even with the tag system

#

or is there an alternative way to cooldown something

wicked siren
#

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

hazy magnet
#

ok it works thanks

wicked siren
#

your way of doing it causes issues in multiplayer though

hazy magnet
#

is there another way i can do it

wicked siren
#

yes

hazy magnet
#

ok how

wise orbitBOT
#

execute store result score @s cooldown_timestamp run schedule function trimeffect:reenable 10t append

and in the reenable function you do this:

execute store result score $time_now temp run time querry gametime
execute as @a if score @s cooldown_timestamp = $time_now temp run advancement revoke @s only trimeffect:click
wicked siren
#

you don't need the disabled tags anymore

hazy magnet
#

it doesnt seem to be working

#

i put query instead of querry

wicked siren
#

raw nbt checks are expensive

hazy magnet
#

is cooldown_timestamp a scoreboard?

wicked siren
#

yes, a dummy scoreboard

hazy magnet
#

ok

wicked siren
hazy magnet
wicked siren
#

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.

hazy magnet
#

it doesnt seem to be working

wicked siren
#

what exactly?

#

How does your code look right now?

hazy magnet
#
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```
wicked siren
#

does the log say anything?

hazy magnet
#

game logs?

regal marshBOT
#
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:

  1. Enable the logs in the Minecraft Launcher (see image)
  2. 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.

hazy magnet
#

nothing showing up in logs

#

both of them are running

#

/valid

#

because i did function <>

wicked siren
#

works for me

#

I assume you have an error in one of your remove_one functions or have referenced a wrong advancement

hazy magnet
#

ok ill check

#

thanks

clear creek
# hazy magnet ok ill check

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