watercolor will now be used if it can be loaded
Right now the Biome Extractor does not extract this with the other biome colors, so making it *required* would lead to a lot of errors for people running servers that don't have the client jar. Once the Biome Extractor has been changed, this should also.
This commit is contained in:
@@ -81,11 +81,18 @@ rendermode_normal_start(void *data, RenderState *state, PyObject *options) {
|
||||
} else {
|
||||
self->foliagecolor = PyObject_GetAttrString(state->textures, "foliagecolor");
|
||||
self->grasscolor = PyObject_GetAttrString(state->textures, "grasscolor");
|
||||
self->watercolor = PyObject_GetAttrString(state->textures, "watercolor");
|
||||
if (self->watercolor == Py_None)
|
||||
{
|
||||
Py_DECREF(self->watercolor);
|
||||
self->watercolor = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self->biome_data = NULL;
|
||||
self->foliagecolor = NULL;
|
||||
self->grasscolor = NULL;
|
||||
self->watercolor = NULL;
|
||||
}
|
||||
|
||||
Py_DECREF(use_biomes);
|
||||
@@ -103,6 +110,7 @@ rendermode_normal_finish(void *data, RenderState *state) {
|
||||
Py_XDECREF(self->biome_data);
|
||||
Py_XDECREF(self->foliagecolor);
|
||||
Py_XDECREF(self->grasscolor);
|
||||
Py_XDECREF(self->watercolor);
|
||||
Py_XDECREF(self->grass_texture);
|
||||
Py_XDECREF(self->black_color);
|
||||
Py_XDECREF(self->white_color);
|
||||
@@ -155,6 +163,8 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
||||
*/
|
||||
if (/* grass, but not snowgrass */
|
||||
(state->block == 2 && !(state->z < 127 && getArrayByte3D(state->blocks, state->x, state->y, state->z+1) == 78)) ||
|
||||
/* water */
|
||||
state->block == 8 || state->block == 9 ||
|
||||
/* leaves */
|
||||
state->block == 18 ||
|
||||
/* tallgrass, but not dead shrubs */
|
||||
@@ -187,6 +197,17 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
||||
/* grass */
|
||||
color = PySequence_GetItem(self->grasscolor, index);
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
/* water */
|
||||
if (self->watercolor)
|
||||
{
|
||||
color = PySequence_GetItem(self->watercolor, index);
|
||||
} else {
|
||||
color = NULL;
|
||||
facemask = NULL;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
/* leaves */
|
||||
color = PySequence_GetItem(self->foliagecolor, index);
|
||||
@@ -229,6 +250,14 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
||||
g = 175;
|
||||
b = 71;
|
||||
}
|
||||
|
||||
if (state->block == 8 || state->block == 9)
|
||||
/* water */
|
||||
{
|
||||
/* by default water is fine with nothing */
|
||||
facemask = NULL;
|
||||
}
|
||||
|
||||
if (state->block == 18 || state->block == 106) /* leaves and vines */
|
||||
{
|
||||
r = 37;
|
||||
@@ -237,6 +266,7 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
||||
}
|
||||
}
|
||||
|
||||
if (facemask)
|
||||
tint_with_mask(state->img, r, g, b, 255, facemask, state->imgx, state->imgy, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ typedef struct {
|
||||
/* biome data for the region */
|
||||
PyObject *biome_data;
|
||||
/* grasscolor and foliagecolor lookup tables */
|
||||
PyObject *grasscolor, *foliagecolor;
|
||||
PyObject *grasscolor, *foliagecolor, *watercolor;
|
||||
/* biome-compatible grass/leaf textures */
|
||||
PyObject *grass_texture;
|
||||
|
||||
|
||||
@@ -90,11 +90,12 @@ def _find_file(filename, mode="rb", verbose=False):
|
||||
|
||||
for jarpath in jarpaths:
|
||||
if os.path.exists(jarpath):
|
||||
try:
|
||||
jar = zipfile.ZipFile(jarpath)
|
||||
if verbose: logging.info("Found %s in '%s'", filename, jarpath)
|
||||
return jar.open(filename)
|
||||
except (KeyError, IOError):
|
||||
for jarfilename in [filename, 'misc/' + filename]:
|
||||
try:
|
||||
if verbose: logging.info("Found %s in '%s'", jarfilename, jarpath)
|
||||
return jar.open(jarfilename)
|
||||
except (KeyError, IOError), e:
|
||||
pass
|
||||
|
||||
raise IOError("Could not find the file `{0}'. You can either place it in the same place as overviewer.py, use --textures-path, or install the Minecraft client.".format(filename))
|
||||
@@ -2194,9 +2195,10 @@ currentBiomeFile = None
|
||||
currentBiomeData = None
|
||||
grasscolor = None
|
||||
foliagecolor = None
|
||||
watercolor = None
|
||||
|
||||
def prepareBiomeData(worlddir):
|
||||
global grasscolor, foliagecolor
|
||||
global grasscolor, foliagecolor, watercolor
|
||||
|
||||
# skip if the color files are already loaded
|
||||
if grasscolor and foliagecolor:
|
||||
@@ -2209,8 +2211,14 @@ def prepareBiomeData(worlddir):
|
||||
# try to find the biome color images. If _find_file can't locate them
|
||||
# then try looking in the EXTRACTEDBIOMES folder
|
||||
try:
|
||||
grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata())
|
||||
foliagecolor = list(Image.open(_find_file("foliagecolor.png")).getdata())
|
||||
grasscolor = list(_load_image("grasscolor.png").getdata())
|
||||
foliagecolor = list(_load_image("foliagecolor.png").getdata())
|
||||
# don't force the water color just yet
|
||||
# since the biome extractor doesn't know about it
|
||||
try:
|
||||
watercolor = list(_load_image("watercolor.png").getdata())
|
||||
except IOError:
|
||||
pass
|
||||
except IOError:
|
||||
try:
|
||||
grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata())
|
||||
@@ -2219,6 +2227,7 @@ def prepareBiomeData(worlddir):
|
||||
# clear anything that managed to get set
|
||||
grasscolor = None
|
||||
foliagecolor = None
|
||||
watercolor = None
|
||||
|
||||
def getBiomeData(worlddir, chunkX, chunkY):
|
||||
'''Opens the worlddir and reads in the biome color information
|
||||
|
||||
Reference in New Issue
Block a user