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;
};

View File

@@ -712,7 +712,7 @@ class Textures(object):
"""
img = Image.new("RGBA", (24,24), self.bgcolor)
front = tex.resize((14, 11), Image.ANTIALIAS)
front = tex.resize((14, 12), Image.ANTIALIAS)
alpha_over(img, front, (5,9))
return img
@@ -1443,8 +1443,16 @@ def wool(self, blockid, data):
# dandelion
sprite(blockid=37, imagename="assets/minecraft/textures/blocks/flower_dandelion.png")
# rose
sprite(blockid=38, imagename="assets/minecraft/textures/blocks/flower_rose.png")
# flowers
@material(blockid=38, data=range(10), transparent=True)
def flower(self, blockid, data):
flower_map = ["rose", "blue_orchid", "allium", "houstonia", "tulip_red", "tulip_orange",
"tulip_white", "tulip_pink", "oxeye_daisy", "dandelion"]
texture = self.load_image_texture("assets/minecraft/textures/blocks/flower_%s.png" % flower_map[data])
return self.build_billboard(texture)
# brown mushroom
sprite(blockid=39, imagename="assets/minecraft/textures/blocks/mushroom_brown.png")
# red mushroom
@@ -3849,7 +3857,7 @@ def beacon(self, blockid, data):
return img
# cobbleston and mossy cobblestone walls
# cobblestone and mossy cobblestone walls
# one additional bit of data value added for mossy and cobblestone
@material(blockid=139, data=range(32), transparent=True, nospawn=True)
def cobblestone_wall(self, blockid, data):
@@ -4184,3 +4192,25 @@ def stained_clay(self, blockid, data):
#coal block
block(blockid=173, top_image="assets/minecraft/textures/blocks/coal_block.png")
#doublePlant blocks
@material(blockid=175, data=range(16), transparent=True)
def flower(self, blockid, data):
doublePlant_map = ["sunflower", "syringa", "grass", "fern", "rose", "paeonia", "paeonia", "paeonia"]
plant = doublePlant_map[data & 0x7]
if data & 0x8:
part = "top"
else:
part = "bottom"
png = "assets/minecraft/textures/blocks/doublePlant_%s_%s.png" % (plant,part)
texture = self.load_image_texture(png)
img = self.build_billboard(texture)
#sunflower top
if data == 8:
bloom_tex = self.load_image_texture("assets/minecraft/textures/blocks/doublePlant_sunflower_front.png")
alpha_over(img, bloom_tex.resize((14, 11), Image.ANTIALIAS), (5,5))
return img