aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/game.cpp32
-rw-r--r--src/util/directiontables.cpp49
-rw-r--r--src/util/directiontables.h6
3 files changed, 75 insertions, 12 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 360ce4f8c..179557cf5 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -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)
+ 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
+ } else {
pp = p + v3s16(0, -1, 0);
+ }
if (!nodedef->get(map.getNode(pp)).walkable) {
soundmaker->m_player_rightpunch_sound = selected_def.sound_place_failed;
diff --git a/src/util/directiontables.cpp b/src/util/directiontables.cpp
index 296585f90..297058c9c 100644
--- a/src/util/directiontables.cpp
+++ b/src/util/directiontables.cpp
@@ -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),
+};
diff --git a/src/util/directiontables.h b/src/util/directiontables.h
index ef00e3bfe..3883a6e37 100644
--- a/src/util/directiontables.h
+++ b/src/util/directiontables.h
@@ -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 {