Add colored beds & use bed facing/type properties
- Add beds with colors other than red - Use bed 'facing' property to determine bed's rotation - Use bed 'type' property to determine if the head or foot is rendered - Correct faulty logic during bed texture generation
This commit is contained in:
@@ -1289,88 +1289,80 @@ def sandstone(self, blockid, data):
|
||||
# note block
|
||||
block(blockid=25, top_image="assets/minecraft/textures/block/note_block.png")
|
||||
|
||||
@material(blockid=26, data=list(range(12)), transparent=True, nospawn=True)
|
||||
# Bed
|
||||
@material(blockid=26, data=list(range(256)), transparent=True, nospawn=True)
|
||||
def bed(self, blockid, data):
|
||||
# Bits 1-2 Rotation
|
||||
# Bit 3 Occupancy, no impact on appearance
|
||||
# Bit 4 Foot/Head of bed (0 = foot, 1 = head)
|
||||
# Bits 5-8 Color
|
||||
|
||||
# first get rotation done
|
||||
# Masked to not clobber block head/foot info
|
||||
if self.rotation == 1:
|
||||
if (data & 0b0011) == 0: data = data & 0b1100 | 1
|
||||
elif (data & 0b0011) == 1: data = data & 0b1100 | 2
|
||||
elif (data & 0b0011) == 2: data = data & 0b1100 | 3
|
||||
elif (data & 0b0011) == 3: data = data & 0b1100 | 0
|
||||
elif self.rotation == 2:
|
||||
if (data & 0b0011) == 0: data = data & 0b1100 | 2
|
||||
elif (data & 0b0011) == 1: data = data & 0b1100 | 3
|
||||
elif (data & 0b0011) == 2: data = data & 0b1100 | 0
|
||||
elif (data & 0b0011) == 3: data = data & 0b1100 | 1
|
||||
elif self.rotation == 3:
|
||||
if (data & 0b0011) == 0: data = data & 0b1100 | 3
|
||||
elif (data & 0b0011) == 1: data = data & 0b1100 | 0
|
||||
elif (data & 0b0011) == 2: data = data & 0b1100 | 1
|
||||
elif (data & 0b0011) == 3: data = data & 0b1100 | 2
|
||||
|
||||
bed_texture = self.load_image("assets/minecraft/textures/entity/bed/red.png") # FIXME: do tile entity colours
|
||||
# Masked to not clobber block head/foot & color info
|
||||
data = data & 0b11111100 | ((self.rotation + (data & 0b11)) % 4)
|
||||
|
||||
bed_texture = self.load_image("assets/minecraft/textures/entity/bed/%s.png" % color_map[data >> 4])
|
||||
increment = 8
|
||||
left_face = None
|
||||
right_face = None
|
||||
top_face = None
|
||||
if data & 0x8 == 0x8: # head of the bed
|
||||
top = bed_texture.copy().crop((6,6,22,22))
|
||||
if data & 0x8 == 0x8: # head of the bed
|
||||
top = bed_texture.copy().crop((6, 6, 22, 22))
|
||||
|
||||
# Composing the side
|
||||
side = Image.new("RGBA", (16,16))
|
||||
side_part1 = bed_texture.copy().crop((0,6,6,22)).rotate(90, expand=True)
|
||||
side = Image.new("RGBA", (16, 16), self.bgcolor)
|
||||
side_part1 = bed_texture.copy().crop((0, 6, 6, 22)).rotate(90, expand=True)
|
||||
# foot of the bed
|
||||
side_part2 = bed_texture.copy().crop((53,3,56,6))
|
||||
side_part2 = bed_texture.copy().crop((53, 3, 56, 6))
|
||||
side_part2_f = side_part2.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
alpha_over(side, side_part1, (0,7), side_part1)
|
||||
alpha_over(side, side_part2, (0,13), side_part2)
|
||||
alpha_over(side, side_part1, (0, 7), side_part1)
|
||||
alpha_over(side, side_part2, (0, 13), side_part2)
|
||||
|
||||
end = Image.new("RGBA", (16,16))
|
||||
end_part = bed_texture.copy().crop((6,0,22,6)).rotate(180)
|
||||
alpha_over(end, end_part, (0,7), end_part)
|
||||
alpha_over(end, side_part2, (0,13), side_part2)
|
||||
alpha_over(end, side_part2_f, (13,13), side_part2_f)
|
||||
if data & 0x00 == 0x00: # South
|
||||
end = Image.new("RGBA", (16, 16), self.bgcolor)
|
||||
end_part = bed_texture.copy().crop((6, 0, 22, 6)).rotate(180)
|
||||
alpha_over(end, end_part, (0, 7), end_part)
|
||||
alpha_over(end, side_part2, (0, 13), side_part2)
|
||||
alpha_over(end, side_part2_f, (13, 13), side_part2_f)
|
||||
if data & 0x03 == 0x00: # South
|
||||
top_face = top.rotate(180)
|
||||
left_face = side.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
right_face = end
|
||||
if data & 0x01 == 0x01: # West
|
||||
elif data & 0x03 == 0x01: # West
|
||||
top_face = top.rotate(90)
|
||||
left_face = end
|
||||
right_face = side.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
if data & 0x02 == 0x02: # North
|
||||
elif data & 0x03 == 0x02: # North
|
||||
top_face = top
|
||||
left_face = side
|
||||
if data & 0x03 == 0x03: # East
|
||||
elif data & 0x03 == 0x03: # East
|
||||
top_face = top.rotate(270)
|
||||
right_face = side
|
||||
|
||||
else: # foot of the bed
|
||||
top = bed_texture.copy().crop((6,28,22,44))
|
||||
side = Image.new("RGBA", (16,16))
|
||||
side_part1 = bed_texture.copy().crop((0,28,6,44)).rotate(90, expand=True)
|
||||
side_part2 = bed_texture.copy().crop((53,3,56,6))
|
||||
side_part2_f = side_part2.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
alpha_over(side, side_part1, (0,7), side_part1)
|
||||
alpha_over(side, side_part2, (13,13), side_part2)
|
||||
|
||||
end = Image.new("RGBA", (16,16))
|
||||
end_part = bed_texture.copy().crop((22,22,38,28)).rotate(180)
|
||||
alpha_over(end, end_part, (0,7), end_part)
|
||||
alpha_over(end, side_part2, (0,13), side_part2)
|
||||
alpha_over(end, side_part2_f, (13,13), side_part2_f)
|
||||
if data & 0x00 == 0x00: # South
|
||||
else: # foot of the bed
|
||||
top = bed_texture.copy().crop((6, 28, 22, 44))
|
||||
side = Image.new("RGBA", (16, 16), self.bgcolor)
|
||||
side_part1 = bed_texture.copy().crop((0, 28, 6, 44)).rotate(90, expand=True)
|
||||
side_part2 = bed_texture.copy().crop((53, 3, 56, 6))
|
||||
side_part2_f = side_part2.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
alpha_over(side, side_part1, (0, 7), side_part1)
|
||||
alpha_over(side, side_part2, (13, 13), side_part2)
|
||||
|
||||
end = Image.new("RGBA", (16, 16), self.bgcolor)
|
||||
end_part = bed_texture.copy().crop((22, 22, 38, 28)).rotate(180)
|
||||
alpha_over(end, end_part, (0, 7), end_part)
|
||||
alpha_over(end, side_part2, (0, 13), side_part2)
|
||||
alpha_over(end, side_part2_f, (13, 13), side_part2_f)
|
||||
if data & 0x03 == 0x00: # South
|
||||
top_face = top.rotate(180)
|
||||
left_face = side.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
if data & 0x01 == 0x01: # West
|
||||
elif data & 0x03 == 0x01: # West
|
||||
top_face = top.rotate(90)
|
||||
right_face = side.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
if data & 0x02 == 0x02: # North
|
||||
elif data & 0x03 == 0x02: # North
|
||||
top_face = top
|
||||
left_face = side
|
||||
right_face = end
|
||||
if data & 0x03 == 0x03: # East
|
||||
elif data & 0x03 == 0x03: # East
|
||||
top_face = top.rotate(270)
|
||||
left_face = end
|
||||
right_face = side
|
||||
|
||||
@@ -346,22 +346,6 @@ class RegionSet(object):
|
||||
'minecraft:cut_sandstone': (24, 2),
|
||||
'minecraft:chiseled_sandstone': (24, 3),
|
||||
'minecraft:note_block': (25, 0),
|
||||
'minecraft:white_bed': (26, 0),
|
||||
'minecraft:orange_bed': (26, 0),
|
||||
'minecraft:magenta_bed': (26, 0),
|
||||
'minecraft:light_blue_bed': (26, 0),
|
||||
'minecraft:yellow_bed': (26, 0),
|
||||
'minecraft:lime_bed': (26, 0),
|
||||
'minecraft:pink_bed': (26, 0),
|
||||
'minecraft:gray_bed': (26, 0),
|
||||
'minecraft:light_gray_bed': (26, 0),
|
||||
'minecraft:cyan_bed': (26, 0),
|
||||
'minecraft:purple_bed': (26, 0),
|
||||
'minecraft:blue_bed': (26, 0),
|
||||
'minecraft:brown_bed': (26, 0),
|
||||
'minecraft:green_bed': (26, 0),
|
||||
'minecraft:red_bed': (26, 0),
|
||||
'minecraft:black_bed': (26, 0),
|
||||
'minecraft:powered_rail': (27, 0),
|
||||
'minecraft:detector_rail': (28, 0),
|
||||
'minecraft:sticky_piston': (29, 0),
|
||||
@@ -870,14 +854,15 @@ class RegionSet(object):
|
||||
'light_gray', 'cyan', 'purple', 'blue',
|
||||
'brown', 'green', 'red', 'black']
|
||||
for i in range(len(colors)):
|
||||
# For beds: bits 1-2 indicate facing, bit 3 occupancy, bit 4 foot (0) or head (1)
|
||||
self._blockmap['minecraft:%s_bed' % colors[i]] = (26, i << 4)
|
||||
self._blockmap['minecraft:%s_stained_glass' % colors[i]] = (95, i)
|
||||
self._blockmap['minecraft:%s_stained_glass_pane' % colors[i]] = (160, i)
|
||||
self._blockmap['minecraft:%s_banner' % colors[i]] = (176, i) #not rendering
|
||||
self._blockmap['minecraft:%s_wall_banner' % colors[i]] = (177, i) #not rendering
|
||||
self._blockmap['minecraft:%s_banner' % colors[i]] = (176, i) # not rendering
|
||||
self._blockmap['minecraft:%s_wall_banner' % colors[i]] = (177, i) # not rendering
|
||||
self._blockmap['minecraft:%s_concrete' % colors[i]] = (251, i)
|
||||
self._blockmap['minecraft:%s_concrete_powder' % colors[i]] = (252, i)
|
||||
|
||||
|
||||
# Re-initialize upon unpickling
|
||||
def __getstate__(self):
|
||||
return (self.regiondir, self.rel)
|
||||
@@ -1155,6 +1140,12 @@ class RegionSet(object):
|
||||
(facing_data[palette_entry['Properties']['facing']] << 1) +
|
||||
(1 if palette_entry['Properties']['open'] == 'true' else 0)
|
||||
)
|
||||
elif key.endswith('_bed'):
|
||||
facing = palette_entry['Properties']['facing']
|
||||
data |= {'south': 0, 'west': 1, 'north': 2, 'east': 3}[facing]
|
||||
if palette_entry['Properties'].get('part', 'foot') == 'head':
|
||||
data |= 8
|
||||
|
||||
return (block, data)
|
||||
|
||||
def get_type(self):
|
||||
|
||||
Reference in New Issue
Block a user