Arqade Asked by Boooooooooooooooooooooooooooof on November 27, 2020
I want to look into the sound files for MCJE, but I don’t know how to classify and decode them. I just find folders of 00
, 01
, … aa
, fe
, ff
, and inside are files like 000c82756fd54e40cb236199f2b479629d0aca2f
without file name extensions. I don’t want to convert all of them to .mp3
s. How do I decode the files?
Look in the versions folder and find the .jar file for your target version. Rename it to be a .zip file and extract it. Go into it, then into the assets > minecraft folder and you should be able to access all of the sounds and textures with english names.
Answered by Sam Hill on November 27, 2020
I see literally no way of doing this without making use of some sort of program or script. So I wrote one.
%appData%.minecraftassetsindexes
folder that contains all the asset "mappings". For example, here is a snippet from it:{
"objects": {
"minecraft/sounds/ambient/cave/cave1.ogg": {
"hash": "29d4dccf3353334c7aa2a49cb6fed3780a51a1ba",
"size": 33948
}
}
}
This is a small C# console application. It's crude, but it got the job done. If you know a little about coding, you should have no problem creating a new console application using Visual Studio (you can download the Community Edition for free if you don't have it) and throwing this code into it to build/run.
Warning: There is no error checking in this code. It's a quick bodge I conjured up. After this runs, the "Minecraft Sounds" folder may take a while to load, since it will contain near ~1000 .ogg files.
Before executing the script, you'll need to do some setup:
%appData%.minecraftassets
out of the appData location and somewhere else (in the code, it references the files/folders in C:
.Here is the code itself:
using System;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Linq;
namespace Minecraft_Sound_Converter
{
class Program
{
static void Main(string[] args)
{
//you'll need to copy these files to this location (or some other location and then update the variables)
string pathToJsonFile = "C:1.14.json"; this what the latest verison I have on my computer
string pathToObjectsFolder = "C:Objects";
string pathToSoundFileFolder = "C:Minecraft Sounds";
//parse the json file into a JObject
JObject json = JObject.Parse(JsonConvert.DeserializeObject(File.ReadAllText(pathToJsonFile)).ToString());
//for each token in the json, perform the following operation
foreach (JToken token in (JEnumerable<JToken>)json.First.Children().Children<JToken>())
{
//it's a sound file
if (token.Path.Contains(".ogg"))
{
//get the "hash" property's value
string hashVal = token.First()["hash"].ToString();
//get the name of the file (this is a crude way of doing it, but it works)
string soundName = token.Path.Substring(token.Path.LastIndexOf("/"), (token.Path.Length - token.Path.LastIndexOf("/")) - 2).Replace("/", null);
//find the file via its hash value in the Objects folder by searching all the subdirectories in the directory
string fileName = Directory.GetFiles(pathToObjectsFolder, hashVal, SearchOption.AllDirectories).FirstOrDefault();
//Copy the file to the Minecraft Sounds folder. If it already exists in the folder, overwrite it.
File.Copy(fileName, Path.Combine(pathToSoundFileFolder, soundName), true);
Console.WriteLine($"Copied {soundName}");
}
}
Console.WriteLine("Operation compelte. Press any key to exit.");
Console.ReadLine();
}
}
}
The comments in the code should speak for itself, but if you run this script, it essentially does the following:
JObject
.JToken
s in the JEnumerable
object that is created in the foreach
expression.JToken
, check to see if its Path
contains the string ".ogg"
. If it does, then we know it is a sound file.hash
property value. This value is that cryptic file name you alluded to in your question.Path
contains this, but it needs some substring logic to be performed on it and cleaned up to actually get it.hashVal
), search the Objects directory that you copied somewhere and all of its sub-directories using the hashVal
and the search criteria.This code is fairly messy (it was kind of meant to be since I had one thing in mind... speed), and it can certainly be cleaned up a lot. But in my tests, it worked, and it copied over 900 files (roughly 140Mb). Since the variable filename
already has the .ogg
extension on it, when Windows detects this, it realizes the file format is a format the it supports, and thus you should be able to play it back without any issues.
Answered by Timmy Jim on November 27, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP