Skip to content

Instantly share code, notes, and snippets.

@gumacahin
Created July 8, 2015 03:27
Show Gist options
  • Save gumacahin/5eae710ac53d2345b322 to your computer and use it in GitHub Desktop.
Save gumacahin/5eae710ac53d2345b322 to your computer and use it in GitHub Desktop.
Minecraft Asset Extraction
#
# This is the ruby script I used the organize the Minecraft assets in a
# human friendly format for my final project in MMS 172
#
require "json"
require "fileutils"
source = "#{Dir.home}/Library/Application Support/minecraft/assets"
destination = File.dirname(__FILE__)
manifest_path = "#{source}/indexes/1.8.json"
manifest = JSON.load(File.read(manifest_path))
manifest["objects"].each do |obj|
dst = File.join(destination, obj[0])
FileUtils.mkdir_p(File.dirname(dst))
src = File.join(source, "objects", obj[1]['hash'][0,2], obj[1]['hash'])
puts "Copying #{dst} from #{src}"
size = File.copy_stream(src, dst)
if (size != obj[1]['size'])
raise "Expected to copy #{obj[1]['size']} bytes. Copied #{size} bytes"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment