Skip to content

Instantly share code, notes, and snippets.

@towerofnix
Last active July 9, 2021 19:52
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save towerofnix/02b2361c38581c1edc29dec0394b2ae8 to your computer and use it in GitHub Desktop.
Save towerofnix/02b2361c38581c1edc29dec0394b2ae8 to your computer and use it in GitHub Desktop.
Downloads a default Minecraft resource pack (1.12 april fools by default)

Minecraft Asset Downloader

Download Minecraft assets and store them as a resource pack for personal usage.

Are you a regular somewhat techno clever citizen of the internet?

After the code below (which you definitely don't need to read yourself), I've written a guide on how to use this, plus some troubleshooting tips!

Are you a smarty pants?

If you are super duper TECHNO CLEVER, you can probably get by with just the script below.

// Stick this file in .minecraft/assets.
// Run `npm install ncp mkdirp`.
// You'll want to be using a relatively recenversion of Node -- 8.0.0 or later.
// Run `node dl.js`.
// (this code is public domain lol)
// Obviously change this line if you want to download a different pack:
const sourceFile = require('./indexes/1.12-af.json')
// Okay actual code here ----------------------------------------------------------
const util = require('util')
const mkdirp = util.promisify(require('mkdirp'))
const ncp = util.promisify(require('ncp'))
const path = require('path')
async function main(objects) {
const entries = Object.entries(objects)
entries.sort((a, b) => {
const af = a[0], bf = b[0]
return af < bf ? -1 : af === bf ? 0 : +1
})
const totalSize = Object.values(objects).reduce((a, o) => a + o.size, 0)
let curSize = 0
for (const [ file, { hash, size } ] of entries) {
console.log(`[${curSize} / ${totalSize} = ${Math.floor(curSize / totalSize * 100)}%] ${file} <- ${hash} (${size})`)
const trueFile = 'pack/assets/' + file
await mkdirp(path.dirname(trueFile))
const objFile = 'objects/' + hash.slice(0, 2) + '/' + hash
await ncp(objFile, trueFile)
curSize += size
}
console.log(`[${curSize} / ${totalSize} = 100%] Done`)
}
main(sourceFile.objects).catch(err => console.error(err))

Minecraft Asset Downloader

Download Minecraft assets and store them as a resource pack for personal usage.

Legality Disclaimer

Mojang's EULA/Terms and Conditions forbid you from uploading Minecraft assets to the internet. This means you CANNOT upload or share resource packs generated with this script. Please don't try to blame me if you get in trouble for uploading assets that are organized by this script -- it's your fault, and your fault alone.

That said, personally using this to make yourself a resource pack for later access - or just to poke around the files, if you're curious - is fine! Just don't distribute any of the assets.

Installation/How to Use

So, just so you know, this program really is targeted towards people who at least have some experience with command line interfaces.

This script runs from .minecraft/assets and copies files into the directory .minecraft/assets/pack. Generally, you always want to be cd'd into .minecraft/assets. (Your .minecraft folder is probably in ~/.minecraft, or ~/Library/Application SUpport/minecraft on a Mac. Here's a page explaining how to get to it. That also has some details for Windows machines, which I don't have experience with.)

You will need Node.js to run this script. You can download it from https://nodejs.org. You need a version that's at least 8.0.0; either the "LTS" or "Current" download links will work. (If you already have Node installed, but it isn't at least 8.0.0 (you can check that with node --version), I recommend you use nvm to update to a more recent version.)

You will need to download the script below to .minecraft/assets/dl.js. (Well, you can call the JS file whatever you want, but I'll call it dl.js for convenience.) You can click the "Raw" button next to the code to get an easy-to-download version (or just go here).

Once you have installed Node and downloaded the script, you can just follow these commands to work the script:

$ cd (path to .minecraft)/assets
$ npm install ncp mkdirp
$ node dl.js

Note that you will need to replace (path to .minecraft). If you are running Windows: cd %AppData%\.minecraft\assets. If you are running macOS: cd ~/Library/Application Support/minecraft/assets. If you running Linux: cd ~/.minecraft/assets.

ncp and mkdirp are dependencies for the script. The npm command will probably give you warnings about package.json being missing; those are just messages that you don't need to worry about.

node dl.js runs the script (of course).

The resulting folder, .minecraft/assets/pack, will not be a valid resource pack folder. It will very nearly be one, but you have to move pack.mcmeta from .minecraft/assets/pack/assets to .minecraft/assets/pack.

After you've done that, you can move pack into your resourcepacks folder, and it should show up in Minecraft's Resource Pack screen! It should appear under the name "pack", since that's the name of the folder. If you want to change that to something more useful, like 2018 April Fools, you can rename the folder.

Grabbing assets other versions of Minecraft

This program is designed to grab the 1.12 April Fools assets, but you can use other versions of Minecraft by changing just a single line of code - in particular, this one:

// Obviously change this line if you want to download a different pack:
const { objects } = require('./indexes/1.12-af.json')

You can change 1.12-af to the name of any other file in the .minecraft/assets/indexes folder, and the script should still work (but I make no guarantees). You do need to run that version of Minecraft first, or else the assets won't be downloaded and the program won't be able to copy them.

Troubleshooting

My console is telling me that it doesn't know of a directory called "(path to .minecraft)/assets". It looks like you forgot to replace that line -- go back to that section and read the text below:

Note that you will need to replace (path to .minecraft). If you are running Windows: cd %AppData%\.minecraft\assets. If you are running macOS: cd ~/Library/Application Support/minecraft/assets. If you running Linux: cd ~/.minecraft/assets.

There is no assets directory in my .minecraft. Perhaps you aren't in the right .minecraft folder? You might accidentally have gone to a profile folder instead (that is, the "Game Directory" option in the profile editor). Profile folders don't contain the assets folder. Here's the Gamepedia page on .minecraft - it will probably help you find the directory we're looking for.

I can't find my resource packs folder. In the Minecraft game itself, open the Resource Pack selector (from the options screen), then click on the "Open Resource Packs Folder" button. That will probably open .minecraft/resourcepacks. (If you're using launcher profiles with different game directories, it might open a different folder instead - the resourcepacks folder of your game directory - but I imagine that if you're using launcher profiles, you already know that!)

Minecraft doesn't recognize the resource pack at all. Make sure that pack.mcmeta is in the "pack" folder, not the "pack/assets" folder. For some reason, Minecraft's asset index file thinks that pack.mcmeta goes into the assets folder, but it doesn't. You'll need to move pack.mcmeta directly into "pack".

I'm getting a "Cannot find module" error. Did you correctly install the modules mentioned earlier? You need to install ncp and mkdirp, and you need to install them from the same folder that dl.js is in (so make sure you're cd'd there).

I'm getting a "TypeError: util.promisify is not a function" error. You probably aren't running a recent version of Node. You can check what version you're using with node --version; the version needs to be 8.0.0 or higher. I recommend you use nvm to manage and update Node.

I'm getting an error related to a copy failing. This program copies files that have already been downloaded. You'll need to run whatever version of Minecraft you're downloading assets from before running this script, or else it won't work.

I have some other issue. Please send me a message with details (such as a screenshot of the error message) on reddit (to /u/towerofnix), Twitter (@towerofnix), or Mastodon (@florrie@cybre.space). I don't get notifications when you comment on this Gist, so it's best you contact me at one of those places instead.

@towerofnix
Copy link
Author

I don't get notifications for anything you post down here!

If you're having an issue, please message me through Reddit, Twitter, or Mastodon. (My handles are in the readme above.) That way I can actually get back to you!

@RichVerySoong
Copy link

If your on mac, typing in ~/Library/Application Support/minecraft/assets does not work! Make sure you include quotes around the space: ~/Library/Application" "Support/minecraft/assets
Important!!!

@haze
Copy link

haze commented Apr 2, 2018

@RichVerySoong
just escape the space with a \.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment