aboutsummaryrefslogtreecommitdiff
path: root/src/client/game.cpp
diff options
context:
space:
mode:
authorWuzzy <Wuzzy@disroot.org>2022-09-16 13:18:55 +0200
committerGitHub <noreply@github.com>2022-09-16 13:18:55 +0200
commit1d04903c1973591e795d3275b900d76d7cb7877a (patch)
tree06891c6fe3075c1868832bc0007308e525cef70f /src/client/game.cpp
parentb5e7280708221cdcca89df7d16f2aea19e4b3c4c (diff)
downloadminetest-1d04903c1973591e795d3275b900d76d7cb7877a.tar.xz
Add paramtype2s for 4 horizontal rotations and 64 colors (#11431)
4dir is like facedir, but only for 4 horizontal directions: NESW. It is identical in behavior to facedir otherwise. The reason why game makers would want to use this over facedir is 1) simplicity and 2) you get 6 free bits. It can be used for things like chests and furnaces and you don't need or want them to "flip them on the side" (like you could with facedir). color4dir is like colorfacedir, but you get 64 colors instead of only 8.
Diffstat (limited to 'src/client/game.cpp')
-rw-r--r--src/client/game.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index 6a4bff61a..b4926d9bf 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -3462,7 +3462,9 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
param2 = dir.Z < 0 ? 5 : 4;
}
} else if (predicted_f.param_type_2 == CPT2_FACEDIR ||
- predicted_f.param_type_2 == CPT2_COLORED_FACEDIR) {
+ predicted_f.param_type_2 == CPT2_COLORED_FACEDIR ||
+ predicted_f.param_type_2 == CPT2_4DIR ||
+ predicted_f.param_type_2 == CPT2_COLORED_4DIR) {
v3s16 dir = nodepos - floatToInt(client->getEnv().getLocalPlayer()->getPosition(), BS);
if (abs(dir.X) > abs(dir.Z)) {
@@ -3501,6 +3503,7 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
// Apply color
if (!place_param2 && (predicted_f.param_type_2 == CPT2_COLOR
|| predicted_f.param_type_2 == CPT2_COLORED_FACEDIR
+ || predicted_f.param_type_2 == CPT2_COLORED_4DIR
|| predicted_f.param_type_2 == CPT2_COLORED_WALLMOUNTED)) {
const auto &indexstr = selected_item.metadata.
getString("palette_index", 0);
@@ -3514,6 +3517,9 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
} else if (predicted_f.param_type_2 == CPT2_COLORED_FACEDIR) {
// param2 = pure palette index + other
param2 = (index & 0xe0) | (param2 & 0x1f);
+ } else if (predicted_f.param_type_2 == CPT2_COLORED_4DIR) {
+ // param2 = pure palette index + other
+ param2 = (index & 0xfc) | (param2 & 0x03);
}
}
}