This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
reububble's profile picture

Listening To Custom Music In Cc

Started by reububble, 18 August 2013 - 03:55 AM
reububble #1
Posted 18 August 2013 - 05:55 AM
Valid with Minecraft 1.6.1

Recently Minecraft has updated to allow for a new type of command.
This command is

/playsound <sound> <player> [x y z] [volume] [velocity] [minimum volume]

Don't worry about all of the parameters just yet. Let's start at the VERY beginning.
You will want a command block, the id is 137. Use the command /give 'yourname' 137

Now you should have the command block, when you right click on the placed block you are able to enter the desired command.


Let's suppose you want to creep out one of your friends. As all good friends do.
We want to find a good creepy sound to play.

I've got an Idea! Why not use a creeper sound!
Good suggestion, lets go find that file.

Your sounds folder will be in your .minecraft/ directory under /assets/sounds/
From here you can see a folder called random which contains the sound we desire.
Lets use minecraft/assets/sounds/random/fuse which sounds like a creeper nearly exploding!

The <sound> parameter is filled with the file path separating directories with a period "."
Our parameter will be
random.fuse

To target your friend we will use the call of
@p[name=Reububble]
Reububble is the name of your friend! ;)/>

To position the sound we will use the [x y z] coords of
~1 ~0 ~0
This will be 1 x coordinate away from Reububble's position! The ~ signs indicate relative position

We want the [Volume]to be LOUD so we set this value to the highest possible,
2
rather than the lowest value, 0 and not any number in between.

I like a creepy LOW sounding fuse, so we use the lowest pitch, and the slowest [velocity]
0
rather than the higher pitches ranging up to 2 maximum.

I don't mind what the [minimum volume] is, so I'll leave it.

Now we have the command
/playsound random.fuse @p[name=Reububble] ~1 ~0 ~0 2 0

Attach the command block up to a trip-wire or other redstone wires, and let Reububble become freaked out by the invisible creeper!

——————————————
CUSTOM SOUNDS
It is possible, all you need to do is have your sound in .ogg format, which is supported by many audio softwares such as audacity. So you can convert from mp3 using this software.
The tricky part is replacing the sounds which already exist, as this is the only way it can be implemented.
You need to create a resource pack or replace a current resource pack sound folder. The name you use in the replacement should be the same as the name of the sound you are replacing, and remember this means you cannot listen to that sound normally anymore, and whenever the sound would normally be heard, you will hear the new sound instead.
Watch a short youtube video explaining how this is achieved!



Thanks, please send me any questions, comments, concerns, theories, queries, or death threats you may have!

EDIT: this is good code

args = {...}
for i,side in ipairs(rs.getSides()) do
  if peripheral.getType(side) == 'command' then
	man=peripheral.wrap(side)
	break
  end
end
local params = ''
for i=1,#args do
  params = params..' '..args[i]
end
man.setCommand('/playsound'..params)
print('current command is : '..man.getCommand())
man.runCommand()
And those are the 3 functions available, along with the peripheral name. Make sure the command peripheral is enabled in config
LBPHacker #2
Posted 18 August 2013 - 08:00 AM
*sigh* Yeah, okay, playing sound with command blocks, awesome. The only problem is that this is a Vanialla feature, and the Tutorials section of the ComputerCraft forums should contain tutorials about ComputerCraft. I know, you can achieve this using a computer controlling a command block, but the part that involves ComputerCraft is the controlling part (you could make a tutorial about that), not the command part. Nobody is going to make a tutorial about controlling the weather with computer controlled command blocks, because it's just trivial. Feel free to hate me, that's my opinion.
oeed #3
Posted 18 August 2013 - 08:32 AM
This is cool, I wasn't aware of the ability to do this.

If I recall correctly, you can (or could) wrap command blocks. Maybe find out how to do that and mix a bit of ComputerCraft in to the tutorial.
PixelToast #4
Posted 18 August 2013 - 03:11 PM
to use cc with command blocks you have to first, enable it in the config
then wrap the peripheral:

local p=peripheral.wrap("side")
then use setCommand then runCommand

p.setCommand("playsound random.fuse @p[name=Reububble] ~1 ~0 ~0 2 0")
p.runCommand()
reububble #5
Posted 19 August 2013 - 03:51 AM
This is cool, I wasn't aware of the ability to do this.

If I recall correctly, you can (or could) wrap command blocks. Maybe find out how to do that and mix a bit of ComputerCraft in to the tutorial.

Yes I was just thinking that, making an edit now