Saturday, January 4, 2014

Hiding the Minecraft Dock icons in OS X

When you launch Minecraft, you get two icons in your Dock. One icon comes from the preloader/launcher, and it is tied to the /Applications/Minecraft.app application that you double-click to play the game. The second icon is embedded within the internals of Minecraft itself, found within your ~/Library/Application Support/minecraft folder.

Changing the former icon is relatively straightforward.

  1. Find any application whose icon you wish to borrow
  2. Right-click the file and select "Show Package Contents"
  3. Navigate to Contents/Resources/favicon.icns
  4. View the file's info (either right-click and choose "Get Info" or hit Command-I on the keyboard)
  5. Select the icon at the very top-left corner of the Info window, and it highlights slightly.
  6. Copy it with Command-C or Edit->Copy. This copies the icon's picture, not the file itself.
  7. Now, navigate to /Applications/Minecraft.app and repeat steps 2-5. You should have the Minecraft icon highlighted.
  8. Paste with Command-V (or Edit->Paste)
This changes the preloader/launcher icon so any time you open it, a different icon than the standard Minecraft icon is shown.

As an aside, you could also hide this Dock icon entirely when it is running. To do this, locate the Info.plist file at:

  /Applications/Minecraft.app/Contents/Info.plist

Add this line somewhere about halfway down:

   <key>LSUIElement</key><string>1</string>

This hides the Dock icon when the application is running.


The second Minecraft icon is embedded within your personal ~/Library folder. The file on my system is located at:

  ~/Library/Application Support/minecraft/assets/objects/99/991b421dfd401f115241601b2b373140a8d78572

This 991b421...572 file has no extension and appears to have a nondescript icon when viewed in Finder. However, if you select the file in Finder and hit Space to show a larger preview, it expands to show a picture of the Minecraft icon.

This file is actually named according to its SHA1 digest: Its file size is exactly 114,786 bytes, and it is in the '/objects/99/' directory because the first two digits of its name start with '99'. (Knowing all this is important for the next steps.)

This 991b..8572 number is referenced within a JSON file located in:

   ~/Library/Application Support/minecraft/assets/indexes/

At the time of this writing, 1.7.4 is out, so the file is called

   ~/Library/Application Support/minecraft/assets/indexes/1.7.4.json

A few entries down, you will see the lines:


    "icons/minecraft.icns": {
      "hash": "991b421dfd401f115241601b2b373140a8d78572",
      "size": 114786
    },


The hash, as well as the file size, match that file exactly.

To replace this icon with another of your choosing, find an application's icon file (use the same steps 1-4 above). Once you locate the .icns file, you need to get its SHA1 digest (I use 'sha1deep' from the MacPorts package 'md5deep', but you can use anything that produces it). You will also want to note its exact file size, in bytes, to replace the information above.

I used the icon from Google Chrome, located at

  /Applications/Google Chrome.app/Contents/Resources/app.icns

which has a digest of

  dcba7f4d611c5b0ea02ef583284ed211f6b5c757

and a filesize of 159,992 bytes. I copied Google Chrome's app.icns file into:


   ~/Library/Application Support/minecraft/assets/objects/dc/dcba7f4d611c5b0ea02ef583284ed211f6b5c757


Notice that the path is '/objects/dc/' instead of '/objects/99/' to match the first 2 characters of the filename.

In the 1.7.4.json file, I replaced the entry above with:


    "icons/minecraft.icns": {
      "hash": "dcba7f4d611c5b0ea02ef583284ed211f6b5c757",
      "size": 159992
    }

I need to point out that the next time you run Minecraft, this JSON file will get overwritten. You will need to change the file permissions to read-only so Minecraft is not able to revert your changes back to the original 991...572 filename.

To make this file read-only, I opened Terminal (/Applications/Utilities/Terminal.app), navigated to the 

   ~/Library/Application Support/minecraft/assets/indexes/

path, and used this command:

   chmod 444 1.7.4.json

This removes the ability for Minecraft to update this file (it'll probably come back to bite me after the 1.7.5 and later revisions, but it works for now), and points the second, harder-to-modify Minecraft icon to the new icon (Google Chrome) instead.


Whew!

That was longer than I anticipated, but I hope it was written simply enough that anyone can understand it. Feel free to leave questions and comments.

10 comments:

  1. I need help! The icon is a java icon only! Is it because i copied my icon wrong? I copied it directly into the folder db...
    Any help would be appreciated. Thanks!

    ReplyDelete
    Replies
    1. 1. What version of Minecraft? 2. Which icon shows as 'java': the launcher icon (the former icon) or the game icon (the latter icon)? I've been able to edit the game icon on 1.7.10 without a problem. Note that in the '1.7.10.json' file, there are _two_ entries with the original hash: "icons/minecraft.icns" and "minecraft/icons/minecraft.icns". You need only modify the "icons/minecraft.icns" one in order to change the app icon.

      Delete
  2. The version of Minecraft is 1.7.4, and the java icon appears in the latter game icon itself. I think it may be wrong with the copying proccess, because the file size changes. How do I get the .icns to work?

    ReplyDelete
    Replies
    1. What is the SHA1 hash of the replacement icon? For sha1deep, the '-z' option will give both the hash and the filesize of whatever replacement .icns file you wish to use. You need to copy that .icns file (into the Minecraft '/objects/[xx]/yyyyyyyy' folder, where [xx] are the first two letters of that hash, and the 'yyyyyyyy' is the actual hash without any kind of extension.

      You need to then replace the entry in the 1.7.4.json file, and after you have, you need to make that file READ-ONLY (per instructions above).

      Delete
  3. I don't know what the sha1deep thing is, but i use mac and opened terminal, inputing {openssl sha1 /Users/admin/Library/Application Support/minecraft/app.icns} because i moved the icon into minecraft's folder. The hash was db4f6bce84e4fdc3c8a7556a4c26ef2ba353de64, and i copied the icon into the minecraft object's {/db} folder. I checked file size, though it had changed, and inputed new file size and hash into the 1.7.4.json. I also made it read only.
    Was it a copying issue?

    ReplyDelete
    Replies
    1. 1. Did you copy the new icon into ~/Library/Application Support/minecraft/assets/objects/db/ and give it the name db4f6bce84e4fdc3c8a7556a4c26ef2ba353de64? In other words, the original filename might have been MyApplication.icns, and its NEW name will need to be db4f6bce84e4fdc3c8a7556a4c26ef2ba353de64 (with no extension).

      2. After the new file has been placed in that directory, did you modify the 1.7.4.json file and replace the line

      "icons/minecraft.icns": {
      "hash": "991b421dfd401f115241601b2b373140a8d78572",
      "size": 114786
      },

      with

      "icons/minecraft.icns": {
      "hash": "db4f6bce84e4fdc3c8a7556a4c26ef2ba353de64",
      "size": 0000 <--- You need to get that icon's filesize and put it here!
      },

      ?

      3. Did you make the 1.7.4.json read-only so the Minecraft package downloader cannot overwrite it with a version that it grabbed off the internet (and undo all of your above changes)?

      Delete
  4. Yes, I did all of that, and yet no improvement. Does it help that I'm using the apple's mail icon? (I'm trying to do some incognito moderating during work...)
    Thanks for your help.

    ReplyDelete