Minecraft Wiki
m (Bot: Fix links to some Java Edition versions)
No edit summary
(29 intermediate revisions by 21 users not shown)
Line 1: Line 1:
This tutorial will help you locate the '''sound directory''', where the [[sound]]s for [[Java Edition]] are stored.
+
This tutorial will help you locate the '''sound directory''', where the [[sound]]s for {{el|je}} are stored.
   
 
== Sound directory (after 1.7.2) ==
 
== Sound directory (after 1.7.2) ==
Line 5: Line 5:
 
The sound file for versions after 1.7.2 is located in the indexes directory:
 
The sound file for versions after 1.7.2 is located in the indexes directory:
   
1.8 Mac OS X: <code>~/Library/Application Support/minecraft/assets/indexes/1.8.json</code>
+
1.8 macOS: <code>~/Library/Application Support/minecraft/assets/indexes/1.8.json</code>
   
1.11 Mac OS X: <code>~/Library/Application Support/minecraft/assets/indexes/1.11.json</code>
+
1.11 macOS: <code>~/Library/Application Support/minecraft/assets/indexes/1.11.json</code>
   
 
The sound files in version [[Java Edition 1.7.2|1.7.2]] (specifically [[13w42a]]) and above are scattered and hashed into different folders, which are located in:
 
The sound files in version [[Java Edition 1.7.2|1.7.2]] (specifically [[13w42a]]) and above are scattered and hashed into different folders, which are located in:
   
 
* Windows: <code>%AppData%\.minecraft\assets\objects</code>
 
* Windows: <code>%AppData%\.minecraft\assets\objects</code>
* Mac OS X: <code>~/Library/Application Support/minecraft/assets/objects</code>
+
* macOS: <code>~/Library/Application Support/minecraft/assets/objects</code>
 
* Linux: <code>~/.minecraft/assets/objects</code>
 
* Linux: <code>~/.minecraft/assets/objects</code>
   
 
=== Locating specific sound files ===
 
=== Locating specific sound files ===
   
Find the folder ''indexes'', which is found under the same ''assets'' folder as ''objects'', where the sound files are indexed and logged in the [[Sounds.json|sounds.json]] file. Select the version you want and open the sounds.json file with a program that supports it, such as Notepad. Programs such as Notepad++ are recommended to help make the file more readable. Once opened, you may find something that looks like this:
+
Find the folder ''indexes'', which is found under the same ''assets'' folder as ''objects'', where the sound files are indexed and logged in the [[sounds.json]] file. Select the version you want and open the sounds.json file with a program that supports it, such as Notepad. Programs such as Notepad++ are recommended to help make the file more readable. Once opened, you may find something that looks like this:
   
 
<pre>
 
<pre>
"sounds/music/menu/menu1.ogg": {
+
"sounds/music/menu/menu1.ogg": {
"hash": "c157c56846f0e50620f808fecd9d069423dd6c41",
+
"hash": "c157c56846f0e50620f808fecd9d069423dd6c41",
"size": 1744657
+
"size": 1744657
},</pre>
+
},</pre>
   
 
From this, we can determine that <code>menu1.ogg</code> is hashed (or labeled) as <code>c157c56846f0e50620f808fecd9d069423dd6c41</code>. Perform a search in the directory ''objects'' under ''assets'' and you should find a file with the same exact string; this is the file "menu1.ogg", one of the pieces of music that plays on the menu screen. The first two letters of the file name ("c1") will match the folder that the file is in as well; knowing this can help locate specific files faster.
 
From this, we can determine that <code>menu1.ogg</code> is hashed (or labeled) as <code>c157c56846f0e50620f808fecd9d069423dd6c41</code>. Perform a search in the directory ''objects'' under ''assets'' and you should find a file with the same exact string; this is the file "menu1.ogg", one of the pieces of music that plays on the menu screen. The first two letters of the file name ("c1") will match the folder that the file is in as well; knowing this can help locate specific files faster.
   
After locating the file, you can test it to make sure it is the right one by playing it with a media player that is able to play .ogg sound files. If the media player you have cannot play the file, try renaming it with ".ogg" at the end. If this fails too, then it either means the media player you use does not have proper .ogg extension to play the sound, or the file you found is not a sound file.
+
After locating the file, you can test it to make sure it is the right one by playing it with a media player that is able to play .ogg sound files. If the media player you have cannot play the file, try renaming it with ".ogg" at the end. If this fails too, then it either means the media player you use does not have a proper .ogg extension to play the sound, or the file you found is not a sound file.
   
 
''Note:'' If you accidentally edit or remove the file from the original directory, the launcher will automatically re-download it again the next time you launch the game. (You must be connected to the Internet when you launch the game. If not, then the sound directory will not be reset and could potentially lead to errors.)
 
''Note:'' If you accidentally edit or remove the file from the original directory, the launcher will automatically re-download it again the next time you launch the game. (You must be connected to the Internet when you launch the game. If not, then the sound directory will not be reset and could potentially lead to errors.)
  +
  +
== Extracting Minecraft Sounds using Node.js ==
  +
This is probably the simplest way to extract the sound files with orginal effections.
  +
; Script 1
  +
<syntaxhighlight lang="javascript" line="1">
  +
var fs = require('fs-extra')
  +
  +
var objects = require('./indexes/1.16.json').objects
  +
  +
