0

Merge remote-tracking branch 'origin/18prep'

This commit is contained in:
Andrew Chin
2011-09-14 09:27:36 -04:00
5 changed files with 209 additions and 22 deletions

View File

@@ -129,7 +129,8 @@ def get_tileentity_data(level):
transparent_blocks = set([ 0, 6, 8, 9, 18, 20, 26, 27, 28, 29, 30, 31, 32, 33,
34, 37, 38, 39, 40, 44, 50, 51, 52, 53, 55, 59, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79,
81, 83, 85, 90, 92, 93, 94, 96])
81, 83, 85, 90, 92, 93, 94, 96, 101, 102, 104, 105,
106, 107, 108, 109])
# This set holds block ids that are solid blocks
solid_blocks = set([1, 2, 3, 4, 5, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,

View File

@@ -283,7 +283,9 @@ generate_pseudo_data(RenderState *state, unsigned char ancilData) {
return final_data;
} else if (state->block == 90) {
/* fences, iron bars and glass panes */
} else if ((state->block == 90) || (state->block == 101) ||
(state->block == 102)) {
return check_adjacent_blocks(state, x, y, z, state->block);
}
@@ -413,11 +415,12 @@ chunk_render(PyObject *self, PyObject *args) {
state.block_data = ancilData;
/* block that need pseudo ancildata:
* grass, water, glass, chest, restone wire,
* ice, fence and portal. */
* 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 == 85) || (state.block == 90) ||
(state.block == 101) || (state.block == 102)) {
ancilData = generate_pseudo_data(&state, ancilData);
state.block_pdata = ancilData;
} else {

View File

@@ -117,7 +117,7 @@ estimate_blocklevel(RenderModeLighting *self, RenderState *state,
blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z);
/* no longer a guess */
if (!(block == 44 || block == 53 || block == 67) && authoratative) {
if (!(block == 44 || block == 53 || block == 67 || block == 108 || block == 109) && authoratative) {
*authoratative = 1;
}
@@ -173,7 +173,7 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state,
blocklevel = getArrayByte3D(blocklight, local_x, local_y, local_z);
/* special half-step handling */
if (block == 44 || block == 53 || block == 67) {
if (block == 44 || block == 53 || block == 67 || block == 108 || block == 109) {
unsigned int upper_block;
/* stairs and half-blocks take the skylevel from the upper block if it's transparent */
@@ -183,7 +183,7 @@ get_lighting_coefficient(RenderModeLighting *self, RenderState *state,
do {
upper_counter++;
upper_block = getArrayByte3D(blocks, local_x, local_y, local_z + upper_counter);
} while ((upper_block == 44 || upper_block == 54 || upper_block == 67) && local_z < 127);
} while ((upper_block == 44 || upper_block == 53 || upper_block == 67 || upper_block == 108 || upper_block == 109) && local_z < 127);
if (is_transparent(upper_block)) {
skylevel = getArrayByte3D(skylight, local_x, local_y, local_z + upper_counter);
}

View File

@@ -213,6 +213,11 @@ rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *
break;
}
break;
case 106:
/* vines */
color = PySequence_GetItem(self->grasscolor, index);
facemask = mask;
break;
default:
break;
};

View File

@@ -435,8 +435,10 @@ def _build_blockimages():
36, 37, -1, -1, 65, -1, -1, -1, 50, 24, -1, -1, 86, -1, -1, -1,
# 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
-1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 51, -1, -1, -1, 66, -1,
# 80 81 82 83 84 85 86 87 88 89 90 91
66, 69, 72, 73, 75, -1,102,103,104,105,-1, 102 # clay?
# 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
66, 69, 72, 73, 75, -1,102,103,104,105,-1, 102, -1, -1, -1, -1,
# 96 97 98 99 100 101 102 103
-1, -1, -1, -1, -1, -1, -1, 137,
]
# NOTE: For non-block textures, the sideid is ignored, but can't be -1
@@ -452,8 +454,10 @@ def _build_blockimages():
36, 37, -1, -1, 65, -1, -1,101, 50, 24, -1, -1, 86, -1, -1, -1,
# 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
-1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 51, -1, -1, -1, 66, -1,
# 80 81 82 83 84 85 86 87 88 89 90 91
66, 70, 72, 73, 74,-1 ,118,103,104,105, -1, 118
# 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
66, 70, 72, 73, 74,-1 ,118,103,104,105, -1, 118,-1, -1, -1, -1,
# 96 97 98 99 100 101 102 103
-1, -1, -1, -1, -1, -1, -1, 136,
]
# This maps block id to the texture that goes on the side of the block
@@ -845,13 +849,17 @@ def generate_special_texture(blockID, data):
if data == 0: # stone slab
top = terrain_images[6]
side = terrain_images[5]
if data == 1: # stone slab
elif data == 1: # stone slab
top = terrain_images[176]
side = terrain_images[192]
if data == 2: # wooden slab
elif data == 2: # wooden slab
top = side = terrain_images[4]
if data == 3: # cobblestone slab
elif data == 3: # cobblestone slab
top = side = terrain_images[16]
elif data == 4: # brick?
top = side = terrain_images[7]
elif data == 5: # stone brick?
top = side = terrain_images[54]
img = _build_block(top, side, blockID)
return generate_texture_tuple(img, blockID)
@@ -926,13 +934,16 @@ def generate_special_texture(blockID, data):
return generate_texture_tuple(img, blockID)
if blockID in (53,67): # wooden and cobblestone stairs.
if blockID in (53,67, 108, 109): # wooden, stone brick, and cobblestone stairs.
if blockID == 53: # wooden
texture = terrain_images[4]
elif blockID == 67: # cobblestone
texture = terrain_images[16]
elif blockID == 108: # red brick stairs
texture = terrain_images[7]
elif blockID == 109: # stone brick stairs
texture = terrain_images[54]
side = texture.copy()
half_block_u = texture.copy() # up, down, left, right
@@ -1682,6 +1693,118 @@ def generate_special_texture(blockID, data):
return generate_texture_tuple(img, blockID)
if blockID == 98: # normal, mossy and cracked stone brick
if data == 0: # normal
t = terrain_images[54]
elif data == 1: # mossy
t = terrain_images[100]
else: # cracked
t = terrain_images[101]
img = _build_full_block(t, None, None, t, t)
return generate_texture_tuple(img, blockID)
if blockID == 99 or blockID == 100: # huge brown and red mushroom
if blockID == 99: # brown
cap = terrain_images[126]
else: # red
cap = terrain_images[125]
stem = terrain_images[141]
porous = terrain_images[142]
if data == 0: # fleshy piece
img = _build_full_block(porous, None, None, porous, porous)
if data == 1: # north-east corner
img = _build_full_block(cap, None, None, cap, porous)
if data == 2: # east side
img = _build_full_block(cap, None, None, porous, porous)
if data == 3: # south-east corner
img = _build_full_block(cap, None, None, porous, cap)
if data == 4: # north side
img = _build_full_block(cap, None, None, cap, porous)
if data == 5: # top piece
img = _build_full_block(cap, None, None, porous, porous)
if data == 6: # south side
img = _build_full_block(cap, None, None, cap, porous)
if data == 7: # north-west corner
img = _build_full_block(cap, None, None, cap, cap)
if data == 8: # west side
img = _build_full_block(cap, None, None, porous, cap)
if data == 9: # south-west corner
img = _build_full_block(cap, None, None, porous, cap)
if data == 10: # stem
img = _build_full_block(porous, None, None, stem, stem)
return generate_texture_tuple(img, blockID)
if blockID == 101 or blockID == 102: # iron bars and glass panes
if blockID == 101:
# iron bars
t = terrain_images[85]
else:
# glass panes
t = terrain_images[49]
left = t.copy()
right = t.copy()
# generate the four small pieces of the glass pane
ImageDraw.Draw(right).rectangle((0,0,7,15),outline=(0,0,0,0),fill=(0,0,0,0))
ImageDraw.Draw(left).rectangle((8,0,15,15),outline=(0,0,0,0),fill=(0,0,0,0))
up_left = transform_image_side(left)
up_right = transform_image_side(right).transpose(Image.FLIP_TOP_BOTTOM)
dw_right = transform_image_side(right)
dw_left = transform_image_side(left).transpose(Image.FLIP_TOP_BOTTOM)
# Create img to compose the texture
img = Image.new("RGBA", (24,24), bgcolor)
# +x axis points top right direction
# +y axis points bottom right direction
# First compose things in the back of the image,
# then things in the front.
if (data & 0b0001) == 1 or data == 0:
composite.alpha_over(img,up_left, (6,3),up_left) # top left
if (data & 0b1000) == 8 or data == 0:
composite.alpha_over(img,up_right, (6,3),up_right) # top right
if (data & 0b0010) == 2 or data == 0:
composite.alpha_over(img,dw_left, (6,3),dw_left) # bottom left
if (data & 0b0100) == 4 or data == 0:
composite.alpha_over(img,dw_right, (6,3),dw_right) # bottom right
return generate_texture_tuple(img, blockID)
if blockID == 106: # vine
img = Image.new("RGBA", (24,24), bgcolor)
raw_texture = terrain_images[143]
# print "vine is facing: %d" % data
if data == 2: # south
tex = transform_image_side(raw_texture)
composite.alpha_over(img, tex, (0,6), tex)
return generate_texture_tuple(img, blockID)
if data == 1: # east
tex = transform_image_side(raw_texture).transpose(Image.FLIP_LEFT_RIGHT)
composite.alpha_over(img, tex, (12,6), tex)
return generate_texture_tuple(img, blockID)
if data == 4: # west
tex = transform_image_side(raw_texture).transpose(Image.FLIP_LEFT_RIGHT)
composite.alpha_over(img, tex, (0,0), tex)
return generate_texture_tuple(img, blockID)
if data == 8: # north
tex = transform_image_side(raw_texture)
composite.alpha_over(img, tex, (12,0), tex)
return generate_texture_tuple(img, blockID)
return None
@@ -1775,7 +1898,7 @@ def convert_data(blockID, data):
elif data == 2: data = 3
elif data == 3: data = 1
elif data == 4: data = 2
if blockID in (53,67): # wooden and cobblestone stairs.
if blockID in (53,67,108,109): # wooden and cobblestone stairs.
if _north == 'upper-left':
if data == 0: data = 2
elif data == 1: data = 3
@@ -1913,7 +2036,50 @@ def convert_data(blockID, data):
elif (data & 0b0011) == 1: data = data & 0b1100 | 3
elif (data & 0b0011) == 2: data = data & 0b1100 | 1
elif (data & 0b0011) == 3: data = data & 0b1100 | 0
if blockID == 99 or blockID == 100: # huge red and brown mushroom
if _north == 'upper-left':
if data == 1: data = 3
elif data == 2: data = 6
elif data == 3: data = 9
elif data == 4: data = 2
elif data == 6: data = 8
elif data == 7: data = 1
elif data == 8: data = 4
elif data == 9: data = 7
elif _north == 'upper-right':
if data == 1: data = 9
elif data == 2: data = 8
elif data == 3: data = 7
elif data == 4: data = 6
elif data == 6: data = 4
elif data == 7: data = 3
elif data == 8: data = 2
elif data == 9: data = 1
elif _north == 'lower-right':
if data == 1: data = 7
elif data == 2: data = 4
elif data == 3: data = 1
elif data == 4: data = 2
elif data == 6: data = 8
elif data == 7: data = 9
elif data == 8: data = 6
elif data == 9: data = 3
if blockID == 106: # vine
if _north == 'upper-left':
if data == 1: data = 2
elif data == 4: data = 8
elif data == 8: data = 1
elif data == 2: data = 4
elif _north == 'upper-right':
if data == 1: data = 4
elif data == 4: data = 1
elif data == 8: data = 2
elif data == 2: data = 8
elif _north == 'lower-right':
if data == 1: data = 8
elif data == 4: data = 2
elif data == 8: data = 4
elif data == 2: data = 1
return data
def tintTexture(im, c):
@@ -2008,7 +2174,8 @@ def getBiomeData(worlddir, chunkX, chunkY):
special_blocks = set([ 2, 6, 9, 17, 18, 20, 26, 23, 27, 28, 29, 31, 33,
34, 35, 43, 44, 50, 51, 53, 54, 55, 58, 59, 61, 62,
63, 64, 65, 66, 67, 68, 71, 75, 76, 79, 85, 86, 90,
91, 92, 93, 94, 96])
91, 92, 93, 94, 96, 98, 99, 100, 101, 102, 106, 108,
109])
# this is a map of special blockIDs to a list of all
# possible values for ancillary data that it might have.
@@ -2027,8 +2194,8 @@ special_map[29] = (0,1,2,3,4,5,8,9,10,11,12,13) # sticky piston body, orientatio
special_map[33] = (0,1,2,3,4,5,8,9,10,11,12,13) # normal piston body, orientation, pushed in/out
special_map[34] = (0,1,2,3,4,5,8,9,10,11,12,13) # normal and sticky piston extension, orientation, sticky/normal
special_map[35] = range(16) # wool, colored and white
special_map[43] = range(4) # stone, sandstone, wooden and cobblestone double-slab
special_map[44] = range(4) # stone, sandstone, wooden and cobblestone slab
special_map[43] = range(6) # stone, sandstone, wooden and cobblestone double-slab
special_map[44] = range(6) # stone, sandstone, wooden and cobblestone slab
special_map[50] = (1,2,3,4,5) # torch, position in the block
special_map[51] = range(16) # fire, position in the block (not implemented)
special_map[53] = range(4) # wooden stairs, orientation
@@ -2056,6 +2223,14 @@ special_map[92] = range(6) # cake, eaten amount, (not implemented)
special_map[93] = range(16) # OFF redstone repeater, orientation and delay
special_map[94] = range(16) # ON redstone repeater, orientation and delay
special_map[96] = range(8) # trapdoor, open, closed, orientation
special_map[98] = range(3) # stone brick, normal, mossy and cracked
special_map[99] = range(11) # huge brown mushroom, side, corner, etc, piece
special_map[100] = range(11) # huge red mushroom, side, corner, etc, piece
special_map[101]= range(16) # iron bars, all the possible combination, uses pseudo data
special_map[102]= range(16) # glass panes, all the possible combination, uses pseudo data
special_map[106] = (1,2,4,8) # vine, orientation
special_map[108]= range(4) # red stairs, orientation
special_map[109]= range(4) # stonebrick stairs, orientation
# grass and leaves are graysacle in terrain.png
# we treat them as special so we can manually tint them
@@ -2076,6 +2251,7 @@ biome_grass_texture = None
biome_tall_grass_texture = None
biome_tall_fern_texture = None
biome_leaf_texture = None
biome_vine_texture = None
specialblockmap = None
def generate(path=None,texture_size=24,bgc = (26,26,26,0),north_direction='lower-left'):
@@ -2098,11 +2274,12 @@ def generate(path=None,texture_size=24,bgc = (26,26,26,0),north_direction='lower
load_water()
# generate biome (still grayscale) leaf, grass textures
global biome_grass_texture, biome_leaf_texture, biome_tall_grass_texture, biome_tall_fern_texture
global biome_grass_texture, biome_leaf_texture, biome_tall_grass_texture, biome_tall_fern_texture, biome_vine_texture
biome_grass_texture = _build_block(terrain_images[0], terrain_images[38], 2)
biome_leaf_texture = _build_block(terrain_images[52], terrain_images[52], 18)
biome_tall_grass_texture = _build_block(terrain_images[39], terrain_images[39], 31)
biome_tall_fern_texture = _build_block(terrain_images[56], terrain_images[56], 31)
biome_vine_texture = _build_block(terrain_images[143], terrain_images[143], 106)
# generate the special blocks
global specialblockmap, special_blocks
@@ -2117,6 +2294,7 @@ def generate(path=None,texture_size=24,bgc = (26,26,26,0),north_direction='lower
biome_leaf_texture = biome_leaf_texture.resize(texture_dimensions, Image.ANTIALIAS)
biome_tall_grass_texture = biome_tall_grass_texture.resize(texture_dimensions, Image.ANTIALIAS)
biome_tall_fern_texture = biome_tall_fern_texture.resize(texture_dimensions, Image.ANTIALIAS)
biome_vine_texture = biome_vine_texture.resize(texture_dimensions, Image.ANTIALIAS)
# rescale the normal block images
for i in range(len(blockmap)):