Add beds and some changes in _build_full_block to simplify the building of fractions of a block.
This commit is contained in:
93
textures.py
93
textures.py
@@ -273,9 +273,37 @@ def _build_full_block(top, side1, side2, side3, side4, bottom=None, blockID=None
|
|||||||
side3 is in the -x (bottom left, north)
|
side3 is in the -x (bottom left, north)
|
||||||
side4 is in the +y (bottom right, west)
|
side4 is in the +y (bottom right, west)
|
||||||
|
|
||||||
A non transparent block uses top, side 3 and side 4
|
A non transparent block uses top, side 3 and side 4.
|
||||||
|
|
||||||
|
If top is a tuple then first member is the top image and the second
|
||||||
|
member is an increment (integer) from 0 to 12. This increment will
|
||||||
|
used to crop the side images to look like a block and to paste all
|
||||||
|
the images increment pixels lower. Using increment = 6 will create
|
||||||
|
a half-block.
|
||||||
|
|
||||||
|
NOTE: this method uses the top of the texture image (as done in
|
||||||
|
minecraft with beds)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
increment = 0
|
||||||
|
if isinstance(top, tuple):
|
||||||
|
increment = top[1]
|
||||||
|
crop_height = int(increment * 16./12.)
|
||||||
|
top = top[0]
|
||||||
|
if side1 != None:
|
||||||
|
side1 = side1.copy()
|
||||||
|
ImageDraw.Draw(side1).rectangle((0, 16 - crop_height,16,16),outline=(0,0,0,0),fill=(0,0,0,0))
|
||||||
|
if side2 != None:
|
||||||
|
side2 = side2.copy()
|
||||||
|
ImageDraw.Draw(side2).rectangle((0, 16 - crop_height,16,16),outline=(0,0,0,0),fill=(0,0,0,0))
|
||||||
|
if side3 != None:
|
||||||
|
side3 = side3.copy()
|
||||||
|
ImageDraw.Draw(side3).rectangle((0, 16 - crop_height,16,16),outline=(0,0,0,0),fill=(0,0,0,0))
|
||||||
|
if side4 != None:
|
||||||
|
side4 = side4.copy()
|
||||||
|
ImageDraw.Draw(side4).rectangle((0, 16 - crop_height,16,16),outline=(0,0,0,0),fill=(0,0,0,0))
|
||||||
|
|
||||||
img = Image.new("RGBA", (24,24), (38,92,255,0))
|
img = Image.new("RGBA", (24,24), (38,92,255,0))
|
||||||
|
|
||||||
# first back sides
|
# first back sides
|
||||||
@@ -288,7 +316,7 @@ def _build_full_block(top, side1, side2, side3, side4, bottom=None, blockID=None
|
|||||||
side1 = ImageEnhance.Brightness(side1).enhance(0.9)
|
side1 = ImageEnhance.Brightness(side1).enhance(0.9)
|
||||||
side1.putalpha(sidealpha)
|
side1.putalpha(sidealpha)
|
||||||
|
|
||||||
composite.alpha_over(img, side1, (0,0), side1)
|
composite.alpha_over(img, side1, (0,0 + increment), side1)
|
||||||
|
|
||||||
|
|
||||||
if side2 != None :
|
if side2 != None :
|
||||||
@@ -299,7 +327,7 @@ def _build_full_block(top, side1, side2, side3, side4, bottom=None, blockID=None
|
|||||||
side2 = ImageEnhance.Brightness(side2).enhance(0.8)
|
side2 = ImageEnhance.Brightness(side2).enhance(0.8)
|
||||||
side2.putalpha(sidealpha2)
|
side2.putalpha(sidealpha2)
|
||||||
|
|
||||||
composite.alpha_over(img, side2, (12,0), side2)
|
composite.alpha_over(img, side2, (12,0 + increment), side2)
|
||||||
|
|
||||||
if bottom != None :
|
if bottom != None :
|
||||||
bottom = transform_image(bottom, blockID)
|
bottom = transform_image(bottom, blockID)
|
||||||
@@ -314,7 +342,7 @@ def _build_full_block(top, side1, side2, side3, side4, bottom=None, blockID=None
|
|||||||
side3 = ImageEnhance.Brightness(side3).enhance(0.9)
|
side3 = ImageEnhance.Brightness(side3).enhance(0.9)
|
||||||
side3.putalpha(sidealpha)
|
side3.putalpha(sidealpha)
|
||||||
|
|
||||||
composite.alpha_over(img, side3, (0,6), side3)
|
composite.alpha_over(img, side3, (0,6 + increment), side3)
|
||||||
|
|
||||||
if side4 != None :
|
if side4 != None :
|
||||||
side4 = transform_image_side(side4, blockID)
|
side4 = transform_image_side(side4, blockID)
|
||||||
@@ -325,11 +353,11 @@ def _build_full_block(top, side1, side2, side3, side4, bottom=None, blockID=None
|
|||||||
side4 = ImageEnhance.Brightness(side4).enhance(0.8)
|
side4 = ImageEnhance.Brightness(side4).enhance(0.8)
|
||||||
side4.putalpha(sidealpha)
|
side4.putalpha(sidealpha)
|
||||||
|
|
||||||
composite.alpha_over(img, side4, (12,6), side4)
|
composite.alpha_over(img, side4, (12,6 + increment), side4)
|
||||||
|
|
||||||
if top != None :
|
if top != None :
|
||||||
top = transform_image(top, blockID)
|
top = transform_image(top, blockID)
|
||||||
composite.alpha_over(img, top, (0,0), top)
|
composite.alpha_over(img, top, (0, increment), top)
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
@@ -516,6 +544,52 @@ def generate_special_texture(blockID, data):
|
|||||||
return (img.convert("RGB"), img.split()[3])
|
return (img.convert("RGB"), img.split()[3])
|
||||||
|
|
||||||
|
|
||||||
|
if blockID == 26: # bed
|
||||||
|
increment = 5
|
||||||
|
left_face = None
|
||||||
|
right_face = None
|
||||||
|
if data & 0x8 == 0x8: # head of the bed
|
||||||
|
top = terrain_images[135]
|
||||||
|
if data & 0x00 == 0x00: # head pointing to West
|
||||||
|
top = top.copy().rotate(270)
|
||||||
|
left_face = terrain_images[151]
|
||||||
|
right_face = terrain_images[152]
|
||||||
|
if data & 0x01 == 0x01: # ... North
|
||||||
|
top = top.rotate(270)
|
||||||
|
left_face = terrain_images[152]
|
||||||
|
right_face = terrain_images[151]
|
||||||
|
if data & 0x02 == 0x02: # East
|
||||||
|
top = top.rotate(180)
|
||||||
|
left_face = terrain_images[151].transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
|
right_face = None
|
||||||
|
if data & 0x03 == 0x03: # South
|
||||||
|
right_face = None
|
||||||
|
right_face = terrain_images[151].transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
|
|
||||||
|
else: # foot of the bed
|
||||||
|
top = terrain_images[134]
|
||||||
|
if data & 0x00 == 0x00: # head pointing to West
|
||||||
|
top = top.rotate(270)
|
||||||
|
left_face = terrain_images[150]
|
||||||
|
right_face = None
|
||||||
|
if data & 0x01 == 0x01: # ... North
|
||||||
|
top = top.rotate(270)
|
||||||
|
left_face = None
|
||||||
|
right_face = terrain_images[150]
|
||||||
|
if data & 0x02 == 0x02: # East
|
||||||
|
top = top.rotate(180)
|
||||||
|
left_face = terrain_images[150].transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
|
right_face = terrain_images[149].transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
|
if data & 0x03 == 0x03: # South
|
||||||
|
left_face = terrain_images[149]
|
||||||
|
right_face = terrain_images[150].transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
|
|
||||||
|
top = (top, increment)
|
||||||
|
img = _build_full_block(top, None, None, left_face, right_face)
|
||||||
|
|
||||||
|
return (img.convert("RGB"), img.split()[3])
|
||||||
|
|
||||||
|
|
||||||
if blockID == 35: # wool
|
if blockID == 35: # wool
|
||||||
if data == 0: # white
|
if data == 0: # white
|
||||||
top = side = terrain_images[64]
|
top = side = terrain_images[64]
|
||||||
@@ -1306,9 +1380,9 @@ def getBiomeData(worlddir, chunkX, chunkY):
|
|||||||
# (when adding new blocks here and in generate_special_textures,
|
# (when adding new blocks here and in generate_special_textures,
|
||||||
# please, if possible, keep the ascending order of blockid value)
|
# please, if possible, keep the ascending order of blockid value)
|
||||||
|
|
||||||
special_blocks = set([ 2, 6, 9, 17, 18, 23, 27, 28, 35, 43, 44, 50, 51,
|
special_blocks = set([ 2, 6, 9, 17, 18, 26, 23, 27, 28, 35, 43, 44, 50,
|
||||||
53, 54, 55, 58, 59, 61, 62, 64, 65, 66, 67, 71, 75,
|
51, 53, 54, 55, 58, 59, 61, 62, 64, 65, 66, 67, 71,
|
||||||
76, 85, 86, 90, 91, 92])
|
75, 76, 85, 86, 90, 91, 92])
|
||||||
|
|
||||||
# this is a map of special blockIDs to a list of all
|
# this is a map of special blockIDs to a list of all
|
||||||
# possible values for ancillary data that it might have.
|
# possible values for ancillary data that it might have.
|
||||||
@@ -1318,6 +1392,7 @@ special_map = {}
|
|||||||
special_map[6] = range(16) # saplings: usual, spruce, birch and future ones (rendered as usual saplings)
|
special_map[6] = range(16) # saplings: usual, spruce, birch and future ones (rendered as usual saplings)
|
||||||
special_map[9] = range(32) # water: spring,flowing, waterfall, and others (unknown) ancildata values, uses pseudo data
|
special_map[9] = range(32) # water: spring,flowing, waterfall, and others (unknown) ancildata values, uses pseudo data
|
||||||
special_map[17] = range(4) # wood: normal, birch and pine
|
special_map[17] = range(4) # wood: normal, birch and pine
|
||||||
|
special_map[26] = range(12) # bed, orientation
|
||||||
special_map[23] = range(6) # dispensers, orientation
|
special_map[23] = range(6) # dispensers, orientation
|
||||||
special_map[27] = range(14) # powered rail, orientation/slope and powered/unpowered
|
special_map[27] = range(14) # powered rail, orientation/slope and powered/unpowered
|
||||||
special_map[28] = range(6) # detector rail, orientation/slope
|
special_map[28] = range(6) # detector rail, orientation/slope
|
||||||
|
|||||||
Reference in New Issue
Block a user