0

Amend end portal frame rendering

- Use portal frame 'eye' property to allow ender eye to be rendered
- Use portal frame 'facing' property to determine block rotation
This commit is contained in:
Joseph Camp
2020-05-02 19:15:27 +00:00
parent 4ee5673e0d
commit c30e976cbd
2 changed files with 22 additions and 14 deletions

View File

@@ -4273,32 +4273,35 @@ def end_portal(self, blockid, data):
return img
# end portal frame (data range 8 to get all orientations of filled)
@material(blockid=120, data=list(range(8)), transparent=True)
@material(blockid=120, data=list(range(8)), transparent=True, solid=True, nospawn=True)
def end_portal_frame(self, blockid, data):
# The bottom 2 bits are oritation info but seems there is no
# graphical difference between orientations
top = self.load_image_texture("assets/minecraft/textures/block/end_portal_frame_top.png")
eye_t = self.load_image_texture("assets/minecraft/textures/block/end_portal_frame_eye.png")
# Do rotation, only seems to affect ender eye & top of frame
data = data & 0b100 | ((self.rotation + (data & 0b11)) % 4)
top = self.load_image_texture("assets/minecraft/textures/block/end_portal_frame_top.png").copy()
top = top.rotate((data % 4) * 90)
side = self.load_image_texture("assets/minecraft/textures/block/end_portal_frame_side.png")
img = self.build_full_block((top, 4), None, None, side, side)
if data & 0x4 == 0x4: # ender eye on it
if data & 0x4 == 0x4: # ender eye on it
# generate the eye
eye_t = self.load_image_texture("assets/minecraft/textures/block/end_portal_frame_eye.png").copy()
eye_t_s = self.load_image_texture("assets/minecraft/textures/block/end_portal_frame_eye.png").copy()
eye_t_s = eye_t.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 = self.transform_image_top(eye_t)
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))
# transform images and paste
eye = self.transform_image_top(eye_t.rotate((data % 4) * 90))
eye_s = self.transform_image_side(eye_t_s)
eye_os = eye_s.transpose(Image.FLIP_LEFT_RIGHT)
alpha_over(img, eye_s, (5,5), eye_s)
alpha_over(img, eye_os, (9,5), eye_os)
alpha_over(img, eye, (0,0), eye)
alpha_over(img, eye_s, (5, 5), eye_s)
alpha_over(img, eye_os, (9, 5), eye_os)
alpha_over(img, eye, (0, 0), eye)
return img
# end stone
block(blockid=121, top_image="assets/minecraft/textures/block/end_stone.png")

View File

@@ -1150,6 +1150,11 @@ class RegionSet(object):
data |= {'south': 0, 'west': 1, 'north': 2, 'east': 3}[facing]
if palette_entry['Properties'].get('part', 'foot') == 'head':
data |= 8
elif key == 'minecraft:end_portal_frame':
facing = palette_entry['Properties']['facing']
data |= {'south': 0, 'west': 1, 'north': 2, 'east': 3}[facing]
if palette_entry['Properties'].get('eye', 'false') == 'true':
data |= 4
return (block, data)