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_fence,
|
||||
block_portal,
|
||||
block_iron_bars,
|
||||
block_glass_pane,
|
||||
block_waterlily,
|
||||
block_nether_brick_fence,
|
||||
block_andesite_wall,
|
||||
@@ -232,7 +230,6 @@ const mc_block_t block_class_ancil[] = {
|
||||
block_lodestone,
|
||||
block_respawn_anchor,
|
||||
block_double_plant,
|
||||
block_stained_glass_pane,
|
||||
block_stained_glass,
|
||||
block_spruce_fence,
|
||||
block_birch_fence,
|
||||
@@ -320,157 +317,3 @@ const mc_block_t block_class_nether_roof[] = {
|
||||
block_nether_gold_ore,
|
||||
block_ancient_debris};
|
||||
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 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
|
||||
|
||||
@@ -317,75 +317,6 @@ generate_pseudo_data(RenderState* state, uint16_t ancilData) {
|
||||
}
|
||||
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)) {
|
||||
/* portal and nether brick fences */
|
||||
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
|
||||
// and want to force users to rebuild
|
||||
#define OVERVIEWER_EXTENSION_VERSION 97
|
||||
#define OVERVIEWER_EXTENSION_VERSION 98
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
Reference in New Issue
Block a user