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 {
|
} else {
|
||||||
self->foliagecolor = PyObject_GetAttrString(state->textures, "foliagecolor");
|
self->foliagecolor = PyObject_GetAttrString(state->textures, "foliagecolor");
|
||||||
self->grasscolor = PyObject_GetAttrString(state->textures, "grasscolor");
|
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 {
|
} else {
|
||||||
self->biome_data = NULL;
|
self->biome_data = NULL;
|
||||||
self->foliagecolor = NULL;
|
self->foliagecolor = NULL;
|
||||||
self->grasscolor = NULL;
|
self->grasscolor = NULL;
|
||||||
|
self->watercolor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(use_biomes);
|
Py_DECREF(use_biomes);
|
||||||
@@ -103,6 +110,7 @@ rendermode_normal_finish(void *data, RenderState *state) {
|
|||||||
Py_XDECREF(self->biome_data);
|
Py_XDECREF(self->biome_data);
|
||||||
Py_XDECREF(self->foliagecolor);
|
Py_XDECREF(self->foliagecolor);
|
||||||
Py_XDECREF(self->grasscolor);
|
Py_XDECREF(self->grasscolor);
|
||||||
|
Py_XDECREF(self->watercolor);
|
||||||
Py_XDECREF(self->grass_texture);
|
Py_XDECREF(self->grass_texture);
|
||||||
Py_XDECREF(self->black_color);
|
Py_XDECREF(self->black_color);
|
||||||
Py_XDECREF(self->white_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 */
|
if (/* grass, but not snowgrass */
|
||||||
(state->block == 2 && !(state->z < 127 && getArrayByte3D(state->blocks, state->x, state->y, state->z+1) == 78)) ||
|
(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 */
|
/* leaves */
|
||||||
state->block == 18 ||
|
state->block == 18 ||
|
||||||
/* tallgrass, but not dead shrubs */
|
/* tallgrass, but not dead shrubs */
|
||||||
@@ -187,6 +197,17 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
|||||||
/* grass */
|
/* grass */
|
||||||
color = PySequence_GetItem(self->grasscolor, index);
|
color = PySequence_GetItem(self->grasscolor, index);
|
||||||
break;
|
break;
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
/* water */
|
||||||
|
if (self->watercolor)
|
||||||
|
{
|
||||||
|
color = PySequence_GetItem(self->watercolor, index);
|
||||||
|
} else {
|
||||||
|
color = NULL;
|
||||||
|
facemask = NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 18:
|
case 18:
|
||||||
/* leaves */
|
/* leaves */
|
||||||
color = PySequence_GetItem(self->foliagecolor, index);
|
color = PySequence_GetItem(self->foliagecolor, index);
|
||||||
@@ -221,14 +242,22 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
|||||||
Py_DECREF(color);
|
Py_DECREF(color);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (state->block == 2 || state->block == 31 ||
|
if (state->block == 2 || state->block == 31 ||
|
||||||
state->block == 104 || state->block == 105)
|
state->block == 104 || state->block == 105)
|
||||||
/* grass and pumpkin/melon stems */
|
/* grass and pumpkin/melon stems */
|
||||||
{
|
{
|
||||||
r = 115;
|
r = 115;
|
||||||
g = 175;
|
g = 175;
|
||||||
b = 71;
|
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 */
|
if (state->block == 18 || state->block == 106) /* leaves and vines */
|
||||||
{
|
{
|
||||||
r = 37;
|
r = 37;
|
||||||
@@ -237,7 +266,8 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tint_with_mask(state->img, r, g, b, 255, facemask, state->imgx, state->imgy, 0, 0);
|
if (facemask)
|
||||||
|
tint_with_mask(state->img, r, g, b, 255, facemask, state->imgx, state->imgy, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->height_fading) {
|
if (self->height_fading) {
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ typedef struct {
|
|||||||
/* biome data for the region */
|
/* biome data for the region */
|
||||||
PyObject *biome_data;
|
PyObject *biome_data;
|
||||||
/* grasscolor and foliagecolor lookup tables */
|
/* grasscolor and foliagecolor lookup tables */
|
||||||
PyObject *grasscolor, *foliagecolor;
|
PyObject *grasscolor, *foliagecolor, *watercolor;
|
||||||
/* biome-compatible grass/leaf textures */
|
/* biome-compatible grass/leaf textures */
|
||||||
PyObject *grass_texture;
|
PyObject *grass_texture;
|
||||||
|
|
||||||
|
|||||||
@@ -90,12 +90,13 @@ def _find_file(filename, mode="rb", verbose=False):
|
|||||||
|
|
||||||
for jarpath in jarpaths:
|
for jarpath in jarpaths:
|
||||||
if os.path.exists(jarpath):
|
if os.path.exists(jarpath):
|
||||||
try:
|
jar = zipfile.ZipFile(jarpath)
|
||||||
jar = zipfile.ZipFile(jarpath)
|
for jarfilename in [filename, 'misc/' + filename]:
|
||||||
if verbose: logging.info("Found %s in '%s'", filename, jarpath)
|
try:
|
||||||
return jar.open(filename)
|
if verbose: logging.info("Found %s in '%s'", jarfilename, jarpath)
|
||||||
except (KeyError, IOError):
|
return jar.open(jarfilename)
|
||||||
pass
|
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))
|
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
|
currentBiomeData = None
|
||||||
grasscolor = None
|
grasscolor = None
|
||||||
foliagecolor = None
|
foliagecolor = None
|
||||||
|
watercolor = None
|
||||||
|
|
||||||
def prepareBiomeData(worlddir):
|
def prepareBiomeData(worlddir):
|
||||||
global grasscolor, foliagecolor
|
global grasscolor, foliagecolor, watercolor
|
||||||
|
|
||||||
# skip if the color files are already loaded
|
# skip if the color files are already loaded
|
||||||
if grasscolor and foliagecolor:
|
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
|
# try to find the biome color images. If _find_file can't locate them
|
||||||
# then try looking in the EXTRACTEDBIOMES folder
|
# then try looking in the EXTRACTEDBIOMES folder
|
||||||
try:
|
try:
|
||||||
grasscolor = list(Image.open(_find_file("grasscolor.png")).getdata())
|
grasscolor = list(_load_image("grasscolor.png").getdata())
|
||||||
foliagecolor = list(Image.open(_find_file("foliagecolor.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:
|
except IOError:
|
||||||
try:
|
try:
|
||||||
grasscolor = list(Image.open(os.path.join(biomeDir,"grasscolor.png")).getdata())
|
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
|
# clear anything that managed to get set
|
||||||
grasscolor = None
|
grasscolor = None
|
||||||
foliagecolor = None
|
foliagecolor = None
|
||||||
|
watercolor = None
|
||||||
|
|
||||||
def getBiomeData(worlddir, chunkX, chunkY):
|
def getBiomeData(worlddir, chunkX, chunkY):
|
||||||
'''Opens the worlddir and reads in the biome color information
|
'''Opens the worlddir and reads in the biome color information
|
||||||
|
|||||||
Reference in New Issue
Block a user