diff --git a/docs/config.rst b/docs/config.rst index f64a52d01..3d233188b 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -1213,23 +1213,24 @@ StructureOverlay a MineralOverlay with alpha support. This Overlay colors according to a patterns that are specified as - multiple tuples of the form ``(relx, rely, relz, blockid)``. So + multiple tuples of the form ``(relx, rely, relz, blockid)`` or ``(relx, rely, relz, blockid, data)``. So by specifying ``(0, -1, 0, 4)`` the block below the current one has to - be a cobblestone. + be a cobblestone. By specifying ``(0, -1, 0, 35, 11)`` the block below has to be Blue wool. One color is then specified as ``((relblockid1, relblockid2, ...), (r, g, b, a))`` where the ``relblockid*`` are relative coordinates and the blockid as specified above. The ``relblockid*`` must match all at the same time for the - color to apply. + color to apply. The Alpha (a) is optional and is set to 255 by default. Example:: StructureOverlay(structures=[(((0, 0, 0, 66), (0, -1, 0, 4)), (255, 0, 0, 255)), - (((0, 0, 0, 27), (0, -1, 0, 4)), (0, 255, 0, 255))]) + (((0, 0, 0, 27), (0, -1, 0, 4)), (0, 255, 0, 255)), + (((0, 0, 0, 66), (0, -1, 0, 35, 11)), (0, 0, 255))]) In this example all rails(66) on top of cobblestone are rendered in - pure red. And all powerrails(27) are rendered in green. + pure red, all powerrails(27) are rendered in green and all rails(66) above blue wool are rendered blue. If ``structures`` is not provided, a default rail coloring is used. diff --git a/overviewer_core/rendermodes.py b/overviewer_core/rendermodes.py index 7ae67fe3f..1be7ad0d8 100644 --- a/overviewer_core/rendermodes.py +++ b/overviewer_core/rendermodes.py @@ -209,7 +209,7 @@ class SlimeOverlay(Overlay): class StructureOverlay(Overlay): name = "overlay-structure" options = { - 'structures': ('a list of ((((relx, rely, relz), blockid), ...), (r, g, b, a)) tuples for coloring minerals', + 'structures': ('a list of (((relx, rely, relz, blockid, data), ...), (r, g, b, a)) tuples for coloring minerals', [(((0, 0, 0, 66), (0, -1, 0, 4)), (255, 0, 0, 255)), (((0, 0, 0, 27), (0, -1, 0, 4)), (0, 255, 0, 255)), (((0, 0, 0, 28), (0, -1, 0, 4)), (255, 255, 0, 255)), diff --git a/overviewer_core/src/primitives/overlay-structure.c b/overviewer_core/src/primitives/overlay-structure.c index a8561c19d..3a6fbe989 100644 --- a/overviewer_core/src/primitives/overlay-structure.c +++ b/overviewer_core/src/primitives/overlay-structure.c @@ -28,6 +28,7 @@ typedef struct { struct Condition { int32_t relx, rely, relz; mc_block_t block; + signed short data; }; struct Color { @@ -65,7 +66,10 @@ static void get_color(void* data, all = true; c = (struct Condition*)&structures[col].conditions[cond]; // check if the condition does apply and break from the conditions loop if not. - if (!(c->block == get_data(state, BLOCKS, x + c->relx, y + c->rely, z + c->relz))) { + if (!( + c->block == get_data(state, BLOCKS, x + c->relx, y + c->rely, z + c->relz) && + (c->data == -1 || (uint32_t)c->data == get_data(state, DATA, x + c->relx, y + c->rely, z + c->relz)) + )) { all = false; break; } @@ -147,8 +151,9 @@ static bool overlay_structure_start(void* data, RenderState* state, PyObject* su return true; } + structures[i].a = 255; // Parse colorpy into a c-struct. - if (!PyArg_ParseTuple(colorpy, "bbbb", + if (!PyArg_ParseTuple(colorpy, "bbb|b", &structures[i].r, &structures[i].g, &structures[i].b, @@ -182,11 +187,13 @@ static bool overlay_structure_start(void* data, RenderState* state, PyObject* su // iterate over all the conditions and read them. for (n = 0; n < structures[i].numconds; n++) { PyObject* ccond = PySequence_Fast_GET_ITEM(condspy, n); - if (!PyArg_ParseTuple(ccond, "iiib", + cond[n].data = -1; // If no data value is given the data value stays at -1 + if (!PyArg_ParseTuple(ccond, "iiih|h", &cond[n].relx, &cond[n].rely, &cond[n].relz, - &cond[n].block)) { + &cond[n].block, + &cond[n].data)) { int32_t x = 0; for (x = 0; x < structures_size; x++) { free(structures[x].conditions);