Add neighbor-connect frustum sprites for stone walls.
Gray cobblestone truncated-pyramid tiles 0–15 autotile like counters; old 1/2 variants replaced.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -0,0 +1,251 @@
/**
* Generate 16×16 gray cobblestone stone-wall PNGs for neighbor-connect masks 0–15.
*
* Shape is a truncated pyramid / frustum (wider base, narrower top). Footprint is a
* strip-union like tables: E–W bar ∪ N–S bar so L/T/+ bends keep concave corners
* while straight runs stay one tile thick and meet at the edges.
*
* node client/scripts/generate-stone-wall-sprites.mjs
*/
import { mkdirSync, writeFileSync, unlinkSync, existsSync } from "node:fs";
import { deflateSync } from "node:zlib";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
import { NeighborBit } from "../../shared/world/neighborConnect.js";
const SIZE = 16;
const OUT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks/stone-wall");
/** Gray cobble palette (no magenta — stone stays gray for now). */
const TOP = [168, 168, 172, 255];
const TOP_HI = [198, 198, 202, 255];
const TOP_LO = [140, 140, 144, 255];
const FACE = [112, 112, 116, 255];
const FACE_HI = [132, 132, 136, 255];
const FACE_LO = [88, 88, 92, 255];
const EDGE = [70, 70, 74, 255];
const MORTAR = [78, 78, 82, 255];
/** Alone / core frustum (inclusive pixel bounds). */
const TOP_Y0 = 3;
const TOP_Y1 = 6;
const FACE_Y1 = 12;
const CX = 7.5;
const TOP_HALF_W = 3.0;
const BASE_HALF_W = 5.5;
function crcTable ()
{
const table = new Uint32Array(256);
for (let n = 0; n < 256; n++)
{
let c = n;
for (let k = 0; k < 8; k++)
{ c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1); }
table[n] = c >>> 0;
}
return table;
}
const CRC_TABLE = crcTable();
function crc32 (buf)
{
let c = 0xffffffff;
for (let i = 0; i < buf.length; i++)
{ c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8); }
return (c ^ 0xffffffff) >>> 0;
}
function chunk (type, data)
{
const len = Buffer.alloc(4);
len.writeUInt32BE(data.length);
const typeBuf = Buffer.from(type, "ascii");
const crcBuf = Buffer.alloc(4);
crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])));
return Buffer.concat([len, typeBuf, data, crcBuf]);
}
function encodePng (rgba)
{
const raw = Buffer.alloc((SIZE * 4 + 1) * SIZE);
for (let y = 0; y < SIZE; y++)
{
const row = y * (SIZE * 4 + 1);
raw[row] = 0;
for (let x = 0; x < SIZE; x++)
{
const i = (y * SIZE + x) * 4;
const o = row + 1 + x * 4;
raw[o] = rgba[i];
raw[o + 1] = rgba[i + 1];
raw[o + 2] = rgba[i + 2];
raw[o + 3] = rgba[i + 3];
}
}
const ihdr = Buffer.alloc(13);
ihdr.writeUInt32BE(SIZE, 0);
ihdr.writeUInt32BE(SIZE, 4);
ihdr[8] = 8;
ihdr[9] = 6;
return Buffer.concat([
Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]),
chunk("IHDR", ihdr),
chunk("IDAT", deflateSync(raw, { level: 9 })),
chunk("IEND", Buffer.alloc(0))
]);
}
function setPx (rgba, x, y, color)
{
if (x < 0 || y < 0 || x >= SIZE || y >= SIZE)
{ return; }
const i = (y * SIZE + x) * 4;
rgba[i] = color[0];
rgba[i + 1] = color[1];
rgba[i + 2] = color[2];
rgba[i + 3] = color[3];
}
function halfWidthAtY (y)
{
if (y <= TOP_Y1)
{ return TOP_HALF_W; }
if (y >= FACE_Y1)
{ return BASE_HALF_W; }
const t = (y - TOP_Y1) / (FACE_Y1 - TOP_Y1);
return TOP_HALF_W + (BASE_HALF_W - TOP_HALF_W) * t;
}
/** Core Y range for alone wall; extended to tile edges when connected N/S. */
function yRange (connectN, connectS)
{
return {
y0: connectN ? 0 : TOP_Y0,
y1: connectS ? SIZE - 1 : FACE_Y1
};
}
/**
* Strip-union footprint: E–W frustum bar ∪ N–S frustum bar.
* Free ends keep the tapered half-width; connected sides run to the tile edge.
*/
function inWall (x, y, connectN, connectE, connectS, connectW)
{
const { y0, y1 } = yRange(connectN, connectS);
if (y < y0 || y > y1)
{ return false; }
const hw = halfWidthAtY(Math.min(FACE_Y1, Math.max(TOP_Y0, y)));
const coreX0 = Math.ceil(CX - hw);
const coreX1 = Math.floor(CX + hw);
const inH = y >= (connectN ? 0 : TOP_Y0)
&& y <= (connectS ? SIZE - 1 : FACE_Y1)
&& (
(x >= coreX0 && x <= coreX1)
|| (connectW && x < coreX0)
|| (connectE && x > coreX1)
);
const inV = x >= coreX0 && x <= coreX1
&& (
(y >= TOP_Y0 && y <= FACE_Y1)
|| (connectN && y < TOP_Y0)
|| (connectS && y > FACE_Y1)
);
return inH || inV;
}
function hash2 (x, y)
{
let n = (x * 374761393 + y * 668265263) | 0;
n = (n ^ (n >>> 13)) * 1274126177;
return (n ^ (n >>> 16)) >>> 0;
}
function cobbleShade (base, x, y)
{
const h = hash2(x, y);
const speck = (h & 7);
if (speck === 0)
{ return MORTAR; }
if (speck === 1 || speck === 2)
{ return base === TOP || base === TOP_HI || base === TOP_LO ? TOP_HI : FACE_HI; }
if (speck === 3)
{ return base === TOP || base === TOP_HI || base === TOP_LO ? TOP_LO : FACE_LO; }
return base;
}
function paintWall (mask)
{
const rgba = new Uint8Array(SIZE * SIZE * 4);
const connectN = (mask & NeighborBit.n) !== 0;
const connectE = (mask & NeighborBit.e) !== 0;
const connectS = (mask & NeighborBit.s) !== 0;
const connectW = (mask & NeighborBit.w) !== 0;
for (let y = 0; y < SIZE; y++)
{
for (let x = 0; x < SIZE; x++)
{
if (!inWall(x, y, connectN, connectE, connectS, connectW))
{ continue; }
const n = inWall(x, y - 1, connectN, connectE, connectS, connectW);
const e = inWall(x + 1, y, connectN, connectE, connectS, connectW);
const s = inWall(x, y + 1, connectN, connectE, connectS, connectW);
const w = inWall(x - 1, y, connectN, connectE, connectS, connectW);
let base;
const onTop = y <= TOP_Y1 || (connectN && y < TOP_Y0 + 2 && n && s);
// Prefer a clear top deck in the core band; south of TOP_Y1 is the face.
if (y <= TOP_Y1 && (y >= TOP_Y0 || connectN))
{
if (!n)
{ base = TOP_HI; }
else if (!s && y === TOP_Y1)
{ base = TOP_LO; }
else
{ base = TOP; }
}
else
{
// South face / body of the frustum
if (!s)
{ base = FACE_LO; }
else if (!n)
{ base = FACE_HI; }
else
{ base = FACE; }
}
// Free side rims read as darker bevels (trapezoid silhouette).
if ((!w && !connectW) || (!e && !connectE))
{
if (base === TOP || base === TOP_HI)
{ base = TOP_LO; }
else if (base === FACE || base === FACE_HI)
{ base = EDGE; }
}
setPx(rgba, x, y, cobbleShade(base, x, y));
}
}
return rgba;
}
mkdirSync(OUT, { recursive: true });
for (const legacy of ["1.png", "2.png"])
{
const path = join(OUT, legacy);
if (existsSync(path))
{ unlinkSync(path); }
}
for (let mask = 0; mask < 16; mask++)
{
writeFileSync(join(OUT, `${mask}.png`), encodePng(paintWall(mask)));
}
console.log(`Wrote cobblestone frustum stone-wall sprites 0–15 to ${OUT}`);
@@ -0,0 +1,251 @@/** * Generate 16×16 gray cobblestone stone-wall PNGs for neighbor-connect masks 0–15. * * Shape is a truncated pyramid / frustum (wider base, narrower top). Footprint is a * strip-union like tables: E–W bar ∪ N–S bar so L/T/+ bends keep concave corners * while straight runs stay one tile thick and meet at the edges. * * node client/scripts/generate-stone-wall-sprites.mjs */import { mkdirSync, writeFileSync, unlinkSync, existsSync } from "node:fs";import { deflateSync } from "node:zlib";import { fileURLToPath } from "node:url";import { dirname, join } from "node:path";import { NeighborBit } from "../../shared/world/neighborConnect.js";const SIZE = 16;const OUT = join(dirname(fileURLToPath(import.meta.url)), "../assets/blocks/stone-wall");/** Gray cobble palette (no magenta — stone stays gray for now). */const TOP = [168, 168, 172, 255];const TOP_HI = [198, 198, 202, 255];const TOP_LO = [140, 140, 144, 255];const FACE = [112, 112, 116, 255];const FACE_HI = [132, 132, 136, 255];const FACE_LO = [88, 88, 92, 255];const EDGE = [70, 70, 74, 255];const MORTAR = [78, 78, 82, 255];/** Alone / core frustum (inclusive pixel bounds). */const TOP_Y0 = 3;const TOP_Y1 = 6;const FACE_Y1 = 12;const CX = 7.5;const TOP_HALF_W = 3.0;const BASE_HALF_W = 5.5;function crcTable (){ const table = new Uint32Array(256); for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) { c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1); } table[n] = c >>> 0; } return table;}const CRC_TABLE = crcTable();function crc32 (buf){ let c = 0xffffffff; for (let i = 0; i < buf.length; i++) { c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8); } return (c ^ 0xffffffff) >>> 0;}function chunk (type, data){ const len = Buffer.alloc(4); len.writeUInt32BE(data.length); const typeBuf = Buffer.from(type, "ascii"); const crcBuf = Buffer.alloc(4); crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data]))); return Buffer.concat([len, typeBuf, data, crcBuf]);}function encodePng (rgba){ const raw = Buffer.alloc((SIZE * 4 + 1) * SIZE); for (let y = 0; y < SIZE; y++) { const row = y * (SIZE * 4 + 1); raw[row] = 0; for (let x = 0; x < SIZE; x++) { const i = (y * SIZE + x) * 4; const o = row + 1 + x * 4; raw[o] = rgba[i]; raw[o + 1] = rgba[i + 1]; raw[o + 2] = rgba[i + 2]; raw[o + 3] = rgba[i + 3]; } } const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(SIZE, 0); ihdr.writeUInt32BE(SIZE, 4); ihdr[8] = 8; ihdr[9] = 6; return Buffer.concat([ Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]), chunk("IHDR", ihdr), chunk("IDAT", deflateSync(raw, { level: 9 })), chunk("IEND", Buffer.alloc(0)) ]);}function setPx (rgba, x, y, color){ if (x < 0 || y < 0 || x >= SIZE || y >= SIZE) { return; } const i = (y * SIZE + x) * 4; rgba[i] = color[0]; rgba[i + 1] = color[1]; rgba[i + 2] = color[2]; rgba[i + 3] = color[3];}function halfWidthAtY (y){ if (y <= TOP_Y1) { return TOP_HALF_W; } if (y >= FACE_Y1) { return BASE_HALF_W; } const t = (y - TOP_Y1) / (FACE_Y1 - TOP_Y1); return TOP_HALF_W + (BASE_HALF_W - TOP_HALF_W) * t;}/** Core Y range for alone wall; extended to tile edges when connected N/S. */function yRange (connectN, connectS){ return { y0: connectN ? 0 : TOP_Y0, y1: connectS ? SIZE - 1 : FACE_Y1 };}/** * Strip-union footprint: E–W frustum bar ∪ N–S frustum bar. * Free ends keep the tapered half-width; connected sides run to the tile edge. */function inWall (x, y, connectN, connectE, connectS, connectW){ const { y0, y1 } = yRange(connectN, connectS); if (y < y0 || y > y1) { return false; } const hw = halfWidthAtY(Math.min(FACE_Y1, Math.max(TOP_Y0, y))); const coreX0 = Math.ceil(CX - hw); const coreX1 = Math.floor(CX + hw); const inH = y >= (connectN ? 0 : TOP_Y0) && y <= (connectS ? SIZE - 1 : FACE_Y1) && ( (x >= coreX0 && x <= coreX1) || (connectW && x < coreX0) || (connectE && x > coreX1) ); const inV = x >= coreX0 && x <= coreX1 && ( (y >= TOP_Y0 && y <= FACE_Y1) || (connectN && y < TOP_Y0) || (connectS && y > FACE_Y1) ); return inH || inV;}function hash2 (x, y){ let n = (x * 374761393 + y * 668265263) | 0; n = (n ^ (n >>> 13)) * 1274126177; return (n ^ (n >>> 16)) >>> 0;}function cobbleShade (base, x, y){ const h = hash2(x, y); const speck = (h & 7); if (speck === 0) { return MORTAR; } if (speck === 1 || speck === 2) { return base === TOP || base === TOP_HI || base === TOP_LO ? TOP_HI : FACE_HI; } if (speck === 3) { return base === TOP || base === TOP_HI || base === TOP_LO ? TOP_LO : FACE_LO; } return base;}function paintWall (mask){ const rgba = new Uint8Array(SIZE * SIZE * 4); const connectN = (mask & NeighborBit.n) !== 0; const connectE = (mask & NeighborBit.e) !== 0; const connectS = (mask & NeighborBit.s) !== 0; const connectW = (mask & NeighborBit.w) !== 0; for (let y = 0; y < SIZE; y++) { for (let x = 0; x < SIZE; x++) { if (!inWall(x, y, connectN, connectE, connectS, connectW)) { continue; } const n = inWall(x, y - 1, connectN, connectE, connectS, connectW); const e = inWall(x + 1, y, connectN, connectE, connectS, connectW); const s = inWall(x, y + 1, connectN, connectE, connectS, connectW); const w = inWall(x - 1, y, connectN, connectE, connectS, connectW); let base; const onTop = y <= TOP_Y1 || (connectN && y < TOP_Y0 + 2 && n && s); // Prefer a clear top deck in the core band; south of TOP_Y1 is the face. if (y <= TOP_Y1 && (y >= TOP_Y0 || connectN)) { if (!n) { base = TOP_HI; } else if (!s && y === TOP_Y1) { base = TOP_LO; } else { base = TOP; } } else { // South face / body of the frustum if (!s) { base = FACE_LO; } else if (!n) { base = FACE_HI; } else { base = FACE; } } // Free side rims read as darker bevels (trapezoid silhouette). if ((!w && !connectW) || (!e && !connectE)) { if (base === TOP || base === TOP_HI) { base = TOP_LO; } else if (base === FACE || base === FACE_HI) { base = EDGE; } } setPx(rgba, x, y, cobbleShade(base, x, y)); } } return rgba;}mkdirSync(OUT, { recursive: true });for (const legacy of ["1.png", "2.png"]){ const path = join(OUT, legacy); if (existsSync(path)) { unlinkSync(path); }}for (let mask = 0; mask < 16; mask++){ writeFileSync(join(OUT, `${mask}.png`), encodePng(paintWall(mask)));}console.log(`Wrote cobblestone frustum stone-wall sprites 0–15 to ${OUT}`);@@ -13,9 +13,11 @@ const ASSET_ROOT = join(fileURLToPath(new URL("../../client/assets", import.meta
test("sprite folders expose alphabetical states; first is default", () =>
{
const catalog = buildSpriteCatalog(ASSET_ROOT);
assert.deepEqual(catalog.blocks["stone-wall"].states, ["1", "2"]);
assert.equal(catalog.blocks["stone-wall"].defaultState, "1");
assert.ok(catalog.images.some((image) => image.name === "block:stone-wall:2"));
assert.deepEqual(catalog.blocks["stone-wall"].states, [
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"
]);
assert.equal(catalog.blocks["stone-wall"].defaultState, "0");
assert.ok(catalog.images.some((image) => image.name === "block:stone-wall:15"));
assert.equal(catalog.images[0].subImgTotal, 1);
assert.equal(catalog.images[0].perRow, 1);
});
@@ -13,9 +13,11 @@ const ASSET_ROOT = join(fileURLToPath(new URL("../../client/assets", import.metatest("sprite folders expose alphabetical states; first is default", () =>test("sprite folders expose alphabetical states; first is default", () =>{{ const catalog = buildSpriteCatalog(ASSET_ROOT); const catalog = buildSpriteCatalog(ASSET_ROOT); assert.deepEqual(catalog.blocks["stone-wall"].states, ["1", "2"]); assert.deepEqual(catalog.blocks["stone-wall"].states, [ assert.equal(catalog.blocks["stone-wall"].defaultState, "1"); "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" assert.ok(catalog.images.some((image) => image.name === "block:stone-wall:2")); ]); assert.equal(catalog.blocks["stone-wall"].defaultState, "0"); assert.ok(catalog.images.some((image) => image.name === "block:stone-wall:15")); assert.equal(catalog.images[0].subImgTotal, 1); assert.equal(catalog.images[0].subImgTotal, 1); assert.equal(catalog.images[0].perRow, 1); assert.equal(catalog.images[0].perRow, 1);});});