overviewer no longer trusts ancillary data from blocks that should have none
This commit is contained in:
@@ -30,6 +30,7 @@ static PyObject *transparent_blocks = NULL;
|
|||||||
static PyObject *solid_blocks = NULL;
|
static PyObject *solid_blocks = NULL;
|
||||||
static PyObject *fluid_blocks = NULL;
|
static PyObject *fluid_blocks = NULL;
|
||||||
static PyObject *nospawn_blocks = NULL;
|
static PyObject *nospawn_blocks = NULL;
|
||||||
|
static PyObject *nodata_blocks = NULL;
|
||||||
|
|
||||||
PyObject *init_chunk_render(PyObject *self, PyObject *args) {
|
PyObject *init_chunk_render(PyObject *self, PyObject *args) {
|
||||||
|
|
||||||
@@ -86,6 +87,9 @@ PyObject *init_chunk_render(PyObject *self, PyObject *args) {
|
|||||||
nospawn_blocks = PyObject_GetAttrString(textures, "nospawn_blocks");
|
nospawn_blocks = PyObject_GetAttrString(textures, "nospawn_blocks");
|
||||||
if (!nospawn_blocks)
|
if (!nospawn_blocks)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
nodata_blocks = PyObject_GetAttrString(textures, "nodata_blocks");
|
||||||
|
if (!nodata_blocks)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
block_properties = calloc(max_blockid, sizeof(unsigned char));
|
block_properties = calloc(max_blockid, sizeof(unsigned char));
|
||||||
for (i = 0; i < max_blockid; i++) {
|
for (i = 0; i < max_blockid; i++) {
|
||||||
@@ -101,6 +105,8 @@ PyObject *init_chunk_render(PyObject *self, PyObject *args) {
|
|||||||
block_properties[i] |= 1 << FLUID;
|
block_properties[i] |= 1 << FLUID;
|
||||||
if (PySequence_Contains(nospawn_blocks, block))
|
if (PySequence_Contains(nospawn_blocks, block))
|
||||||
block_properties[i] |= 1 << NOSPAWN;
|
block_properties[i] |= 1 << NOSPAWN;
|
||||||
|
if (PySequence_Contains(nodata_blocks, block))
|
||||||
|
block_properties[i] |= 1 << NODATA;
|
||||||
|
|
||||||
Py_DECREF(block);
|
Py_DECREF(block);
|
||||||
}
|
}
|
||||||
@@ -443,22 +449,30 @@ chunk_render(PyObject *self, PyObject *args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* everything stored here will be a borrowed ref */
|
/* everything stored here will be a borrowed ref */
|
||||||
|
|
||||||
ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z);
|
if (block_has_property(state.block, NODATA)) {
|
||||||
state.block_data = ancilData;
|
/* block shouldn't have data associated with it, set it to 0 */
|
||||||
/* block that need pseudo ancildata:
|
ancilData = 0;
|
||||||
* grass, water, glass, chest, restone wire,
|
state.block_data = 0;
|
||||||
* ice, fence, portal, iron bars, glass panes */
|
|
||||||
if ((state.block == 2) || (state.block == 9) ||
|
|
||||||
(state.block == 20) || (state.block == 54) ||
|
|
||||||
(state.block == 55) || (state.block == 79) ||
|
|
||||||
(state.block == 85) || (state.block == 90) ||
|
|
||||||
(state.block == 101) || (state.block == 102) ||
|
|
||||||
(state.block == 113)) {
|
|
||||||
ancilData = generate_pseudo_data(&state, ancilData);
|
|
||||||
state.block_pdata = ancilData;
|
|
||||||
} else {
|
|
||||||
state.block_pdata = 0;
|
state.block_pdata = 0;
|
||||||
|
} else {
|
||||||
|
/* block has associated data, use it */
|
||||||
|
ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z);
|
||||||
|
state.block_data = ancilData;
|
||||||
|
/* block that need pseudo ancildata:
|
||||||
|
* grass, water, glass, chest, restone wire,
|
||||||
|
* ice, fence, portal, iron bars, glass panes */
|
||||||
|
if ((state.block == 2) || (state.block == 9) ||
|
||||||
|
(state.block == 20) || (state.block == 54) ||
|
||||||
|
(state.block == 55) || (state.block == 79) ||
|
||||||
|
(state.block == 85) || (state.block == 90) ||
|
||||||
|
(state.block == 101) || (state.block == 102) ||
|
||||||
|
(state.block == 113)) {
|
||||||
|
ancilData = generate_pseudo_data(&state, ancilData);
|
||||||
|
state.block_pdata = ancilData;
|
||||||
|
} else {
|
||||||
|
state.block_pdata = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make sure our block info is in-bounds */
|
/* make sure our block info is in-bounds */
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// increment this value if you've made a change to the c extesion
|
// increment this value if you've made a change to the c extesion
|
||||||
// and want to force users to rebuild
|
// and want to force users to rebuild
|
||||||
#define OVERVIEWER_EXTENSION_VERSION 13
|
#define OVERVIEWER_EXTENSION_VERSION 14
|
||||||
|
|
||||||
/* Python PIL, and numpy headers */
|
/* Python PIL, and numpy headers */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
@@ -102,6 +102,7 @@ typedef enum
|
|||||||
SOLID,
|
SOLID,
|
||||||
FLUID,
|
FLUID,
|
||||||
NOSPAWN,
|
NOSPAWN,
|
||||||
|
NODATA,
|
||||||
} BlockProperty;
|
} BlockProperty;
|
||||||
/* globals set in init_chunk_render, here because they're used
|
/* globals set in init_chunk_render, here because they're used
|
||||||
in block_has_property */
|
in block_has_property */
|
||||||
|
|||||||
@@ -611,11 +611,12 @@ transparent_blocks = set()
|
|||||||
solid_blocks = set()
|
solid_blocks = set()
|
||||||
fluid_blocks = set()
|
fluid_blocks = set()
|
||||||
nospawn_blocks = set()
|
nospawn_blocks = set()
|
||||||
|
nodata_blocks = set()
|
||||||
|
|
||||||
# the material registration decorator
|
# the material registration decorator
|
||||||
def material(blockid=[], data=[0], **kwargs):
|
def material(blockid=[], data=[0], **kwargs):
|
||||||
# mapping from property name to the set to store them in
|
# mapping from property name to the set to store them in
|
||||||
properties = {"transparent" : transparent_blocks, "solid" : solid_blocks, "fluid" : fluid_blocks, "nospawn" : nospawn_blocks}
|
properties = {"transparent" : transparent_blocks, "solid" : solid_blocks, "fluid" : fluid_blocks, "nospawn" : nospawn_blocks, "nodata" : nodata_blocks}
|
||||||
|
|
||||||
# make sure blockid and data are iterable
|
# make sure blockid and data are iterable
|
||||||
try:
|
try:
|
||||||
@@ -657,9 +658,9 @@ def material(blockid=[], data=[0], **kwargs):
|
|||||||
return func_wrapper
|
return func_wrapper
|
||||||
return inner_material
|
return inner_material
|
||||||
|
|
||||||
# shortcut function for pure blocks, default to solid
|
# shortcut function for pure blocks, default to solid, nodata
|
||||||
def block(blockid=[], top_index=None, side_index=None, **kwargs):
|
def block(blockid=[], top_index=None, side_index=None, **kwargs):
|
||||||
new_kwargs = {'solid' : True}
|
new_kwargs = {'solid' : True, 'nodata' : True}
|
||||||
new_kwargs.update(kwargs)
|
new_kwargs.update(kwargs)
|
||||||
|
|
||||||
if top_index is None:
|
if top_index is None:
|
||||||
@@ -673,9 +674,9 @@ def block(blockid=[], top_index=None, side_index=None, **kwargs):
|
|||||||
return build_block(terrain_images[top_index], terrain_images[side_index])
|
return build_block(terrain_images[top_index], terrain_images[side_index])
|
||||||
return inner_block
|
return inner_block
|
||||||
|
|
||||||
# shortcut function for sprite blocks, defaults to transparent
|
# shortcut function for sprite blocks, defaults to transparent, nodata
|
||||||
def sprite(blockid=[], index=None, **kwargs):
|
def sprite(blockid=[], index=None, **kwargs):
|
||||||
new_kwargs = {'transparent' : True}
|
new_kwargs = {'transparent' : True, 'nodata' : True}
|
||||||
new_kwargs.update(kwargs)
|
new_kwargs.update(kwargs)
|
||||||
|
|
||||||
if index is None:
|
if index is None:
|
||||||
@@ -686,9 +687,9 @@ def sprite(blockid=[], index=None, **kwargs):
|
|||||||
return build_sprite(terrain_images[index])
|
return build_sprite(terrain_images[index])
|
||||||
return inner_sprite
|
return inner_sprite
|
||||||
|
|
||||||
# shortcut function for billboard blocks, defaults to transparent
|
# shortcut function for billboard blocks, defaults to transparent, nodata
|
||||||
def billboard(blockid=[], index=None, **kwargs):
|
def billboard(blockid=[], index=None, **kwargs):
|
||||||
new_kwargs = {'transparent' : True}
|
new_kwargs = {'transparent' : True, 'nodata' : True}
|
||||||
new_kwargs.update(kwargs)
|
new_kwargs.update(kwargs)
|
||||||
|
|
||||||
if index is None:
|
if index is None:
|
||||||
@@ -1685,7 +1686,7 @@ block(blockid=57, top_index=24)
|
|||||||
|
|
||||||
# crafting table
|
# crafting table
|
||||||
# needs two different sides
|
# needs two different sides
|
||||||
@material(blockid=58, solid=True)
|
@material(blockid=58, solid=True, nodata=True)
|
||||||
def crafting_table(blockid, data):
|
def crafting_table(blockid, data):
|
||||||
top = terrain_images[43]
|
top = terrain_images[43]
|
||||||
side3 = terrain_images[43+16]
|
side3 = terrain_images[43+16]
|
||||||
@@ -2187,7 +2188,7 @@ def buttons(blockid, data, north):
|
|||||||
return img
|
return img
|
||||||
|
|
||||||
# snow
|
# snow
|
||||||
@material(blockid=78, data=range(8), transparent=True, solid=True)
|
@material(blockid=78, data=range(16), transparent=True, solid=True)
|
||||||
def snow(blockid, data):
|
def snow(blockid, data):
|
||||||
# still not rendered correctly: data other than 0
|
# still not rendered correctly: data other than 0
|
||||||
|
|
||||||
@@ -2319,7 +2320,7 @@ def fence(blockid, data):
|
|||||||
fence_small_side = ImageEnhance.Brightness(fence_small_side).enhance(0.9)
|
fence_small_side = ImageEnhance.Brightness(fence_small_side).enhance(0.9)
|
||||||
fence_small_side.putalpha(sidealpha)
|
fence_small_side.putalpha(sidealpha)
|
||||||
|
|
||||||
# Create img to compose the fence
|
# Create img to compose the fence
|
||||||
img = Image.new("RGBA", (24,24), bgcolor)
|
img = Image.new("RGBA", (24,24), bgcolor)
|
||||||
|
|
||||||
# Position of fence small sticks in img.
|
# Position of fence small sticks in img.
|
||||||
@@ -2982,7 +2983,7 @@ def nether_wart(blockid, data):
|
|||||||
|
|
||||||
# enchantment table
|
# enchantment table
|
||||||
# TODO there's no book at the moment
|
# TODO there's no book at the moment
|
||||||
@material(blockid=116, transparent=True)
|
@material(blockid=116, transparent=True, nodata=True)
|
||||||
def enchantment_table(blockid, data):
|
def enchantment_table(blockid, data):
|
||||||
# no book at the moment
|
# no book at the moment
|
||||||
top = terrain_images[166]
|
top = terrain_images[166]
|
||||||
@@ -3027,7 +3028,7 @@ def cauldron(blockid, data):
|
|||||||
return img
|
return img
|
||||||
|
|
||||||
# end portal
|
# end portal
|
||||||
@material(blockid=119, transparent=True)
|
@material(blockid=119, transparent=True, nodata=True)
|
||||||
def end_portal(blockid, data):
|
def end_portal(blockid, data):
|
||||||
img = Image.new("RGBA", (24,24), bgcolor)
|
img = Image.new("RGBA", (24,24), bgcolor)
|
||||||
# generate a black texure with white, blue and grey dots resembling stars
|
# generate a black texure with white, blue and grey dots resembling stars
|
||||||
|
|||||||
Reference in New Issue
Block a user