diff --git a/chunk.py b/chunk.py index 2817979..a1deab1 100644 --- a/chunk.py +++ b/chunk.py @@ -272,8 +272,10 @@ class ChunkRenderer(object): # alone. additional data is required. # TODO torches, redstone torches, crops, ladders, stairs, # levers, doors, buttons, and signs all need to be handled here (and in textures.py) - if blockid in (66,59,61,62, 65): ## minecart track, crops, ladder - # also handle furnaces here, since one side has a different texture than the other + + ## minecart track, crops, ladder, doors + if blockid in (66,59,61,62, 65,64,71): + # also handle furnaces here, since one side has a different texture than the other ancilData = blockData_expanded[x,y,z] t = textures.generate_special_texture(blockid, ancilData) diff --git a/textures.py b/textures.py index dbcac8a..755dae7 100644 --- a/textures.py +++ b/textures.py @@ -421,6 +421,56 @@ def generate_special_texture(blockID, data): img.paste(tex, (12,0), tex) return (img.convert("RGB"), img.split()[3]) + if blockID in (64,71): #wooden door, or iron door + if data & 0x8 == 0x8: # top of the door + raw_door = terrain_images[81 if blockID == 64 else 82] + else: # bottom of the door + raw_door = terrain_images[97 if blockID == 64 else 98] + + # if you want to render all doors as closed, then force + # force swung to be False + if data & 0x4 == 0x4: + swung=True + else: + swung=False + # mask out the high bits to figure out the orientation + img = Image.new("RGBA", (24,24), (38,92,255,0)) + if (data & 0x03) == 0: + if not swung: + tex = _transform_image_side(raw_door) + img.paste(tex, (0,6), tex) + else: + # flip first to set the doornob on the correct side + tex = _transform_image_side(raw_door.transpose(Image.FLIP_LEFT_RIGHT)) + tex = tex.transpose(Image.FLIP_LEFT_RIGHT) + img.paste(tex, (0,0), tex) + + if (data & 0x03) == 1: + if not swung: + tex = _transform_image_side(raw_door).transpose(Image.FLIP_LEFT_RIGHT) + img.paste(tex, (0,0), tex) + else: + tex = _transform_image_side(raw_door) + img.paste(tex, (12,0), tex) + + if (data & 0x03) == 2: + if not swung: + tex = _transform_image_side(raw_door.transpose(Image.FLIP_LEFT_RIGHT)) + img.paste(tex, (12,0), tex) + else: + tex = _transform_image_side(raw_door).transpose(Image.FLIP_LEFT_RIGHT) + img.paste(tex, (12,6), tex) + + if (data & 0x03) == 3: + if not swung: + tex = _transform_image_side(raw_door.transpose(Image.FLIP_LEFT_RIGHT)).transpose(Image.FLIP_LEFT_RIGHT) + img.paste(tex, (12,6), tex) + else: + tex = _transform_image_side(raw_door.transpose(Image.FLIP_LEFT_RIGHT)) + img.paste(tex, (0,6), tex) + + return (img.convert("RGB"), img.split()[3]) + return None