From 3f628dcc1b159e04ef9613de7a921f6018a4688a Mon Sep 17 00:00:00 2001 From: Alejandro Aguilera Date: Mon, 7 Nov 2011 13:16:35 +0100 Subject: [PATCH] Add all the 1.9 pre-release blocks. --- overviewer_core/textures.py | 451 ++++++++++++++++++++++++++++++++++++ 1 file changed, 451 insertions(+) diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index 71581f8..77a00d0 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -2340,3 +2340,454 @@ def trapdoor(blockid, data, north): img = build_full_block((texture, 12), None, None, texture, texture) return img + +# block with hidden silverfish (stone, cobblestone and stone brick) +@material(blockid=97, data=range(3), solid=True) +def hidden_silverfish(blockid, data): + if data == 0: # stone + t = terrain_images[1] + elif data == 1: # cobblestone + t = terrain_images[16] + elif data == 2: # stone brick + t = terrain_images[54] + + img = build_block(t, t) + + return img + +# stone brick +@material(blockid=98, data=range(3), solid=True) +def stone_brick(blockid, data): + 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 img + +# huge brown and red mushroom +@material(blockid=[99,100], data=range(11), solid=True) +def huge_mushroom(blockid, data, north): + # north rotation + 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 + + # texture generation + 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 img + +# iron bars and glass pane +# TODO glass pane is not a sprite, it has a texture for the side, +# at the moment is not used +@material(blockid=[101,102], data=range(16), transparent=True) +def panes(blockid, data): + # no north rotation, uses pseudo data + 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 img + +# melon +block(blockid=103, top_index=137, side_index=136, solid=True) + +# pumpkin and melon stem +# TODO To render it as in game needs from pseudo data and ancil data: +# once fully grown the stem bends to the melon/pumpkin block, +# at the moment only render the growing stem +@material(blockid=[104,105], data=range(8), transparent=True) +def stem(blockid, data, north): + # the ancildata value indicates how much of the texture + # is shown. + if data & 7 == 0: + # not fully grown stem or no pumpkin/melon touching it, + # straight up stem + t = terrain_images[111].copy() + img = Image.new("RGBA", (16,16), bgcolor) + composite.alpha_over(img, t, (0, int(16 - 16*((data + 1)/8.))), t) + img = build_sprite(t) + if data & 7 == 7: + # fully grown stem gets brown color! + # there is a conditional in rendermode-normal to not + # tint the data value 7 + img = tintTexture(img, (211,169,116)) + return img + + else: # fully grown, and a pumpking/melon touching it, + # corner stem + return None + +# vines +# TODO multiple sides of a block can contain vines! At the moment +# only pure directions are rendered +# (source http://www.minecraftwiki.net/wiki/Data_values#Vines) +@material(blockid=106, data=range(8), transparent=True) +def vines(blockid, data, north): + # north rotation + 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 + + # texture generation + img = Image.new("RGBA", (24,24), bgcolor) + raw_texture = terrain_images[143] + + if data == 2: # south + tex = transform_image_side(raw_texture) + composite.alpha_over(img, tex, (0,6), tex) + + if data == 1: # east + tex = transform_image_side(raw_texture).transpose(Image.FLIP_LEFT_RIGHT) + composite.alpha_over(img, tex, (12,6), tex) + + if data == 4: # west + tex = transform_image_side(raw_texture).transpose(Image.FLIP_LEFT_RIGHT) + composite.alpha_over(img, tex, (0,0), tex) + + if data == 8: # north + tex = transform_image_side(raw_texture) + composite.alpha_over(img, tex, (12,0), tex) + + return img + +# fence gates +@material(blockid=107, data=range(8), transparent=True) +def fence_gate(blockid, data, north): + + # north rotation + opened = False + if data & 0x4: + data = data & 0x3 + opened = True + if north == 'upper-left': + if data == 0: data = 1 + elif data == 1: data = 2 + elif data == 2: data = 3 + elif data == 3: data = 0 + elif north == 'upper-right': + if data == 0: data = 2 + elif data == 1: data = 3 + elif data == 2: data = 0 + elif data == 3: data = 1 + elif north == 'lower-right': + if data == 0: data = 3 + elif data == 1: data = 0 + elif data == 2: data = 1 + elif data == 3: data = 2 + if opened: + data = data | 0x4 + + # create the closed gate side + gate_side = terrain_images[4].copy() + gate_side_draw = ImageDraw.Draw(gate_side) + gate_side_draw.rectangle((7,0,15,0),outline=(0,0,0,0),fill=(0,0,0,0)) + gate_side_draw.rectangle((7,4,9,6),outline=(0,0,0,0),fill=(0,0,0,0)) + gate_side_draw.rectangle((7,10,15,16),outline=(0,0,0,0),fill=(0,0,0,0)) + gate_side_draw.rectangle((0,12,15,16),outline=(0,0,0,0),fill=(0,0,0,0)) + gate_side_draw.rectangle((0,0,4,15),outline=(0,0,0,0),fill=(0,0,0,0)) + gate_side_draw.rectangle((14,0,15,15),outline=(0,0,0,0),fill=(0,0,0,0)) + + # darken the sides slightly, as with the fences + sidealpha = gate_side.split()[3] + gate_side = ImageEnhance.Brightness(gate_side).enhance(0.9) + gate_side.putalpha(sidealpha) + + # create the other sides + mirror_gate_side = transform_image_side(gate_side.transpose(Image.FLIP_LEFT_RIGHT)) + gate_side = transform_image_side(gate_side) + gate_other_side = gate_side.transpose(Image.FLIP_LEFT_RIGHT) + mirror_gate_other_side = mirror_gate_side.transpose(Image.FLIP_LEFT_RIGHT) + + # Create img to compose the fence gate + img = Image.new("RGBA", (24,24), bgcolor) + + if data & 0x4: + # opened + data = data & 0x3 + if data == 0: + composite.alpha_over(img, gate_side, (2,8), gate_side) + composite.alpha_over(img, gate_side, (13,3), gate_side) + elif data == 1: + composite.alpha_over(img, gate_other_side, (-1,3), gate_other_side) + composite.alpha_over(img, gate_other_side, (10,8), gate_other_side) + elif data == 2: + composite.alpha_over(img, mirror_gate_side, (-1,7), mirror_gate_side) + composite.alpha_over(img, mirror_gate_side, (10,2), mirror_gate_side) + elif data == 3: + composite.alpha_over(img, mirror_gate_other_side, (2,1), mirror_gate_other_side) + composite.alpha_over(img, mirror_gate_other_side, (13,7), mirror_gate_other_side) + else: + # closed + + # positions for pasting the fence sides, as with fences + pos_top_left = (2,3) + pos_top_right = (10,3) + pos_bottom_right = (10,7) + pos_bottom_left = (2,7) + + if data == 0 or data == 2: + composite.alpha_over(img, gate_other_side, pos_top_right, gate_other_side) + composite.alpha_over(img, mirror_gate_other_side, pos_bottom_left, mirror_gate_other_side) + elif data == 1 or data == 3: + composite.alpha_over(img, gate_side, pos_top_left, gate_side) + composite.alpha_over(img, mirror_gate_side, pos_bottom_right, mirror_gate_side) + + return img + +# mycelium +block(blockid=110, top_index=78, side_index=77) + +# lilypad +# TODO the data-block orientation relation is not clear +@material(blockid=111, data=range(4), transparent=True) +def lilypad(blockid, data, north): + if north == 'upper-left': + if data == 0: data = 2 + elif data == 1: data = 3 + elif data == 2: data = 1 + elif data == 3: data = 0 + elif north == 'upper-right': + if data == 0: data = 1 + elif data == 1: data = 0 + elif data == 2: data = 3 + elif data == 3: data = 2 + elif north == 'lower-right': + if data == 0: data = 3 + elif data == 1: data = 2 + elif data == 2: data = 0 + elif data == 3: data = 1 + + t = terrain_images[76] # NOTE: using same data as stairs, no + # info in minepedia at the moment. + if data == 0: # pointing south + img = build_full_block(None, None, None, None, None, t) + elif data == 1: # pointing north + img = build_full_block(None, None, None, None, None, t.rotate(180)) + elif data == 2: # pointing west + img = build_full_block(None, None, None, None, None, t.rotate(270)) + elif data == 3: # pointing east + img = build_full_block(None, None, None, None, None, t.rotate(90)) + + return img + +# nether brick +block(blockid=112, top_index=224, side_index=224) + +# nether wart +@material(blockid=115, data=range(4), transparent=True) +def nether_wart(blockid, data): + if data == 0: # just come up + t = terrain_images[226] + elif data in (1, 2): + t = terrain_images[227] + else: # fully grown + t = terrain_images[228] + + # use the same technic as tall grass + img = build_billboard(t) + + return img + +# enchantment table +# TODO there's no book at the moment +@material(blockid=116, transparent=True) +def enchantment_table(blockid, data): + # no book at the moment + top = terrain_images[166] + side = terrain_images[182] + img = build_full_block((top, 4), None, None, side, side) + + return img + +# brewing stand +# TODO this is a place holder, is a 2d image pasted +@material(blockid=117, data=range(5), transparent=True) +def brewing_stand(blockid, data, north): + t = terrain_images[157] + img = build_billboard(t) + return img + +# cauldron +@material(blockid=118, data=range(4), transparent=True) +def cauldron(blockid, data): + side = terrain_images[154] + top = terrain_images[138] + bottom = terrain_images[139] + water = transform_image_top(_load_image("water.png")) + if data == 0: # empty + img = build_full_block(top, side, side, side, side) + if data == 1: # 1/3 filled + img = build_full_block(None , side, side, None, None) + composite.alpha_over(img, water, (0,8), water) + img2 = build_full_block(top , None, None, side, side) + composite.alpha_over(img, img2, (0,0), img2) + if data == 2: # 2/3 filled + img = build_full_block(None , side, side, None, None) + composite.alpha_over(img, water, (0,4), water) + img2 = build_full_block(top , None, None, side, side) + composite.alpha_over(img, img2, (0,0), img2) + if data == 3: # 3/3 filled + img = build_full_block(None , side, side, None, None) + composite.alpha_over(img, water, (0,0), water) + img2 = build_full_block(top , None, None, side, side) + composite.alpha_over(img, img2, (0,0), img2) + + return img + +# end portal +@material(blockid=119, transparent=True) +def end_portal(blockid, data): + img = Image.new("RGBA", (24,24), bgcolor) + # generate a black texure with white, blue and grey dots resembling stars + t = Image.new("RGBA", (16,16), (0,0,0,255)) + for color in [(155,155,155,255), (100,255,100,255), (255,255,255,255)]: + for i in range(6): + x = randint(0,15) + y = randint(0,15) + t.putpixel((x,y),color) + + t = transform_image_top(t) + composite.alpha_over(img, t, (0,0), t) + + return img + +# end portal frame +@material(blockid=120, data=range(5), transparent=True) +def end_porta_frame(blockid, data): + # The bottom 2 bits are oritation info but seems there is no + # graphical difference between orientations + top = terrain_images[158] + eye_t = terrain_images[174] + side = terrain_images[159] + img = build_full_block((top, 4), None, None, side, side) + if data & 0x4 == 0x4: # ender eye on it + # generate the eye + eye_t = terrain_images[174].copy() + eye_t_s = terrain_images[174].copy() + # cut out from the texture the side and the top of the eye + ImageDraw.Draw(eye_t).rectangle((0,0,15,4),outline=(0,0,0,0),fill=(0,0,0,0)) + ImageDraw.Draw(eye_t_s).rectangle((0,4,15,15),outline=(0,0,0,0),fill=(0,0,0,0)) + # trnasform images and paste + eye = transform_image_top(eye_t) + eye_s = transform_image_side(eye_t_s) + eye_os = eye_s.transpose(Image.FLIP_LEFT_RIGHT) + composite.alpha_over(img, eye_s, (5,5), eye_s) + composite.alpha_over(img, eye_os, (9,5), eye_os) + composite.alpha_over(img, eye, (0,0), eye) + + return img + +# end stone +block(blockid=121, top_index=175)