From a3960bd41992af0e723bc3f3adf0391f687160ca Mon Sep 17 00:00:00 2001 From: Auron956 Date: Sat, 1 Feb 2020 23:39:34 +0000 Subject: [PATCH] Fix chest rendering by using 'type' property Resolves an issue where chests with more than one adjacent chest would fail to render. Instead of distinguishing double from single chests by checking for the presence of adjacent chests, use the provided "type" property of chests to determine if they are single or the left/right part of a double chest. --- overviewer_core/src/block_class.c | 2 -- overviewer_core/src/iterate.c | 37 ------------------------------- overviewer_core/src/overviewer.h | 2 +- overviewer_core/textures.py | 6 +++-- overviewer_core/world.py | 4 ++++ 5 files changed, 9 insertions(+), 42 deletions(-) diff --git a/overviewer_core/src/block_class.c b/overviewer_core/src/block_class.c index c07f47d..6112260 100644 --- a/overviewer_core/src/block_class.c +++ b/overviewer_core/src/block_class.c @@ -164,7 +164,6 @@ const mc_block_t block_class_ancil[] = { block_flowing_water, block_water, block_glass, - block_chest, block_redstone_wire, block_ice, block_fence, @@ -190,7 +189,6 @@ const mc_block_t block_class_ancil[] = { block_double_plant, block_stained_glass_pane, block_stained_glass, - block_trapped_chest, block_spruce_fence, block_birch_fence, block_jungle_fence, diff --git a/overviewer_core/src/iterate.c b/overviewer_core/src/iterate.c index f27e400..3635090 100644 --- a/overviewer_core/src/iterate.c +++ b/overviewer_core/src/iterate.c @@ -316,43 +316,6 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) { } return final_data; - } else if (block_class_is_subset(state->block, (mc_block_t[]){block_chest, block_trapped_chest}, 2)) { - /* Orientation is given by ancilData, pseudo data needed to - * choose from single or double chest and the correct half of - * the chest. */ - - /* Add two bits to ancilData to store single or double chest - * and which half of the chest it is: bit 0x10 = second half - * bit 0x8 = first half */ - - uint8_t chest_data = 0, final_data = 0; - - /* search for adjacent chests of the same type */ - chest_data = check_adjacent_blocks(state, x, y, z, state->block); - - if (chest_data == 1) { /* another chest in the upper-left */ - final_data = final_data | 0x10 | ancilData; - - } else if (chest_data == 2) { /* in the bottom-left */ - final_data = final_data | 0x8 | ancilData; - - } else if (chest_data == 4) { /*in the bottom-right */ - final_data = final_data | 0x8 | ancilData; - - } else if (chest_data == 8) { /*in the upper-right */ - final_data = final_data | 0x10 | ancilData; - - } else if (chest_data == 0) { - /* Single chest, determine the orientation */ - final_data = ancilData; - - } else { - /* more than one adjacent chests! That shouldn't be - * possible! render as normal chest */ - return 0; - } - return final_data; - } else if (block_class_is_subset(state->block, (mc_block_t[]){block_iron_bars, block_glass_pane, block_stained_glass_pane}, 3)) { /* iron bars and glass panes: * they seem to stick to almost everything but air, diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index 3debcf9..a65da08 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -31,7 +31,7 @@ // increment this value if you've made a change to the c extension // and want to force users to rebuild -#define OVERVIEWER_EXTENSION_VERSION 80 +#define OVERVIEWER_EXTENSION_VERSION 81 #include #include diff --git a/overviewer_core/textures.py b/overviewer_core/textures.py index 02d3f71..798517d 100644 --- a/overviewer_core/textures.py +++ b/overviewer_core/textures.py @@ -2341,7 +2341,8 @@ def chests(self, blockid, data): alpha_over(side_r, side_r_top, (1, 1)) alpha_over(side_r, side_r_bottom, (1, 5)) - if data & 24 == 8: # double chest, first half + # double chest, left half + if ((data & 24 == 8 and data & 7 in [3, 5]) or (data & 24 == 16 and data & 7 in [2, 4])): top = top.crop((0, 0, 16, 16)) top.load() front = front.crop((0, 0, 16, 16)) @@ -2350,7 +2351,8 @@ def chests(self, blockid, data): back.load() #~ side = side_l - elif data & 24 == 16: # double, second half + # double chest, right half + elif ((data & 24 == 16 and data & 7 in [3, 5]) or (data & 24 == 8 and data & 7 in [2, 4])): top = top.crop((16, 0, 32, 16)) top.load() front = front.crop((16, 0, 32, 16)) diff --git a/overviewer_core/world.py b/overviewer_core/world.py index faa172d..09a3a73 100644 --- a/overviewer_core/world.py +++ b/overviewer_core/world.py @@ -1022,6 +1022,10 @@ class RegionSet(object): elif key in ['minecraft:ladder', 'minecraft:chest', 'minecraft:ender_chest', 'minecraft:trapped_chest', 'minecraft:furnace']: facing = palette_entry['Properties']['facing'] data = {'north': 2, 'south': 3, 'west': 4, 'east': 5}[facing] + if key in ['minecraft:chest', 'minecraft:trapped_chest']: + # type property should exist, but default to 'single' just in case + chest_type = palette_entry['Properties'].get('type', 'single') + data |= {'left': 0x8, 'right': 0x10, 'single': 0x0}[chest_type] elif key in ['minecraft:beehive', 'minecraft:bee_nest']: facing = palette_entry['Properties']['facing'] honey_level = int(palette_entry['Properties']['honey_level'])