#Cooldown not working resolved

1 messages · Page 1 of 1 (latest)

stone flume
#
{
    "format_version": "1.20.50",
    "minecraft:item": {
        "description": {
            "identifier": "cosmos:asteroid_annihilator",
            "menu_category": {
                "category": "equipment",
                "group": "itemGroup.name.sword"
            }
        },
        "components": {
            "minecraft:max_stack_size": 1,
            "minecraft:icon": "asteroid_annihilator",
            "minecraft:damage": 9,
            "minecraft:can_destroy_in_creative": false,
            "minecraft:hand_equipped": true,
            "minecraft:enchantable": {
                "slot": "sword",
                "value": 14
            },
            "minecraft:durability": {
                "max_durability": 2043
            },
            "minecraft:cooldown": {
                "category": "wind_charge",
                "duration": 0.5
            }
        }
    }
}
#

i have the cooldown component

#

but tvery time i use the item

#

it doesnt do the cooldown

tidal urchin
#

cooldowns are triggered when using items that have a component that makes them usable, such as these:

  • shooter
  • throwable
  • food
  • bundle_interaction
#

if you haven't applied a component that makes the item usable, you'll have to handle the triggering of the cooldown yourself in scripts

#

also you probably shouldn't be using wind_charge as the cooldown category (unless you want your item to share its cooldown with wind charges)
something like "category": "cosmos:asteroid_annihilator" would be better

stone flume
#

@tidal urchinhow do i make the item just useable

#

like i can js interact with it

#

its not a shooter or anything like that

#

because ms learn is kinda cheeks at explaining this stuff

tidal urchin
#

There's no way to make an item generically usable
You could make a custom component that handles the cooldown for the item

stone flume
#

how do i do that?

tidal urchin
#

the event you're using to trigger the content log should give you access to the ItemStack being used

#

you can then use itemStack.getComponent("minecraft:cooldown").startCooldown(player)

stone flume
#

yes but how do i active the cooldown upon the event firing

#

oh ok

#

thanks

#

@tidal urchingoat

tidal urchin
#

btw I think the itemuse event will trigger even if the item is in cooldown so you might also have to check that the item is not currently in cooldown

heady elbow
vast tusk
#

You can use a custom components and do the component event onUse to say that this will do this when used. You can then do something like itemStack.getComponent(ItemCooldownComponent.componentId).startCooldown(player);. This will also make it so it will only fire when the cooldown is up, so it won't fire before.

stone flume
#

Cooldown not working resolved