diff --git a/tools/assemble-realistic-stone-pack.py b/tools/assemble-realistic-stone-pack.py
new file mode 100644
index 00000000..76d03aea
--- /dev/null
+++ b/tools/assemble-realistic-stone-pack.py
@@ -0,0 +1,72 @@
+"""Build the two immutable resource packs from reviewed vanilla tile exports."""
+
+import argparse
+import hashlib
+import json
+from pathlib import Path
+import struct
+
+from plugin_supplied_item_art import read_pack
+from plugin_wild_update import write_archive
+
+
+BASE_SOURCE = "e9c8db19a000dea4625db70e724f1e615ceebf89"
+BASE = {
+ "arrakis": "09fc179ca0ecc018a6906e2cc948dd671b19f1d7312c0819bd99bbedfbd87416",
+ "fleet": "ec4b46f0c6362cd4284a18e84b799c850b44f2bf14a36589af3c3bcaa8f7f595",
+}
+CATALOG = Path(__file__).with_name("realistic-stone-family-paths.json")
+PNG = bytes.fromhex("89504e470d0a1a0a0000000d49484452")
+
+
+def sha(data):
+ return hashlib.sha256(data).hexdigest()
+
+
+def assemble(variant, baseline, export, receipt_sha, output, require_full=True):
+ if sha(baseline.read_bytes()) != BASE[variant]:
+ raise ValueError(f"{variant} pack differs from the accepted Soft Dune preimage")
+ receipt = (export / "stone-family.json").read_bytes()
+ if sha(receipt) != receipt_sha:
+ raise ValueError("Texture export receipt differs from the accepted hash")
+ manifest = json.loads(receipt)
+ catalog = set(json.loads(CATALOG.read_bytes()))
+ names = set(manifest["entries"])
+ if manifest["size"] != 256 or not names or not names <= catalog or (require_full and names != catalog):
+ raise ValueError("Unexpected vanilla block texture scope")
+ retained = read_pack(baseline)
+ updated = {}
+ for key in sorted(names):
+ data = (export / key).read_bytes()
+ if sha(data) != manifest["entries"][key]["sha256"]:
+ raise ValueError(f"Texture differs from the verified export: {key}")
+ if not data.startswith(PNG) or struct.unpack(">II", data[16:24]) != (256, 256):
+ raise ValueError(f"Invalid tile dimensions: {key}")
+ if key + ".mcmeta" in retained:
+ raise ValueError(f"Review inherited animation metadata before replacing {key}")
+ updated[key] = data
+ final = retained | updated
+ payload = write_archive(final)
+ with output.open("xb") as file:
+ file.write(payload)
+ if read_pack(output) != final:
+ raise ValueError("Unexpected ZIP entry after material merge")
+ return {
+ "filename": output.name,
+ "variant": variant,
+ "textureCount": len(updated),
+ "changed": sum(retained.get(k) != v for k, v in updated.items()),
+ "sha1": hashlib.sha1(payload).hexdigest(),
+ "sha256": sha(payload),
+ }
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("variant", choices=BASE)
+ parser.add_argument("baseline", type=Path)
+ parser.add_argument("export", type=Path)
+ parser.add_argument("receipt_sha")
+ parser.add_argument("output", type=Path)
+ parser.add_argument("--allow-partial", action="store_false", dest="require_full")
+ print(json.dumps(assemble(**vars(parser.parse_args())), indent=2))
diff --git a/tools/compile-realistic-stone-family.py b/tools/compile-realistic-stone-family.py
new file mode 100644
index 00000000..4b6d2fe7
--- /dev/null
+++ b/tools/compile-realistic-stone-family.py
@@ -0,0 +1,236 @@
+"""Compile supplied stone albedos into one repeatable vanilla material family."""
+
+import argparse
+import hashlib
+import json
+from pathlib import Path
+
+import numpy as np
+from PIL import Image, ImageDraw, ImageEnhance, ImageFilter
+
+SIZE = 256
+EDGE = 12
+TEXTURES = Path("assets/minecraft/textures/block")
+CORE = ("stone", "cobblestone", "andesite", "granite", "diorite", "tuff", "deepslate")
+OPTIONAL = ("calcite", "dripstone_block", "blackstone", "basalt", "sandstone", "red_sandstone",
+ "netherrack", "end_stone", "obsidian", "bedrock")
+MINERALS = ("coal", "copper", "diamond", "emerald", "gold", "iron", "lapis", "redstone")
+VARIANTS = {
+ "stone": {
+ "smooth_stone": "polished",
+ "smooth_stone_slab_side": "slab",
+ "stone_bricks": "bricks",
+ "mossy_stone_bricks": "mossy_bricks",
+ "cracked_stone_bricks": "cracked_bricks",
+ "chiseled_stone_bricks": "chiseled",
+ },
+ "cobblestone": {"mossy_cobblestone": "moss"},
+ "andesite": {"polished_andesite": "polished"},
+ "granite": {"polished_granite": "polished"},
+ "diorite": {"polished_diorite": "polished"},
+ "tuff": {
+ "polished_tuff": "polished", "tuff_bricks": "bricks",
+ "chiseled_tuff": "chiseled", "chiseled_tuff_top": "polished",
+ "chiseled_tuff_bricks": "chiseled", "chiseled_tuff_bricks_top": "polished",
+ },
+ "deepslate": {
+ "deepslate_top": "top", "cobbled_deepslate": "rubble",
+ "polished_deepslate": "polished", "deepslate_bricks": "bricks",
+ "cracked_deepslate_bricks": "cracked_bricks", "deepslate_tiles": "tiles",
+ "cracked_deepslate_tiles": "cracked_tiles", "chiseled_deepslate": "chiseled",
+ },
+ "blackstone": {
+ "blackstone_top": "top", "polished_blackstone": "polished",
+ "polished_blackstone_bricks": "bricks", "cracked_polished_blackstone_bricks": "cracked_bricks",
+ "chiseled_polished_blackstone": "chiseled",
+ },
+ "basalt": {
+ "basalt_side": "plain", "basalt_top": "top", "polished_basalt_side": "polished",
+ "polished_basalt_top": "polished_top", "smooth_basalt": "polished",
+ },
+ "sandstone": {
+ "sandstone_top": "top", "sandstone_bottom": "bottom",
+ "cut_sandstone": "cut", "chiseled_sandstone": "chiseled",
+ },
+ "red_sandstone": {
+ "red_sandstone_top": "top", "red_sandstone_bottom": "bottom",
+ "cut_red_sandstone": "cut", "chiseled_red_sandstone": "chiseled",
+ },
+ "end_stone": {"end_stone_bricks": "bricks"},
+}
+
+
+def sha(data):
+ return hashlib.sha256(data).hexdigest()
+
+
+def seamless(image):
+ pixels = np.asarray(image, dtype=np.float32).copy()
+ for axis in (0, 1):
+ strips = np.moveaxis(pixels, axis, 0)
+ for offset in range(EDGE):
+ weight = 0.5 * (1.0 + np.cos(np.pi * offset / (EDGE - 1)))
+ near = strips[offset].copy()
+ far = strips[-offset - 1].copy()
+ change = (far - near) * weight / 2
+ strips[offset] = near + change
+ strips[-offset - 1] = far - change
+ return Image.fromarray(np.rint(pixels).astype(np.uint8))
+
+
+def source_tile(path, mode):
+ with Image.open(path) as image:
+ if image.width != image.height or image.width < SIZE:
+ raise ValueError(f"{path.name} must be a square image of at least {SIZE} pixels")
+ if mode == "RGBA":
+ alpha = image.convert("RGBA").getchannel("A")
+ if alpha.getextrema()[0] != 0 or alpha.getextrema()[1] < 128:
+ raise ValueError(f"{path.name} requires a transparent background and visible deposits")
+ return image.convert(mode).resize((SIZE, SIZE), Image.Resampling.LANCZOS)
+
+
+def masonry(image, columns, rows, stagger):
+ y, x = np.indices((SIZE, SIZE))
+ width, height = SIZE // columns, SIZE // rows
+ u, v = (x + (y // height % 2) * (width // 2 if stagger else 0)) % width, y % height
+ lit = ((u == 2) | (v == 2)) * 0.12
+ mortar = (u < 2) | (v < 2)
+ shadow = (u >= width - 2) | (v >= height - 2)
+ face = 1 + lit - mortar * 0.41 - shadow * 0.17
+ return Image.fromarray(np.uint8(np.clip(np.asarray(image) * face[..., None], 0, 255)))
+
+
+def smooth(image):
+ return ImageEnhance.Contrast(Image.blend(image, image.filter(ImageFilter.GaussianBlur(2.4)), 0.52)).enhance(0.82)
+
+
+def moss(image):
+ random = np.random.default_rng(413)
+ mask = Image.fromarray(np.uint8(random.integers(0, 256, (16, 16)))).resize(image.size, Image.Resampling.BICUBIC)
+ alpha = mask.point(lambda n: max(0, min(140, (n - 118) * 2)))
+ tint = Image.blend(image, Image.new("RGB", image.size, (85, 104, 60)), 0.76)
+ return Image.composite(tint, image, alpha)
+
+
+def carved(image, style):
+ surface = image.convert("RGBA")
+ relief = Image.new("RGBA", image.size)
+ draw = ImageDraw.Draw(relief)
+ if style == "chiseled":
+ draw.rounded_rectangle((41, 41, 214, 214), radius=13, outline=(22, 16, 13, 135), width=7)
+ draw.rounded_rectangle((48, 48, 207, 207), radius=10, outline=(255, 246, 223, 72), width=4)
+ draw.line(((128, 79), (176, 128), (128, 177), (79, 128), (128, 79)),
+ fill=(36, 27, 19, 110), width=6, joint="curve")
+ else:
+ draw.line(((74, 37), (69, 58), (88, 82), (80, 105), (108, 121), (124, 151),
+ (148, 157), (143, 180)), fill=(28, 22, 18, 139), width=3, joint="curve")
+ draw.line(((89, 84), (113, 80), (132, 93), (151, 87)), fill=(36, 27, 18, 97), width=2)
+ return Image.alpha_composite(surface, relief).convert("RGB")
+
+
+def derive(tile, style):
+ if style == "plain":
+ return tile
+ if style == "top":
+ return tile.transpose(Image.Transpose.ROTATE_90)
+ if style == "bottom":
+ return ImageEnhance.Brightness(tile).enhance(0.90)
+ if style == "polished_top":
+ return smooth(tile.transpose(Image.Transpose.ROTATE_90))
+ if style in {"polished", "slab", "cut", "chiseled"}:
+ polished = smooth(tile)
+ if style == "polished":
+ return polished
+ if style == "chiseled":
+ return carved(polished, style)
+ return masonry(polished, 1, 2 if style == "slab" else 1, False)
+ if style == "moss":
+ return moss(tile)
+ columns, rows = (4, 4) if style in {"tiles", "cracked_tiles", "rubble"} else (2, 4)
+ built = masonry(tile, columns, rows, True)
+ if style.startswith("cracked"):
+ return carved(built, style)
+ return moss(built) if style == "mossy_bricks" else built
+
+
+def compile_tiles(source, complete):
+ tiles = {}
+ bases = {}
+ for family in CORE + OPTIONAL:
+ path = source / f"{family}-source.png"
+ if family in OPTIONAL and not complete and not path.is_file():
+ continue
+ base = seamless(source_tile(path, "RGB"))
+ bases[family] = (base, path)
+ if family != "basalt":
+ tiles[family] = (base, (path,))
+ for name, style in VARIANTS.get(family, {}).items():
+ tiles[name] = (seamless(derive(base, style)), (path,))
+
+ if "blackstone" in bases and (source / "gold-deposit.png").is_file():
+ ore_jobs = [("gilded_blackstone", "blackstone", "gold")]
+ else:
+ ore_jobs = []
+ ore_jobs += [(f"{prefix}{mineral}_ore", family, mineral)
+ for mineral in MINERALS for prefix, family in (("", "stone"), ("deepslate_", "deepslate"))]
+ ore_jobs += [(f"nether_{mineral}_ore", "netherrack", mineral) for mineral in ("gold", "quartz")]
+ ore_jobs += [("ancient_debris_side", "netherrack", "ancient_debris"),
+ ("ancient_debris_top", "netherrack", "ancient_debris")]
+ deposits = {}
+ for name, base, mineral in ore_jobs:
+ path = source / f"{mineral}-deposit.png"
+ if not complete and (base not in bases or not path.is_file()):
+ continue
+ tile, albedo = bases[base]
+ if mineral not in deposits:
+ deposits[mineral] = source_tile(path, "RGBA")
+ layer = deposits[mineral]
+ if name == "ancient_debris_top":
+ layer = layer.transpose(Image.Transpose.ROTATE_90)
+ rendered = Image.alpha_composite(tile.convert("RGBA"), layer).convert("RGB")
+ tiles[name] = (seamless(rendered), (albedo, path))
+ return tiles
+
+
+def write_tiles(source, output, complete=False):
+ tiles = compile_tiles(source, complete)
+ output.mkdir(parents=True, exist_ok=False)
+ (output / TEXTURES).mkdir(parents=True)
+ inputs = {}
+ entries = {}
+ for name, (texture, dependencies) in sorted(tiles.items()):
+ for path in dependencies:
+ if path.name not in inputs:
+ inputs[path.name] = sha(path.read_bytes())
+ key = (TEXTURES / f"{name}.png").as_posix()
+ path = output / key
+ texture.save(path, format="PNG", optimize=True)
+ a = np.asarray(texture)
+ if not (np.array_equal(a[0], a[-1]) and np.array_equal(a[:, 0], a[:, -1])):
+ raise ValueError(f"Unmatched tile edges: {key}")
+ entries[key] = {"sha256": sha(path.read_bytes()), "inputs": [p.name for p in dependencies]}
+ receipt = {"size": SIZE, "inputs": inputs, "entries": entries}
+ (output / "stone-family.json").write_text(json.dumps(receipt, indent=2) + "\n", encoding="utf-8")
+ charts = "".join(
+ f'