0

Amend observer rendering

- Allow rendering of powered observers with appropriate back texture
This commit is contained in:
Joseph Camp
2020-05-03 22:39:59 +00:00
parent 0bb4785008
commit b2244f5b76
2 changed files with 23 additions and 32 deletions

View File

@@ -4940,44 +4940,34 @@ def boneblock(self, blockid, data):
elif boneblock_orientation == 8: # north-south orientation elif boneblock_orientation == 8: # north-south orientation
return self.build_full_block(side, None, None, side.rotate(270), top) return self.build_full_block(side, None, None, side.rotate(270), top)
# observer # observer
@material(blockid=218, data=list(range(6)), solid=True, nospawn=True) @material(blockid=218, data=[0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13], solid=True, nospawn=True)
def observer(self, blockid, data): def observer(self, blockid, data):
# first, do the rotation if needed # Do rotation
if self.rotation == 1: if self.rotation in [1, 2, 3] and (data & 0b111) in [2, 3, 4, 5]:
if data == 2: data = 5 rotation_map = {1: {2: 5, 3: 4, 4: 2, 5: 3},
elif data == 3: data = 4 2: {2: 3, 3: 2, 4: 5, 5: 4},
elif data == 4: data = 2 3: {2: 4, 3: 5, 4: 3, 5: 2}}
elif data == 5: data = 3 data = (data & 0b1000) | rotation_map[self.rotation][data & 0b111]
elif self.rotation == 2:
if data == 2: data = 3
elif data == 3: data = 2
elif data == 4: data = 5
elif data == 5: data = 4
elif self.rotation == 3:
if data == 2: data = 4
elif data == 3: data = 5
elif data == 4: data = 3
elif data == 5: data = 2
front = self.load_image_texture("assets/minecraft/textures/block/observer_front.png").copy() front = self.load_image_texture("assets/minecraft/textures/block/observer_front.png")
side = self.load_image_texture("assets/minecraft/textures/block/observer_side.png").copy() side = self.load_image_texture("assets/minecraft/textures/block/observer_side.png")
back = self.load_image_texture("assets/minecraft/textures/block/observer_back.png").copy() top = self.load_image_texture("assets/minecraft/textures/block/observer_top.png")
top = self.load_image_texture("assets/minecraft/textures/block/observer_top.png").copy() file_name_back = "observer_back_on" if data & 0b1000 else "observer_back"
back = self.load_image_texture("assets/minecraft/textures/block/%s.png" % file_name_back)
if data == 0: # down if data & 0b0111 == 0: # Down
side = side.rotate(90) img = self.build_full_block(back, None, None, side.rotate(90), top)
img = self.build_full_block(back, None, None, side, top) elif data & 0b0111 == 1: # Up
elif data == 1: # up img = self.build_full_block(front.rotate(180), None, None, side.rotate(90), top.rotate(180))
side = side.rotate(90) elif data & 0b0111 == 2: # East
img = self.build_full_block(front.rotate(180), None, None, side, top.rotate(180))
elif data == 2: # east
img = self.build_full_block(top.rotate(180), None, None, side, back) img = self.build_full_block(top.rotate(180), None, None, side, back)
elif data == 3: # west elif data & 0b0111 == 3: # West
img = self.build_full_block(top, None, None, side, front) img = self.build_full_block(top, None, None, side, front)
elif data == 4: # north elif data & 0b0111 == 4: # North
img = self.build_full_block(top.rotate(270), None, None, front, side) img = self.build_full_block(top.rotate(270), None, None, front, side)
elif data == 5: # south elif data & 0b0111 == 5: # South
img = self.build_full_block(top.rotate(90), None, None, back, side) img = self.build_full_block(top.rotate(90), None, None, back, side)
return img return img

View File

@@ -1027,7 +1027,8 @@ class RegionSet(object):
p = palette_entry['Properties'] p = palette_entry['Properties']
data = {'down': 0, 'up': 1, 'north': 2, 'south': 3, 'west': 4, 'east': 5}[p['facing']] data = {'down': 0, 'up': 1, 'north': 2, 'south': 3, 'west': 4, 'east': 5}[p['facing']]
if ((key.endswith('piston') and p.get('extended', 'false') == 'true') or if ((key.endswith('piston') and p.get('extended', 'false') == 'true') or
(key == 'minecraft:piston_head' and p.get('type', 'normal') == 'sticky')): (key == 'minecraft:piston_head' and p.get('type', 'normal') == 'sticky') or
(key == 'minecraft:observer' and p.get('powered', 'false') == 'true')):
data |= 0x08 data |= 0x08
elif key.endswith('_log') or key.endswith('_wood') or key == 'minecraft:bone_block': elif key.endswith('_log') or key.endswith('_wood') or key == 'minecraft:bone_block':
axis = palette_entry['Properties']['axis'] axis = palette_entry['Properties']['axis']