Palettes can set a blocks color into a specific color, So if you set your brush to use that block, then the color that it comes with in palette.yml will also be defined, For example:
if you set the color to be this in the palette:
and you do /eb set brush block STONE Then the brush will automatically make the brushs color to #808080
Want to generate a palette for EVERY block from a texture pack?
1
Folder Structure
Create a folder, and add a folder called "Blocks" that contains every block texture (either yours or from a texturepack)
2
Adding the code
In the root folder, create a Python script file and add this code:
Make sure you have the Pillow and NumPy libraries installed (you can install them via pip install Pillow numpy).
import os
from PIL import Image
import numpy as np
def compute_average_color(image_path):
"""Compute the average color of an image."""
with Image.open(image_path) as img:
# Ensure the image is in RGB mode.
img = img.convert('RGB')
# Convert the image to a NumPy array.
np_img = np.array(img)
# Calculate the mean of each color channel.
avg = np.mean(np_img.reshape(-1, 3), axis=0)
return tuple(avg.astype(int))
def rgb_to_hex(rgb):
"""Convert an (R, G, B) tuple to a hex string."""
return '#{:02X}{:02X}{:02X}'.format(*rgb)
def main():
# Set the directory containing the block texture images to "blocks".
input_dir = "blocks" # Images should be placed in this folder.
output_file = "blocks_colors.txt"
blocks = {}
# Iterate over all image files in the input directory.
for filename in os.listdir(input_dir):
if filename.lower().endswith(('.png', '.jpg', '.jpeg')):
# Use the filename (without extension) as the block name, in uppercase.
block_name = os.path.splitext(filename)[0].upper()
image_path = os.path.join(input_dir, filename)
# Compute the average color.
avg_color = compute_average_color(image_path)
# Convert the average color to a hex string.
hex_color = rgb_to_hex(avg_color)
blocks[block_name] = hex_color
# Write the results in the desired YAML-like format.
with open(output_file, "w") as file:
file.write("blocks:\n")
for block, color in blocks.items():
file.write(f" {block}: \"{color}\"\n")
print(f"Block colors written to {output_file}")
if __name__ == "__main__":
main()
3
Final Steps
Run the Python Script and boom! You're done! Copy the text inside the newly created file and add it to Palette.yml
The python script also adds the TOP, SIDE, and other textures to the file so you may need to manually change these.