Skip to content

Generate Color Lists

Roan-V edited this page May 3, 2023 · 6 revisions

Generate a list of colors for pl3xmap

Add colors for newly added blocks

Pl3xmap contains a list of all the blocks in-game and their corresponding colors, it uses this color list to render the map.
This list is fully configurable in the advanced.yml file, except a few special hardcoded cases.

This color list is derived from the actual game textures, which is why they look so good!
Every entry on the list is the average color of that corresponding block texture.

This color list will need an update when Mojang adds new blocks to the game, or if you want to add colors for custom blocks.
This wiki page will outline how to generate these lists.

Why?

Mojang has a build in map in game, why does pl3xmap need it’s own colors?
Frankly, the build in colors are just bad ^_^

There is total of 64 colors they can use, which makes it pretty hard to show the subtler differences between blocks.
In some cases the colors are completely wrong too, mycelium is pink for example!

Generate a color list

The list can be generated automatically with a script, some manual tweaking might be required to match up texture filenames with in game block IDs.

To generate new textures start with grabbing the texture files for the blocks that you want to add to the list.

For a vanilla game they are .png files and they can be found inside the jar for your specific game version

  • Locate the jar for your game version, you can find it inside the folder for your game client: <clientfolder>\versions\<game_version>\<game_version>.jar
  • Open the contents of that .jar file by using a program like 7zip, and extract the \assets\minecraft\textures\block\ folder.

Now you have the texture files straight from the actual game!


To convert these texture files into hex colors that pl3xmap can use we use program called ImageMagick in combination with a bash script.

ImageMagick is used to convert the texture file into a 1x1 picture, blending and averaging the used colors into one.
ImageMagick is also used to output the color data of this single pixel into text form.

A bash script is used to;

  • Loop over multiple of these texture files
  • Convert them all into a singular color using ImageMagick
  • Collect all the color values
  • Output the values to a text file in the correct syntax for Pl3xmap to use

Here is that script:

for file in *.png
do
  hex=`convert $file -resize 1x1 txt:- | grep -Po "#[[:xdigit:]]{6}"`
  echo "      minecraft:"${file%.*}": '"$hex"'"
done >textures_hex.txt


Prerequisites for using the script:

  • Use a Linux OS or alternatively WSL (unless you convert the bash script to a batch script that windows can understand, in that case, feel free to pr!)
  • Have ImageMagick installed


Running the script

  • Copy the textures that you want to add into a folder, make sure to only grab the textures you want to add onto the existing list
  • Run the script in that same folder and wait for it to finish, color list obtained \o/
  • Go through that list and make sure the blocknames line up with in game block IDs

For example, the script might output a few different lines for one block:

      minecraft:crafting_table_front: '#846C48'
      minecraft:crafting_table_side: '#836841'
      minecraft:crafting_table_top: '#7B4B2B'

In this case you would want to use the _top texture, because Pl3xmap is a top down map.
The block ID for a crafting table is minecraft:crafting_table, so the resulting, correct line will be:

      minecraft:crafting_table: '#7B4B2B'

Finally just simply add the lines you created to the advanced.yml file, your colors will now show up after a new render of the map!