for (var filePath in objects) {
  +
  +
if (!/\/(?:sounds)\//.test(filePath)) continue
  +
if (!/\/(?:ambient|block|damage|dig|enchant|entity|event|fire|fireworks|item|liquid|minecart|mob|music|note|portal|random|records|step|title|ui)\//.test(filePath)) continue
  +
  +
var copyPath = filePath.replace('minecraft/', './')
  +
var hash = objects[filePath].hash
  +
var objectPath = './objects/' + hash.substring(0, 2) + '/' + hash
  +
console.log(objectPath, '->', copyPath)
  +
fs.copySync(objectPath, copyPath)
  +
}
  +
</syntaxhighlight>
  +
; Script 2 to run Script 1:
  +
<syntaxhighlight lang="batch" line="1">
  +
@echo off
  +
npm install fs-extra -y
  +
node extract-music.js
  +
pause
  +
</syntaxhighlight>
  +
  +
# First of all, install [https://nodejs.org/en/ Node.js] onto your computer.
  +
# Create a new file inside {{cd|[[.minecraft]]/assets}} called {{cd|extract-music.js}} and paste the first script into it.
  +
# Create a new file inside {{cd|.minecraft/assets}} called {{cd|Extract.bat}} and paste the second script into it.
  +
# Now you can run it by double clicking the {{cd|Extract.bat}} file. It will create a new {{cd|sounds}} folder with all the sounds in it.
  +
  +
* By default it will extract 1.16 files. To change the version, go into the {{cd|extract-music.js}} file and on the 3rd line, change {{cd|1.16.json}} to any version you want (you need to have actually played the version at least once).
  +
  +
; Note
  +
'''Make sure the file extensions are {{cd|.js}} and {{cd|.bat}} and not {{cd|.txt}} when you rename it!''' In other words, remove your old file extension. You may be warned that changing a file name extension could make the file unusable. However, this actually indicates that you have renamed it correctly. It will work if you keep it .txt as example, but it's probably nicer to have it for what it is for.
  +
  +
If you are using Microsoft Windows and can't see file extensions, for Windows 10, you can turn them on by going to the ''View'' menu of the file explorer and checking the check box for file name extensions. For Windows beneath Windows 10, you can uncheck "hide extensions" in folder settings.
  +
  +
[[File:FileExtensions.png|750px|link=|center]]
  +
  +
== Extracting Minecraft Sounds using Python ==
  +
  +
<syntaxhighlight lang="python3" line="1">
  +
import json, os, platform, shutil, sys
  +
  +
'''
  +
Copies audio files from indescript hashed folders to named sorted folders.
  +
You may need to change output path.
  +
'''
  +
  +
# This section should work on any system as well
  +
print("Your OS is " + platform.system())
  +
if platform.system() == "Windows":
  +
MC_ASSETS = os.path.expandvars(r"%APPDATA%/.minecraft/assets")
  +
else:
  +
MC_ASSETS = os.path.expanduser(r"~/.minecraft/assets")
  +
  +
# Find the latest installed version of minecraft (choose the last element in assets/indexes)
  +
MC_VERSION = os.listdir(MC_ASSETS+"/indexes/")[-1]
  +
print("Your latest installed version of minecraft is " + MC_VERSION[:-5] + "\n")
  +
  +
# Change this if you want to put the sound files somewhere else
  +
OUTPUT_PATH = os.path.normpath(os.path.expandvars(os.path.expanduser(f"~/Desktop/MC_Sounds/")))
  +
  +
# These are unlikely to change
  +
MC_OBJECT_INDEX = f"{MC_ASSETS}/indexes/{MC_VERSION}"
  +
MC_OBJECTS_PATH = f"{MC_ASSETS}/objects"
  +
MC_SOUNDS = r"minecraft/sounds/"
  +
  +
  +
with open(MC_OBJECT_INDEX, "r") as read_file:
  +
# Parse the JSON file into a dictionary
  +
data = json.load(read_file)
  +
  +
# Find each line with MC_SOUNDS prefix, remove the prefix and keep the rest of the path and the hash
  +
sounds = {k[len(MC_SOUNDS):] : v["hash"] for (k, v) in data["objects"].items() if k.startswith(MC_SOUNDS)}
  +
  +
print("File extraction :")
  +
  +
for fpath, fhash in sounds.items():
  +
# Ensure the paths are good to go for Windows with properly escaped backslashes in the string
  +
src_fpath = os.path.normpath(f"{MC_OBJECTS_PATH}/{fhash[:2]}/{fhash}")
  +
dest_fpath = os.path.normpath(f"{OUTPUT_PATH}/sounds/{fpath}")
  +
  +
# Print current extracted file
  +
print(fpath)
  +
  +
# Make any directories needed to put the output file into as Python expects
  +
os.makedirs(os.path.dirname(dest_fpath), exist_ok=True)
  +
  +
# Copy the file
  +
shutil.copyfile(src_fpath, dest_fpath)
  +
</syntaxhighlight>
   
 
== Extracting Minecraft Music On Windows (via Windows Subsystem for Linux) ==
 
== Extracting Minecraft Music On Windows (via Windows Subsystem for Linux) ==
Line 35: Line 131:
 
# Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
 
# Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
 
# Paste the following into the file: (when you run the file, it'll ask you what your Windows username is and Minecraft version, the rest is automatic, and outputs to the desktop)
 
# Paste the following into the file: (when you run the file, it'll ask you what your Windows username is and Minecraft version, the rest is automatic, and outputs to the desktop)
 
# Update the variables (e.g. MINECRAFT_ASSETS_DIR) with your correct directory paths
<pre>#!/bin/bash
 
  +
# If you want all sounds, replace "grep music" with "grep sounds", if you want the records, replace "grep music" with "grep records", these are shown commented out above the line of code.
 
# Run the script from terminal with "bash minecraft-music-extractor.sh".
  +
<syntaxhighlight lang="shell" line="1">
 
#!/bin/bash
 
#
 
#
 
# Description: Minecraft Music Extractor
 
# Description: Minecraft Music Extractor
Line 68: Line 168:
 
fi
 
fi
   
#for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
+
# for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
#cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);'
+
# cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);'
#cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music
+
# cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep sounds
  +
# cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep records
   
for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep sounds | awk -F\' '{print $2 "," $6}'`
+
for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
 
do
 
do
 
echo "Processing $ENTRY..."
 
echo "Processing $ENTRY..."
Line 88: Line 189:
   
 
done
 
done
  +
</syntaxhighlight>
</pre>
 
 
#Update the variables (e.g. MINECRAFT_ASSETS_DIR) with your correct directory paths
 
# If you want all sounds, replace "grep music" with "grep sounds".
 
# Run the script from terminal with "bash minecraft-music-extractor.sh".
 
   
 
== Extracting Minecraft Music On Linux ==
 
== Extracting Minecraft Music On Linux ==
Line 98: Line 195:
 
# Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
 
# Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
 
# Paste the following into the file: (when you run the file, it'll ask you what Minecraft version, the rest is automatic, and outputs to the desktop)
 
# Paste the following into the file: (when you run the file, it'll ask you what Minecraft version, the rest is automatic, and outputs to the desktop)
  +
<syntaxhighlight lang="shell" line="1">
<pre>#!/bin/bash
+
#!/bin/bash
 
#
 
#
 
# Description: Minecraft Music Extractor
 
# Description: Minecraft Music Extractor
Line 114: Line 212:
 
# Version doesn't exist = Can't run
 
# Version doesn't exist = Can't run
 
if [ ! -f $JSON_FILE ]; then
 
if [ ! -f $JSON_FILE ]; then
echo -e "Unable to extract because that version isn't downloaded or doesn't exist."
+
echo -e "Unable to extract because that version isn't downloaded or doesn't exist without orgins."
 
echo -e "Make sure to open the launcher and download the version you need to create a pack for.\n"
 
echo -e "Make sure to open the launcher and download the version you need to create a pack for.\n"
 
read -p "Press [Enter] key to continue..." && exit
 
read -p "Press [Enter] key to continue..." && exit
Line 140: Line 238:
   
 
done
 
done
  +
</syntaxhighlight>
</pre>
 
   
#If you want all sounds, replace "grep music" with "grep sounds".
+
# If you want all sounds, replace "grep music" with "grep sounds".
#You may need to run `chmod u+x minecraft-music-extractor.sh` if the script isn't executing.
+
# You may need to run `chmod u+x minecraft-music-extractor.sh` if the script isn't executing.
 
# Run the script from terminal with "./minecraft-music-extractor.sh".
 
# Run the script from terminal with "./minecraft-music-extractor.sh".
   
Line 150: Line 248:
 
# Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
 
# Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
 
# Paste the following into the file:
 
# Paste the following into the file:
  +
<syntaxhighlight lang="shell" line="1">
<pre>#!/bin/sh
+
#!/bin/sh
 
#
 
#
 
# Description: Minecraft Music Extractor
 
# Description: Minecraft Music Extractor
Line 179: Line 278:
   
 
done
 
done
  +
</syntaxhighlight>
</pre>
 
 
# Update the variables (e.g. MINECRAFT_ASSETS_DIR) with your correct directory paths
 
# Update the variables (e.g. MINECRAFT_ASSETS_DIR) with your correct directory paths
 
# If you want all sounds, replace "grep music" with "grep sounds".
 
# If you want all sounds, replace "grep music" with "grep sounds".
Line 189: Line 288:
   
 
* Windows: <code>%AppData%\.minecraft\assets</code> or <code>%AppData%\.minecraft\assets\virtual\legacy</code>
 
* Windows: <code>%AppData%\.minecraft\assets</code> or <code>%AppData%\.minecraft\assets\virtual\legacy</code>
* Mac OS X: <code>~/Library/Application Support/minecraft/assets</code>
+
* macOS: <code>~/Library/Application Support/minecraft/assets</code>
 
* Linux: <code>~/.minecraft/assets</code>
 
* Linux: <code>~/.minecraft/assets</code>
   
Line 214: Line 313:
 
== Warning ==
 
== Warning ==
   
If you edit, add, or remove sounds directly in the sound directory, executing the [[launcher]] and then launching ''Minecraft'' while connected to the Internet will automatically ''re-download and revert any changes'' you've made to the sound directory, deleting your work. This applies for both the new and old sound directories. Disconnecting from the Internet before launching the game will not revert the files, but this is not recommended. The best method to safely store custom sounds is to [[Tutorials/Creating_a_resource_pack|create your own resource pack]].
+
If you edit, add, or remove sounds directly in the sound directory, executing the [[launcher]] and then launching ''Minecraft'' while connected to the Internet will automatically ''re-download and revert any changes'' you've made to the sound directory, deleting your work. This applies for both the new and old sound directories. Disconnecting from the Internet before launching the game will not revert the files, but this is not recommended. The best method to safely store custom sounds is to [[Tutorials/Creating a resource pack|create your own resource pack]].
   
 
== Video tutorials ==
 
== Video tutorials ==
Line 232: Line 331:
 
[[de:Standard-Ressourcen]]
 
[[de:Standard-Ressourcen]]
 
[[fr:Tutoriels/Répertoire des sons de Minecraft]]
 
[[fr:Tutoriels/Répertoire des sons de Minecraft]]
  +
[[ko:튜토리얼/마인크래프트 사운드 디렉토리]]
 
[[zh:教程/声音目录]]
 
[[zh:教程/声音目录]]

Revision as of 05:53, 24 July 2021

This tutorial will help you locate the sound directory, where the sounds for Java Edition are stored.

Sound directory (after 1.7.2)

The sound file for versions after 1.7.2 is located in the indexes directory:

1.8 macOS: ~/Library/Application Support/minecraft/assets/indexes/1.8.json

1.11 macOS: ~/Library/Application Support/minecraft/assets/indexes/1.11.json

The sound files in version 1.7.2 (specifically 13w42a) and above are scattered and hashed into different folders, which are located in:

  • Windows: %AppData%\.minecraft\assets\objects
  • macOS: ~/Library/Application Support/minecraft/assets/objects
  • Linux: ~/.minecraft/assets/objects

Locating specific sound files

Find the folder indexes, which is found under the same assets folder as objects, where the sound files are indexed and logged in the sounds.json file. Select the version you want and open the sounds.json file with a program that supports it, such as Notepad. Programs such as Notepad++ are recommended to help make the file more readable. Once opened, you may find something that looks like this:

"sounds/music/menu/menu1.ogg": {
    "hash": "c157c56846f0e50620f808fecd9d069423dd6c41",
    "size": 1744657
},

From this, we can determine that menu1.ogg is hashed (or labeled) as c157c56846f0e50620f808fecd9d069423dd6c41. Perform a search in the directory objects under assets and you should find a file with the same exact string; this is the file "menu1.ogg", one of the pieces of music that plays on the menu screen. The first two letters of the file name ("c1") will match the folder that the file is in as well; knowing this can help locate specific files faster.

After locating the file, you can test it to make sure it is the right one by playing it with a media player that is able to play .ogg sound files. If the media player you have cannot play the file, try renaming it with ".ogg" at the end. If this fails too, then it either means the media player you use does not have a proper .ogg extension to play the sound, or the file you found is not a sound file.

Note: If you accidentally edit or remove the file from the original directory, the launcher will automatically re-download it again the next time you launch the game. (You must be connected to the Internet when you launch the game. If not, then the sound directory will not be reset and could potentially lead to errors.)

Extracting Minecraft Sounds using Node.js

This is probably the simplest way to extract the sound files with orginal effections.

Script 1
var fs = require('fs-extra')

var objects = require('./indexes/1.16.json').objects

for (var filePath in objects) {

	if (!/\/(?:sounds)\//.test(filePath)) continue
	if (!/\/(?:ambient|block|damage|dig|enchant|entity|event|fire|fireworks|item|liquid|minecart|mob|music|note|portal|random|records|step|title|ui)\//.test(filePath)) continue
	  
	var copyPath = filePath.replace('minecraft/', './')
	var hash = objects[filePath].hash
	var objectPath = './objects/' + hash.substring(0, 2) + '/' + hash
	console.log(objectPath, '->', copyPath)
	fs.copySync(objectPath, copyPath)
}
Script 2 to run Script 1
@echo off
npm install fs-extra -y
node extract-music.js
pause
  1. First of all, install Node.js onto your computer.
  2. Create a new file inside .minecraft/assets called extract-music.js and paste the first script into it.
  3. Create a new file inside .minecraft/assets called Extract.bat and paste the second script into it.
  4. Now you can run it by double clicking the Extract.bat file. It will create a new sounds folder with all the sounds in it.
  • By default it will extract 1.16 files. To change the version, go into the extract-music.js file and on the 3rd line, change 1.16.json to any version you want (you need to have actually played the version at least once).
Note

Make sure the file extensions are .js and .bat and not .txt when you rename it! In other words, remove your old file extension. You may be warned that changing a file name extension could make the file unusable. However, this actually indicates that you have renamed it correctly. It will work if you keep it .txt as example, but it's probably nicer to have it for what it is for.

If you are using Microsoft Windows and can't see file extensions, for Windows 10, you can turn them on by going to the View menu of the file explorer and checking the check box for file name extensions. For Windows beneath Windows 10, you can uncheck "hide extensions" in folder settings.

FileExtensions

Extracting Minecraft Sounds using Python

import json, os, platform, shutil, sys

''' 
    Copies audio files from indescript hashed folders to named sorted folders.
    You may need to change output path.
'''

# This section should work on any system as well
print("Your OS is " + platform.system())
if platform.system() == "Windows":
    MC_ASSETS = os.path.expandvars(r"%APPDATA%/.minecraft/assets")
else:
    MC_ASSETS = os.path.expanduser(r"~/.minecraft/assets")

# Find the latest installed version of minecraft (choose the last element in assets/indexes)
MC_VERSION = os.listdir(MC_ASSETS+"/indexes/")[-1]
print("Your latest installed version of minecraft is " + MC_VERSION[:-5] + "\n")

# Change this if you want to put the sound files somewhere else
OUTPUT_PATH = os.path.normpath(os.path.expandvars(os.path.expanduser(f"~/Desktop/MC_Sounds/")))

# These are unlikely to change
MC_OBJECT_INDEX = f"{MC_ASSETS}/indexes/{MC_VERSION}"
MC_OBJECTS_PATH = f"{MC_ASSETS}/objects"
MC_SOUNDS = r"minecraft/sounds/"


with open(MC_OBJECT_INDEX, "r") as read_file:
    # Parse the JSON file into a dictionary
    data = json.load(read_file)

    # Find each line with MC_SOUNDS prefix, remove the prefix and keep the rest of the path and the hash
    sounds = {k[len(MC_SOUNDS):] : v["hash"] for (k, v) in data["objects"].items() if k.startswith(MC_SOUNDS)}

    print("File extraction :")

    for fpath, fhash in sounds.items():
        # Ensure the paths are good to go for Windows with properly escaped backslashes in the string
        src_fpath = os.path.normpath(f"{MC_OBJECTS_PATH}/{fhash[:2]}/{fhash}")
        dest_fpath = os.path.normpath(f"{OUTPUT_PATH}/sounds/{fpath}")

        # Print current extracted file
        print(fpath)

        # Make any directories needed to put the output file into as Python expects
        os.makedirs(os.path.dirname(dest_fpath), exist_ok=True)

        # Copy the file
        shutil.copyfile(src_fpath, dest_fpath)

Extracting Minecraft Music On Windows (via Windows Subsystem for Linux)

  1. Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
  2. Paste the following into the file: (when you run the file, it'll ask you what your Windows username is and Minecraft version, the rest is automatic, and outputs to the desktop)
  3. Update the variables (e.g. MINECRAFT_ASSETS_DIR) with your correct directory paths
  4. If you want all sounds, replace "grep music" with "grep sounds", if you want the records, replace "grep music" with "grep records", these are shown commented out above the line of code.
  5. Run the script from terminal with "bash minecraft-music-extractor.sh".
#!/bin/bash
#
# Description: Minecraft Music Extractor

echo -e "Enter your Windows username:"
read winusername
echo

USER_DIR="/mnt/c/Users/$winusername"

# Windows Profile doesn't exist = Can't run
if [ ! $(ls /mnt/c/Users/ | grep $winusername) ]; then
	echo -e "Unable to run, you entered an invalid user."
	echo -e "Make sure you entered everything correctly, spelled right with caps and lower case.\n"
	read -p "Press [Enter] key to continue..." && exit
fi

MINECRAFT_ASSETS_DIR="$USER_DIR/AppData/Roaming/.minecraft/assets"
OUTPUT_DIR="$USER_DIR/Desktop"

echo -e "Enter the Minecraft version you want to extract from:"
read version
echo

JSON_FILE=$(echo $MINECRAFT_ASSETS_DIR/indexes/$version.json | grep "/")

# Version doesn't exist = Can't run
if [ ! -f $JSON_FILE ]; then
	echo -e "Unable to extract because that version isn't downloaded or doesn't exist."
	echo -e "Make sure to open the launcher and download the version you need to create a pack for.\n"
	read -p "Press [Enter] key to continue..." && exit
fi

# for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
# cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);'
# cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep sounds
# cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep records

for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
do
	echo "Processing $ENTRY..."
	echo $ENTRY | cut -d, -f1
	FILENAME=`echo $ENTRY | cut -d, -f1`
	FILEHASH=`echo $ENTRY | cut -d, -f2`

	#Locate the file in the assets directory structure
	FULLPATH_HASHFILE=`find "$MINECRAFT_ASSETS_DIR" -name $FILEHASH`

	#Copy the file

	mkdir -p  $OUTPUT_DIR/`echo $FILENAME | sed -E 's/\/[a-z0-9_]+\..+//'`
	cp "$FULLPATH_HASHFILE" "$OUTPUT_DIR/$FILENAME"

done

Extracting Minecraft Music On Linux

  1. Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
  2. Paste the following into the file: (when you run the file, it'll ask you what Minecraft version, the rest is automatic, and outputs to the desktop)
#!/bin/bash
#
# Description: Minecraft Music Extractor

USER_DIR=$(echo ~ | grep "/")
MINECRAFT_ASSETS_DIR="$USER_DIR/.minecraft/assets"
OUTPUT_DIR="$USER_DIR/Desktop"

echo -e "Enter the Minecraft version you want to extract from:"
read version
echo

JSON_FILE="$MINECRAFT_ASSETS_DIR/indexes/$version.json"

# Version doesn't exist = Can't run
if [ ! -f $JSON_FILE ]; then
	echo -e "Unable to extract because that version isn't downloaded or doesn't exist without orgins."
	echo -e "Make sure to open the launcher and download the version you need to create a pack for.\n"
	read -p "Press [Enter] key to continue..." && exit
fi

#for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
#cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);'
#cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music


for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep sounds | awk -F\' '{print $2 "," $6}'`
do
	echo "Processing $ENTRY..."
	echo $ENTRY | cut -d, -f1
	FILENAME=`echo $ENTRY | cut -d, -f1`
	FILEHASH=`echo $ENTRY | cut -d, -f2`

	#Locate the file in the assets directory structure
	FULLPATH_HASHFILE=`find "$MINECRAFT_ASSETS_DIR" -name $FILEHASH`

	#Copy the file

	mkdir -p  $OUTPUT_DIR/`echo $FILENAME | sed -E 's/\/[a-z0-9_]+\..+//'`
	cp "$FULLPATH_HASHFILE" "$OUTPUT_DIR/$FILENAME"

done
  1. If you want all sounds, replace "grep music" with "grep sounds".
  2. You may need to run `chmod u+x minecraft-music-extractor.sh` if the script isn't executing.
  3. Run the script from terminal with "./minecraft-music-extractor.sh".

Extracting Minecraft Music On Mac

  1. Create a new file (for example from the terminal): vi minecraft-music-extractor.sh
  2. Paste the following into the file:
#!/bin/sh
#
# Description: Minecraft Music Extractor

MINECRAFT_ASSETS_DIR="/Users/YOURUSERNAMEHERE/Library/Application Support/minecraft/assets"
OUTPUT_DIR="/Users/YOURUSERNAMEHERE/Desktop"
JSON_FILE="/Users/YOURUSERNAMEHERE/Library/Application Support/minecraft/assets/indexes/YOURJSON.json"

#for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music | awk -F\' '{print $2 "," $6}'`
#cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);'
#cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep music


for ENTRY in `cat "$JSON_FILE" | python -c 'import sys,json; from pprint import pprint; data = json.load(sys.stdin); pprint(data);' | grep sounds | awk -F\' '{print $2 "," $6}'`
do
  echo "Processing $ENTRY..."
  echo $ENTRY | cut -d, -f1 
  FILENAME=`echo $ENTRY | cut -d, -f1`
  FILEHASH=`echo $ENTRY | cut -d, -f2`

  #Locate the file in the assets directory structure
  FULLPATH_HASHFILE=`find "$MINECRAFT_ASSETS_DIR" -name $FILEHASH`

  #Copy the file

  mkdir -p  $OUTPUT_DIR/`echo $FILENAME | sed -E 's/\/[a-z0-9_]+\..+//'`
  cp "$FULLPATH_HASHFILE" "$OUTPUT_DIR/$FILENAME"

done
  1. Update the variables (e.g. MINECRAFT_ASSETS_DIR) with your correct directory paths
  2. If you want all sounds, replace "grep music" with "grep sounds".
  3. Run the script from terminal with "bash minecraft-music-extractor.sh".

Old sound directory (pre-1.7)

If you play the game before 1.7.2, the sound directory is located as follows:

  • Windows: %AppData%\.minecraft\assets or %AppData%\.minecraft\assets\virtual\legacy
  • macOS: ~/Library/Application Support/minecraft/assets
  • Linux: ~/.minecraft/assets

If you have played both the old and new versions, then both the old and new directories will exist in the game files. The old directory is only used for pre-1.7 versions.

Legacy sub-folders

In .minecraft\assets\virtual\legacy\sounds, there are 13 sub folders:

  • ambient: Ambiance and rain/thunder
  • damage: Sounds of the player taking damage
  • dig: Breaking blocks
  • fire: Fire sounds
  • firework: Fireworks sound effects
  • liquids: Sounds made by liquids such as water and lava
  • minecart: Sounds created by moving minecarts
  • mob: Mob sounds
  • music: Background music by C418
  • random: Various sound effects from eating to explosions
  • records: Music on the record discs found
  • step: Footsteps
  • tile: Pistons

Warning

If you edit, add, or remove sounds directly in the sound directory, executing the launcher and then launching Minecraft while connected to the Internet will automatically re-download and revert any changes you've made to the sound directory, deleting your work. This applies for both the new and old sound directories. Disconnecting from the Internet before launching the game will not revert the files, but this is not recommended. The best method to safely store custom sounds is to create your own resource pack.

Video tutorials

Minecraft Tutorial: Locate the Minecraft Sound Directory and Convert Audio Files (Old sound directory only)

See also