mirror of
https://github.com/minetest/minetest.git
synced 2025-07-05 01:10:22 +02:00
Add support for attached facedir/4dir nodes (#11432)
This commit is contained in:
@ -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;
|
||||
|
@ -118,3 +118,52 @@ const u8 wallmounted_to_facedir[6] = {
|
||||
8,
|
||||
4 + 2
|
||||
};
|
||||
|
||||
const 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),
|
||||
};
|
||||
|
||||
const v3s16 facedir_dirs[32] = {
|
||||
//0
|
||||
v3s16(0, 0, 1),
|
||||
v3s16(1, 0, 0),
|
||||
v3s16(0, 0, -1),
|
||||
v3s16(-1, 0, 0),
|
||||
//4
|
||||
v3s16(0, -1, 0),
|
||||
v3s16(1, 0, 0),
|
||||
v3s16(0, 1, 0),
|
||||
v3s16(-1, 0, 0),
|
||||
//8
|
||||
v3s16(0, 1, 0),
|
||||
v3s16(1, 0, 0),
|
||||
v3s16(0, -1, 0),
|
||||
v3s16(-1, 0, 0),
|
||||
//12
|
||||
v3s16(0, 0, 1),
|
||||
v3s16(0, -1, 0),
|
||||
v3s16(0, 0, -1),
|
||||
v3s16(0, 1, 0),
|
||||
//16
|
||||
v3s16(0, 0, 1),
|
||||
v3s16(0, 1, 0),
|
||||
v3s16(0, 0, -1),
|
||||
v3s16(0, -1, 0),
|
||||
//20
|
||||
v3s16(0, 0, 1),
|
||||
v3s16(-1, 0, 0),
|
||||
v3s16(0, 0, -1),
|
||||
v3s16(1, 0, 0),
|
||||
};
|
||||
|
||||
const v3s16 fourdir_dirs[4] = {
|
||||
v3s16(0, 0, 1),
|
||||
v3s16(1, 0, 0),
|
||||
v3s16(0, 0, -1),
|
||||
v3s16(-1, 0, 0),
|
||||
};
|
||||
|
@ -33,6 +33,12 @@ extern const v3s16 g_27dirs[27];
|
||||
|
||||
extern const u8 wallmounted_to_facedir[6];
|
||||
|
||||
extern const v3s16 wallmounted_dirs[8];
|
||||
|
||||
extern const v3s16 facedir_dirs[32];
|
||||
|
||||
extern const v3s16 fourdir_dirs[4];
|
||||
|
||||
/// Direction in the 6D format. g_27dirs contains corresponding vectors.
|
||||
/// Here P means Positive, N stands for Negative.
|
||||
enum Direction6D {
|
||||
|
Reference in New Issue
Block a user