0

Amend shulker box rendering

- Correct shulker box side textures being resized to 4x4 resolution
- Use intended texture for 'uncolored' shulker boxes instead of purple
This commit is contained in:
Joseph Camp
2020-05-03 00:07:38 +00:00
parent 7e0c880a58
commit 0bb4785008
3 changed files with 28 additions and 46 deletions

View File

@@ -259,6 +259,7 @@ enum mc_block_id {
block_concrete_powder = 252,
block_structure_block = 255,
block_jigsaw = 256,
block_shulker_box = 257,
block_prismarine_stairs = 11337,
block_dark_prismarine_stairs = 11338,
block_prismarine_brick_stairs = 11339,

View File

@@ -4982,30 +4982,25 @@ def observer(self, blockid, data):
return img
# shulker box
@material(blockid=list(range(219,235)), data=list(range(6)), solid=True, nospawn=True)
def shulker_box(self, blockid, data):
# first, do the rotation if needed
data = data & 7
if self.rotation == 1:
if data == 2: data = 5
elif data == 3: data = 4
elif data == 4: data = 2
elif data == 5: data = 3
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
color = color_map[blockid - 219]
shulker_t = self.load_image_texture("assets/minecraft/textures/entity/shulker/shulker_%s.png" % color).copy()
w,h = shulker_t.size
# shulker box
@material(blockid=list(range(219, 235)) + [257], data=list(range(6)), solid=True, nospawn=True)
def shulker_box(self, blockid, data):
# Do rotation
if self.rotation in [1, 2, 3] and data in [2, 3, 4, 5]:
rotation_map = {1: {2: 5, 3: 4, 4: 2, 5: 3},
2: {2: 3, 3: 2, 4: 5, 5: 4},
3: {2: 4, 3: 5, 4: 3, 5: 2}}
data = rotation_map[self.rotation][data]
if blockid == 257:
# Uncolored shulker box
file_name = "shulker.png"
else:
file_name = "shulker_%s.png" % color_map[blockid - 219]
shulker_t = self.load_image("assets/minecraft/textures/entity/shulker/%s" % file_name).copy()
w, h = shulker_t.size
res = w // 4
# Cut out the parts of the shulker texture we need for the box
top = shulker_t.crop((res, 0, res * 2, res))
@@ -5016,22 +5011,23 @@ def shulker_box(self, blockid, data):
side.paste(side_top, (0, 0), side_top)
side.paste(side_bottom, (0, res // 2), side_bottom)
if data == 0: # down
if data == 0: # down
side = side.rotate(180)
img = self.build_full_block(bottom, None, None, side, side)
elif data == 1: # up
elif data == 1: # up
img = self.build_full_block(top, None, None, side, side)
elif data == 2: # east
elif data == 2: # east
img = self.build_full_block(side, None, None, side.rotate(90), bottom)
elif data == 3: # west
elif data == 3: # west
img = self.build_full_block(side.rotate(180), None, None, side.rotate(270), top)
elif data == 4: # north
elif data == 4: # north
img = self.build_full_block(side.rotate(90), None, None, top, side.rotate(270))
elif data == 5: # south
elif data == 5: # south
img = self.build_full_block(side.rotate(270), None, None, bottom, side.rotate(90))
return img
# structure block
@material(blockid=255, data=list(range(4)), solid=True)
def structure_block(self, blockid, data):

View File

@@ -655,23 +655,6 @@ class RegionSet(object):
'minecraft:red_nether_bricks': (215, 0),
'minecraft:bone_block': (216, 0),
'minecraft:observer': (218, 0),
'minecraft:white_shulker_box': (219, 0),
'minecraft:orange_shulker_box': (220, 0),
'minecraft:magenta_shulker_box': (221, 0),
'minecraft:light_blue_shulker_box': (222, 0),
'minecraft:yellow_shulker_box': (223, 0),
'minecraft:lime_shulker_box': (224, 0),
'minecraft:pink_shulker_box': (225, 0),
'minecraft:gray_shulker_box': (226, 0),
'minecraft:light_gray_shulker_box': (227, 0),
'minecraft:cyan_shulker_box': (228, 0),
'minecraft:shulker_box': (229, 0), # wrong color
'minecraft:purple_shulker_box': (229, 0),
'minecraft:blue_shulker_box': (230, 0),
'minecraft:brown_shulker_box': (231, 0),
'minecraft:green_shulker_box': (232, 0),
'minecraft:red_shulker_box': (233, 0),
'minecraft:black_shulker_box': (234, 0),
'minecraft:white_glazed_terracotta': (235, 0),
'minecraft:orange_glazed_terracotta': (236, 0),
'minecraft:magenta_glazed_terracotta': (237, 0),
@@ -691,6 +674,7 @@ class RegionSet(object):
'minecraft:structure_block': (255, 0),
'minecraft:jigsaw': (256, 0),
'minecraft:shulker_box': (257, 0),
'minecraft:armor_stand': (416, 0), # not rendering
@@ -861,6 +845,7 @@ class RegionSet(object):
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_shulker_box' % colors[i]] = (219 + i, 0)
self._blockmap['minecraft:%s_concrete' % colors[i]] = (251, i)
self._blockmap['minecraft:%s_concrete_powder' % colors[i]] = (252, i)