forum Forumskeyboard_arrow_right Help keyboard_arrow_right sports_esportsBedrock Edition

Create Forum Thread
3

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

3 emeralds9 replies101 views
Bentendo started 05/25/2020 1:33 pm
BlazeDrake replied 05/27/2020 11:22 am
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 avatar
Bentendo
Level 8 : Apprentice Mage
5

comment Login or register to post a reply.

9 replies

2
05/26/2020 7:57 pm
Level 1 : New Miner
KoalaNZ
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 8 : Apprentice Mage
Bentendo
Thanks, and I posted this in the Bedrock category. I’m on Switch.
2
05/25/2020 4:22 pm
Level 13 : Journeyman Button Pusher
BlazeDrake
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 8 : Apprentice Mage
Bentendo
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 13 : Journeyman Button Pusher
BlazeDrake
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 8 : Apprentice Mage
Bentendo
I’m making this map on my Switch, so I can’t mod anything.
1
05/26/2020 4:38 pm
Level 13 : Journeyman Button Pusher
BlazeDrake
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 8 : Apprentice Mage
Bentendo
What other commands? Are you referring to the ones you mentioned in the first comment?
Planet Minecraft Logo

Website

© 2010 - 2020
www.planetminecraft.com

Welcome