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.
This commit is contained in:
@@ -164,7 +164,6 @@ const mc_block_t block_class_ancil[] = {
|
|||||||
block_flowing_water,
|
block_flowing_water,
|
||||||
block_water,
|
block_water,
|
||||||
block_glass,
|
block_glass,
|
||||||
block_chest,
|
|
||||||
block_redstone_wire,
|
block_redstone_wire,
|
||||||
block_ice,
|
block_ice,
|
||||||
block_fence,
|
block_fence,
|
||||||
@@ -190,7 +189,6 @@ const mc_block_t block_class_ancil[] = {
|
|||||||
block_double_plant,
|
block_double_plant,
|
||||||
block_stained_glass_pane,
|
block_stained_glass_pane,
|
||||||
block_stained_glass,
|
block_stained_glass,
|
||||||
block_trapped_chest,
|
|
||||||
block_spruce_fence,
|
block_spruce_fence,
|
||||||
block_birch_fence,
|
block_birch_fence,
|
||||||
block_jungle_fence,
|
block_jungle_fence,
|
||||||
|
|||||||
@@ -316,43 +316,6 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) {
|
|||||||
}
|
}
|
||||||
return final_data;
|
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)) {
|
} 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:
|
/* iron bars and glass panes:
|
||||||
* they seem to stick to almost everything but air,
|
* they seem to stick to almost everything but air,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
// increment this value if you've made a change to the c extension
|
// increment this value if you've made a change to the c extension
|
||||||
// and want to force users to rebuild
|
// and want to force users to rebuild
|
||||||
#define OVERVIEWER_EXTENSION_VERSION 80
|
#define OVERVIEWER_EXTENSION_VERSION 81
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -2341,7 +2341,8 @@ def chests(self, blockid, data):
|
|||||||
alpha_over(side_r, side_r_top, (1, 1))
|
alpha_over(side_r, side_r_top, (1, 1))
|
||||||
alpha_over(side_r, side_r_bottom, (1, 5))
|
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 = top.crop((0, 0, 16, 16))
|
||||||
top.load()
|
top.load()
|
||||||
front = front.crop((0, 0, 16, 16))
|
front = front.crop((0, 0, 16, 16))
|
||||||
@@ -2350,7 +2351,8 @@ def chests(self, blockid, data):
|
|||||||
back.load()
|
back.load()
|
||||||
#~ side = side_l
|
#~ 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 = top.crop((16, 0, 32, 16))
|
||||||
top.load()
|
top.load()
|
||||||
front = front.crop((16, 0, 32, 16))
|
front = front.crop((16, 0, 32, 16))
|
||||||
|
|||||||
@@ -1022,6 +1022,10 @@ class RegionSet(object):
|
|||||||
elif key in ['minecraft:ladder', 'minecraft:chest', 'minecraft:ender_chest', 'minecraft:trapped_chest', 'minecraft:furnace']:
|
elif key in ['minecraft:ladder', 'minecraft:chest', 'minecraft:ender_chest', 'minecraft:trapped_chest', 'minecraft:furnace']:
|
||||||
facing = palette_entry['Properties']['facing']
|
facing = palette_entry['Properties']['facing']
|
||||||
data = {'north': 2, 'south': 3, 'west': 4, 'east': 5}[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']:
|
elif key in ['minecraft:beehive', 'minecraft:bee_nest']:
|
||||||
facing = palette_entry['Properties']['facing']
|
facing = palette_entry['Properties']['facing']
|
||||||
honey_level = int(palette_entry['Properties']['honey_level'])
|
honey_level = int(palette_entry['Properties']['honey_level'])
|
||||||
|
|||||||
Reference in New Issue
Block a user