Rworked glass pane connection
- use in game data instead of manually calculating the adjacency data
This commit is contained in:
@@ -207,8 +207,6 @@ const mc_block_t block_class_ancil[] = {
|
|||||||
block_ice,
|
block_ice,
|
||||||
block_fence,
|
block_fence,
|
||||||
block_portal,
|
block_portal,
|
||||||
block_iron_bars,
|
|
||||||
block_glass_pane,
|
|
||||||
block_waterlily,
|
block_waterlily,
|
||||||
block_nether_brick_fence,
|
block_nether_brick_fence,
|
||||||
block_andesite_wall,
|
block_andesite_wall,
|
||||||
@@ -232,7 +230,6 @@ const mc_block_t block_class_ancil[] = {
|
|||||||
block_lodestone,
|
block_lodestone,
|
||||||
block_respawn_anchor,
|
block_respawn_anchor,
|
||||||
block_double_plant,
|
block_double_plant,
|
||||||
block_stained_glass_pane,
|
|
||||||
block_stained_glass,
|
block_stained_glass,
|
||||||
block_spruce_fence,
|
block_spruce_fence,
|
||||||
block_birch_fence,
|
block_birch_fence,
|
||||||
@@ -320,157 +317,3 @@ const mc_block_t block_class_nether_roof[] = {
|
|||||||
block_nether_gold_ore,
|
block_nether_gold_ore,
|
||||||
block_ancient_debris};
|
block_ancient_debris};
|
||||||
const size_t block_class_nether_roof_len = COUNT_OF(block_class_nether_roof);
|
const size_t block_class_nether_roof_len = COUNT_OF(block_class_nether_roof);
|
||||||
|
|
||||||
const mc_block_t block_connects_to_glass_pane[] = {
|
|
||||||
block_stone,
|
|
||||||
block_grass,
|
|
||||||
block_dirt,
|
|
||||||
block_cobblestone,
|
|
||||||
block_planks,
|
|
||||||
block_bedrock,
|
|
||||||
block_sand,
|
|
||||||
block_gravel,
|
|
||||||
block_gold_ore,
|
|
||||||
block_iron_ore,
|
|
||||||
block_coal_ore,
|
|
||||||
block_log,
|
|
||||||
block_sponge,
|
|
||||||
block_glass,
|
|
||||||
block_lapis_ore,
|
|
||||||
block_lapis_block,
|
|
||||||
block_dispenser,
|
|
||||||
block_sandstone,
|
|
||||||
block_noteblock,
|
|
||||||
block_sticky_piston,
|
|
||||||
block_piston,
|
|
||||||
block_wool,
|
|
||||||
block_gold_block,
|
|
||||||
block_iron_block,
|
|
||||||
block_double_stone_slab,
|
|
||||||
block_brick_block,
|
|
||||||
block_tnt,
|
|
||||||
block_bookshelf,
|
|
||||||
block_mossy_cobblestone,
|
|
||||||
block_obsidian,
|
|
||||||
block_mob_spawner,
|
|
||||||
block_diamond_ore,
|
|
||||||
block_diamond_block,
|
|
||||||
block_crafting_table,
|
|
||||||
block_furnace,
|
|
||||||
block_lit_furnace,
|
|
||||||
block_redstone_ore,
|
|
||||||
block_lit_redstone_ore,
|
|
||||||
block_ice,
|
|
||||||
block_snow,
|
|
||||||
block_clay,
|
|
||||||
block_jukebox,
|
|
||||||
block_netherrack,
|
|
||||||
block_soul_sand,
|
|
||||||
block_glowstone,
|
|
||||||
block_stained_glass,
|
|
||||||
block_stonebrick,
|
|
||||||
block_brown_mushroom_block,
|
|
||||||
block_red_mushroom_block,
|
|
||||||
block_iron_bars,
|
|
||||||
block_glass_pane,
|
|
||||||
block_mycelium,
|
|
||||||
block_nether_brick,
|
|
||||||
block_cauldron,
|
|
||||||
block_end_stone,
|
|
||||||
block_redstone_lamp,
|
|
||||||
block_lit_redstone_lamp,
|
|
||||||
block_double_wooden_slab,
|
|
||||||
block_emerald_ore,
|
|
||||||
block_emerald_block,
|
|
||||||
block_beacon,
|
|
||||||
block_mushroom_stem,
|
|
||||||
block_redstone_block,
|
|
||||||
block_quartz_ore,
|
|
||||||
block_hopper,
|
|
||||||
block_quartz_block,
|
|
||||||
block_dropper,
|
|
||||||
block_stained_hardened_clay,
|
|
||||||
block_stained_glass_pane,
|
|
||||||
block_prismarine,
|
|
||||||
block_sea_lantern,
|
|
||||||
block_hay_block,
|
|
||||||
block_hardened_clay,
|
|
||||||
block_coal_block,
|
|
||||||
block_packed_ice,
|
|
||||||
block_red_sandstone,
|
|
||||||
block_double_stone_slab2,
|
|
||||||
block_chorus_flower,
|
|
||||||
block_purpur_block,
|
|
||||||
block_purpur_pillar,
|
|
||||||
block_purpur_double_slab,
|
|
||||||
block_end_bricks,
|
|
||||||
block_frosted_ice,
|
|
||||||
block_magma,
|
|
||||||
block_nether_wart_block,
|
|
||||||
block_red_nether_brick,
|
|
||||||
block_bone_block,
|
|
||||||
block_observer,
|
|
||||||
block_white_glazed_terracotta,
|
|
||||||
block_orange_glazed_terracotta,
|
|
||||||
block_magenta_glazed_terracotta,
|
|
||||||
block_light_blue_glazed_terracotta,
|
|
||||||
block_yellow_glazed_terracotta,
|
|
||||||
block_lime_glazed_terracotta,
|
|
||||||
block_pink_glazed_terracotta,
|
|
||||||
block_gray_glazed_terracotta,
|
|
||||||
block_light_gray_glazed_terracotta,
|
|
||||||
block_cyan_glazed_terracotta,
|
|
||||||
block_purple_glazed_terracotta,
|
|
||||||
block_blue_glazed_terracotta,
|
|
||||||
block_brown_glazed_terracotta,
|
|
||||||
block_green_glazed_terracotta,
|
|
||||||
block_red_glazed_terracotta,
|
|
||||||
block_black_glazed_terracotta,
|
|
||||||
block_concrete,
|
|
||||||
block_concrete_powder,
|
|
||||||
block_ancient_debris,
|
|
||||||
block_basalt,
|
|
||||||
block_polished_basalt,
|
|
||||||
block_blackstone,
|
|
||||||
block_netherite_block,
|
|
||||||
block_warped_wart_block,
|
|
||||||
block_shroomlight,
|
|
||||||
block_soul_soil,
|
|
||||||
block_nether_gold_ore,
|
|
||||||
block_andesite_wall,
|
|
||||||
block_brick_wall,
|
|
||||||
block_cobblestone_wall,
|
|
||||||
block_diorite_wall,
|
|
||||||
block_end_stone_brick_wall,
|
|
||||||
block_granite_wall,
|
|
||||||
block_mossy_cobblestone_wall,
|
|
||||||
block_mossy_stone_brick_wall,
|
|
||||||
block_nether_brick_wall,
|
|
||||||
block_prismarine_wall,
|
|
||||||
block_red_nether_brick_wall,
|
|
||||||
block_red_sandstone_wall,
|
|
||||||
block_sandstone_wall,
|
|
||||||
block_stone_brick_wall,
|
|
||||||
block_fletching_table,
|
|
||||||
block_cartography_table,
|
|
||||||
block_smithing_table,
|
|
||||||
block_blast_furnace,
|
|
||||||
block_smoker,
|
|
||||||
block_loom,
|
|
||||||
block_composter,
|
|
||||||
block_beehive,
|
|
||||||
block_bee_nest,
|
|
||||||
block_honeycomb_block
|
|
||||||
};
|
|
||||||
const size_t block_connects_to_glass_pane_len = COUNT_OF(block_connects_to_glass_pane);
|
|
||||||
|
|
||||||
const mc_block_t block_class_trapdoor[] = {
|
|
||||||
block_trapdoor,
|
|
||||||
block_iron_trapdoor,
|
|
||||||
block_spruce_trapdoor,
|
|
||||||
block_birch_trapdoor,
|
|
||||||
block_jungle_trapdoor,
|
|
||||||
block_acacia_trapdoor,
|
|
||||||
block_dark_oak_trapdoor
|
|
||||||
};
|
|
||||||
const size_t block_class_trapdoor_len = COUNT_OF(block_class_trapdoor);
|
|
||||||
|
|||||||
@@ -51,10 +51,4 @@ extern const size_t block_class_alt_height_len;
|
|||||||
extern const mc_block_t block_class_nether_roof[];
|
extern const mc_block_t block_class_nether_roof[];
|
||||||
extern const size_t block_class_nether_roof_len;
|
extern const size_t block_class_nether_roof_len;
|
||||||
|
|
||||||
extern const mc_block_t block_class_trapdoor[];
|
|
||||||
extern const size_t block_class_trapdoor_len;
|
|
||||||
|
|
||||||
extern const mc_block_t block_connects_to_glass_pane[];
|
|
||||||
extern const size_t block_connects_to_glass_pane_len;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -317,75 +317,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_iron_bars, block_glass_pane, block_stained_glass_pane}, 3)) {
|
|
||||||
|
|
||||||
uint8_t pdata = 0;
|
|
||||||
|
|
||||||
PyObject* texrot;
|
|
||||||
int32_t northdir;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
int32_t x;
|
|
||||||
int32_t y;
|
|
||||||
int32_t z;
|
|
||||||
uint8_t direction; /*!< direction bit if glass pane should connect */
|
|
||||||
} blocks[] = { {x + 1, y, z, 1 << 3},
|
|
||||||
{x, y, z + 1, 1 << 2},
|
|
||||||
{x - 1, y, z, 1 << 1},
|
|
||||||
{x, y, z - 1, 1 << 0} };
|
|
||||||
texrot = PyObject_GetAttrString(state->textures, "rotation");
|
|
||||||
northdir = PyLong_AsLong(texrot) & 0x3;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sizeof(blocks)/sizeof(blocks[0]); ++i) {
|
|
||||||
|
|
||||||
mc_block_t block = get_data(state, BLOCKS, blocks[i].x, blocks[i].y, blocks[i].z);
|
|
||||||
|
|
||||||
if (block_class_is_subset(block, block_connects_to_glass_pane, block_connects_to_glass_pane_len)) {
|
|
||||||
|
|
||||||
pdata |= blocks[i].direction;
|
|
||||||
|
|
||||||
} else if (block_class_is_subset(block, block_class_stair, block_class_stair_len)) {
|
|
||||||
|
|
||||||
uint8_t stair_direction[4][4] = {
|
|
||||||
{ 1, 3, 0, 2 }, // 'northdirection': 'upper-left'
|
|
||||||
{ 2, 1, 3, 0 }, // 'northdirection': 'upper-right'
|
|
||||||
{ 0, 2, 1, 3 }, // 'northdirection': 'lower-right'
|
|
||||||
{ 3, 0, 2, 1 } // 'northdirection': 'lower-left'
|
|
||||||
};
|
|
||||||
|
|
||||||
mc_block_t block_data = get_data(state, DATA, blocks[i].x, blocks[i].y, blocks[i].z);
|
|
||||||
if ((block_data & 0xf) == stair_direction[northdir][i]) {
|
|
||||||
pdata |= blocks[i].direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (block_class_is_subset(block, block_class_trapdoor, block_class_trapdoor_len)) {
|
|
||||||
|
|
||||||
uint8_t trapdoor_direction[4][4] = {
|
|
||||||
{ 3, 1, 2, 0 }, // 'northdirection': 'upper-left'
|
|
||||||
{ 0, 3, 1, 2 }, // 'northdirection': 'upper-right'
|
|
||||||
{ 2, 0, 3, 1 }, // 'northdirection': 'lower-right'
|
|
||||||
{ 1, 2, 0, 3 } // 'northdirection': 'lower-left'
|
|
||||||
};
|
|
||||||
|
|
||||||
mc_block_t block_data = get_data(state, DATA, blocks[i].x, blocks[i].y, blocks[i].z);
|
|
||||||
// only connects to "open" trapdoors
|
|
||||||
if ((block_data & 0x4) == 0x4 && (block_data & 0x3) == trapdoor_direction[northdir][i]) {
|
|
||||||
pdata |= blocks[i].direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (block == block_snow_layer) {
|
|
||||||
|
|
||||||
// glass pane only connect to full high snow layers
|
|
||||||
mc_block_t skylight_data = get_data(state, SKYLIGHT, blocks[i].x, blocks[i].y, blocks[i].z);
|
|
||||||
if (skylight_data == 0) {
|
|
||||||
pdata |= blocks[i].direction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// shift up 4 bits because the lower 4 bits encode color
|
|
||||||
return (pdata << 4) | (ancilData & 0xf);
|
|
||||||
|
|
||||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_portal, block_nether_brick_fence}, 2)) {
|
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_portal, block_nether_brick_fence}, 2)) {
|
||||||
/* portal and nether brick fences */
|
/* portal and nether brick fences */
|
||||||
return check_adjacent_blocks(state, x, y, z, state->block);
|
return check_adjacent_blocks(state, x, y, z, state->block);
|
||||||
|
|||||||
@@ -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 97
|
#define OVERVIEWER_EXTENSION_VERSION 98
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -4303,16 +4303,30 @@ def panes(self, blockid, data):
|
|||||||
data = data >> 4
|
data = data >> 4
|
||||||
|
|
||||||
if data == 0:
|
if data == 0:
|
||||||
alpha_over(img,up_center,(6,3),up_center) # center
|
alpha_over(img, up_center, (6, 3), up_center) # center
|
||||||
else:
|
else:
|
||||||
|
def draw_top_left():
|
||||||
|
alpha_over(img, up_left, (6, 3), up_left) # top left
|
||||||
|
|
||||||
|
def draw_top_right():
|
||||||
|
alpha_over(img, up_right, (6, 3), up_right) # top right
|
||||||
|
|
||||||
|
def draw_bottom_right():
|
||||||
|
alpha_over(img, dw_right, (6, 3), dw_right) # bottom right
|
||||||
|
|
||||||
|
def draw_bottom_left():
|
||||||
|
alpha_over(img, dw_left, (6, 3), dw_left) # bottom left
|
||||||
|
|
||||||
|
draw_funcs = [draw_top_left, draw_top_right, draw_bottom_right, draw_bottom_left]
|
||||||
|
|
||||||
if (data & 0b0001) == 1:
|
if (data & 0b0001) == 1:
|
||||||
alpha_over(img,up_left, (6,3),up_left) # top left
|
draw_funcs[(self.rotation + 0) % len(draw_funcs)]()
|
||||||
if (data & 0b1000) == 8:
|
|
||||||
alpha_over(img,up_right, (6,3),up_right) # top right
|
|
||||||
if (data & 0b0010) == 2:
|
if (data & 0b0010) == 2:
|
||||||
alpha_over(img,dw_left, (6,3),dw_left) # bottom left
|
draw_funcs[(self.rotation + 1) % len(draw_funcs)]()
|
||||||
if (data & 0b0100) == 4:
|
if (data & 0b0100) == 4:
|
||||||
alpha_over(img,dw_right, (6,3),dw_right) # bottom right
|
draw_funcs[(self.rotation + 2) % len(draw_funcs)]()
|
||||||
|
if (data & 0b1000) == 8:
|
||||||
|
draw_funcs[(self.rotation + 3) % len(draw_funcs)]()
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
|||||||
@@ -957,6 +957,9 @@ class RegionSet(object):
|
|||||||
|
|
||||||
prismarine_slabs = ('minecraft:prismarine_slab','minecraft:dark_prismarine_slab','minecraft:prismarine_brick_slab')
|
prismarine_slabs = ('minecraft:prismarine_slab','minecraft:dark_prismarine_slab','minecraft:prismarine_brick_slab')
|
||||||
|
|
||||||
|
colors = ['white', 'orange', 'magenta', 'light_blue', 'yellow', 'lime', 'pink', 'gray', 'light_gray', 'cyan',
|
||||||
|
'purple', 'blue', 'brown', 'green', 'red', 'black']
|
||||||
|
|
||||||
key = palette_entry['Name']
|
key = palette_entry['Name']
|
||||||
(block, data) = self._blockmap[key]
|
(block, data) = self._blockmap[key]
|
||||||
if key in ['minecraft:redstone_ore', 'minecraft:redstone_lamp']:
|
if key in ['minecraft:redstone_ore', 'minecraft:redstone_lamp']:
|
||||||
@@ -1268,6 +1271,17 @@ class RegionSet(object):
|
|||||||
elif key == 'minecraft:bell':
|
elif key == 'minecraft:bell':
|
||||||
data |= {'floor': 0, 'ceiling': 4, 'single_wall': 8,
|
data |= {'floor': 0, 'ceiling': 4, 'single_wall': 8,
|
||||||
'double_wall': 12}[p['attachment']]
|
'double_wall': 12}[p['attachment']]
|
||||||
|
elif key in ['minecraft:iron_bars', 'minecraft:glass_pane'] or \
|
||||||
|
key in ['minecraft:%s_stained_glass_pane' % item for item in colors]:
|
||||||
|
p = palette_entry['Properties']
|
||||||
|
if p['north'] == 'true':
|
||||||
|
data |= (1 << 4)
|
||||||
|
if p['east'] == 'true':
|
||||||
|
data |= (2 << 4)
|
||||||
|
if p['south'] == 'true':
|
||||||
|
data |= (4 << 4)
|
||||||
|
if p['west'] == 'true':
|
||||||
|
data |= (8 << 4)
|
||||||
|
|
||||||
return (block, data)
|
return (block, data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user