3

Is it possible to play a sound upon picking up an item?

Bentendo's Avatar Bentendo5/25/20 1:33 pm
3 emeralds 248 9
5/27/2020 11:22 am
BlazeDrake's Avatar BlazeDrake
So, I’ve been making a map, and I happened to stumble upon a blockade. What I’m trying to do is automatically play a sound upon touching a gold nugget with command blocks. I was able to specify the particular item by using the name variable and get the value for the sound, but that’s as far as I got.



That’s all I really have to say about the issue. Is it possible to execute this task? All feedback is appreciated.
Posted by Bentendo's Avatar
Bentendo
Level 12 : Journeyman Mage
5

Create an account or sign in to comment.

9

2
05/26/2020 7:57 pm
Level 1 : New Miner
KoalaNZ
KoalaNZ's Avatar
Try and specify what device and version you are making it on, because there are different commands for different versions *gave emerald
1
05/26/2020 8:34 pmhistory
Level 12 : Journeyman Mage
Bentendo
Bentendo's Avatar
Thanks, and I posted this in the Bedrock category. I’m on Switch.
2
05/25/2020 4:22 pm
Level 12 : Journeyman Button Pusher
BlazeDrake
BlazeDrake's Avatar
Does it need to work with multiplayer? If it's a singleplayer world, you can put/execute @p ~~~ testfor @e[type=item,name="gold nugget"]in a repeating command block. Then, put
/clear @p ~~~ gold_nugget 0 0in a conditional chain command block with a slight delay(1 should do, make sure to also delay the repeat). Finally, in another conditional chain(with no delay), put/execute @p ~~~ playsound <soundname> @s ~~~ [volume: float] [pitch: float] [minimumVolume: float] It's more complex if it needs to be done in multiplayer
1
05/25/2020 5:13 pm
Level 12 : Journeyman Mage
Bentendo
Bentendo's Avatar
The world I’m working on will be available to online friends very soon. So yes, it will be multiplayer-compatible.
2
05/26/2020 10:07 am
Level 12 : Journeyman Button Pusher
BlazeDrake
BlazeDrake's Avatar
Ok. If you need it to be multiplayer compatible, you'd need to put
/execute @a ~~~ execute @e[type=item,r=1,name="gold nugget"] ~~~ function goldGivein the repeating, and not use the chain command blocks. You'd also have to make a behavior pack, with a folder called functions(you'd also need a manifest & pack icon, but that's it). In that folder, you'd have to make an mcfunction file called goldGive with
give @p gold_nugget 1
playsound <soundname> @p ~~~ [volume: float] [pitch: float] [minimumVolume: float]
kill @s
in it. Then, you'd need to send the behavior pack folder to a zip, change the file extension to .mcpack from .zip, and open it up. This will import the pack, and you can then choose to add it from your world. You'd need win10 for this.
1
05/26/2020 4:11 pm
Level 12 : Journeyman Mage
Bentendo
Bentendo's Avatar
I’m making this map on my Switch, so I can’t mod anything.
1
05/26/2020 4:38 pm
Level 12 : Journeyman Button Pusher
BlazeDrake
BlazeDrake's Avatar
That would be harder. maybe replace the command in the repeating block with

/execute @a ~~~ tag @e[type=item,r=1,name="gold nugget"] add grabbedand then add
execute @e[tag=grabbed] ~~~to the front of each of the other commands & put them in chain blocks connected to the repeating one
1
05/26/2020 7:40 pm
Level 12 : Journeyman Mage
Bentendo
Bentendo's Avatar
What other commands? Are you referring to the ones you mentioned in the first comment?
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome