#Right-click detection with cooldown

1 messages · Page 1 of 1 (latest)

balmy basin
#

Hi! I'm in love with the new components and the ability to add cooldowns and custom consume times and animations to items, and I reeeeeally want to use these cooldowns on items. Unfortunately, the cooldown only applies when the item is fully consumed, which also kind of destroys the item (or converts it to a different item). Is there any way to apply this cooldown component without getting rid of the item? Maybe a clever way to get the item back immediately after? What ideas can y'all come up with? :3

lost scarabBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1730380973: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

wild turret
#

goat horns

#

they apply cooldown on use

balmy basin
#

Hmmmm

balmy basin
#

And if it is... could I do that to other items too?

wild turret
#

only goat horns

#

though you can differentiate between different goat horns because:

  • you can set individual cooldown groups
  • you can detect different goat horns based on their item_model with a predicate
#

an 'instrument' registry entry is like a jukebox, you can specify the duration

balmy basin
wild turret
#

easily

balmy basin
#

Hmmmm... so, how would I do this?

#

And is there any way with an ordinary item or weapon?

wild turret
#

it has to be based on the goat horn, unfortunately

balmy basin
#

I was thinking of a method, but it may not work

#

Would it be possible to use the "use_remainder" component to give you a temporary item that gets detected and replaced if held?

wild turret
#

using 'inventory_changed'?

#

technically it works

#

but I think it has limitations, like you can't keep renames

balmy basin
#

Like, could I make an advancement to detect it?

#

That would probably be fine

#

Actually wait

#

umm

#

hmmm

wild turret
#

wait, I don't know if it can detect which slot to clear

balmy basin
#

If the item can't stack, won't it just be in the slot it was previously on?

wild turret
#

it could be working that way, but idk if it works for offhand

#

also test when there are items on the ground and your inventory is full

balmy basin
#

I can't test rn, can u?

wild turret
#

I'm outside too

balmy basin
#

Oh lol

#

I'll see

#

I can't figure it out 😭

balmy basin
#

It doesn't work lol 😭

#

Anyways, about the goat horns

#

Do I change the cooldown component? Or something else?

wild turret
#

the cooldown's number component doesn't work on goat horns, but the cooldown group does, so it should be defined

#

the real cooldown is controlled by an instrument definition

lilac flicker
#

use the use_remainder component and make it change to itself, or just make the use time 1000000 and make an advancement that triggers when you use that item

lilac flicker
#

@balmy basin

wild turret
#

you can't make the item give back itself, it's not recursive

lilac flicker
#

OKAY I did it:

  1. make an advancement that tracks when you use the item
    "criteria": {
      "requirement": {
        "trigger": "consume_item",
        "conditions": {
          "item": {
            "components": {
                "item_name": "[\"a\"]"
            }
          }
        }
      }
    },
    "rewards": {
      "function": "sandwitches:staffs/forest"
    }
  }```
#
  1. in the function make it so that you get that same item but with one difference (or you will get visual bugs), depending on which one you have in hand.

#checks if its in mainhand or offhand and if its the first version or the second one

execute if items entity @s weapon.mainhand *[item_name="[\"a\"]",use_cooldown={seconds:0.8,cooldown_group:"foresta"}] run item replace entity @s weapon.mainhand with stick[minecraft:item_name="[\"a\"]",minecraft:consumable={consume_seconds:1,animation:none,has_consume_particles:false,sound:"block.amethyst_block.resonate"},use_cooldown={seconds:0.8,cooldown_group:"forestb"},max_stack_size=1]
execute if items entity @s weapon.offhand *[item_name="[\"a\"]",use_cooldown={seconds:0.8,cooldown_group:"forestb"}] unless items entity @s weapon.mainhand *[item_name="[\"a\"]"] run item replace entity @s weapon.offhand with stick[minecraft:item_name="[\"a\"]",minecraft:consumable={consume_seconds:1,animation:none,has_consume_particles:false,sound:"block.amethyst_block.resonate"},use_cooldown={seconds:0.8,cooldown_group:"foresta"},max_stack_size=1]
execute if items entity @s weapon.mainhand *[item_name="[\"a\"]",use_cooldown={seconds:0.8,cooldown_group:"forestb"}] run item replace entity @s weapon.mainhand with stick[minecraft:item_name="[\"a\"]",minecraft:consumable={consume_seconds:1,animation:none,has_consume_particles:false,sound:"block.amethyst_block.resonate"},use_cooldown={seconds:0.8,cooldown_group:"foresta"},max_stack_size=1]
advancement revoke @s only sandwitches:staff_of_the_forest```
#

idk if maybe discord made some of this not work because of "*" and other things

#

in "if items entity @s" after "weapon.mainhand" and "weapon.offhand" there is a space and a "*" before the components

#

It won't work if you put "consume_seconds" as 0

lilac flicker
lilac flicker
balmy basin
#

AWESOMEEEEE

#

I'm in the middle of something but I'll def check this out! :3

#

Ty!! ^^

lilac flicker
#

🫡

balmy basin
#

yyippeee

lilac flicker
#

I'm currently using this to create a wand for my data pack

balmy basin
#

OOOOOOOOOOO

#

:DDDDD

balmy basin
#

wait so.... how does it work exactly? Like what are the steps? ^^

lilac flicker
#

the advancement and function?

balmy basin
#

It's okii I'll study a lil later ^^

wild turret
lilac flicker
#

oh ok I didn't know that thanks

balmy basin
lilac flicker
#

I'm going to upload a new update in a few minutes I think

balmy basin
#

YAYYYY!!!

brave kestrel
#

@balmy basin I might be able to help you out. I've got a similar system (I think for the staffs)

wild turret
#

how's it going crews

balmy basin
#

Pretty good! I may close this thread because I have other things to ask, but ya

balmy basin
#

Hey, isn't there a component called use_cooldown?

silk solstice
#

There is

balmy basin
#

Hmmm

#

Alright, I think I have a good enough idea of what to do

#

Thank you everyone!!