0

Merge Pull Request #987

This commit is contained in:
Andrew Chin
2013-09-17 19:28:37 -04:00
3 changed files with 63 additions and 9 deletions

View File

@@ -252,7 +252,7 @@ generate_pseudo_data(RenderState *state, unsigned char ancilData) {
*/
int x = state->x, y = state->y, z = state->z;
unsigned char data = 0;
if (state->block == 2) { /* grass */
/* return 0x10 if grass is covered in snow */
if (get_data(state, BLOCKS, x, y+1, z) == 78)
@@ -416,6 +416,17 @@ generate_pseudo_data(RenderState *state, unsigned char ancilData) {
pr = pr * pr * 42317861 + pr * 11;
rotation = 3 & (pr >> 16);
return rotation;
} else if (state->block == 175) { /* doublePlants */
/* use bottom block data format plus one bit for top
* block (0x8)
*/
if( get_data(state, BLOCKS, x, y-1, z) == 175 ) {
data = get_data(state, DATA, x, y-1, z) | 0x8;
} else {
data = ancilData;
}
return data;
}
@@ -564,7 +575,7 @@ chunk_render(PyObject *self, PyObject *args) {
(state.block == 85) || (state.block == 90) ||
(state.block == 101) || (state.block == 102) ||
(state.block == 111) || (state.block == 113) ||
(state.block == 139)) {
(state.block == 139) || (state.block == 175)) {
ancilData = generate_pseudo_data(&state, ancilData);
state.block_pdata = ancilData;
} else {
@@ -586,6 +597,7 @@ chunk_render(PyObject *self, PyObject *args) {
if (t != NULL && t != Py_None)
{
PyObject *src, *mask, *mask_light;
int do_rand = (state.block == 31 /*|| state.block == 38 || state.block == 175*/);
int randx = 0, randy = 0;
src = PyTuple_GetItem(t, 0);
mask = PyTuple_GetItem(t, 0);
@@ -594,7 +606,7 @@ chunk_render(PyObject *self, PyObject *args) {
if (mask == Py_None)
mask = src;
if (state.block == 31) {
if (do_rand) {
/* add a random offset to the postion of the tall grass to make it more wild */
randx = rand() % 6 + 1 - 3;
randy = rand() % 6 + 1 - 3;
@@ -604,7 +616,7 @@ chunk_render(PyObject *self, PyObject *args) {
render_mode_draw(rendermode, src, mask, mask_light);
if (state.block == 31) {
if (do_rand) {
/* undo the random offsets */
state.imgx -= randx;
state.imgy -= randy;

View File

@@ -74,6 +74,10 @@ static void
base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
PrimitiveBase *self = (PrimitiveBase *)data;
/* in order to detect top parts of doublePlant grass & ferns */
unsigned char below_block = get_data(state, BLOCKS, state->x, state->y-1, state->z);
unsigned char below_data = get_data(state, DATA, state->x, state->y-1, state->z);
/* draw the block! */
alpha_over(state->img, src, mask, state->imgx, state->imgy, 0, 0);
@@ -102,7 +106,11 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
/* vines */
state->block == 106 ||
/* lily pads */
state->block == 111)
state->block == 111 ||
/* doublePlant grass & ferns */
(state->block == 175 && (state->block_data == 2 || state->block_data == 3)) ||
/* doublePlant grass & ferns tops */
(state->block == 175 && below_block == 175 && (below_data == 2 || below_data == 3)) )
{
/* do the biome stuff! */
PyObject *facemask = mask;
@@ -155,6 +163,10 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
/* lily pads */
color_table = self->grasscolor;
break;
case 175:
/* doublePlant grass & ferns */
color_table = self->grasscolor;
break;
default:
break;
};