1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add support for attached facedir/4dir nodes (#11432)

This commit is contained in:
Wuzzy 2022-11-24 23:56:07 +01:00 committed by GitHub
parent 1c10988d6a
commit 3c7f26d937
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 177 additions and 27 deletions

View file

@ -3585,22 +3585,30 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
}
// Check attachment if node is in group attached_node
if (itemgroup_get(predicted_f.groups, "attached_node") != 0) {
const static v3s16 wallmounted_dirs[8] = {
v3s16(0, 1, 0),
v3s16(0, -1, 0),
v3s16(1, 0, 0),
v3s16(-1, 0, 0),
v3s16(0, 0, 1),
v3s16(0, 0, -1),
};
int an = itemgroup_get(predicted_f.groups, "attached_node");
if (an != 0) {
v3s16 pp;
if (predicted_f.param_type_2 == CPT2_WALLMOUNTED ||
predicted_f.param_type_2 == CPT2_COLORED_WALLMOUNTED)
pp = p + wallmounted_dirs[param2];
else
if (an == 3) {
pp = p + v3s16(0, -1, 0);
} else if (an == 4) {
pp = p + v3s16(0, 1, 0);
} else if (an == 2) {
if (predicted_f.param_type_2 == CPT2_FACEDIR ||
predicted_f.param_type_2 == CPT2_COLORED_FACEDIR) {
pp = p + facedir_dirs[param2];
} else if (predicted_f.param_type_2 == CPT2_4DIR ||
predicted_f.param_type_2 == CPT2_COLORED_4DIR ) {
pp = p + fourdir_dirs[param2];
} else {
pp = p;
}
} else if (predicted_f.param_type_2 == CPT2_WALLMOUNTED ||
predicted_f.param_type_2 == CPT2_COLORED_WALLMOUNTED) {
pp = p + wallmounted_dirs[param2];
} else {
pp = p + v3s16(0, -1, 0);
}
if (!nodedef->get(map.getNode(pp)).walkable) {
soundmaker->m_player_rightpunch_sound = selected_def.sound_place_failed;