3
Is it possible to play a sound upon picking up an item?
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.
That’s all I really have to say about the issue. Is it possible to execute this task? All feedback is appreciated.
Create an account or sign in to comment.
9
2
Try and specify what device and version you are making it on, because there are different commands for different versions *gave emerald
1
Thanks, and I posted this in the Bedrock category. I’m on Switch.
2
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 0
in 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 multiplayer1
The world I’m working on will be available to online friends very soon. So yes, it will be multiplayer-compatible.
2
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 goldGive
in 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 withgive @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
I’m making this map on my Switch, so I can’t mod anything.
1
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 grabbed
and then add execute @e[tag=grabbed] ~~~
to the front of each of the other commands & put them in chain blocks connected to the repeating one1
What other commands? Are you referring to the ones you mentioned in the first comment?
view more replies ( 1 )